Browse Source

console text highlighting, style detection by log level improved

Arnis Lielturks 9 years ago
parent
commit
e89a769a76
3 changed files with 17 additions and 11 deletions
  1. 10 8
      Source/Urho3D/Engine/Console.cpp
  2. 1 1
      Source/Urho3D/IO/Log.cpp
  3. 6 2
      bin/Data/UI/DefaultStyle.xml

+ 10 - 8
Source/Urho3D/Engine/Console.cpp

@@ -48,6 +48,15 @@ namespace Urho3D
 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;
 
 
+const char* logStyles[] =
+{
+    "ConsoleDebugText",
+    "ConsoleInfoText",
+    "ConsoleWarningText",
+    "ConsoleErrorText",
+    "ConsoleText"
+};
+
 Console::Console(Context* context) :
 Console::Console(Context* context) :
     Object(context),
     Object(context),
     autoVisibleOnError_(false),
     autoVisibleOnError_(false),
@@ -565,14 +574,7 @@ void Console::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
         text->SetText(pendingRows_[i].second_);
         text->SetText(pendingRows_[i].second_);
         
         
         //Highlight console messages based on their type
         //Highlight console messages based on their type
-        if (pendingRows_[i].first_ == LOG_ERROR)
-            text->SetStyle("ConsoleErrorText");
-        else if (pendingRows_[i].first_ == LOG_WARNING)
-            text->SetStyle("ConsoleWarningText");
-        else if (pendingRows_[i].first_ == LOG_INFO)
-            text->SetStyle("ConsoleInfoText");
-        else
-            text->SetStyle("ConsoleText");
+        text->SetStyle(logStyles[pendingRows_[i].first_]);
 
 
         rowContainer_->AddItem(text);
         rowContainer_->AddItem(text);
     }
     }

+ 1 - 1
Source/Urho3D/IO/Log.cpp

@@ -257,7 +257,7 @@ void Log::WriteRaw(const String& message, bool error)
 
 
     VariantMap& eventData = logInstance->GetEventDataMap();
     VariantMap& eventData = logInstance->GetEventDataMap();
     eventData[P_MESSAGE] = message;
     eventData[P_MESSAGE] = message;
-    eventData[P_LEVEL] = error ? LOG_ERROR : LOG_RAW;
+    eventData[P_LEVEL] = error ? LOG_ERROR : LOG_INFO;
     logInstance->SendEvent(E_LOGMESSAGE, eventData);
     logInstance->SendEvent(E_LOGMESSAGE, eventData);
 
 
     logInstance->inWrite_ = false;
     logInstance->inWrite_ = false;

+ 6 - 2
bin/Data/UI/DefaultStyle.xml

@@ -249,13 +249,17 @@
         <attribute name="Layout Border" value="4 4 4 4" />
         <attribute name="Layout Border" value="4 4 4 4" />
     </element>
     </element>
     <element type="ConsoleText" style="Text" auto="false">
     <element type="ConsoleText" style="Text" auto="false">
-        <attribute name="Color" value="0.85 0.85 0.85" />
+        <attribute name="Hover Color" value="0.3 0.4 0.7 1" />
+        <attribute name="Selection Color" value="0.2 0.225 0.35 1" />
     </element>
     </element>
     <element type="ConsoleErrorText" style="ConsoleText" auto="false">
     <element type="ConsoleErrorText" style="ConsoleText" auto="false">
         <attribute name="Color" value="1 0 0 1" />
         <attribute name="Color" value="1 0 0 1" />
     </element>
     </element>
+    <element type="ConsoleDebugText" style="ConsoleText" auto="false">
+        <attribute name="Color" value="1 0.6 0 1" />
+    </element>
     <element type="ConsoleInfoText" style="ConsoleText" auto="false">
     <element type="ConsoleInfoText" style="ConsoleText" auto="false">
-        <attribute name="Color" value="0 1 0 1" />
+        <attribute name="Color" value="0.85 0.85 0.85" />
     </element>
     </element>
     <element type="ConsoleWarningText" style="ConsoleText" auto="false">
     <element type="ConsoleWarningText" style="ConsoleText" auto="false">
         <attribute name="Color" value="1 1 0 1" />
         <attribute name="Color" value="1 1 0 1" />