From 9b7b46143d2df7d4f2efcb89ceb5034c7a57e79c Mon Sep 17 00:00:00 2001 From: Leon Krause Date: Mon, 13 Nov 2017 21:46:57 +0100 Subject: Move singleton management from ProjectSettings to Engine --- core/engine.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'core/engine.cpp') diff --git a/core/engine.cpp b/core/engine.cpp index c609ae952..d2ef70d82 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -100,6 +100,32 @@ Dictionary Engine::get_version_info() const { return dict; } +void Engine::add_singleton(const Singleton &p_singleton) { + + singletons.push_back(p_singleton); + singleton_ptrs[p_singleton.name] = p_singleton.ptr; +} + +Object *Engine::get_singleton_object(const String &p_name) const { + + const Map::Element *E = singleton_ptrs.find(p_name); + if (!E) + return NULL; + else + return E->get(); +}; + +bool Engine::has_singleton(const String &p_name) const { + + return get_singleton_object(p_name) != NULL; +}; + +void Engine::get_singletons(List *p_singletons) { + + for (List::Element *E = singletons.front(); E; E = E->next()) + p_singletons->push_back(E->get()); +} + Engine *Engine::singleton = NULL; Engine *Engine::get_singleton() { -- cgit v1.2.3-70-g09d2