aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LoadFilesCommand.cpp2
-rw-r--r--Museum.h2
-rw-r--r--View.cpp20
-rw-r--r--View.h3
-rw-r--r--ViewController.cpp18
-rw-r--r--ViewController.h4
-rw-r--r--readme.md5
7 files changed, 46 insertions, 8 deletions
diff --git a/LoadFilesCommand.cpp b/LoadFilesCommand.cpp
index 6bcf7da..9a0ca08 100644
--- a/LoadFilesCommand.cpp
+++ b/LoadFilesCommand.cpp
@@ -39,7 +39,5 @@ void LoadFilesCommand::load_files(vector<string> files) {
throw Exception("parser error: %s (%s)", e.what(), url.c_str());
}
}
-
- MuseumPauseCommand(this).set(false);
}
diff --git a/Museum.h b/Museum.h
index 0792ec3..ae7e71e 100644
--- a/Museum.h
+++ b/Museum.h
@@ -25,7 +25,7 @@ public:
void skip_backward();
private:
- bool paused = false;
+ bool paused = true;
unsigned long jump = 0;
private:
diff --git a/View.cpp b/View.cpp
index 998356f..05b823c 100644
--- a/View.cpp
+++ b/View.cpp
@@ -91,7 +91,7 @@ void View::draw_end() {
SDL_RenderPresent(this->renderer);
}
-void View::draw_rect(Rectangle r, Color c) {
+void View::fill_rect(Rectangle r, Color c) {
SDL_SetRenderDrawColor(this->renderer, c.red, c.green, c.blue, 255);
SDL_FRect rect = {
.x = static_cast<float>(r.x),
@@ -102,6 +102,24 @@ void View::draw_rect(Rectangle r, Color c) {
SDL_RenderFillRect(this->renderer, &rect);
}
+void View::draw_rect(Rectangle r, Color c, unsigned border_width) {
+ SDL_SetRenderDrawColor(this->renderer, c.red, c.green, c.blue, 255);
+ SDL_FRect rect;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.w = r.width;
+ rect.h = border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.y = r.y + r.height - border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.y = r.y;
+ rect.h = r.height;
+ rect.w = border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+ rect.x = r.x + r.width - border_width;
+ SDL_RenderFillRect(this->renderer, &rect);
+}
+
typedef struct {
void (* callback)(std::vector<std::string> files, void* data);
void * data;
diff --git a/View.h b/View.h
index c8b2133..6162571 100644
--- a/View.h
+++ b/View.h
@@ -17,7 +17,8 @@ public:
public:
virtual void window_size(unsigned int width, unsigned int height);
virtual void dialog_file(void(*callback)(std::vector<std::string> files, void* data), void* data);
- virtual void draw_rect(Rectangle r, Color c);
+ virtual void fill_rect(Rectangle r, Color c);
+ virtual void draw_rect(Rectangle r, Color c, unsigned border_width);
private:
virtual void draw_begin();
diff --git a/ViewController.cpp b/ViewController.cpp
index 52cdefc..74873e7 100644
--- a/ViewController.cpp
+++ b/ViewController.cpp
@@ -22,6 +22,8 @@ void ViewController::update() {
this->update_size();
this->update_tiles();
if (this->draw_artists) this->update_artists();
+ if (this->draw_pathfinding) this->update_pathfinding();
+ if (this->draw_quadtree) this->update_quadtree();
}
void ViewController::update_size() {
@@ -41,7 +43,7 @@ void ViewController::update_tiles() {
.width = scale - line_width,
.height = scale - line_width,
};
- this->view.draw_rect(rect, tile.color);
+ this->view.fill_rect(rect, tile.color);
}
}
}
@@ -56,10 +58,16 @@ void ViewController::update_artists() {
.width = artist_size,
.height = artist_size,
};
- this->view.draw_rect(rect, artist->color);
+ this->view.fill_rect(rect, artist->color);
}
}
+void ViewController::update_pathfinding() {
+}
+
+void ViewController::update_quadtree() {
+}
+
void ViewController::ev_keydown(KeyboardCode key) {
try {
switch (key) {
@@ -98,7 +106,11 @@ void ViewController::ev_mousedown(MouseCode button) {
try {
switch (button) {
case MOUSE_LEFT: {
- TileDecayCommand(this->cmd_base).execute(get<0>(this->mouse_pos), get<1>(this->mouse_pos));
+ // TODO: pathfinding start point
+ break;
+ }
+ case MOUSE_RIGHT: {
+ // TODO: pathfinding end point
break;
}
default: break;
diff --git a/ViewController.h b/ViewController.h
index 0b86468..9066d05 100644
--- a/ViewController.h
+++ b/ViewController.h
@@ -28,6 +28,8 @@ private:
void update_size();
void update_tiles();
void update_artists();
+ void update_pathfinding();
+ void update_quadtree();
private:
Museum & museum;
@@ -35,6 +37,8 @@ private:
const Command * cmd_base = nullptr;
bool draw_artists = true;
+ bool draw_pathfinding = false;
+ bool draw_quadtree = false;
private:
unsigned int scale = 16;
diff --git a/readme.md b/readme.md
index 8437c65..282a42e 100644
--- a/readme.md
+++ b/readme.md
@@ -7,4 +7,9 @@ DPA:
ALGA:
- artist-artist collision behavior
+- artist-path collision behavior (toggleable)
+- pathfinding start/end selection w/ mouse buttons (left for start, right for end)
+- show {shortest,fastest,no} path toggle
+
+TODO: