Browse Source

Draw green box in command row background when selected

master
chrisgregan 10 years ago
parent
commit
632f4ebfb7
  1. 56
      Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs
  2. BIN
      Assets/Shuttle/ShuttleGame.unity

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

@ -154,23 +154,10 @@ namespace Fungus.Script
indentRect.width = indentWidth + 1; indentRect.width = indentWidth + 1;
indentRect.y -= 2; indentRect.y -= 2;
indentRect.height += 5; indentRect.height += 5;
GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.1f); GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.25f);
GUI.Box(indentRect, ""); GUI.Box(indentRect, "");
} }
if (!command.enabled)
{
GUI.backgroundColor = Color.grey;
}
else if (error)
{
GUI.backgroundColor = Color.red;
}
else
{
GUI.backgroundColor = commandInfoAttr.ButtonColor;
}
string commandName = commandInfoAttr.CommandName; string commandName = commandInfoAttr.CommandName;
GUIStyle commandStyle = new GUIStyle(GUI.skin.box); GUIStyle commandStyle = new GUIStyle(GUI.skin.box);
float buttonWidth = Mathf.Max(commandStyle.CalcSize(new GUIContent(commandName)).x, 80f); float buttonWidth = Mathf.Max(commandStyle.CalcSize(new GUIContent(commandName)).x, 80f);
@ -181,8 +168,6 @@ namespace Fungus.Script
buttonRect.y -= 2; buttonRect.y -= 2;
buttonRect.height += 5; buttonRect.height += 5;
GUI.Box(buttonRect, commandName, commandStyle);
Rect summaryRect = position; Rect summaryRect = position;
summaryRect.x = buttonRect.x + buttonWidth + 5; summaryRect.x = buttonRect.x + buttonWidth + 5;
summaryRect.width = position.width - buttonWidth - 5; summaryRect.width = position.width - buttonWidth - 5;
@ -196,6 +181,34 @@ namespace Fungus.Script
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus)
} }
if ((Application.isPlaying && command.IsExecuting()) ||
(!Application.isPlaying && fungusScript.selectedCommand == command))
{
Rect boxRect = summaryRect;
boxRect.x -= 6;
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)
{
GUI.backgroundColor = Color.red;
}
else
{
GUI.backgroundColor = commandInfoAttr.ButtonColor;
}
GUI.Box(buttonRect, commandName, commandStyle);
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
GUIStyle labelStyle = new GUIStyle(EditorStyles.miniLabel); GUIStyle labelStyle = new GUIStyle(EditorStyles.miniLabel);
@ -210,17 +223,6 @@ namespace Fungus.Script
} }
GUI.Label(summaryRect, summary, labelStyle); GUI.Label(summaryRect, summary, labelStyle);
if (Event.current.type == EventType.Repaint)
{
if ((Application.isPlaying && command.IsExecuting()) ||
(!Application.isPlaying && fungusScript.selectedCommand == command))
{
Rect boxRect = position;
boxRect.y += 1;
GLDraw.DrawBox(boxRect, Color.green, 1.5f);
}
}
} }
public virtual float GetItemHeight(int index) { public virtual float GetItemHeight(int index) {

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save