diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 13:58:19 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 13:58:19 +0100 |
commit | d228d4b3856606ad4395723b2703759a0ebe9832 (patch) | |
tree | bfd3019ca2c9bec258fffca9a9204ddc88768264 /src/crepe/api | |
parent | 770496ee9d0e45480c0e0f8951adb8eee247bfe1 (diff) | |
parent | c45b60941b82dec2097d958b396a117b1634eada (diff) |
Merge branch 'master' into loek/replay
Diffstat (limited to 'src/crepe/api')
-rw-r--r-- | src/crepe/api/LoopManager.h | 3 | ||||
-rw-r--r-- | src/crepe/api/Script.cpp | 8 | ||||
-rw-r--r-- | src/crepe/api/Script.h | 3 | ||||
-rw-r--r-- | src/crepe/api/Script.hpp | 3 |
4 files changed, 11 insertions, 6 deletions
diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h index 1ac6a39..1183a4d 100644 --- a/src/crepe/api/LoopManager.h +++ b/src/crepe/api/LoopManager.h @@ -4,6 +4,7 @@ #include "../manager/ComponentManager.h" #include "../manager/ResourceManager.h" #include "../manager/SceneManager.h" +#include "../manager/SaveManager.h" #include "../system/System.h" #include "LoopTimer.h" @@ -68,6 +69,8 @@ private: SceneManager scene_manager{mediator}; //! Resource manager instance ResourceManager resource_manager{mediator}; + //! Save manager instance + SaveManager save_manager{mediator}; //! SDL context \todo no more singletons! SDLContext & sdl_context = SDLContext::get_instance(); diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp index 4091fd4..753a9e3 100644 --- a/src/crepe/api/Script.cpp +++ b/src/crepe/api/Script.cpp @@ -8,8 +8,7 @@ using namespace crepe; using namespace std; Script::~Script() { - Mediator & mediator = this->mediator; - EventManager & mgr = mediator.event_manager; + EventManager & mgr = this->mediator->event_manager; for (auto id : this->listeners) { mgr.unsubscribe(id); } @@ -21,7 +20,8 @@ void Script::subscribe(const EventHandler<CollisionEvent> & callback) { } void Script::set_next_scene(const string & name) { - Mediator & mediator = this->mediator; - SceneManager & mgr = mediator.scene_manager; + SceneManager & mgr = this->mediator->scene_manager; mgr.set_next_scene(name); } + +SaveManager & Script::get_save_manager() const { return this->mediator->save_manager; } diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 49bdcf5..668e5d1 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -132,6 +132,9 @@ protected: */ void set_next_scene(const std::string & name); + //! Retrieve SaveManager reference + SaveManager & get_save_manager() const; + //! \} private: diff --git a/src/crepe/api/Script.hpp b/src/crepe/api/Script.hpp index 16e0dc5..225a51c 100644 --- a/src/crepe/api/Script.hpp +++ b/src/crepe/api/Script.hpp @@ -31,8 +31,7 @@ void Script::logf(Args &&... args) { template <typename EventType> void Script::subscribe_internal(const EventHandler<EventType> & callback, event_channel_t channel) { - Mediator & mediator = this->mediator; - EventManager & mgr = mediator.event_manager; + EventManager & mgr = this->mediator->event_manager; subscription_t listener = mgr.subscribe<EventType>( [this, callback](const EventType & data) -> bool { bool & active = this->active; |