From 04ad84efbed30cd80fb17471e9c34c606331dd63 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Mon, 26 Jun 2017 18:36:12 +0300 Subject: [PATCH 1/4] Tidy up initialization of SystemUI --- Source/Atomic/Engine/Engine.cpp | 6 ++++++ Source/Atomic/UI/SystemUI/SystemUI.cpp | 14 +++----------- Source/Atomic/UI/SystemUI/SystemUI.h | 2 -- Source/Atomic/UI/UI.cpp | 4 ---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Source/Atomic/Engine/Engine.cpp b/Source/Atomic/Engine/Engine.cpp index b49c187fc8..103451e252 100644 --- a/Source/Atomic/Engine/Engine.cpp +++ b/Source/Atomic/Engine/Engine.cpp @@ -42,6 +42,7 @@ // ATOMIC BEGIN #include "../Resource/XMLFile.h" +#include "../UI/SystemUI/SystemUI.h" // ATOMIC END #ifdef ATOMIC_NAVIGATION @@ -344,6 +345,11 @@ bool Engine::Initialize(const VariantMap& parameters) EventProfiler::SetActive(true); } #endif + + // ATOMIC BEGIN + context_->RegisterSubsystem(new SystemUI(context_)); + // ATOMIC END + frameTimer_.Reset(); ATOMIC_LOGINFO("Initialized engine"); diff --git a/Source/Atomic/UI/SystemUI/SystemUI.cpp b/Source/Atomic/UI/SystemUI/SystemUI.cpp index 04e0790dc0..e78b2fd79e 100644 --- a/Source/Atomic/UI/SystemUI/SystemUI.cpp +++ b/Source/Atomic/UI/SystemUI/SystemUI.cpp @@ -87,6 +87,9 @@ SystemUI::SystemUI(Atomic::Context* context) }); SubscribeToEvent(E_SDLRAWINPUT, std::bind(&SystemUI::OnRawEvent, this, _2)); SubscribeToEvent(E_SCREENMODE, std::bind(&SystemUI::UpdateProjectionMatrix, this)); + + context_->RegisterSubsystem(new Console(context_)); + context_->RegisterSubsystem(new DebugHud(context_)); } SystemUI::~SystemUI() @@ -368,16 +371,5 @@ void SystemUI::SetScale(float scale) UpdateProjectionMatrix(); } -void SystemUI::CreateConsoleAndDebugHud() -{ - Console* console = new Console(context_); - DebugHud* debugHud = new DebugHud(context_); - - // Create console & debug hud - context_->RegisterSubsystem(console); - context_->RegisterSubsystem(debugHud); - -} - } diff --git a/Source/Atomic/UI/SystemUI/SystemUI.h b/Source/Atomic/UI/SystemUI/SystemUI.h index 892b6a0697..4204c29c36 100644 --- a/Source/Atomic/UI/SystemUI/SystemUI.h +++ b/Source/Atomic/UI/SystemUI/SystemUI.h @@ -73,8 +73,6 @@ ATOMIC_OBJECT(SystemUI, Atomic::Object); const Atomic::String& font_path, float size = 0, const std::initializer_list& ranges = {}, bool merge = false); - void CreateConsoleAndDebugHud(); - protected: float uiScale_ = 1.f; Atomic::Matrix4 projection_; diff --git a/Source/Atomic/UI/UI.cpp b/Source/Atomic/UI/UI.cpp index 930dbacbb3..b5779f9be9 100644 --- a/Source/Atomic/UI/UI.cpp +++ b/Source/Atomic/UI/UI.cpp @@ -242,10 +242,6 @@ void UI::Initialize(const String& languageFile) initialized_ = true; - SystemUI* systemUI = new SystemUI(context_); - context_->RegisterSubsystem(systemUI); - systemUI->CreateConsoleAndDebugHud(); - //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1; } From 4b61629919e91513a64271d4a1f5c6ef0a169b2d Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Mon, 26 Jun 2017 18:38:02 +0300 Subject: [PATCH 2/4] Added pointers of most commonly used subsystems to Context --- Source/Atomic/Core/Context.h | 42 +++++++++++++++++++++++++++++++++ Source/Atomic/Engine/Engine.cpp | 25 ++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Source/Atomic/Core/Context.h b/Source/Atomic/Core/Context.h index cf4689e68c..6deff5fc41 100644 --- a/Source/Atomic/Core/Context.h +++ b/Source/Atomic/Core/Context.h @@ -38,6 +38,27 @@ class GlobalEventListener virtual void EndSendEvent(Context* context, Object* sender, StringHash eventType, VariantMap& eventData) = 0; }; +class Metrics; +class Engine; +class Time; +class WorkQueue; +class Profiler; +class FileSystem; +class Log; +class ResourceCache; +class Localization; +class Network; +class Web; +class Database; +class Input; +class Audio; +class UI; +class SystemUI; +class Graphics; +class Renderer; +class Console; +class DebugHud; + // ATOMIC END /// Tracking structure for event receivers. @@ -228,6 +249,27 @@ class ATOMIC_API Context : public RefCounted void AddGlobalEventListener(GlobalEventListener* listener) { globalEventListeners_.Push(listener); } void RemoveGlobalEventListener(GlobalEventListener* listener) { globalEventListeners_.Erase(globalEventListeners_.Find(listener)); } + WeakPtr engine_; + WeakPtr