From 45f1f18c78e73280a8a861df2db6237bae6f6d80 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 12 Dec 2024 19:02:40 +0100 Subject: add script api for replaymanager --- src/crepe/api/Script.cpp | 21 +++++++++++++++++++++ src/crepe/api/Script.h | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'src/crepe/api') diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp index 753a9e3..8b95cc9 100644 --- a/src/crepe/api/Script.cpp +++ b/src/crepe/api/Script.cpp @@ -25,3 +25,24 @@ void Script::set_next_scene(const string & name) { } SaveManager & Script::get_save_manager() const { return this->mediator->save_manager; } + +void Script::replay::record_start() { + ReplayManager & mgr = this->mediator->replay_manager; + return mgr.record_start(); +} + +recording_t Script::replay::record_end() { + ReplayManager & mgr = this->mediator->replay_manager; + return mgr.record_end(); +} + +void Script::replay::play(recording_t recording) { + ReplayManager & mgr = this->mediator->replay_manager; + return mgr.play(recording); +} + +void Script::replay::release(recording_t recording) { + ReplayManager & mgr = this->mediator->replay_manager; + return mgr.release(recording); +} + diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 668e5d1..c797db0 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -2,6 +2,7 @@ #include +#include "../manager/ReplayManager.h" #include "../manager/EventManager.h" #include "../manager/Mediator.h" #include "../system/CollisionSystem.h" @@ -135,6 +136,23 @@ protected: //! Retrieve SaveManager reference SaveManager & get_save_manager() const; + //! Replay management functions + struct replay { // NOLINT + //! \copydoc ReplayManager::record_start + void record_start(); + //! \copydoc ReplayManager::record_end + recording_t record_end(); + //! \copydoc ReplayManager::play + void play(recording_t); + //! \copydoc ReplayManager::release + void release(recording_t); + + private: + OptionalRef & mediator; + replay(OptionalRef & mediator) : mediator(mediator) {} + friend class Script; + } replay{mediator}; + //! \} private: -- cgit v1.2.3