diff options
-rw-r--r-- | game/menus/ButtonNextMainMenuSubScript.cpp | 4 | ||||
-rw-r--r-- | game/menus/ButtonReplaySubScript.cpp | 8 | ||||
-rw-r--r-- | game/menus/ButtonReplaySubScript.h | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/game/menus/ButtonNextMainMenuSubScript.cpp b/game/menus/ButtonNextMainMenuSubScript.cpp index e03a34a..631b4d3 100644 --- a/game/menus/ButtonNextMainMenuSubScript.cpp +++ b/game/menus/ButtonNextMainMenuSubScript.cpp @@ -1,4 +1,5 @@ #include "ButtonNextMainMenuSubScript.h" +#include "ButtonReplaySubScript.h" #include "MenusConfig.h" #include "ValueBroker.h" @@ -26,7 +27,8 @@ bool ButtonNextMainMenuSubScript::on_button_press(const ButtonPressEvent & e) { for (AudioSource & audio : audios) { audio.stop(); } - + + this->trigger_event<DeleteRecordingEvent>(); SaveManager & savemgr = this->get_save_manager(); ValueBroker<int> coins = savemgr.get<int>(TOTAL_COINS_RUN, 0); diff --git a/game/menus/ButtonReplaySubScript.cpp b/game/menus/ButtonReplaySubScript.cpp index 9308350..ddd9fa4 100644 --- a/game/menus/ButtonReplaySubScript.cpp +++ b/game/menus/ButtonReplaySubScript.cpp @@ -16,6 +16,9 @@ void ButtonReplaySubScript::init() { this->subscribe<EndGameEvent>([this](const EndGameEvent & e) { return this->set_recording(); }); + this->subscribe<DeleteRecordingEvent>([this](const DeleteRecordingEvent & e) { + return this->delete_recording(); + }); replay.record_start(); } @@ -28,3 +31,8 @@ bool ButtonReplaySubScript::set_recording() { this->recording = replay.record_end(); return false; } + +bool ButtonReplaySubScript::delete_recording() { + replay.release(this->recording); + return false; +} diff --git a/game/menus/ButtonReplaySubScript.h b/game/menus/ButtonReplaySubScript.h index bfc684d..3eb8aa9 100644 --- a/game/menus/ButtonReplaySubScript.h +++ b/game/menus/ButtonReplaySubScript.h @@ -4,6 +4,8 @@ #include <crepe/api/Script.h> +struct DeleteRecordingEvent : public crepe::Event {}; + class ButtonReplaySubScript : public IButtonScript { public: void init() override; @@ -12,6 +14,7 @@ public: private: crepe::recording_t recording = 0; bool set_recording(); + bool delete_recording(); protected: bool transition = false; |