From bc484442d80a616d0a05cfb40a1a956950ce0bc2 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 3 Sep 2014 21:55:13 +0100 Subject: [PATCH] Improved command button colours & layout --- .../Editor/FungusCommandEditor.cs | 2 +- .../Editor/FungusCommandListAdaptor.cs | 61 ++++++++---------- .../FungusScript/Editor/FungusScriptWindow.cs | 29 ++++++--- Assets/Shuttle/ShuttleGame.unity | Bin 129988 -> 129900 bytes 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs index f39b77ea..511ad891 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs @@ -59,7 +59,7 @@ namespace Fungus.Script } string commandName = commandInfoAttr.CommandName; - GUIStyle commandStyle = new GUIStyle(GUI.skin.box); + GUIStyle commandStyle = new GUIStyle(GUI.skin.button); if (t.enabled) { GUI.backgroundColor = commandInfoAttr.ButtonColor; diff --git a/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs b/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs index 4c1b69dc..b8c6c70b 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs @@ -146,12 +146,12 @@ namespace Fungus.Script error = true; } - float indentWidth = 20; + float indentSize = 20; for (int i = 0; i < command.indentLevel; ++i) { Rect indentRect = position; - indentRect.x += i * indentWidth; - indentRect.width = indentWidth + 1; + indentRect.x += i * indentSize; + indentRect.width = indentSize + 1; indentRect.y -= 2; indentRect.height += 5; GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.25f); @@ -159,18 +159,19 @@ namespace Fungus.Script } 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 indentWidth = command.indentLevel * indentSize; Rect buttonRect = position; - buttonRect.x += command.indentLevel * indentWidth; + buttonRect.x += indentWidth; buttonRect.width = buttonWidth; buttonRect.y -= 2; buttonRect.height += 5; - Rect summaryRect = position; - summaryRect.x = buttonRect.x + buttonWidth + 5; - summaryRect.width = position.width - buttonWidth - 5; + Rect summaryRect = buttonRect; + summaryRect.x += buttonWidth - 1; + summaryRect.width = position.width - buttonWidth - indentWidth; if (!Application.isPlaying && Event.current.type == EventType.MouseDown && @@ -181,48 +182,38 @@ namespace Fungus.Script GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) } + Color buttonBackgroundColor = commandInfoAttr.ButtonColor; + Color summaryBackgroundColor = Color.white; + 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; + summaryBackgroundColor = Color.green; + buttonBackgroundColor = Color.green; } 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); - labelStyle.wordWrap = true; + GUIStyle labelStyle = new GUIStyle(EditorStyles.miniButtonRight); + labelStyle.alignment = TextAnchor.MiddleLeft; if (!command.enabled) { 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) { diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs index 693ced6b..77fe190b 100755 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs @@ -105,8 +105,10 @@ namespace Fungus.Script BeginWindows(); - GUIStyle windowStyle = new GUIStyle(GUI.skin.window); - + GUIStyle windowStyle = new GUIStyle(EditorStyles.toolbarButton); + windowStyle.stretchHeight = true; + windowStyle.fixedHeight = 40; + windowSequenceMap.Clear(); for (int i = 0; i < sequences.Length; ++i) { @@ -132,8 +134,15 @@ namespace Fungus.Script 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); } @@ -149,7 +158,8 @@ namespace Fungus.Script } EndWindows(); - + + /* if (fungusScript.selectedSequence != null || fungusScript.executingSequence != null) { @@ -168,6 +178,7 @@ namespace Fungus.Script outlineRect.y -= 5; GLDraw.DrawBox(outlineRect, Color.green, 2); } + */ GLDraw.EndScrollView(); } @@ -303,16 +314,16 @@ namespace Fungus.Script } } - GUILayout.Space(10); - Sequence sequence = windowSequenceMap[windowId]; GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.alignment = TextAnchor.MiddleCenter; + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); GUILayout.Label(sequence.name, labelStyle); - - GUILayout.Space(10); + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); GUI.DragWindow(); } diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index bfddae3a867c184c1f8ba5b97120d4c6d9ab747e..729bd122785f755470282408bd89ae16f8b30629 100644 GIT binary patch delta 1890 zcmZ9NZA?>F7{{NZEYv0KiZ4ks9hN0amKmp*EU7_aqx*oGnHGWJ8YwS2idJlEQwpen z8-@wG`husT6Zl}_2aPPUw2O(U(S&|58EBk*aTb}%=DUe#qLckEJ+0@o>63f!@A=>V zIp;agz4z*?>_?N?I%1ACVsG4Sy5DpxWLw@xM3YlfQ$8I3&3o`&Yk7MQhJ)fJ9ibcXq5 z&Ej=NY9&&(T|_R7h>1?joy%kGc2pHsSgH{>j7N81$iMVucQH|+Gq5*79Y6;(bf4U~#PK1AY&(?$4 zxLvat-ACky{6FDt(^4JNL#9WxgT=sXuy`YM#b8F>uURbpiD--DKJvU^a~KTUk#4H% zV5a@5?G3OF{u~x9XONP&E`DdoMV)Ga7H>>!D+iNxUxE!}=z5F#-MTJS*9TS!CU1F-?F6$NB?^P3-c9zYkZ%~w3x-abj$*K)?&)zW(tWf6 zFbXI)MhTeZnA*k-X1l)}Om5jASON^)oo=c|Fc@$pZzLOc~WhlV_;D*t?pSOx^DIcjK8S517I#NS!eicG!RSb-Z%9}fF}Mc z=2Yl8rFzVJTGkK;lRX}t8{cE@RdtWSf)Q5E&MnZ-T{V2IXBAN#VUAq%v-2M?b7Wf+ zTenhxK-F+Xj6;}14#2FvHSN7$!x%zj^0U431BZC>+|njP*PzTFhrdYvWayC|kg_KDU6_emBDWzu&m_E_tqYK!l|l3-FHMT@$* zbJi@sAX%7psin=3PJuZQj*aE}b7tbMRUcE^PJlUiWfLr>$|TR;YaNE&YFl=dY$BMu zg6P*}g|*}MHd}_dd=DYte-t<#qo0Q=KB%I1Z;+!Ygl{>=gD9?L`c5 zer*Fg#m$n%`uB)};Qz?(CP^B|rz~YOgBji@GU4%ia$FOblb?_*1|T^U?lX5bc4fhE zM5Up+3?}YZ+g<_7@H?=G)1bORsh_5uZD7gcQfHa~o%~?4G&2RQB&EkUiG~ljBG_F%OuN_roH- z@KK@f#c&Z)+sB1>$G|CeFlDY=VChNL#!j!*Y8uj)MjD7xST&R9 zg6xa?S8trOWuEPU`v{$}mD=OH2{=*D=EFP`x^t!$Nm=N^a zTppLFyE+t{0_kt5CYyFhY+>L>|S?QwALOIY@RM5>WaC7Hn*!YTI<4tjz}>7 z%+`>@-y3woLkKt=Jpm!;73^^F2ws1e!;j5YV|$sC_@Th3BLA0%(yVH7%VqZY8tnGZ ITdY_6A2PTGRR910