diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 21:04:30 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 21:04:30 +0100 |
commit | 359ad8db97305856f4cfdade1cd1dada78a7a635 (patch) | |
tree | a6d5dce34c2aa5406744c414baccf6a2450dd8a5 /src/crepe/manager/ReplayManager.cpp | |
parent | 313da47b72aafa0b40ac2cd2b586d525ed17fbd4 (diff) |
more replay system WIP
Diffstat (limited to 'src/crepe/manager/ReplayManager.cpp')
-rw-r--r-- | src/crepe/manager/ReplayManager.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/crepe/manager/ReplayManager.cpp b/src/crepe/manager/ReplayManager.cpp index 82c2275..81ff114 100644 --- a/src/crepe/manager/ReplayManager.cpp +++ b/src/crepe/manager/ReplayManager.cpp @@ -1,4 +1,4 @@ -#include "../util/Log.h" +#include <format> #include "ReplayManager.h" #include "Manager.h" @@ -11,26 +11,29 @@ ReplayManager::ReplayManager(Mediator & mediator) : Manager(mediator) { } void ReplayManager::record_start() { - if (this->recording) this->release(this->current_recording); - this->current_recording++; - this->recording = true; + if (this->state == RECORDING) this->release(this->id); + this->id++; + this->memory[this->id] = make_unique<Recording>(); + this->recording = *this->memory.at(this->id); + this->state = RECORDING; } recording_t ReplayManager::record_end() { - this->recording = false; - return this->current_recording; + this->state = IDLE; + return this->id; } void ReplayManager::play(recording_t handle) { if (!this->memory.contains(handle)) throw out_of_range(format("ReplayManager: no recording for handle {}", handle)); - Recording & recording = *this->memory.at(handle); - - dbg_log("TODO: magic"); + this->recording = *this->memory.at(handle); + this->recording->frame = 0; + this->state = PLAYING; } void ReplayManager::release(recording_t handle) { - dbg_log("release"); - + if (!this->memory.contains(handle)) + return; + this->memory.erase(handle); } |