Browse Source

Handle autometrics better

Josh Engebretson 9 years ago
parent
commit
f365212243

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

@@ -70,6 +70,8 @@ Application::Application(Context* context) :
 
     if (autoMetrics_ || engineParameters_["AutoMetrics"].GetBool())
     {
+        // ensure autoMetrics reflects state
+        autoMetrics_ = true;
         context->GetSubsystem<Metrics>()->Enable();
     }
 

+ 1 - 0
Source/Atomic/Engine/Application.h

@@ -56,6 +56,7 @@ public:
 
     // ATOMIC BEGIN
 
+    static bool GetAutoMetrics() { return autoMetrics_;  }
     static void SetAutoMetrics(bool value) { autoMetrics_ = value;  }
 
     // ATOMIC END

+ 9 - 2
Source/AtomicApp/Player/IPCPlayerApp.cpp

@@ -213,11 +213,18 @@ namespace Atomic
     {
         brokerActive_ = true;
 
+        // If the parent application has a profile mode up, sync 
         SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
         if (debugHud)
         {
-            debugHud->SetMode(eventData["debugHudMode"].GetUInt());
-            debugHud->SetProfilerMode((DebugHudProfileMode)eventData["debugHudProfilerMode"].GetUInt());
+            unsigned mode = eventData["debugHudMode"].GetUInt();
+
+            // Only set if we haven't set the mode in player code
+            if (mode && !debugHud->GetMode())
+            {
+                debugHud->SetMode(mode);
+                debugHud->SetProfilerMode((DebugHudProfileMode)eventData["debugHudProfilerMode"].GetUInt());
+            }
         }
 
     }

+ 4 - 10
Source/AtomicEditor/EditorMode/AEEditorMode.cpp

@@ -21,6 +21,7 @@
 //
 
 #include <Atomic/IO/Log.h>
+#include <Atomic/Engine/Application.h>
 
 #include <Atomic/IPC/IPC.h>
 #include <Atomic/IPC/IPCEvents.h>
@@ -262,18 +263,11 @@ bool EditorMode::PlayProjectInternal(const String &addArgs, bool debug)
     if (debug)
         vargs.Insert(0, "--debug");
 
-    // If the debug hud up is up with metrics info, pass the --autometrics to player
-    SystemUI::DebugHud* debugHud = GetSubsystem<SystemUI::DebugHud>();
-
-    if (debugHud)
+    // forward autometrics to player
+    if (Application::GetAutoMetrics())
     {
-        if (debugHud->GetMode() & Atomic::SystemUI::DEBUGHUD_SHOW_PROFILER)
-        {
-            if (debugHud->GetProfilerMode() == DEBUG_HUD_PROFILE_METRICS)
-                vargs.Insert(0, "--autometrics");
-        }
+        vargs.Insert(0, "--autometrics");
     }
-
     if (addArgs.Length() > 0)
         vargs.Insert(0, addArgs.Split(' '));