Browse Source

Tidy up initialization of SystemUI

Rokas Kupstys 8 years ago
parent
commit
04ad84efbe

+ 6 - 0
Source/Atomic/Engine/Engine.cpp

@@ -42,6 +42,7 @@
 
 
 // ATOMIC BEGIN
 // ATOMIC BEGIN
 #include "../Resource/XMLFile.h"
 #include "../Resource/XMLFile.h"
+#include "../UI/SystemUI/SystemUI.h"
 // ATOMIC END
 // ATOMIC END
 
 
 #ifdef ATOMIC_NAVIGATION
 #ifdef ATOMIC_NAVIGATION
@@ -344,6 +345,11 @@ bool Engine::Initialize(const VariantMap& parameters)
         EventProfiler::SetActive(true);
         EventProfiler::SetActive(true);
     }
     }
 #endif
 #endif
+
+    // ATOMIC BEGIN
+    context_->RegisterSubsystem(new SystemUI(context_));
+    // ATOMIC END
+
     frameTimer_.Reset();
     frameTimer_.Reset();
 
 
     ATOMIC_LOGINFO("Initialized engine");
     ATOMIC_LOGINFO("Initialized engine");

+ 3 - 11
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_SDLRAWINPUT, std::bind(&SystemUI::OnRawEvent, this, _2));
     SubscribeToEvent(E_SCREENMODE, std::bind(&SystemUI::UpdateProjectionMatrix, this));
     SubscribeToEvent(E_SCREENMODE, std::bind(&SystemUI::UpdateProjectionMatrix, this));
+
+    context_->RegisterSubsystem(new Console(context_));
+    context_->RegisterSubsystem(new DebugHud(context_));
 }
 }
 
 
 SystemUI::~SystemUI()
 SystemUI::~SystemUI()
@@ -368,16 +371,5 @@ void SystemUI::SetScale(float scale)
     UpdateProjectionMatrix();
     UpdateProjectionMatrix();
 }
 }
 
 
-void SystemUI::CreateConsoleAndDebugHud()
-{
-    Console* console = new Console(context_);
-    DebugHud* debugHud = new DebugHud(context_);
-
-    // Create console & debug hud
-    context_->RegisterSubsystem(console);
-    context_->RegisterSubsystem(debugHud);
-
-}
-
 }
 }
 
 

+ 0 - 2
Source/Atomic/UI/SystemUI/SystemUI.h

@@ -73,8 +73,6 @@ public:
             const Atomic::String& font_path, float size = 0,
             const Atomic::String& font_path, float size = 0,
             const std::initializer_list<unsigned short>& ranges = {}, bool merge = false);
             const std::initializer_list<unsigned short>& ranges = {}, bool merge = false);
 
 
-    void CreateConsoleAndDebugHud();
-
 protected:
 protected:
     float uiScale_ = 1.f;
     float uiScale_ = 1.f;
     Atomic::Matrix4 projection_;
     Atomic::Matrix4 projection_;

+ 0 - 4
Source/Atomic/UI/UI.cpp

@@ -242,10 +242,6 @@ void UI::Initialize(const String& languageFile)
 
 
     initialized_ = true;
     initialized_ = true;
 
 
-    SystemUI* systemUI = new SystemUI(context_);
-    context_->RegisterSubsystem(systemUI);
-    systemUI->CreateConsoleAndDebugHud();
-
     //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1;
     //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1;
 }
 }