From 424da5eb1500d90389d939cd0b3e6e75d729578d Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Wed, 8 Jan 2025 16:17:39 +0100 Subject: delete replay --- game/menus/ButtonNextMainMenuSubScript.cpp | 4 +++- game/menus/ButtonReplaySubScript.cpp | 8 ++++++++ game/menus/ButtonReplaySubScript.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'game/menus') 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(); SaveManager & savemgr = this->get_save_manager(); ValueBroker coins = savemgr.get(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([this](const EndGameEvent & e) { return this->set_recording(); }); + this->subscribe([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 +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; -- cgit v1.2.3