From 359ad8db97305856f4cfdade1cd1dada78a7a635 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 11 Dec 2024 21:04:30 +0100 Subject: more replay system WIP --- src/crepe/manager/ReplayManager.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/crepe/manager/ReplayManager.cpp') 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 #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(); + 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); } -- cgit v1.2.3