Browse Source

Improved command button colours & layout

master
chrisgregan 11 years ago
parent
commit
bc484442d8
  1. 2
      Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs
  2. 59
      Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs
  3. 23
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  4. BIN
      Assets/Shuttle/ShuttleGame.unity

2
Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs

@ -59,7 +59,7 @@ namespace Fungus.Script
} }
string commandName = commandInfoAttr.CommandName; string commandName = commandInfoAttr.CommandName;
GUIStyle commandStyle = new GUIStyle(GUI.skin.box); GUIStyle commandStyle = new GUIStyle(GUI.skin.button);
if (t.enabled) if (t.enabled)
{ {
GUI.backgroundColor = commandInfoAttr.ButtonColor; GUI.backgroundColor = commandInfoAttr.ButtonColor;

59
Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs

@ -146,12 +146,12 @@ namespace Fungus.Script
error = true; error = true;
} }
float indentWidth = 20; float indentSize = 20;
for (int i = 0; i < command.indentLevel; ++i) for (int i = 0; i < command.indentLevel; ++i)
{ {
Rect indentRect = position; Rect indentRect = position;
indentRect.x += i * indentWidth; indentRect.x += i * indentSize;
indentRect.width = indentWidth + 1; indentRect.width = indentSize + 1;
indentRect.y -= 2; indentRect.y -= 2;
indentRect.height += 5; indentRect.height += 5;
GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.25f); GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.25f);
@ -159,18 +159,19 @@ namespace Fungus.Script
} }
string commandName = commandInfoAttr.CommandName; string commandName = commandInfoAttr.CommandName;
GUIStyle commandStyle = new GUIStyle(GUI.skin.box); GUIStyle commandStyle = new GUIStyle(EditorStyles.miniButtonLeft);
float buttonWidth = Mathf.Max(commandStyle.CalcSize(new GUIContent(commandName)).x, 80f); float buttonWidth = Mathf.Max(commandStyle.CalcSize(new GUIContent(commandName)).x, 80f);
float indentWidth = command.indentLevel * indentSize;
Rect buttonRect = position; Rect buttonRect = position;
buttonRect.x += command.indentLevel * indentWidth; buttonRect.x += indentWidth;
buttonRect.width = buttonWidth; buttonRect.width = buttonWidth;
buttonRect.y -= 2; buttonRect.y -= 2;
buttonRect.height += 5; buttonRect.height += 5;
Rect summaryRect = position; Rect summaryRect = buttonRect;
summaryRect.x = buttonRect.x + buttonWidth + 5; summaryRect.x += buttonWidth - 1;
summaryRect.width = position.width - buttonWidth - 5; summaryRect.width = position.width - buttonWidth - indentWidth;
if (!Application.isPlaying && if (!Application.isPlaying &&
Event.current.type == EventType.MouseDown && Event.current.type == EventType.MouseDown &&
@ -181,48 +182,38 @@ namespace Fungus.Script
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus)
} }
Color buttonBackgroundColor = commandInfoAttr.ButtonColor;
Color summaryBackgroundColor = Color.white;
if ((Application.isPlaying && command.IsExecuting()) || if ((Application.isPlaying && command.IsExecuting()) ||
(!Application.isPlaying && fungusScript.selectedCommand == command)) (!Application.isPlaying && fungusScript.selectedCommand == command))
{ {
Rect boxRect = summaryRect; summaryBackgroundColor = Color.green;
boxRect.x -= 6; buttonBackgroundColor = Color.green;
boxRect.width += 6 - indentWidth * command.indentLevel;
boxRect.y -= 2;
boxRect.height += 5;
GUI.backgroundColor = Color.green;
GUI.Box(boxRect, "");
}
if (!command.enabled)
{
GUI.backgroundColor = Color.grey;
} }
else if (error) else if (error)
{ {
GUI.backgroundColor = Color.red; summaryBackgroundColor = Color.red;
} }
else
if (!command.enabled)
{ {
GUI.backgroundColor = commandInfoAttr.ButtonColor; buttonBackgroundColor = Color.grey;
} }
GUI.Box(buttonRect, commandName, commandStyle); GUI.backgroundColor = buttonBackgroundColor;
GUI.Label(buttonRect, commandName, commandStyle);
GUI.backgroundColor = Color.white;
GUIStyle labelStyle = new GUIStyle(EditorStyles.miniLabel); GUIStyle labelStyle = new GUIStyle(EditorStyles.miniButtonRight);
labelStyle.wordWrap = true; labelStyle.alignment = TextAnchor.MiddleLeft;
if (!command.enabled) if (!command.enabled)
{ {
labelStyle.normal.textColor = Color.grey; labelStyle.normal.textColor = Color.grey;
} }
else if (error)
{
labelStyle.normal.textColor = Color.red;
}
GUI.Label(summaryRect, summary, labelStyle); GUI.backgroundColor = summaryBackgroundColor;
GUI.Box(summaryRect, summary, labelStyle);
GUI.backgroundColor = Color.white;
} }
public virtual float GetItemHeight(int index) { public virtual float GetItemHeight(int index) {

23
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -105,7 +105,9 @@ namespace Fungus.Script
BeginWindows(); BeginWindows();
GUIStyle windowStyle = new GUIStyle(GUI.skin.window); GUIStyle windowStyle = new GUIStyle(EditorStyles.toolbarButton);
windowStyle.stretchHeight = true;
windowStyle.fixedHeight = 40;
windowSequenceMap.Clear(); windowSequenceMap.Clear();
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < sequences.Length; ++i)
@ -132,8 +134,15 @@ namespace Fungus.Script
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
*/ */
sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, "", GUI.skin.box, GUILayout.Width(windowWidth), GUILayout.Height(20), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (fungusScript.selectedSequence == sequence ||
fungusScript.executingSequence == sequence)
{
GUI.backgroundColor = Color.green;
}
sequence.nodeRect = GUILayout.Window(i, sequence.nodeRect, DrawWindow, "", windowStyle, GUILayout.Width(windowWidth), GUILayout.Height(20), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
GUI.backgroundColor = Color.white;
windowSequenceMap.Add(sequence); windowSequenceMap.Add(sequence);
} }
@ -150,6 +159,7 @@ namespace Fungus.Script
EndWindows(); EndWindows();
/*
if (fungusScript.selectedSequence != null || if (fungusScript.selectedSequence != null ||
fungusScript.executingSequence != null) fungusScript.executingSequence != null)
{ {
@ -168,6 +178,7 @@ namespace Fungus.Script
outlineRect.y -= 5; outlineRect.y -= 5;
GLDraw.DrawBox(outlineRect, Color.green, 2); GLDraw.DrawBox(outlineRect, Color.green, 2);
} }
*/
GLDraw.EndScrollView(); GLDraw.EndScrollView();
} }
@ -303,16 +314,16 @@ namespace Fungus.Script
} }
} }
GUILayout.Space(10);
Sequence sequence = windowSequenceMap[windowId]; Sequence sequence = windowSequenceMap[windowId];
GUIStyle labelStyle = new GUIStyle(GUI.skin.label); GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.alignment = TextAnchor.MiddleCenter;
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(sequence.name, labelStyle); GUILayout.Label(sequence.name, labelStyle);
GUILayout.FlexibleSpace();
GUILayout.Space(10); GUILayout.EndVertical();
GUI.DragWindow(); GUI.DragWindow();
} }

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save