From c26e81a40c594eed06bc317395d1704fd2acbe25 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 13 Aug 2014 17:06:36 +0100 Subject: [PATCH] Improved button layout, using foldout --- .../Editor/FungusScript/AddOptionEditor.cs | 2 +- .../Fungus/Editor/FungusScript/CallEditor.cs | 2 +- .../FungusScript/FungusCommandEditor.cs | 48 ++++++++++++------ .../Editor/FungusScript/FungusEditorWindow.cs | 25 ++------- .../Editor/FungusScript/FungusScriptEditor.cs | 21 +++----- .../Fungus/Editor/FungusScript/SayEditor.cs | 2 +- .../Fungus/Editor/FungusScript/SetEditor.cs | 2 +- Assets/Fungus/VisualScripting/Call.cs | 35 +++++++++++-- .../Fungus/VisualScripting/FungusCommand.cs | 4 +- Assets/Fungus/VisualScripting/FungusScript.cs | 4 -- Assets/Fungus/VisualScripting/Say.cs | 5 ++ Assets/Fungus/VisualScripting/Sequence.cs | 5 -- Assets/Shuttle/ShuttleGame.unity | Bin 81628 -> 81956 bytes 13 files changed, 85 insertions(+), 70 deletions(-) diff --git a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs index d187f2f6..b6a07df1 100644 --- a/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs @@ -10,7 +10,7 @@ namespace Fungus.Script [CustomEditor (typeof(AddOption))] public class AddOptionEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { AddOption t = target as AddOption; diff --git a/Assets/Fungus/Editor/FungusScript/CallEditor.cs b/Assets/Fungus/Editor/FungusScript/CallEditor.cs index 34cfc713..f3a16099 100644 --- a/Assets/Fungus/Editor/FungusScript/CallEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/CallEditor.cs @@ -9,7 +9,7 @@ namespace Fungus.Script [CustomEditor (typeof(Call))] public class CallEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { serializedObject.Update(); diff --git a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs index 002abb90..162344de 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs @@ -25,50 +25,66 @@ namespace Fungus.Script { FungusCommand t = target as FungusCommand; - Rect rect = EditorGUILayout.BeginVertical(); + GUILayout.BeginHorizontal(); + + t.expanded = EditorGUILayout.Foldout(t.expanded, t.GetType().Name); + + GUIStyle labelStyle = EditorStyles.miniLabel; + GUILayout.Label(t.GetDescription().Replace("\n", "").Replace("\r", ""), labelStyle); + + GUILayout.FlexibleSpace(); + + GUILayout.EndHorizontal(); + + if (!t.expanded) + { + return; + } GUILayout.BeginHorizontal(); - if (GUILayout.Button("Up")) + GUILayout.FlexibleSpace(); + + if (GUILayout.Button("Up", EditorStyles.miniButtonLeft)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(t); } - if (GUILayout.Button("Down")) + if (GUILayout.Button("Down", EditorStyles.miniButtonMid)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(t); } - - GUILayout.FlexibleSpace(); - + FungusScript fungusScript = t.GetFungusScript(); - + if (fungusScript != null) { - if (GUILayout.Button("Copy")) + if (GUILayout.Button("Copy", EditorStyles.miniButtonMid)) { fungusScript.copyCommand = t; } - + if (fungusScript.copyCommand != null) { - if (GUILayout.Button("Paste")) + if (GUILayout.Button("Paste", EditorStyles.miniButtonMid)) { CopyComponent(fungusScript.copyCommand, t.gameObject); } } } - - if (GUILayout.Button("Delete")) + + if (GUILayout.Button("Delete", EditorStyles.miniButtonRight)) { Undo.DestroyObjectImmediate(t); return; } + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); EditorGUILayout.Separator(); - DrawCommandInspectorGUI(); + DrawCommandGUI(); EditorGUILayout.Separator(); @@ -81,6 +97,7 @@ namespace Fungus.Script EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); } + /* if (t.IsExecuting()) { EditorGUI.DrawRect(rect, new Color(0f, 1f, 0f, 0.25f)); @@ -89,12 +106,11 @@ namespace Fungus.Script { EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f)); } + */ } - - EditorGUILayout.EndVertical(); } - public virtual void DrawCommandInspectorGUI() + public virtual void DrawCommandGUI() { DrawDefaultInspector(); } diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index 67dcc700..abe96bd4 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -166,12 +166,7 @@ namespace Fungus.Script GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); - GUILayout.Space(15); - if (GUILayout.Button(labelText)) - { - Selection.activeGameObject = fungusScript.gameObject; - } - + GUILayout.Space(10); GUI.backgroundColor = Color.white; if (GUILayout.Button("Show Variables")) { @@ -224,21 +219,9 @@ namespace Fungus.Script Sequence sequence = windowSequenceMap[windowId]; - if (!Application.isPlaying && sequence.gameObject == Selection.activeGameObject) - { - string description = GUILayout.TextArea(sequence.description, GUILayout.ExpandWidth(true)); - if (description != sequence.description) - { - Undo.RecordObject(sequence, "Set Description"); - sequence.description = description; - } - } - else - { - GUIStyle labelStyle = new GUIStyle(GUI.skin.label); - labelStyle.wordWrap = true; - GUILayout.Label(sequence.description, labelStyle); - } + GUIStyle labelStyle = new GUIStyle(GUI.skin.label); + labelStyle.wordWrap = true; + GUILayout.Label(sequence.description, labelStyle); /* GUIStyle style = new GUIStyle(GUI.skin.button); diff --git a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs index cad8111f..7b37c535 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs @@ -75,7 +75,8 @@ namespace Fungus.Script GUILayout.FlexibleSpace(); } - if (GUILayout.Button("Create")) + if (GUILayout.Button("Create", + t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft)) { GameObject go = new GameObject("Sequence"); go.transform.parent = t.transform; @@ -96,12 +97,12 @@ namespace Fungus.Script if (t.selectedSequence != null) { - if (GUILayout.Button("Delete")) + if (GUILayout.Button("Delete", EditorStyles.miniButtonMid)) { Undo.DestroyObjectImmediate(t.selectedSequence.gameObject); t.selectedSequence = null; } - if (GUILayout.Button("Duplicate")) + if (GUILayout.Button("Duplicate", EditorStyles.miniButtonRight)) { GameObject copy = GameObject.Instantiate(t.selectedSequence.gameObject) as GameObject; copy.transform.parent = t.transform; @@ -149,20 +150,12 @@ namespace Fungus.Script } EditorGUILayout.PrefixLabel("Commands"); - + FungusCommand[] commands = sequence.GetComponents(); foreach (FungusCommand command in commands) { - if (GUILayout.Button(command.GetCommandTitle(), GUILayout.ExpandWidth(true))) - { - command.expanded = !command.expanded; - } - - if (command.expanded) - { - Editor commandEditor = Editor.CreateEditor(command); - commandEditor.OnInspectorGUI(); - } + Editor commandEditor = Editor.CreateEditor(command); + commandEditor.OnInspectorGUI(); } } diff --git a/Assets/Fungus/Editor/FungusScript/SayEditor.cs b/Assets/Fungus/Editor/FungusScript/SayEditor.cs index 71cb5290..5dab650a 100644 --- a/Assets/Fungus/Editor/FungusScript/SayEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SayEditor.cs @@ -10,7 +10,7 @@ namespace Fungus.Script [CustomEditor (typeof(Say))] public class SayEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { Say t = target as Say; diff --git a/Assets/Fungus/Editor/FungusScript/SetEditor.cs b/Assets/Fungus/Editor/FungusScript/SetEditor.cs index eb348bb4..7db41410 100644 --- a/Assets/Fungus/Editor/FungusScript/SetEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/SetEditor.cs @@ -9,7 +9,7 @@ namespace Fungus.Script [CustomEditor (typeof(Set))] public class SetEditor : FungusCommandEditor { - public override void DrawCommandInspectorGUI() + public override void DrawCommandGUI() { serializedObject.Update(); diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/Call.cs index 04e240fa..a1a6538b 100644 --- a/Assets/Fungus/VisualScripting/Call.cs +++ b/Assets/Fungus/VisualScripting/Call.cs @@ -185,14 +185,41 @@ namespace Fungus.Script } } - public override string GetCommandTitle() + public override string GetDescription() { if (callCondition == CallCondition.CallAlways) { - return GetType().Name; + return targetSequence.name; + } + else + { + if (variable == null) + { + return "No variable selected"; + } + + string description = "If " + variable.key + " then "; + + if (onTrueSequence == null) + { + description += ""; + } + else + { + description += onTrueSequence.name; + } + description += " else "; + if (onFalseSequence == null) + { + description += ""; + } + else + { + description += onFalseSequence.name; + } + + return description; } - - return GetType().Name + "?"; } } diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index 145082c5..c7bcd0e8 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -88,9 +88,9 @@ namespace Fungus.Script public virtual void GetConnectedSequences(ref List connectedSequences) {} - public virtual string GetCommandTitle() + public virtual string GetDescription() { - return GetType().Name; + return ""; } } diff --git a/Assets/Fungus/VisualScripting/FungusScript.cs b/Assets/Fungus/VisualScripting/FungusScript.cs index 87a3a577..8b2accb8 100644 --- a/Assets/Fungus/VisualScripting/FungusScript.cs +++ b/Assets/Fungus/VisualScripting/FungusScript.cs @@ -52,10 +52,6 @@ namespace Fungus.Script return; } - #if UNITY_EDITOR - Selection.activeGameObject = sequence.gameObject; - #endif - executingSequence = sequence; sequence.ExecuteNextCommand(); } diff --git a/Assets/Fungus/VisualScripting/Say.cs b/Assets/Fungus/VisualScripting/Say.cs index 28e14c21..39e9052e 100644 --- a/Assets/Fungus/VisualScripting/Say.cs +++ b/Assets/Fungus/VisualScripting/Say.cs @@ -82,6 +82,11 @@ namespace Fungus.Script Continue(); }); } + + public override string GetDescription() + { + return "\"" + text + "\""; + } } } \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Sequence.cs b/Assets/Fungus/VisualScripting/Sequence.cs index 4aa1e174..d4eb076f 100644 --- a/Assets/Fungus/VisualScripting/Sequence.cs +++ b/Assets/Fungus/VisualScripting/Sequence.cs @@ -131,11 +131,6 @@ namespace Fungus.Script { activeCommand = null; fungusScript.executingSequence = null; - - // No more commands to run in current sequence - #if UNITY_EDITOR - Selection.activeGameObject = fungusScript.gameObject; - #endif } } } diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 0b019652fe2f5185b155fad75288cc6352ae14c2..e7cb8aef7e26559b928e9a2c8af756d0a0d3a5f3 100644 GIT binary patch delta 2856 zcmajhdu&rx90&08>u$HA42n$Hlf7Bl7;PPFb4^}V{8^)M+Tfv9~(T>_l2EegWhB1_QAT3uUFBQQ2C9` z>eu6_t~s{3t?fHxo;6H0t=we z1JO6*=hy81IHocMA6$zwT77I&e6!s;U<2%Pn0dfPm^0owVC@gVq&C=lm_#n*8JIJ{ z+P4nY3TsAOET$SO@dHl-j{~D3!+IX*U~DVwzOV+^7;KNp8esv{`E`>u@i>@yygvKn zqn!^iwhM7G!4Fg*d)S)chp=XtdE$>?Bd~7MBqw>?Y@;vo)3@Z{L$Fa8FaLxv4d$B5*hW-hTv!;^y^ygW;_eDN z409w~7q>Uom>q!aM;xl4>ZN!C7y)Jh>qXlKbEX*90pqO;<`MP+-t)E}=7;gmlSF$H zHVWfOE25n`)4bZ1YCT)SXVm7^T|l1odC|T^AWJg_mz_7&9a$TInGfrMyYH`U&9Dym zHf#iDp7^RxC8WMT07r`b;I~dQB{49$6*ne`EX6Z!db>7 zcSPJIY#e4jNB3Z@*{CGO@CjUr2V{e%P^I^@48Eb{z5(zGborcxG zZ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