diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 18:37:23 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-11 18:37:23 +0100 |
commit | ca6c4f30df6612f60db0fdfe4c2d366d7e4da8ea (patch) | |
tree | 199878898c2ddcdd2f7f6a1b76c165c2c7db5c8d /src/crepe/manager | |
parent | f0ecbea57a4d75905c4ee79608807187cd8f3e72 (diff) | |
parent | 30c17c98e54c1534664de08ca3838c40c859d166 (diff) |
merge master
Diffstat (limited to 'src/crepe/manager')
-rw-r--r-- | src/crepe/manager/ComponentManager.cpp | 2 | ||||
-rw-r--r-- | src/crepe/manager/ComponentManager.h | 1 | ||||
-rw-r--r-- | src/crepe/manager/Mediator.h | 8 | ||||
-rw-r--r-- | src/crepe/manager/ResourceManager.cpp | 2 | ||||
-rw-r--r-- | src/crepe/manager/ResourceManager.hpp | 2 | ||||
-rw-r--r-- | src/crepe/manager/SaveManager.cpp | 6 | ||||
-rw-r--r-- | src/crepe/manager/SaveManager.h | 5 |
7 files changed, 12 insertions, 14 deletions
diff --git a/src/crepe/manager/ComponentManager.cpp b/src/crepe/manager/ComponentManager.cpp index df30d27..24ba0d7 100644 --- a/src/crepe/manager/ComponentManager.cpp +++ b/src/crepe/manager/ComponentManager.cpp @@ -53,7 +53,7 @@ GameObject ComponentManager::new_object(const string & name, const string & tag, this->next_id++; } - GameObject object{*this, this->next_id, name, tag, position, rotation, scale}; + GameObject object{this->mediator, this->next_id, name, tag, position, rotation, scale}; this->next_id++; return object; diff --git a/src/crepe/manager/ComponentManager.h b/src/crepe/manager/ComponentManager.h index 94fd94f..dd7c154 100644 --- a/src/crepe/manager/ComponentManager.h +++ b/src/crepe/manager/ComponentManager.h @@ -143,7 +143,6 @@ public: RefVector<T> get_components_by_tag(const std::string & tag) const; struct SnapshotComponent { - by_type<by_id_index<std::vector<std::unique_ptr<Component>>>> components; Component component; }; struct Snapshot { diff --git a/src/crepe/manager/Mediator.h b/src/crepe/manager/Mediator.h index 35ac181..628154a 100644 --- a/src/crepe/manager/Mediator.h +++ b/src/crepe/manager/Mediator.h @@ -3,9 +3,7 @@ #include "../util/OptionalRef.h" // TODO: remove these singletons: -#include "../facade/SDLContext.h" #include "EventManager.h" -#include "api/LoopTimer.h" namespace crepe { @@ -13,6 +11,8 @@ class ComponentManager; class SceneManager; class SaveManager; class ResourceManager; +class SDLContext; +class LoopTimer; /** * Struct to pass references to classes that would otherwise need to be singletons down to @@ -27,13 +27,13 @@ class ResourceManager; * \warning This class should never be directly accessible from the API */ struct Mediator { + OptionalRef<SDLContext> sdl_context; OptionalRef<ComponentManager> component_manager; OptionalRef<SceneManager> scene_manager; OptionalRef<SaveManager> save_manager; OptionalRef<EventManager> event_manager = EventManager::get_instance(); OptionalRef<ResourceManager> resource_manager; - OptionalRef<SDLContext> sdl_context = SDLContext::get_instance(); - OptionalRef<LoopTimer> timer = LoopTimer::get_instance(); + OptionalRef<LoopTimer> timer; }; } // namespace crepe diff --git a/src/crepe/manager/ResourceManager.cpp b/src/crepe/manager/ResourceManager.cpp index 7c01808..a141a46 100644 --- a/src/crepe/manager/ResourceManager.cpp +++ b/src/crepe/manager/ResourceManager.cpp @@ -6,8 +6,8 @@ using namespace crepe; using namespace std; ResourceManager::ResourceManager(Mediator & mediator) : Manager(mediator) { - mediator.resource_manager = *this; dbg_trace(); + mediator.resource_manager = *this; } ResourceManager::~ResourceManager() { dbg_trace(); } diff --git a/src/crepe/manager/ResourceManager.hpp b/src/crepe/manager/ResourceManager.hpp index 5167d71..cf5c949 100644 --- a/src/crepe/manager/ResourceManager.hpp +++ b/src/crepe/manager/ResourceManager.hpp @@ -13,7 +13,7 @@ T & ResourceManager::get(const Asset & asset) { "cache must recieve a derivative class of Resource"); CacheEntry & entry = this->get_entry(asset); - if (entry.resource == nullptr) entry.resource = make_unique<T>(asset); + if (entry.resource == nullptr) entry.resource = make_unique<T>(asset, this->mediator); T * concrete_resource = dynamic_cast<T *>(entry.resource.get()); if (concrete_resource == nullptr) diff --git a/src/crepe/manager/SaveManager.cpp b/src/crepe/manager/SaveManager.cpp index 39b92d4..691ea2f 100644 --- a/src/crepe/manager/SaveManager.cpp +++ b/src/crepe/manager/SaveManager.cpp @@ -14,10 +14,8 @@ SaveManager::SaveManager(Mediator & mediator) : Manager(mediator) { DB & SaveManager::get_db() { if (this->db == nullptr) { Config & cfg = Config::get_instance(); - this->db = { - new DB(cfg.savemgr.location), - [](void * db){ delete static_cast<DB *>(db); } - }; + this->db + = {new DB(cfg.savemgr.location), [](void * db) { delete static_cast<DB *>(db); }}; } return *static_cast<DB *>(this->db.get()); } diff --git a/src/crepe/manager/SaveManager.h b/src/crepe/manager/SaveManager.h index 27e625c..61a978d 100644 --- a/src/crepe/manager/SaveManager.h +++ b/src/crepe/manager/SaveManager.h @@ -1,7 +1,7 @@ #pragma once -#include <memory> #include <functional> +#include <memory> #include "../ValueBroker.h" @@ -95,9 +95,10 @@ private: protected: //! Create or return DB virtual DB & get_db(); + private: //! Database - std::unique_ptr<void, std::function<void(void*)>> db = nullptr; + std::unique_ptr<void, std::function<void(void *)>> db = nullptr; }; } // namespace crepe |