diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 19:47:31 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 19:47:31 +0100 |
commit | 30974f588816aa03652002111c6a946b138e3bc5 (patch) | |
tree | 247b7f5b01c3a9ffad7f2c6ef7ac2c30109f3f8f /game/preview/PreviewReplaySubScript.cpp | |
parent | ef3f5b0845ba127c0bfcda8c2fce37013fef3878 (diff) |
replay in preview scene
Diffstat (limited to 'game/preview/PreviewReplaySubScript.cpp')
-rw-r--r-- | game/preview/PreviewReplaySubScript.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/game/preview/PreviewReplaySubScript.cpp b/game/preview/PreviewReplaySubScript.cpp new file mode 100644 index 0000000..9725ba2 --- /dev/null +++ b/game/preview/PreviewReplaySubScript.cpp @@ -0,0 +1,51 @@ +#include "PreviewReplaySubScript.h" +#include "menus/ButtonReplaySubScript.h" +#include <crepe/api/AudioSource.h> +#include <crepe/types.h> + +using namespace crepe; +using namespace std; + +void PreviewReplaySubScript::init() { + IButtonScript::init(); + this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) { + return this->on_button_press(e); + }); + this->subscribe<StopPreviewRecording>([this](const StopPreviewRecording & e) { + return this->stop_recording(); + }); + this->subscribe<DeleteRecordingEvent>([this](const DeleteRecordingEvent & e) { + return this->delete_recording(); + }); + this->subscribe<StartPreviewRecording>([this](const StartPreviewRecording & e) { + return this->start_recording(); + }); + +} + +bool PreviewReplaySubScript::on_button_press(const ButtonPressEvent & e) { + replay.play(this->recording); + return false; +} +bool PreviewReplaySubScript::start_recording(){ + if(record_saved){ + this->stop_recording(); + this->delete_recording(); + } + replay.record_start(); + this->record_started = true; + return false; +} + +bool PreviewReplaySubScript::stop_recording() { + if(this->record_started)this->recording = replay.record_end(); + this->record_saved = true; + return false; +} + +bool PreviewReplaySubScript::delete_recording() { + if(this->record_started) this->stop_recording(); + if(this->record_saved)replay.release(this->recording); + this->record_saved = false; + return false; +} |