Browse Source

Console and DebugHud rendering

Josh Engebretson 10 years ago
parent
commit
f35300c632

+ 1 - 1
CMakeLists.txt

@@ -9,7 +9,7 @@ include(AtomicUtils)
 
 
 add_definitions(-DATOMIC_ROOT_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DATOMIC_ROOT_BUILD_DIR="${CMAKE_BINARY_DIR}")
 add_definitions(-DATOMIC_ROOT_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DATOMIC_ROOT_BUILD_DIR="${CMAKE_BINARY_DIR}")
 
 
-add_definitions( -DATOMIC_API= -DATOMIC_STATIC_DEFINE -DATOMIC_ATOMIC2D -DATOMIC_LOGGING)
+add_definitions( -DATOMIC_API= -DATOMIC_STATIC_DEFINE -DATOMIC_ATOMIC2D -DATOMIC_LOGGING -DATOMIC_PROFILING)
 
 
 if (NOT DEFINED ATOMIC_DEV_BUILD)
 if (NOT DEFINED ATOMIC_DEV_BUILD)
     set(ATOMIC_DEV_BUILD 1)
     set(ATOMIC_DEV_BUILD 1)

+ 0 - 0
Source/Atomic/Engine/Console.h


+ 0 - 0
Source/Atomic/Engine/DebugHud.h


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

@@ -28,8 +28,6 @@
 #include "../Core/ProcessUtils.h"
 #include "../Core/ProcessUtils.h"
 #include "../Core/Profiler.h"
 #include "../Core/Profiler.h"
 #include "../Core/WorkQueue.h"
 #include "../Core/WorkQueue.h"
-#include "../Engine/Console.h"
-#include "../Engine/DebugHud.h"
 #include "../Engine/Engine.h"
 #include "../Engine/Engine.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Renderer.h"
 #include "../Graphics/Renderer.h"

+ 3 - 1
Source/Atomic/UI/SystemUI/BorderImage.cpp

@@ -30,10 +30,12 @@
 namespace Atomic
 namespace Atomic
 {
 {
 
 
+extern const char* blendModeNames[];
+
+
 namespace SystemUI
 namespace SystemUI
 {
 {
 
 
-extern const char* blendModeNames[];
 extern const char* UI_CATEGORY;
 extern const char* UI_CATEGORY;
 
 
 BorderImage::BorderImage(Context* context) :
 BorderImage::BorderImage(Context* context) :

+ 27 - 28
Source/Atomic/Engine/Console.cpp → Source/Atomic/UI/SystemUI/Console.cpp

@@ -1,5 +1,3 @@
-#ifdef __DISABLED
-
 //
 //
 // Copyright (c) 2008-2015 the Urho3D project.
 // Copyright (c) 2008-2015 the Urho3D project.
 //
 //
@@ -22,32 +20,33 @@
 // THE SOFTWARE.
 // THE SOFTWARE.
 //
 //
 
 
-#include "../Precompiled.h"
-
-#include "../Core/Context.h"
-#include "../Core/CoreEvents.h"
-#include "../Engine/Console.h"
-#include "../Engine/EngineEvents.h"
-#include "../Graphics/Graphics.h"
-#include "../Graphics/GraphicsEvents.h"
-#include "../Input/Input.h"
-#include "../IO/IOEvents.h"
-#include "../IO/Log.h"
-#include "../Resource/ResourceCache.h"
-#include "../UI/DropDownList.h"
-#include "../UI/Font.h"
-#include "../UI/LineEdit.h"
-#include "../UI/ListView.h"
-#include "../UI/ScrollBar.h"
-#include "../UI/Text.h"
-#include "../UI/UI.h"
-#include "../UI/UIEvents.h"
-
-#include "../DebugNew.h"
+#include "../../Core/Context.h"
+#include "../../Core/CoreEvents.h"
+#include "../../Engine/EngineEvents.h"
+#include "../../Graphics/Graphics.h"
+#include "../../Graphics/GraphicsEvents.h"
+#include "../../Input/Input.h"
+#include "../../IO/IOEvents.h"
+#include "../../IO/Log.h"
+#include "../../Resource/ResourceCache.h"
+#include "DropDownList.h"
+#include "Font.h"
+#include "LineEdit.h"
+#include "ListView.h"
+#include "ScrollBar.h"
+#include "Text.h"
+#include "SystemUI.h"
+#include "SystemUIEvents.h"
+#include "Console.h"
+
+#include "../../DebugNew.h"
 
 
 namespace Atomic
 namespace Atomic
 {
 {
 
 
+namespace SystemUI
+{
+
 static const int DEFAULT_CONSOLE_ROWS = 16;
 static const int DEFAULT_CONSOLE_ROWS = 16;
 static const int DEFAULT_HISTORY_SIZE = 16;
 static const int DEFAULT_HISTORY_SIZE = 16;
 
 
@@ -58,7 +57,7 @@ Console::Console(Context* context) :
     historyPosition_(0),
     historyPosition_(0),
     printing_(false)
     printing_(false)
 {
 {
-    UI* ui = GetSubsystem<UI>();
+    SystemUI* ui = GetSubsystem<SystemUI>();
     UIElement* uiRoot = ui->GetRoot();
     UIElement* uiRoot = ui->GetRoot();
 
 
     // By default prevent the automatic showing of the screen keyboard
     // By default prevent the automatic showing of the screen keyboard
@@ -138,7 +137,7 @@ void Console::SetVisible(bool enable)
         bool hasInterpreter = PopulateInterpreter();
         bool hasInterpreter = PopulateInterpreter();
         commandLine_->SetVisible(hasInterpreter);
         commandLine_->SetVisible(hasInterpreter);
         if (hasInterpreter && focusOnShow_)
         if (hasInterpreter && focusOnShow_)
-            GetSubsystem<UI>()->SetFocusElement(lineEdit_);
+            GetSubsystem<SystemUI>()->SetFocusElement(lineEdit_);
 
 
         // Ensure the background has no empty space when shown without the lineedit
         // Ensure the background has no empty space when shown without the lineedit
         background_->SetHeight(background_->GetMinHeight());
         background_->SetHeight(background_->GetMinHeight());
@@ -409,7 +408,7 @@ void Console::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
     // Ensure UI-elements are not detached
     // Ensure UI-elements are not detached
     if (!background_->GetParent())
     if (!background_->GetParent())
     {
     {
-        UI* ui = GetSubsystem<UI>();
+        SystemUI* ui = GetSubsystem<SystemUI>();
         UIElement* uiRoot = ui->GetRoot();
         UIElement* uiRoot = ui->GetRoot();
         uiRoot->AddChild(background_);
         uiRoot->AddChild(background_);
         uiRoot->AddChild(closeButton_);
         uiRoot->AddChild(closeButton_);
@@ -443,4 +442,4 @@ void Console::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 
 
 }
 }
 
 
-#endif
+}

+ 176 - 0
Source/Atomic/UI/SystemUI/Console.h

@@ -0,0 +1,176 @@
+//
+// Copyright (c) 2008-2015 the Urho3D project.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "../../Core/Object.h"
+
+namespace Atomic
+{
+
+class Engine;
+class XMLFile;
+
+namespace SystemUI
+{
+
+class Button;
+class BorderImage;
+class DropDownList;
+class Font;
+class LineEdit;
+class ListView;
+class Text;
+class UIElement;
+
+/// %Console window with log history and command line prompt.
+class ATOMIC_API Console : public Object
+{
+    OBJECT(Console);
+
+public:
+    /// Construct.
+    Console(Context* context);
+    /// Destruct.
+    ~Console();
+
+    /// Set UI elements' style from an XML file.
+    void SetDefaultStyle(XMLFile* style);
+    /// Show or hide.
+    void SetVisible(bool enable);
+    /// Toggle visibility.
+    void Toggle();
+
+    /// Automatically set console to visible when receiving an error log message.
+    void SetAutoVisibleOnError(bool enable) { autoVisibleOnError_ = enable; }
+
+    /// Set the command interpreter.
+    void SetCommandInterpreter(const String& interpreter) { commandInterpreter_ = interpreter; }
+
+    /// Set number of buffered rows.
+    void SetNumBufferedRows(unsigned rows);
+    /// Set number of displayed rows.
+    void SetNumRows(unsigned rows);
+    /// Set command history maximum size, 0 disables history.
+    void SetNumHistoryRows(unsigned rows);
+    /// Set whether to automatically focus the line edit when showing. Default true on desktops and false on mobile devices, as on mobiles it would pop up the screen keyboard.
+    void SetFocusOnShow(bool enable);
+    /// Update elements to layout properly. Call this after manually adjusting the sub-elements.
+    void UpdateElements();
+
+    /// Return the UI style file.
+    XMLFile* GetDefaultStyle() const;
+
+    /// Return the background element.
+    BorderImage* GetBackground() const { return background_; }
+
+    /// Return the line edit element.
+    LineEdit* GetLineEdit() const { return lineEdit_; }
+
+    /// Return the close butoon element.
+    Button* GetCloseButton() const { return closeButton_; }
+
+    /// Return whether is visible.
+    bool IsVisible() const;
+
+    /// Return true when console is set to automatically visible when receiving an error log message.
+    bool IsAutoVisibleOnError() const { return autoVisibleOnError_; }
+
+    /// Return the last used command interpreter.
+    const String& GetCommandInterpreter() const { return commandInterpreter_; }
+
+    /// Return number of buffered rows.
+    unsigned GetNumBufferedRows() const;
+
+    /// Return number of displayed rows.
+    unsigned GetNumRows() const { return displayedRows_; }
+
+    /// Copy selected rows to system clipboard.
+    void CopySelectedRows() const;
+
+    /// Return history maximum size.
+    unsigned GetNumHistoryRows() const { return historyRows_; }
+
+    /// Return current history position.
+    unsigned GetHistoryPosition() const { return historyPosition_; }
+
+    /// Return history row at index.
+    const String& GetHistoryRow(unsigned index) const;
+
+    /// Return whether automatically focuses the line edit when showing.
+    bool GetFocusOnShow() const { return focusOnShow_; }
+
+private:
+    /// Populate the command line interpreters that could handle the console command.
+    bool PopulateInterpreter();
+    /// Handle interpreter being selected on the drop down list.
+    void HandleInterpreterSelected(StringHash eventType, VariantMap& eventData);
+    /// Handle enter pressed on the line edit.
+    void HandleTextFinished(StringHash eventType, VariantMap& eventData);
+    /// Handle unhandled key on the line edit for scrolling the history.
+    void HandleLineEditKey(StringHash eventType, VariantMap& eventData);
+    /// Handle close button being pressed.
+    void HandleCloseButtonPressed(StringHash eventType, VariantMap& eventData);
+    /// Handle rendering window resize.
+    void HandleScreenMode(StringHash eventType, VariantMap& eventData);
+    /// Handle a log message.
+    void HandleLogMessage(StringHash eventType, VariantMap& eventData);
+    /// Handle the application post-update.
+    void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
+
+    /// Auto visible on error flag.
+    bool autoVisibleOnError_;
+    /// Background.
+    SharedPtr<BorderImage> background_;
+    /// Container for text rows.
+    ListView* rowContainer_;
+    /// Container for the command line.
+    UIElement* commandLine_;
+    /// Interpreter drop down list.
+    DropDownList* interpreters_;
+    /// Line edit.
+    LineEdit* lineEdit_;
+    /// Close button.
+    SharedPtr<Button> closeButton_;
+    /// Last used command interpreter.
+    String commandInterpreter_;
+    /// Command history.
+    Vector<String> history_;
+    /// Pending log message rows.
+    Vector<Pair<int, String> > pendingRows_;
+    /// Current row being edited.
+    String currentRow_;
+    /// Maximum displayed rows.
+    unsigned displayedRows_;
+    /// Command history maximum rows.
+    unsigned historyRows_;
+    /// Command history current position.
+    unsigned historyPosition_;
+    /// Flag when printing messages to prevent endless loop.
+    bool printing_;
+    /// Flag for automatically focusing the line edit on showing the console.
+    bool focusOnShow_;
+};
+
+}
+
+}

+ 17 - 16
Source/Atomic/Engine/DebugHud.cpp → Source/Atomic/UI/SystemUI/DebugHud.cpp

@@ -1,5 +1,3 @@
-#ifdef __DISABLED
-
 //
 //
 // Copyright (c) 2008-2015 the Urho3D project.
 // Copyright (c) 2008-2015 the Urho3D project.
 //
 //
@@ -22,21 +20,25 @@
 // THE SOFTWARE.
 // THE SOFTWARE.
 //
 //
 
 
-#include "../Precompiled.h"
-
-#include "../Core/CoreEvents.h"
-#include "../Core/Profiler.h"
-#include "../Engine/DebugHud.h"
-#include "../Engine/Engine.h"
-#include "../Graphics/Graphics.h"
-#include "../Graphics/Renderer.h"
-#include "../IO/Log.h"
+#include "../../Core/CoreEvents.h"
+#include "../../Core/Profiler.h"
+#include "../../Engine/Engine.h"
+#include "../../Graphics/Graphics.h"
+#include "../../Graphics/Renderer.h"
+#include "../../IO/Log.h"
+#include "Font.h"
+#include "Text.h"
+#include "SystemUI.h"
+#include "DebugHud.h"
 
 
-#include "../DebugNew.h"
+#include "../../DebugNew.h"
 
 
 namespace Atomic
 namespace Atomic
 {
 {
 
 
+namespace SystemUI
+{
+
 static const char* qualityTexts[] =
 static const char* qualityTexts[] =
 {
 {
     "Low",
     "Low",
@@ -59,7 +61,7 @@ DebugHud::DebugHud(Context* context) :
     useRendererStats_(false),
     useRendererStats_(false),
     mode_(DEBUGHUD_SHOW_NONE)
     mode_(DEBUGHUD_SHOW_NONE)
 {
 {
-    UI* ui = GetSubsystem<UI>();
+    SystemUI* ui = GetSubsystem<SystemUI>();
     UIElement* uiRoot = ui->GetRoot();
     UIElement* uiRoot = ui->GetRoot();
 
 
     statsText_ = new Text(context_);
     statsText_ = new Text(context_);
@@ -100,7 +102,7 @@ void DebugHud::Update()
     // Ensure UI-elements are not detached
     // Ensure UI-elements are not detached
     if (!statsText_->GetParent())
     if (!statsText_->GetParent())
     {
     {
-        UI* ui = GetSubsystem<UI>();
+        SystemUI* ui = GetSubsystem<SystemUI>();
         UIElement* uiRoot = ui->GetRoot();
         UIElement* uiRoot = ui->GetRoot();
         uiRoot->AddChild(statsText_);
         uiRoot->AddChild(statsText_);
         uiRoot->AddChild(modeText_);
         uiRoot->AddChild(modeText_);
@@ -264,5 +266,4 @@ void DebugHud::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 
 
 }
 }
 
 
-
-#endif
+}

+ 133 - 0
Source/Atomic/UI/SystemUI/DebugHud.h

@@ -0,0 +1,133 @@
+//
+// Copyright (c) 2008-2015 the Urho3D project.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#include "../../Core/Object.h"
+#include "../../Core/Timer.h"
+
+namespace Atomic
+{
+
+class Engine;
+class XMLFile;
+
+namespace SystemUI
+{
+
+class Font;
+class Text;
+
+static const unsigned DEBUGHUD_SHOW_NONE = 0x0;
+static const unsigned DEBUGHUD_SHOW_STATS = 0x1;
+static const unsigned DEBUGHUD_SHOW_MODE = 0x2;
+static const unsigned DEBUGHUD_SHOW_PROFILER = 0x4;
+static const unsigned DEBUGHUD_SHOW_ALL = 0x7;
+
+/// Displays rendering stats and profiling information.
+class ATOMIC_API DebugHud : public Object
+{
+    OBJECT(DebugHud);
+
+public:
+    /// Construct.
+    DebugHud(Context* context);
+    /// Destruct.
+    ~DebugHud();
+
+    /// Update. Called by HandlePostUpdate().
+    void Update();
+    /// Set UI elements' style from an XML file.
+    void SetDefaultStyle(XMLFile* style);
+    /// Set elements to show.
+    void SetMode(unsigned mode);
+    /// Set maximum profiler block depth, default unlimited.
+    void SetProfilerMaxDepth(unsigned depth);
+    /// Set profiler accumulation interval in seconds.
+    void SetProfilerInterval(float interval);
+    /// Set whether to show 3D geometry primitive/batch count only. Default false.
+    void SetUseRendererStats(bool enable);
+    /// Toggle elements.
+    void Toggle(unsigned mode);
+    /// Toggle all elements.
+    void ToggleAll();
+
+    /// Return the UI style file.
+    XMLFile* GetDefaultStyle() const;
+
+    /// Return rendering stats text.
+    Text* GetStatsText() const { return statsText_; }
+
+    /// Return rendering mode text.
+    Text* GetModeText() const { return modeText_; }
+
+    /// Return profiler text.
+    Text* GetProfilerText() const { return profilerText_; }
+
+    /// Return currently shown elements.
+    unsigned GetMode() const { return mode_; }
+
+    /// Return maximum profiler block depth.
+    unsigned GetProfilerMaxDepth() const { return profilerMaxDepth_; }
+
+    /// Return profiler accumulation interval in seconds
+    float GetProfilerInterval() const;
+
+    /// Return whether showing 3D geometry primitive/batch count only.
+    bool GetUseRendererStats() const { return useRendererStats_; }
+
+    /// Set application-specific stats.
+    void SetAppStats(const String& label, const Variant& stats);
+    /// Set application-specific stats.
+    void SetAppStats(const String& label, const String& stats);
+    /// Reset application-specific stats. Return true if it was erased successfully.
+    bool ResetAppStats(const String& label);
+    /// Clear all application-specific stats.
+    void ClearAppStats();
+
+private:
+    /// Handle logic post-update event. The HUD texts are updated here.
+    void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
+
+    /// Rendering stats text.
+    SharedPtr<Text> statsText_;
+    /// Rendering mode text.
+    SharedPtr<Text> modeText_;
+    /// Profiling information text.
+    SharedPtr<Text> profilerText_;
+    /// Hashmap containing application specific stats.
+    HashMap<String, String> appStats_;
+    /// Profiler timer.
+    Timer profilerTimer_;
+    /// Profiler max block depth.
+    unsigned profilerMaxDepth_;
+    /// Profiler accumulation interval.
+    unsigned profilerInterval_;
+    /// Show 3D geometry primitive/batch count flag.
+    bool useRendererStats_;
+    /// Current shown-element mode.
+    unsigned mode_;
+};
+
+}
+
+}

+ 2 - 1
Source/Atomic/UI/SystemUI/Sprite.cpp

@@ -30,10 +30,11 @@
 namespace Atomic
 namespace Atomic
 {
 {
 
 
+extern const char* blendModeNames[];
+
 namespace SystemUI
 namespace SystemUI
 {
 {
 
 
-extern const char* blendModeNames[];
 extern const char* horizontalAlignments[];
 extern const char* horizontalAlignments[];
 extern const char* verticalAlignments[];
 extern const char* verticalAlignments[];
 extern const char* UI_CATEGORY;
 extern const char* UI_CATEGORY;

+ 27 - 3
Source/Atomic/UI/SystemUI/SystemUI.cpp

@@ -51,6 +51,9 @@
 #include "SystemUIEvents.h"
 #include "SystemUIEvents.h"
 #include "Window.h"
 #include "Window.h"
 
 
+#include "Console.h"
+#include "DebugHud.h"
+
 #include <SDL/include/SDL.h>
 #include <SDL/include/SDL.h>
 
 
 #include "../../DebugNew.h"
 #include "../../DebugNew.h"
@@ -112,7 +115,7 @@ SystemUI::SystemUI(Context* context) :
     rootModalElement_->SetTraversalMode(TM_DEPTH_FIRST);
     rootModalElement_->SetTraversalMode(TM_DEPTH_FIRST);
 
 
     // Register UI library object factories
     // Register UI library object factories
-    RegisterUILibrary(context_);
+    RegisterSystemUILibrary(context_);
 
 
     SubscribeToEvent(E_SCREENMODE, HANDLER(SystemUI, HandleScreenMode));
     SubscribeToEvent(E_SCREENMODE, HANDLER(SystemUI, HandleScreenMode));
     SubscribeToEvent(E_MOUSEBUTTONDOWN, HANDLER(SystemUI, HandleMouseButtonDown));
     SubscribeToEvent(E_MOUSEBUTTONDOWN, HANDLER(SystemUI, HandleMouseButtonDown));
@@ -708,7 +711,7 @@ void SystemUI::Initialize()
     SubscribeToEvent(E_POSTUPDATE, HANDLER(SystemUI, HandlePostUpdate));
     SubscribeToEvent(E_POSTUPDATE, HANDLER(SystemUI, HandlePostUpdate));
     SubscribeToEvent(E_RENDERUPDATE, HANDLER(SystemUI, HandleRenderUpdate));
     SubscribeToEvent(E_RENDERUPDATE, HANDLER(SystemUI, HandleRenderUpdate));
 
 
-    LOGINFO("Initialized user interface");
+    LOGINFO("Initialized system user interface");
 }
 }
 
 
 void SystemUI::Update(float timeStep, UIElement* element)
 void SystemUI::Update(float timeStep, UIElement* element)
@@ -1765,7 +1768,28 @@ IntVector2 SystemUI::SumTouchPositions(SystemUI::DragData* dragData, const IntVe
     return sendPos;
     return sendPos;
 }
 }
 
 
-void RegisterUILibrary(Context* context)
+void SystemUI::CreateConsoleAndDebugHud()
+{
+    // Get default style
+    ResourceCache* cache = GetSubsystem<ResourceCache>();
+    XMLFile* xmlFile = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
+
+    Console* console = new Console(context_);
+    console->SetDefaultStyle(xmlFile);
+    console->GetBackground()->SetOpacity(0.8f);
+
+    DebugHud* debugHud = new DebugHud(context_);
+    debugHud->SetDefaultStyle(xmlFile);
+
+    // Create console & debug hud
+    context_->RegisterSubsystem(console);
+    context_->RegisterSubsystem(debugHud);
+
+    console->Toggle();
+    debugHud->ToggleAll();
+}
+
+void RegisterSystemUILibrary(Context* context)
 {
 {
     Font::RegisterObject(context);
     Font::RegisterObject(context);
 
 

+ 3 - 1
Source/Atomic/UI/SystemUI/SystemUI.h

@@ -185,6 +185,8 @@ public:
         IntVector2 dragBeginSumPos;
         IntVector2 dragBeginSumPos;
     };
     };
 
 
+    void CreateConsoleAndDebugHud();
+
 private:
 private:
     /// Initialize when screen mode initially set.
     /// Initialize when screen mode initially set.
     void Initialize();
     void Initialize();
@@ -338,7 +340,7 @@ private:
 };
 };
 
 
 /// Register UI library objects.
 /// Register UI library objects.
-void ATOMIC_API RegisterUILibrary(Context* context);
+void ATOMIC_API RegisterSystemUILibrary(Context* context);
 
 
 }
 }
 
 

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

@@ -57,6 +57,8 @@ using namespace tb;
 #include "UISeparator.h"
 #include "UISeparator.h"
 #include "UIDimmer.h"
 #include "UIDimmer.h"
 
 
+#include "SystemUI/SystemUI.h"
+
 namespace tb
 namespace tb
 {
 {
 
 
@@ -159,6 +161,10 @@ void UI::Initialize(const String& languageFile)
 
 
     initialized_ = true;
     initialized_ = true;
 
 
+    SystemUI::SystemUI* systemUI = new SystemUI::SystemUI(context_);
+    context_->RegisterSubsystem(systemUI);
+    systemUI->CreateConsoleAndDebugHud();
+
     //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1;
     //TB_DEBUG_SETTING(LAYOUT_BOUNDS) = 1;
 }
 }
 
 
@@ -299,6 +305,8 @@ void UI::Render(bool resetRenderTargets)
 {
 {
     SetVertexData(vertexBuffer_, vertexData_);
     SetVertexData(vertexBuffer_, vertexData_);
     Render(vertexBuffer_, batches_, 0, batches_.Size());
     Render(vertexBuffer_, batches_, 0, batches_.Size());
+
+    GetSubsystem<SystemUI::SystemUI>()->Render();
 }
 }
 
 
 void UI::HandleRenderUpdate(StringHash eventType, VariantMap& eventData)
 void UI::HandleRenderUpdate(StringHash eventType, VariantMap& eventData)