aboutsummaryrefslogtreecommitdiff
path: root/ViewController.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 16:37:02 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 16:37:02 +0200
commit4cb7ca42003c177e3acc80075d7594e555966106 (patch)
treed2f5836d70a1fa2dc1d18c4fb59f1bf1f2f91f5a /ViewController.cpp
parentd8289105193707daede1a5b59137f18e20f20aeb (diff)
fix command design pattern
Diffstat (limited to 'ViewController.cpp')
-rw-r--r--ViewController.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/ViewController.cpp b/ViewController.cpp
index a37c49a..d64ec35 100644
--- a/ViewController.cpp
+++ b/ViewController.cpp
@@ -11,11 +11,9 @@
#include "Museum.h"
ViewController::ViewController(Museum & m, View & v) : museum(m), view(v) {
- this->cmd_base = new Command(this->museum, this->view, *this);
}
ViewController::~ViewController() {
- delete this->cmd_base;
}
void ViewController::update() {
@@ -71,27 +69,27 @@ void ViewController::ev_keydown(KeyboardCode key) {
try {
switch (key) {
case KEY_SPACE: {
- ToggleMuseumPauseCommand(this->cmd_base).toggle();
+ ToggleMuseumPauseCommand(this->museum).execute();
break;
}
case KEY_ENTER: {
- StepTileCommand(this->cmd_base).execute(get<0>(this->mouse_pos), get<1>(this->mouse_pos));
+ StepTileCommand(this->museum.canvas, this->mouse_pos).execute();
break;
}
case KEY_O: {
- OpenFileGUICommand(this->cmd_base).execute();
+ OpenFileGUICommand(this->museum, this->view).execute();
break;
}
case KEY_A: {
- ToggleArtistVisibilityCommand(this->cmd_base).toggle();
+ ToggleArtistVisibilityCommand(*this).execute();
break;
}
case KEY_LEFT: {
- TimeTravelCommand(this->cmd_base).backwards();
+ TimeTravelCommand(this->museum, false).execute();
break;
}
case KEY_RIGHT: {
- TimeTravelCommand(this->cmd_base).forwards();
+ TimeTravelCommand(this->museum, true).execute();
break;
}
default: break;