From 4cb7ca42003c177e3acc80075d7594e555966106 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 18 Oct 2024 16:37:02 +0200 Subject: fix command design pattern --- ViewController.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'ViewController.cpp') 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; -- cgit v1.2.3