From db928d3a3395cf8ec81fedbdb38dec5bb57e578c Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 4 Sep 2014 13:01:29 +0100 Subject: [PATCH] Command colours are specified in a virtual function --- Assets/Fungus/Audio/Commands/PlayMusic.cs | 8 ++++++-- Assets/Fungus/Audio/Commands/PlaySound.cs | 8 ++++++-- Assets/Fungus/Audio/Commands/SetMusicVolume.cs | 8 ++++++-- Assets/Fungus/Audio/Commands/StopMusic.cs | 8 ++++++-- Assets/Fungus/Camera/Commands/FadeToView.cs | 8 ++++++-- Assets/Fungus/Camera/Commands/MoveToView.cs | 8 ++++++-- Assets/Fungus/Dialog/Commands/AddOption.cs | 8 ++++++-- Assets/Fungus/Dialog/Commands/Choose.cs | 8 ++++++-- Assets/Fungus/Dialog/Commands/Say.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/Call.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/Else.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/EndIf.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/If.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/LoadGlobals.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/LoadScene.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/SaveGlobals.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/Set.cs | 8 ++++++-- Assets/Fungus/FungusScript/Commands/Wait.cs | 8 ++++++-- .../Fungus/FungusScript/Editor/FungusCommandEditor.cs | 2 +- .../FungusScript/Editor/FungusCommandListAdaptor.cs | 2 +- Assets/Fungus/FungusScript/Scripts/FungusCommand.cs | 10 ++++++---- Assets/Fungus/Sprite/Commands/FadeSprite.cs | 8 ++++++-- 22 files changed, 122 insertions(+), 44 deletions(-) diff --git a/Assets/Fungus/Audio/Commands/PlayMusic.cs b/Assets/Fungus/Audio/Commands/PlayMusic.cs index 84cb30e3..1cb3bea6 100644 --- a/Assets/Fungus/Audio/Commands/PlayMusic.cs +++ b/Assets/Fungus/Audio/Commands/PlayMusic.cs @@ -5,8 +5,7 @@ namespace Fungus.Script { [CommandInfo("Audio", "Play Music", - "Plays game music. If any game music is already playing, it is stopped. Music continues playing across scene loads.", - 242, 209, 176)] + "Plays game music. If any game music is already playing, it is stopped. Music continues playing across scene loads.")] public class PlayMusic : FungusCommand { public AudioClip musicClip; @@ -31,6 +30,11 @@ namespace Fungus.Script return musicClip.name; } + + public override Color GetButtonColor() + { + return new Color32(242, 209, 176, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Audio/Commands/PlaySound.cs b/Assets/Fungus/Audio/Commands/PlaySound.cs index 590fe0e1..2c5870ad 100644 --- a/Assets/Fungus/Audio/Commands/PlaySound.cs +++ b/Assets/Fungus/Audio/Commands/PlaySound.cs @@ -5,8 +5,7 @@ namespace Fungus.Script { [CommandInfo("Audio", "Play Sound", - "Plays a sound effect. Multiple sound effects can play at the same time.", - 242, 209, 176)] + "Plays a sound effect. Multiple sound effects can play at the same time.")] public class PlaySound : FungusCommand { public AudioClip soundClip; @@ -34,6 +33,11 @@ namespace Fungus.Script return soundClip.name; } + + public override Color GetButtonColor() + { + return new Color32(242, 209, 176, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Audio/Commands/SetMusicVolume.cs b/Assets/Fungus/Audio/Commands/SetMusicVolume.cs index 6bdbed76..06fac65c 100644 --- a/Assets/Fungus/Audio/Commands/SetMusicVolume.cs +++ b/Assets/Fungus/Audio/Commands/SetMusicVolume.cs @@ -5,8 +5,7 @@ namespace Fungus.Script { [CommandInfo("Audio", "Set Music Volume", - "Sets the game music volume level.", - 242, 209, 176)] + "Sets the game music volume level.")] public class SetMusicVolume : FungusCommand { [Range(0,1)] @@ -30,6 +29,11 @@ namespace Fungus.Script { return "Set to " + volume + " over " + fadeDuration + " seconds."; } + + public override Color GetButtonColor() + { + return new Color32(242, 209, 176, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Audio/Commands/StopMusic.cs b/Assets/Fungus/Audio/Commands/StopMusic.cs index dc967042..b21254f9 100644 --- a/Assets/Fungus/Audio/Commands/StopMusic.cs +++ b/Assets/Fungus/Audio/Commands/StopMusic.cs @@ -5,8 +5,7 @@ namespace Fungus.Script { [CommandInfo("Audio", "Stop Music", - "Stops the currently playing game music.", - 242, 209, 176)] + "Stops the currently playing game music.")] public class StopMusic : FungusCommand { public override void OnEnter() @@ -19,6 +18,11 @@ namespace Fungus.Script Continue(); } + + public override Color GetButtonColor() + { + return new Color32(242, 209, 176, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Camera/Commands/FadeToView.cs b/Assets/Fungus/Camera/Commands/FadeToView.cs index 4339fd09..a7883bbd 100644 --- a/Assets/Fungus/Camera/Commands/FadeToView.cs +++ b/Assets/Fungus/Camera/Commands/FadeToView.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Camera", "Fade To View", - "Fades the camera out and in again at a location specified by a View object.", - 216, 228, 170)] + "Fades the camera out and in again at a location specified by a View object.")] public class FadeToView : FungusCommand { public float duration; @@ -65,6 +64,11 @@ namespace Fungus.Script return targetView.name; } } + + public override Color GetButtonColor() + { + return new Color32(216, 228, 170, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Camera/Commands/MoveToView.cs b/Assets/Fungus/Camera/Commands/MoveToView.cs index 738b00cb..8cd3fabb 100644 --- a/Assets/Fungus/Camera/Commands/MoveToView.cs +++ b/Assets/Fungus/Camera/Commands/MoveToView.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Camera", "Move To View", - "Moves the camera to a location specified by a View object.", - 216, 228, 170)] + "Moves the camera to a location specified by a View object.")] public class MoveToView : FungusCommand { public float duration; @@ -52,6 +51,11 @@ namespace Fungus.Script return targetView.name; } } + + public override Color GetButtonColor() + { + return new Color32(216, 228, 170, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Commands/AddOption.cs b/Assets/Fungus/Dialog/Commands/AddOption.cs index 75f78c13..5e3a3e8a 100644 --- a/Assets/Fungus/Dialog/Commands/AddOption.cs +++ b/Assets/Fungus/Dialog/Commands/AddOption.cs @@ -7,8 +7,7 @@ namespace Fungus.Script { [CommandInfo("Dialog", "Add Option", - "Adds an option for the player to select, displayed by the next Say command.", - 184, 210, 235)] + "Adds an option for the player to select, displayed by the next Say command.")] public class AddOption : FungusCommand { public string optionText; @@ -56,6 +55,11 @@ namespace Fungus.Script connectedSequences.Add (targetSequence); } } + + public override Color GetButtonColor() + { + return new Color32(184, 210, 235, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Commands/Choose.cs b/Assets/Fungus/Dialog/Commands/Choose.cs index a4488e10..b58d1bac 100644 --- a/Assets/Fungus/Dialog/Commands/Choose.cs +++ b/Assets/Fungus/Dialog/Commands/Choose.cs @@ -7,8 +7,7 @@ namespace Fungus.Script { [CommandInfo("Dialog", "Choose", - "Presents a list of options for the player to choose from, with an optional timeout. Add options using preceding AddOption commands.", - 184, 210, 235)] + "Presents a list of options for the player to choose from, with an optional timeout. Add options using preceding AddOption commands.")] public class Choose : FungusCommand { public ChooseDialog dialog; @@ -164,6 +163,11 @@ namespace Fungus.Script GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } + + public override Color GetButtonColor() + { + return new Color32(184, 210, 235, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index e3664c8d..0dc8ad7e 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -7,8 +7,7 @@ namespace Fungus.Script { [CommandInfo("Dialog", "Say", - "Writes a line of story text to the dialog. A list of options can be specified for the player to choose from. Use a non-zero timeout to give the player a limited time to choose.", - 184, 210, 235)] + "Writes a line of story text to the dialog. A list of options can be specified for the player to choose from. Use a non-zero timeout to give the player a limited time to choose.")] public class Say : FungusCommand { public SayDialog dialog; @@ -110,6 +109,11 @@ namespace Fungus.Script GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } + + public override Color GetButtonColor() + { + return new Color32(184, 210, 235, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/Call.cs b/Assets/Fungus/FungusScript/Commands/Call.cs index 5f486c87..1d739d63 100644 --- a/Assets/Fungus/FungusScript/Commands/Call.cs +++ b/Assets/Fungus/FungusScript/Commands/Call.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Call", - "Execute another sequence.", - 255, 255, 255)] + "Execute another sequence.")] public class Call : FungusCommand { public Sequence targetSequence; @@ -41,6 +40,11 @@ namespace Fungus.Script return targetSequence.name; } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/Else.cs b/Assets/Fungus/FungusScript/Commands/Else.cs index d999aec1..5862e458 100644 --- a/Assets/Fungus/FungusScript/Commands/Else.cs +++ b/Assets/Fungus/FungusScript/Commands/Else.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Else", - "Marks the start of a sequence block to be executed when the preceding If statement is false.", - 253, 253, 150)] + "Marks the start of a sequence block to be executed when the preceding If statement is false.")] public class Else : FungusCommand { public override void OnEnter() @@ -47,6 +46,11 @@ namespace Fungus.Script { return 1; } + + public override Color GetButtonColor() + { + return new Color32(253, 253, 150, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/EndIf.cs b/Assets/Fungus/FungusScript/Commands/EndIf.cs index c86c804d..1ce92521 100644 --- a/Assets/Fungus/FungusScript/Commands/EndIf.cs +++ b/Assets/Fungus/FungusScript/Commands/EndIf.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "EndIf", - "Marks the end of an If statement block.", - 253, 253, 150)] + "Marks the end of an If statement block.")] public class EndIf : FungusCommand { public override void OnEnter() @@ -19,6 +18,11 @@ namespace Fungus.Script { return -1; } + + public override Color GetButtonColor() + { + return new Color32(253, 253, 150, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/If.cs b/Assets/Fungus/FungusScript/Commands/If.cs index d36d1018..a0502b5b 100644 --- a/Assets/Fungus/FungusScript/Commands/If.cs +++ b/Assets/Fungus/FungusScript/Commands/If.cs @@ -16,8 +16,7 @@ namespace Fungus.Script [CommandInfo("Scripting", "If", - "If the test expression is true, execute the following block of commands.", - 253, 253, 150)] + "If the test expression is true, execute the following block of commands.")] public class If : FungusCommand { public FungusVariable variable; @@ -222,6 +221,11 @@ namespace Fungus.Script { return 1; } + + public override Color GetButtonColor() + { + return new Color32(253, 253, 150, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/LoadGlobals.cs b/Assets/Fungus/FungusScript/Commands/LoadGlobals.cs index 4b3c1bcc..67ab9d67 100644 --- a/Assets/Fungus/FungusScript/Commands/LoadGlobals.cs +++ b/Assets/Fungus/FungusScript/Commands/LoadGlobals.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Load Globals", - "Loads a set of global variables previously saved using the SaveGlobals command.", - 255, 255, 255)] + "Loads a set of global variables previously saved using the SaveGlobals command.")] public class LoadGlobals : FungusCommand { public string saveName = ""; @@ -21,6 +20,11 @@ namespace Fungus.Script { return saveName; } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/LoadScene.cs b/Assets/Fungus/FungusScript/Commands/LoadScene.cs index aba52343..c2ab86a4 100644 --- a/Assets/Fungus/FungusScript/Commands/LoadScene.cs +++ b/Assets/Fungus/FungusScript/Commands/LoadScene.cs @@ -9,8 +9,7 @@ namespace Fungus.Script "Loads a new scene and displays an optional loading image. This is useful " + "for splitting a large game across multiple scene files to reduce peak memory " + "usage. All previously loaded assets (including textures and audio) will be released." + - "The scene to be loaded must be added to the scene list in Build Settings.", - 255, 255, 255)] + "The scene to be loaded must be added to the scene list in Build Settings.")] public class LoadScene : FungusCommand { public string sceneName = ""; @@ -31,6 +30,11 @@ namespace Fungus.Script return sceneName; } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/SaveGlobals.cs b/Assets/Fungus/FungusScript/Commands/SaveGlobals.cs index 84c4782c..dde7790b 100644 --- a/Assets/Fungus/FungusScript/Commands/SaveGlobals.cs +++ b/Assets/Fungus/FungusScript/Commands/SaveGlobals.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Save Globals", - "Saves all current global variables to be loaded again later using the LoadGlobals command. This provides a basic save game system.", - 255, 255, 255)] + "Saves all current global variables to be loaded again later using the LoadGlobals command. This provides a basic save game system.")] public class SaveGlobals : FungusCommand { public string saveName = ""; @@ -21,6 +20,11 @@ namespace Fungus.Script { return saveName; } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/Set.cs b/Assets/Fungus/FungusScript/Commands/Set.cs index a8de3821..219532a8 100644 --- a/Assets/Fungus/FungusScript/Commands/Set.cs +++ b/Assets/Fungus/FungusScript/Commands/Set.cs @@ -5,8 +5,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Set", - "Sets a variable to a new value using simple arithmetic operations. The value can be a constant or another variable.", - 255, 255, 255)] + "Sets a variable to a new value using simple arithmetic operations. The value can be a constant or another variable.")] public class Set : FungusCommand { public enum SetOperator @@ -178,6 +177,11 @@ namespace Fungus.Script { return (variable == this.variable); } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } diff --git a/Assets/Fungus/FungusScript/Commands/Wait.cs b/Assets/Fungus/FungusScript/Commands/Wait.cs index e5d340fd..272df99c 100644 --- a/Assets/Fungus/FungusScript/Commands/Wait.cs +++ b/Assets/Fungus/FungusScript/Commands/Wait.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Scripting", "Wait", - "Waits for period of time before executing the next command in the sequence.", - 255, 255, 255)] + "Waits for period of time before executing the next command in the sequence.")] public class Wait : FungusCommand { public float duration = 1; @@ -26,6 +25,11 @@ namespace Fungus.Script { return duration.ToString() + " seconds"; } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs index 107499b1..c65904a1 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusCommandEditor.cs @@ -61,7 +61,7 @@ namespace Fungus.Script GUIStyle commandStyle = new GUIStyle(EditorStyles.miniButton); if (t.enabled) { - GUI.backgroundColor = commandInfoAttr.ButtonColor; + GUI.backgroundColor = t.GetButtonColor(); } else { diff --git a/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs b/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs index 15ee1c83..f738fdb9 100644 --- a/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusCommandListAdaptor.cs @@ -185,7 +185,7 @@ namespace Fungus.Script GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) } - Color buttonBackgroundColor = commandInfoAttr.ButtonColor; + Color buttonBackgroundColor = command.GetButtonColor(); Color summaryBackgroundColor = Color.white; if (selected) diff --git a/Assets/Fungus/FungusScript/Scripts/FungusCommand.cs b/Assets/Fungus/FungusScript/Scripts/FungusCommand.cs index 333fb9f8..c7ec0230 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusCommand.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusCommand.cs @@ -11,19 +11,16 @@ namespace Fungus.Script public class CommandInfoAttribute : Attribute { - public CommandInfoAttribute(string category, string commandName, string helpText, byte red, byte green, byte blue) + public CommandInfoAttribute(string category, string commandName, string helpText) { this.Category = category; this.CommandName = commandName; this.HelpText = helpText; - this.ButtonColor = new Color32(red, green, blue, 255); } public string Category { get; set; } public string CommandName { get; set; } public string HelpText { get; set; } - public Color ButtonColor { get; set; } - public Color IndentOffset { get; set; } } [RequireComponent(typeof(Sequence))] @@ -142,6 +139,11 @@ namespace Fungus.Script { return 0; } + + public virtual Color GetButtonColor() + { + return Color.white; + } } } \ No newline at end of file diff --git a/Assets/Fungus/Sprite/Commands/FadeSprite.cs b/Assets/Fungus/Sprite/Commands/FadeSprite.cs index 7cdf9153..c6d7e4d3 100644 --- a/Assets/Fungus/Sprite/Commands/FadeSprite.cs +++ b/Assets/Fungus/Sprite/Commands/FadeSprite.cs @@ -6,8 +6,7 @@ namespace Fungus.Script { [CommandInfo("Sprite", "Fade Sprite", - "Fades a sprite to a target color over a period of time.", - 212, 178, 211)] + "Fades a sprite to a target color over a period of time.")] public class FadeSprite : FungusCommand { public SpriteRenderer spriteRenderer; @@ -47,6 +46,11 @@ namespace Fungus.Script return spriteRenderer.name + " to " + targetColor.ToString(); } + + public override Color GetButtonColor() + { + return new Color32(221, 184, 169, 255); + } } } \ No newline at end of file