aboutsummaryrefslogtreecommitdiff
path: root/game/menus
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-08 16:17:39 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-08 16:17:39 +0100
commit424da5eb1500d90389d939cd0b3e6e75d729578d (patch)
tree991094effc4a5261e5d2ab0771fdd38e95eca94f /game/menus
parente2f9c0bcaf22aa73689305faca70f2ec4682f55c (diff)
delete replay
Diffstat (limited to 'game/menus')
-rw-r--r--game/menus/ButtonNextMainMenuSubScript.cpp4
-rw-r--r--game/menus/ButtonReplaySubScript.cpp8
-rw-r--r--game/menus/ButtonReplaySubScript.h3
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;