Browse Source

log message colour in console displayed based on it's type

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

+ 18 - 2
Source/Urho3D/Engine/Console.cpp

@@ -563,8 +563,24 @@ void Console::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
         rowContainer_->RemoveItem((unsigned)0);
         text = new Text(context_);
         text->SetText(pendingRows_[i].second_);
-        // Make error message highlight
-        text->SetStyle(pendingRows_[i].first_ == LOG_ERROR ? "ConsoleHighlightedText" : "ConsoleText");
+        
+		//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");
+		}
         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();
     eventData[P_MESSAGE] = message;
-    eventData[P_LEVEL] = error ? LOG_ERROR : LOG_INFO;
+    eventData[P_LEVEL] = error ? LOG_ERROR : LOG_RAW;
     logInstance->SendEvent(E_LOGMESSAGE, eventData);
 
     logInstance->inWrite_ = false;

+ 8 - 3
bin/Data/UI/DefaultStyle.xml

@@ -249,12 +249,17 @@
         <attribute name="Layout Border" value="4 4 4 4" />
     </element>
     <element type="ConsoleText" style="Text" auto="false">
-        <attribute name="Hover Color" value="0.3 0.4 0.7 1" />
-        <attribute name="Selection Color" value="0.2 0.225 0.35 1" />
+        <attribute name="Color" value="0.85 0.85 0.85" />
     </element>
-    <element type="ConsoleHighlightedText" style="ConsoleText" auto="false">
+    <element type="ConsoleErrorText" style="ConsoleText" auto="false">
         <attribute name="Color" value="1 0 0 1" />
     </element>
+    <element type="ConsoleInfoText" style="ConsoleText" auto="false">
+        <attribute name="Color" value="0 1 0 1" />
+    </element>
+    <element type="ConsoleWarningText" style="ConsoleText" auto="false">
+        <attribute name="Color" value="1 1 0 1" />
+    </element>
     <element type="ConsoleLineEdit" style="LineEdit" auto="false">
         <attribute name="Min Size" value="0 17" />
         <attribute name="Max Size" value="2147483647 17" />