-
-
Notifications
You must be signed in to change notification settings - Fork 117
Pr/48 dark mode #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr/48 dark mode #69
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Display settings of the behaviour tree window | ||
/// </summary> | ||
public class DisplaySettings { | ||
public static Color lightModeActive { get; } = new Color(0.39f, 0.78f, 0.39f); | ||
public static Color lightModeInactive { get; } = new Color(0.65f, 0.65f, 0.65f); | ||
public static Color lightModeActiveText { get; } = Color.white; | ||
public static Color lightModeInactiveText { get; } = Color.black; | ||
public static Color lightModeActiveMainIcon { get; } = new Color(1, 1, 1, 1f); | ||
public static Color lightModeInactiveMainIcon { get; } = new Color(1, 1, 1, 0.3f); | ||
|
||
public static Color darkModeActive { get; } = Color.white; | ||
public static Color darkModeInactive { get; } = new Color(0f, 0f, 0f, 1f); | ||
public static Color darkModeActiveText { get; } = Color.white; | ||
public static Color darkModeInactiveText { get; } = Color.grey; | ||
public static Color darkModeActiveMainIcon { get; } = new Color(1, 1, 1, 1f); | ||
public static Color darkModeInactiveMainIcon { get; } = new Color(1, 1, 1, 0.3f); | ||
|
||
public static GUIStyle taskFontFormat { get; } = new GUIStyle(GUI.skin.label) { | ||
fontSize = 9, | ||
alignment = TextAnchor.LowerCenter, | ||
wordWrap = true, | ||
padding = new RectOffset(3, 3, 3, 3), | ||
}; | ||
|
||
public static GUIStyle lightModeBoxStyle = new GUIStyle(GUI.skin.box) { | ||
// Perhaps make it better one day | ||
}; | ||
|
||
public static GUIStyle darkModeBoxStyle = new GUIStyle(GUI.skin.box) { | ||
// Perhaps make it better one day | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public class NodeFaders { | ||
public ColorFader BackgroundFader { get; } = new ColorFader( | ||
new Color(0.65f, 0.65f, 0.65f), new Color(0.39f, 0.78f, 0.39f)); | ||
|
||
public ColorFader TextFader { get; } = new ColorFader( | ||
Color.white, Color.black); | ||
|
||
public ColorFader MainIconFader { get; } = new ColorFader( | ||
new Color(1, 1, 1, 0.3f), new Color(1, 1, 1, 1f)); | ||
public ColorFader BackgroundFader { get; } | ||
|
||
public ColorFader TextFader { get; } | ||
|
||
public ColorFader MainIconFader { get; } | ||
|
||
public NodeFaders() { | ||
// If in dark mode choose dark mode | ||
if (EditorGUIUtility.isProSkin){ | ||
BackgroundFader = new ColorFader( | ||
DisplaySettings.darkModeInactive, | ||
DisplaySettings.darkModeActive); | ||
TextFader = new ColorFader( | ||
DisplaySettings.darkModeInactiveText, | ||
DisplaySettings.darkModeActiveText); | ||
MainIconFader = new ColorFader( | ||
DisplaySettings.darkModeInactiveMainIcon, | ||
DisplaySettings.darkModeActiveMainIcon); | ||
}else { | ||
BackgroundFader = new ColorFader( | ||
DisplaySettings.lightModeInactive, | ||
DisplaySettings.lightModeActive); | ||
TextFader = new ColorFader( | ||
DisplaySettings.lightModeInactiveText, | ||
DisplaySettings.lightModeActiveText); | ||
MainIconFader = new ColorFader( | ||
DisplaySettings.lightModeInactiveMainIcon, | ||
DisplaySettings.lightModeActiveMainIcon); | ||
} | ||
} | ||
|
||
public void Update (bool active) { | ||
BackgroundFader.Update(active); | ||
TextFader.Update(active); | ||
MainIconFader.Update(active); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
using System.Linq; | ||
using CleverCrow.Fluid.BTs.TaskParents; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace CleverCrow.Fluid.BTs.Trees.Editors { | ||
public class NodePrintController { | ||
|
@@ -15,8 +16,6 @@ public class NodePrintController { | |
private Texture2D _verticalBottom; | ||
private Texture2D _verticalTop; | ||
|
||
private static GuiStyleCollection Styles => BehaviorTreePrinter.SharedStyles; | ||
|
||
public NodePrintController (VisualTask node) { | ||
_node = node; | ||
_box = node.Box; | ||
|
@@ -40,25 +39,38 @@ private void PaintBody () { | |
var prevBackgroundColor = GUI.backgroundColor; | ||
|
||
var rect = new Rect( | ||
_box.GlobalPositionX + _box.PaddingX, | ||
_box.GlobalPositionX + _box.PaddingX, | ||
_box.GlobalPositionY + _box.PaddingY, | ||
_box.Width - _box.PaddingX, | ||
_box.Width - _box.PaddingX, | ||
_box.Height - _box.PaddingY); | ||
|
||
if (_node.Task.HasBeenActive) { | ||
GUI.backgroundColor = _faders.BackgroundFader.CurrentColor; | ||
GUI.Box(rect, GUIContent.none, Styles.BoxActive.Style); | ||
|
||
if (EditorGUIUtility.isProSkin) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move if block to a static |
||
GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.darkModeBoxStyle)); | ||
} | ||
else { | ||
GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.lightModeBoxStyle)); | ||
} | ||
|
||
GUI.backgroundColor = prevBackgroundColor; | ||
|
||
PrintLastStatus(rect); | ||
} else { | ||
GUI.Box(rect, GUIContent.none, Styles.BoxInactive.Style); | ||
} | ||
|
||
else { | ||
if (EditorGUIUtility.isProSkin) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move if block to a static |
||
GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.darkModeBoxStyle)); | ||
} | ||
else { | ||
GUI.Box(rect, GUIContent.none, new GUIStyle(DisplaySettings.lightModeBoxStyle)); | ||
} | ||
} | ||
|
||
PrintIcon(); | ||
|
||
Styles.Title.normal.textColor = _faders.TextFader.CurrentColor; | ||
GUI.Label(rect, _node.Task.Name, Styles.Title); | ||
var textFormat = DisplaySettings.taskFontFormat; | ||
textFormat.normal.textColor = _faders.TextFader.CurrentColor; | ||
GUI.Label(rect, _node.Task.Name, textFormat); | ||
} | ||
|
||
private void PrintLastStatus (Rect rect) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging this, makes sense.