Browse Source

Move DebugHud update to PostUpdate event so that values set during Update will be displayed on the same frame. Additionally, exposed DebugHud::Update() to script to allow calling it manually and forcing update of values, if necessary. Closes #466.

Lasse Öörni 11 years ago
parent
commit
0f9e8c6762

+ 3 - 3
Source/Engine/Engine/DebugHud.cpp

@@ -80,7 +80,7 @@ DebugHud::DebugHud(Context* context) :
     profilerText_->SetVisible(false);
     profilerText_->SetVisible(false);
     uiRoot->AddChild(profilerText_);
     uiRoot->AddChild(profilerText_);
 
 
-    SubscribeToEvent(E_UPDATE, HANDLER(DebugHud, HandleUpdate));
+    SubscribeToEvent(E_POSTUPDATE, HANDLER(DebugHud, HandlePostUpdate));
 }
 }
 
 
 DebugHud::~DebugHud()
 DebugHud::~DebugHud()
@@ -259,9 +259,9 @@ void DebugHud::ClearAppStats()
     appStats_.Clear();
     appStats_.Clear();
 }
 }
 
 
-void DebugHud::HandleUpdate(StringHash eventType, VariantMap& eventData)
+void DebugHud::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 {
 {
-    using namespace Update;
+    using namespace PostUpdate;
 
 
     Update();
     Update();
 }
 }

+ 3 - 3
Source/Engine/Engine/DebugHud.h

@@ -50,7 +50,7 @@ public:
     /// Destruct.
     /// Destruct.
     ~DebugHud();
     ~DebugHud();
 
 
-    /// Update. Called by HandleUpdate().
+    /// Update. Called by HandlePostUpdate().
     void Update();
     void Update();
     /// Set UI elements' style from an XML file.
     /// Set UI elements' style from an XML file.
     void SetDefaultStyle(XMLFile* style);
     void SetDefaultStyle(XMLFile* style);
@@ -94,8 +94,8 @@ public:
     void ClearAppStats();
     void ClearAppStats();
 
 
 private:
 private:
-    /// Handle logic update event.
-    void HandleUpdate(StringHash eventType, VariantMap& eventData);
+    /// Handle logic post-update event. The HUD texts are updated here.
+    void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
 
 
     /// Rendering stats text.
     /// Rendering stats text.
     SharedPtr<Text> statsText_;
     SharedPtr<Text> statsText_;

+ 1 - 0
Source/Engine/LuaScript/pkgs/Engine/DebugHud.pkg

@@ -8,6 +8,7 @@ static const unsigned DEBUGHUD_SHOW_ALL;
 
 
 class DebugHud : public Object
 class DebugHud : public Object
 {
 {
+    void Update();
     void SetDefaultStyle(XMLFile* style);
     void SetDefaultStyle(XMLFile* style);
     void SetMode(unsigned mode);
     void SetMode(unsigned mode);
     void SetProfilerMaxDepth(unsigned depth);
     void SetProfilerMaxDepth(unsigned depth);

+ 1 - 0
Source/Engine/Script/EngineAPI.cpp

@@ -78,6 +78,7 @@ static void RegisterDebugHud(asIScriptEngine* engine)
     engine->RegisterGlobalProperty("const uint DEBUGHUD_SHOW_ALL", (void*)&DEBUGHUD_SHOW_ALL);
     engine->RegisterGlobalProperty("const uint DEBUGHUD_SHOW_ALL", (void*)&DEBUGHUD_SHOW_ALL);
 
 
     RegisterObject<Console>(engine, "DebugHud");
     RegisterObject<Console>(engine, "DebugHud");
+    engine->RegisterObjectMethod("DebugHud", "void Update()", asMETHOD(DebugHud, Update), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void Toggle(uint)", asMETHOD(DebugHud, Toggle), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void Toggle(uint)", asMETHOD(DebugHud, Toggle), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void ToggleAll()", asMETHOD(DebugHud, ToggleAll), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void ToggleAll()", asMETHOD(DebugHud, ToggleAll), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void set_defaultStyle(XMLFile@+)", asMETHOD(DebugHud, SetDefaultStyle), asCALL_THISCALL);
     engine->RegisterObjectMethod("DebugHud", "void set_defaultStyle(XMLFile@+)", asMETHOD(DebugHud, SetDefaultStyle), asCALL_THISCALL);