From 2e6fcb1d048edd13a2ec69ddd226fc8ebabc2389 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 7 Dec 2024 16:01:19 +0100 Subject: add SaveManager to Script --- src/crepe/api/Script.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/crepe/api/Script.cpp') diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp index 4091fd4..961e6e7 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,11 @@ void Script::subscribe(const EventHandler & 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; +} + -- cgit v1.2.3 From dd8bbe2fde97786ab29490bc7ba9962deb08fb4c Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 7 Dec 2024 16:01:59 +0100 Subject: `make format` --- src/crepe/api/Script.cpp | 5 +---- src/crepe/api/Script.h | 2 +- src/test/SaveManagerTest.cpp | 5 ++--- src/test/ScriptSaveManagerTest.cpp | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/crepe/api/Script.cpp') diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp index 961e6e7..753a9e3 100644 --- a/src/crepe/api/Script.cpp +++ b/src/crepe/api/Script.cpp @@ -24,7 +24,4 @@ void Script::set_next_scene(const string & name) { mgr.set_next_scene(name); } -SaveManager & Script::get_save_manager() const { - return this->mediator->save_manager; -} - +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 024f1d7..0d59ab6 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -2,12 +2,12 @@ #include +#include "../ValueBroker.h" #include "../manager/EventManager.h" #include "../manager/Mediator.h" #include "../system/CollisionSystem.h" #include "../types.h" #include "../util/OptionalRef.h" -#include "../ValueBroker.h" namespace crepe { diff --git a/src/test/SaveManagerTest.cpp b/src/test/SaveManagerTest.cpp index a1efc33..e9b0c29 100644 --- a/src/test/SaveManagerTest.cpp +++ b/src/test/SaveManagerTest.cpp @@ -1,8 +1,8 @@ #include -#include -#include #include +#include +#include using namespace std; using namespace crepe; @@ -38,4 +38,3 @@ TEST_F(SaveManagerTest, DefaultValue) { value.set(5); ASSERT_EQ(value.get(), 5); } - diff --git a/src/test/ScriptSaveManagerTest.cpp b/src/test/ScriptSaveManagerTest.cpp index 098afa0..64403c4 100644 --- a/src/test/ScriptSaveManagerTest.cpp +++ b/src/test/ScriptSaveManagerTest.cpp @@ -4,8 +4,8 @@ #define private public #define protected public -#include #include +#include #include "ScriptTest.h" @@ -33,4 +33,3 @@ TEST_F(ScriptSaveManagerTest, GetSaveManager) { EXPECT_EQ(&mgr, &save_mgr); } - -- cgit v1.2.3