Просмотр исходного кода

Better icons for the console window

BearishSun 10 лет назад
Родитель
Сommit
839ae0f784

+ 1 - 1
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -174,7 +174,7 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Retrieves an icon that represents a specific log message type.
 		 * @brief	Retrieves an icon that represents a specific log message type.
 		 */
 		 */
-		HSpriteTexture getLogMessageIcon(LogMessageIcon icon, UINT32 size) const;
+		HSpriteTexture getLogMessageIcon(LogMessageIcon icon, UINT32 size, bool dark) const;
 
 
 		/**
 		/**
 		 * @brief	Returns text contained in the default "empty" shader.
 		 * @brief	Returns text contained in the default "empty" shader.

+ 26 - 11
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -2177,18 +2177,33 @@ namespace BansheeEngine
 		return HSpriteTexture();
 		return HSpriteTexture();
 	}
 	}
 
 
-	HSpriteTexture BuiltinEditorResources::getLogMessageIcon(LogMessageIcon icon, UINT32 size) const
+	HSpriteTexture BuiltinEditorResources::getLogMessageIcon(LogMessageIcon icon, UINT32 size, bool dark) const
 	{
 	{
 		if (size < 24) // Round to 16
 		if (size < 24) // Round to 16
 		{
 		{
-			switch (icon)
+			if (dark)
 			{
 			{
-			case LogMessageIcon::Info:
-				return getGUIIcon(L"IconInfo.psd");
-			case LogMessageIcon::Warning:
-				return getGUIIcon(L"IconWarning.psd");
-			case LogMessageIcon::Error:
-				return getGUIIcon(L"IconError.psd");
+				switch (icon)
+				{
+				case LogMessageIcon::Info:
+					return getGUIIcon(L"IconInfoDark.png");
+				case LogMessageIcon::Warning:
+					return getGUIIcon(L"IconWarningDark.png");
+				case LogMessageIcon::Error:
+					return getGUIIcon(L"IconErrorDark.png");
+				}
+			}
+			else
+			{
+				switch (icon)
+				{
+				case LogMessageIcon::Info:
+					return getGUIIcon(L"IconInfo.png");
+				case LogMessageIcon::Warning:
+					return getGUIIcon(L"IconWarning.png");
+				case LogMessageIcon::Error:
+					return getGUIIcon(L"IconError.png");
+				}
 			}
 			}
 		}
 		}
 		else // Round to 32
 		else // Round to 32
@@ -2196,11 +2211,11 @@ namespace BansheeEngine
 			switch (icon)
 			switch (icon)
 			{
 			{
 			case LogMessageIcon::Info:
 			case LogMessageIcon::Info:
-				return getGUIIcon(L"IconInfo32.psd");
+				return getGUIIcon(L"IconInfo32.png");
 			case LogMessageIcon::Warning:
 			case LogMessageIcon::Warning:
-				return getGUIIcon(L"IconWarning32.psd");
+				return getGUIIcon(L"IconWarning32.png");
 			case LogMessageIcon::Error:
 			case LogMessageIcon::Error:
-				return getGUIIcon(L"IconError32.psd");
+				return getGUIIcon(L"IconError32.png");
 			}
 			}
 		}
 		}
 
 

+ 3 - 3
BansheeEditor/Source/BsGUIStatusBar.cpp

@@ -149,14 +149,14 @@ namespace BansheeEngine
 		switch (logChannel)
 		switch (logChannel)
 		{
 		{
 		case (UINT32)DebugChannel::Debug:
 		case (UINT32)DebugChannel::Debug:
-			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info, 16);
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info, 16, false);
 			break;
 			break;
 		case (UINT32)DebugChannel::Warning:
 		case (UINT32)DebugChannel::Warning:
-			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning, 16);
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning, 16, false);
 			textColor = COLOR_WARNING;
 			textColor = COLOR_WARNING;
 			break;
 			break;
 		case (UINT32)DebugChannel::Error:
 		case (UINT32)DebugChannel::Error:
-			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error, 16);
+			iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error, 16, false);
 			textColor = COLOR_ERROR;
 			textColor = COLOR_ERROR;
 			break;
 			break;
 		}
 		}

+ 20 - 8
MBansheeEditor/ConsoleWindow.cs

@@ -62,12 +62,24 @@ namespace BansheeEditor
             GUILayoutY layout = GUI.AddLayoutY();
             GUILayoutY layout = GUI.AddLayoutY();
             GUILayoutX titleLayout = layout.AddLayoutX();
             GUILayoutX titleLayout = layout.AddLayoutX();
 
 
-            GUIToggle infoBtn = new GUIToggle(new GUIContent(EditorBuiltin.GetLogIcon(LogIcon.Info, 16)), EditorStyles.Button);
-            GUIToggle warningBtn = new GUIToggle(new GUIContent(EditorBuiltin.GetLogIcon(LogIcon.Warning, 16)), EditorStyles.Button);
-            GUIToggle errorBtn = new GUIToggle(new GUIContent(EditorBuiltin.GetLogIcon(LogIcon.Error, 16)), EditorStyles.Button);
+            GUIContentImages infoImages = new GUIContentImages(
+                EditorBuiltin.GetLogIcon(LogIcon.Info, 16, false), 
+                EditorBuiltin.GetLogIcon(LogIcon.Info, 16, true));
 
 
-            GUIToggle detailsBtn = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button);
-            GUIButton clearBtn = new GUIButton(new LocEdString("Clear"));
+            GUIContentImages warningImages = new GUIContentImages(
+                EditorBuiltin.GetLogIcon(LogIcon.Warning, 16, false), 
+                EditorBuiltin.GetLogIcon(LogIcon.Warning, 16, true));
+
+            GUIContentImages errorImages = new GUIContentImages(
+                EditorBuiltin.GetLogIcon(LogIcon.Error, 16, false), 
+                EditorBuiltin.GetLogIcon(LogIcon.Error, 16, true));
+
+            GUIToggle infoBtn = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(25));
+            GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(25));
+            GUIToggle errorBtn = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(25));
+
+            GUIToggle detailsBtn = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(25));
+            GUIButton clearBtn = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(25));
 
 
             titleLayout.AddElement(infoBtn);
             titleLayout.AddElement(infoBtn);
             titleLayout.AddElement(warningBtn);
             titleLayout.AddElement(warningBtn);
@@ -417,13 +429,13 @@ namespace BansheeEditor
                 switch (data.type)
                 switch (data.type)
                 {
                 {
                     case DebugMessageType.Info:
                     case DebugMessageType.Info:
-                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Info, 32));
+                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Info, 32, false));
                         break;
                         break;
                     case DebugMessageType.Warning:
                     case DebugMessageType.Warning:
-                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Warning, 32));
+                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Warning, 32, false));
                         break;
                         break;
                     case DebugMessageType.Error:
                     case DebugMessageType.Error:
-                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Error, 32));
+                        icon.SetTexture(EditorBuiltin.GetLogIcon(LogIcon.Error, 32, false));
                         break;
                         break;
                 }
                 }
 
 

+ 4 - 3
MBansheeEditor/EditorBuiltin.cs

@@ -124,10 +124,11 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         /// <param name="icon">Type of icon to retrieve.</param>
         /// <param name="icon">Type of icon to retrieve.</param>
         /// <param name="size">Size of the icon in pixels. Nearest available size will be returned.</param>
         /// <param name="size">Size of the icon in pixels. Nearest available size will be returned.</param>
+        /// <param name="dark">Controls should the dark or light version of the icon be returned.</param>
         /// <returns>Sprite texture of the icon.</returns>
         /// <returns>Sprite texture of the icon.</returns>
-        public static SpriteTexture GetLogIcon(LogIcon icon, int size)
+        public static SpriteTexture GetLogIcon(LogIcon icon, int size, bool dark)
         {
         {
-            return Internal_GetLogIcon(icon, size);
+            return Internal_GetLogIcon(icon, size, dark);
         }
         }
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
@@ -155,6 +156,6 @@ namespace BansheeEditor
         private static extern GUIContentImages Internal_GetSceneWindowIcon(SceneWindowIcon icon);
         private static extern GUIContentImages Internal_GetSceneWindowIcon(SceneWindowIcon icon);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern SpriteTexture Internal_GetLogIcon(LogIcon icon, int size);
+        private static extern SpriteTexture Internal_GetLogIcon(LogIcon icon, int size, bool dark);
     }
     }
 }
 }

+ 17 - 0
MBansheeEngine/GUI/GUIContent.cs

@@ -193,6 +193,23 @@ namespace BansheeEngine
             focusedOn = image;
             focusedOn = image;
         }
         }
 
 
+        /// <summary>
+        /// Creates a new object where content images for on and off states are different.
+        /// </summary>
+        /// <param name="imageOff">Image to assign to all off states.</param>
+        // <param name="imageOn">Image to assign to all on states.</param>
+        public GUIContentImages(SpriteTexture imageOff, SpriteTexture imageOn)
+        {
+            normal = imageOff;
+            hover = imageOff;
+            active = imageOff;
+            focused = imageOff;
+            normalOn = imageOn;
+            hoverOn = imageOn;
+            activeOn = imageOn;
+            focusedOn = imageOn;
+        }
+
         /// <summary>
         /// <summary>
         /// Implicitly converts a sprite texture into a GUI content images object.
         /// Implicitly converts a sprite texture into a GUI content images object.
         /// </summary>
         /// </summary>

+ 1 - 1
SBansheeEditor/Include/BsScriptEditorBuiltin.h

@@ -30,6 +30,6 @@ namespace BansheeEngine
 		static MonoObject* internal_GetLibraryWindowIcon(LibraryWindowIcon icon);
 		static MonoObject* internal_GetLibraryWindowIcon(LibraryWindowIcon icon);
 		static MonoObject* internal_GetInspectorWindowIcon(InspectorWindowIcon icon);
 		static MonoObject* internal_GetInspectorWindowIcon(InspectorWindowIcon icon);
 		static MonoObject* internal_GetSceneWindowIcon(SceneWindowIcon icon);
 		static MonoObject* internal_GetSceneWindowIcon(SceneWindowIcon icon);
-		static MonoObject* internal_GetLogIcon(LogMessageIcon icon, int size);
+		static MonoObject* internal_GetLogIcon(LogMessageIcon icon, int size, bool dark);
 	};
 	};
 }
 }

+ 2 - 2
SBansheeEditor/Source/BsScriptEditorBuiltin.cpp

@@ -81,9 +81,9 @@ namespace BansheeEngine
 		return ScriptGUIContentImages::getManaged(images);
 		return ScriptGUIContentImages::getManaged(images);
 	}
 	}
 
 
-	MonoObject* ScriptEditorBuiltin::internal_GetLogIcon(LogMessageIcon icon, int size)
+	MonoObject* ScriptEditorBuiltin::internal_GetLogIcon(LogMessageIcon icon, int size, bool dark)
 	{
 	{
-		HSpriteTexture tex = BuiltinEditorResources::instance().getLogMessageIcon(icon, size);
+		HSpriteTexture tex = BuiltinEditorResources::instance().getLogMessageIcon(icon, size, dark);
 
 
 		return ScriptSpriteTexture::toManaged(tex);
 		return ScriptSpriteTexture::toManaged(tex);
 	}
 	}

+ 1 - 1
TODO.txt

@@ -44,7 +44,7 @@ Optional:
  - When starting drag from hierarchy tree view it tends to select another object (can't repro)
  - When starting drag from hierarchy tree view it tends to select another object (can't repro)
  - Handle seems to lag behind the selected mesh
  - Handle seems to lag behind the selected mesh
  - When starting play-in-editor, automatically make the Game Window active
  - When starting play-in-editor, automatically make the Game Window active
- - Console filter icons look ugly when toggled (also message warning/info icons seem misaligned compared to each other)
+ - Console message warning/info icons seem misaligned compared to each other
  - When resizing library window while docked, selection area appears
  - When resizing library window while docked, selection area appears
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
  - MenuBar - will likely need a way to mark elements as disabled when not appropriate (e.g. no "frame selected unless scene is focused")
  - MenuBar - will likely need a way to mark elements as disabled when not appropriate (e.g. no "frame selected unless scene is focused")