Browse Source

Adding profiler and console to AtomicEditor menus, forward whether profiling to player app, when console is open filter input

Josh Engebretson 10 years ago
parent
commit
fcae0d9a89

+ 31 - 3
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -13,6 +13,8 @@ class MainFrameMenu extends Atomic.ScriptObject {
         MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
         MenuItemSources.createMenuItemSource("menu edit", editItems);
         MenuItemSources.createMenuItemSource("menu file", fileItems);
+        MenuItemSources.createMenuItemSource("menu tools", toolsItems);
+        MenuItemSources.createMenuItemSource("menu developer", developerItems);
     }
 
     handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
@@ -28,9 +30,9 @@ class MainFrameMenu extends Atomic.ScriptObject {
 
             if (refid == "manage license") {
 
-              EditorUI.getModelOps().showManageLicense();
+                EditorUI.getModelOps().showManageLicense();
 
-              return true;
+                return true;
 
             }
 
@@ -119,8 +121,22 @@ class MainFrameMenu extends Atomic.ScriptObject {
                 return true;
             }
 
-
             return false;
+
+        } else if (target.id == "menu developer popup") {
+
+            if (refid == "developer show console") {
+                Atomic.ui.showConsole(true);
+                return true;
+            }
+
+        } else if (target.id == "menu tools popup") {
+
+            if (refid == "tools toggle profiler") {
+                Atomic.ui.toggleDebugHud();
+                return true;
+            }
+
         }
 
     }
@@ -163,6 +179,18 @@ var editItems = {
 
 };
 
+var toolsItems = {
+
+    "Toggle Profiler": ["tools toggle profiler"]
+
+}
+
+var developerItems = {
+
+    "Show Console": ["developer show console"]
+
+}
+
 var fileItems = {
 
     "New Project": ["file new project"],

+ 1 - 0
Source/Atomic/UI/SystemUI/Console.cpp

@@ -377,6 +377,7 @@ void Console::HandleLineEditKey(StringHash eventType, VariantMap& eventData)
 void Console::HandleCloseButtonPressed(StringHash eventType, VariantMap& eventData)
 {
     SetVisible(false);
+    SendEvent(E_CONSOLECLOSED);
 }
 
 void Console::HandleScreenMode(StringHash eventType, VariantMap& eventData)

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

@@ -1785,8 +1785,6 @@ void SystemUI::CreateConsoleAndDebugHud()
     context_->RegisterSubsystem(console);
     context_->RegisterSubsystem(debugHud);
 
-    console->Toggle();
-    debugHud->ToggleAll();
 }
 
 void RegisterSystemUILibrary(Context* context)

+ 5 - 0
Source/Atomic/UI/SystemUI/SystemUIEvents.h

@@ -379,6 +379,11 @@ EVENT(E_UIDROPFILE, UIDropFile)
     PARAM(P_ELEMENTY, ElementY);            // int (only if element is non-null)
 }
 
+EVENT(E_CONSOLECLOSED, ConsoleClosed)
+{
+
+}
+
 }
 
 }

+ 54 - 1
Source/Atomic/UI/UI.cpp

@@ -58,6 +58,9 @@ using namespace tb;
 #include "UIDimmer.h"
 
 #include "SystemUI/SystemUI.h"
+#include "SystemUI/SystemUIEvents.h"
+#include "SystemUI/DebugHud.h"
+#include "SystemUI/Console.h"
 
 namespace tb
 {
@@ -82,7 +85,8 @@ UI::UI(Context* context) :
     inputDisabled_(false),
     keyboardDisabled_(false),
     initialized_(false),
-    skinLoaded_(false)
+    skinLoaded_(false),
+    consoleVisible_(false)
 {
 
 }
@@ -154,6 +158,7 @@ void UI::Initialize(const String& languageFile)
     SubscribeToEvent(E_KEYUP, HANDLER(UI, HandleKeyUp));
     SubscribeToEvent(E_TEXTINPUT, HANDLER(UI, HandleTextInput));
     SubscribeToEvent(E_UPDATE, HANDLER(UI, HandleUpdate));
+    SubscribeToEvent(SystemUI::E_CONSOLECLOSED, HANDLER(UI, HandleConsoleClosed));
 
     SubscribeToEvent(E_RENDERUPDATE, HANDLER(UI, HandleRenderUpdate));
 
@@ -666,6 +671,54 @@ bool UI::OnWidgetDying(tb::TBWidget *widget)
     return false;
 }
 
+void UI::ShowDebugHud(bool value)
+{
+    SystemUI::DebugHud* hud = GetSubsystem<SystemUI::DebugHud>();
+
+    if (!hud)
+        return;
+
+    if (value)
+        hud->SetMode(SystemUI::DEBUGHUD_SHOW_ALL);
+    else
+        hud->SetMode(SystemUI::DEBUGHUD_SHOW_NONE);
+}
+
+void UI::ToggleDebugHud()
+{
+    SystemUI::DebugHud* hud = GetSubsystem<SystemUI::DebugHud>();
+
+    if (!hud)
+        return;
+
+    hud->ToggleAll();
+}
+
+void UI::ShowConsole(bool value)
+{
+    SystemUI::Console* console = GetSubsystem<SystemUI::Console>();
+
+    if (!console)
+        return;
+
+    console->SetVisible(value);
+    consoleVisible_ = console->IsVisible();
+}
+
+void UI::ToggleConsole()
+{
+    SystemUI::Console* console = GetSubsystem<SystemUI::Console>();
 
+    if (!console)
+        return;
+
+    console->Toggle();
+    consoleVisible_ = console->IsVisible();
+}
+
+void UI::HandleConsoleClosed(StringHash eventType, VariantMap& eventData)
+{
+    consoleVisible_ = false;
+}
 
 }

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

@@ -62,6 +62,12 @@ public:
 
     void GetTBIDString(unsigned id, String& value);
 
+    void ShowDebugHud(bool value);
+    void ToggleDebugHud();
+
+    void ShowConsole(bool value);
+    void ToggleConsole();
+
     UIRenderer* GetRenderer() { return renderer_; }
 
 private:
@@ -96,6 +102,7 @@ private:
     bool keyboardDisabled_;
     bool initialized_;
     bool skinLoaded_;
+    bool consoleVisible_;
 
     // Events
     void HandleScreenMode(StringHash eventType, VariantMap& eventData);
@@ -108,6 +115,7 @@ private:
     void HandleKey(bool keydown, int keycode, int scancode);
     void HandleTextInput(StringHash eventType, VariantMap& eventData);
     void HandleUpdate(StringHash eventType, VariantMap& eventData);
+    void HandleConsoleClosed(StringHash eventType, VariantMap& eventData);
 
 
 };

+ 7 - 7
Source/Atomic/UI/UIInput.cpp

@@ -33,7 +33,7 @@ static int toupr_ascii(int ascii)
 
 void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_)
+    if (inputDisabled_ || consoleVisible_)
         return;
 
     using namespace MouseButtonDown;
@@ -77,7 +77,7 @@ void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
 
 void UI::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_)
+    if (inputDisabled_ || consoleVisible_)
         return;
 
     using namespace MouseButtonUp;
@@ -109,7 +109,7 @@ void UI::HandleMouseMove(StringHash eventType, VariantMap& eventData)
 {
     using namespace MouseMove;
 
-    if (inputDisabled_)
+    if (inputDisabled_ || consoleVisible_)
         return;
 
     int px = eventData[P_X].GetInt();
@@ -122,7 +122,7 @@ void UI::HandleMouseMove(StringHash eventType, VariantMap& eventData)
 
 void UI::HandleMouseWheel(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_)
+    if (inputDisabled_ || consoleVisible_)
         return;
 
     using namespace MouseWheel;
@@ -339,7 +339,7 @@ void UI::HandleKey(bool keydown, int keycode, int scancode)
 
 void UI::HandleKeyDown(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_ || keyboardDisabled_)
+    if (inputDisabled_ || keyboardDisabled_ || consoleVisible_)
         return;
 
     using namespace KeyDown;
@@ -376,7 +376,7 @@ void UI::HandleKeyDown(StringHash eventType, VariantMap& eventData)
 
 void UI::HandleKeyUp(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_ || keyboardDisabled_)
+    if (inputDisabled_ || keyboardDisabled_ || consoleVisible_)
         return;
 
     using namespace KeyUp;
@@ -390,7 +390,7 @@ void UI::HandleKeyUp(StringHash eventType, VariantMap& eventData)
 
 void UI::HandleTextInput(StringHash eventType, VariantMap& eventData)
 {
-    if (inputDisabled_ || keyboardDisabled_)
+    if (inputDisabled_ || keyboardDisabled_ || consoleVisible_)
         return;
 
     using namespace TextInput;

+ 6 - 0
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -11,6 +11,8 @@
 
 #include <AtomicJS/Javascript/JSIPCEvents.h>
 
+#include <Atomic/UI/SystemUI/DebugHud.h>
+
 #include "AEEditorMode.h"
 
 using namespace ToolCore;
@@ -32,6 +34,10 @@ EditorMode::~EditorMode()
 void EditorMode::HandleIPCWorkerStarted(StringHash eventType, VariantMap& eventData)
 {
     VariantMap startupData;
+    SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
+
+    startupData["debugHudMode"] = debugHud ? debugHud->GetMode() : (unsigned) 0;
+
     playerBroker_->PostMessage(E_IPCINITIALIZE, startupData);
 
     SendEvent("EditorPlayerStarted");

+ 5 - 0
Source/AtomicEditor/PlayerMode/AEPlayerMode.cpp

@@ -3,6 +3,7 @@
 #include <Atomic/IO/Log.h>
 #include <Atomic/Input/InputEvents.h>
 #include <Atomic/Core/ProcessUtils.h>
+#include <Atomic/UI/SystemUI/DebugHud.h>
 #include <Atomic/IPC/IPCEvents.h>
 #include <Atomic/IPC/IPCWorker.h>
 
@@ -45,6 +46,10 @@ void PlayerMode::HandleIPCInitialize(StringHash eventType, VariantMap& eventData
         SendEvent(E_EXITREQUESTED);
     }
 
+    SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
+    if (debugHud)
+        debugHud->SetMode(eventData["debugHudMode"].GetUInt());
+
 }
 
 void PlayerMode::ProcessArguments() {