From f1ecf1718216c082ec9cf93d5da646c6226b531b Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 18 Aug 2014 15:55:47 +0100 Subject: [PATCH] Highlight active variable --- .../FungusScript/FungusVariableListAdaptor.cs | 40 +++++++++++++++++++ .../Fungus/VisualScripting/FungusCommand.cs | 5 +++ Assets/Fungus/VisualScripting/If.cs | 5 +++ Assets/Fungus/VisualScripting/Set.cs | 5 +++ 4 files changed, 55 insertions(+) diff --git a/Assets/Fungus/Editor/FungusScript/FungusVariableListAdaptor.cs b/Assets/Fungus/Editor/FungusScript/FungusVariableListAdaptor.cs index fe6acd7f..f2cf6264 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusVariableListAdaptor.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusVariableListAdaptor.cs @@ -173,6 +173,46 @@ namespace Fungus.Script variable.key = key; variable.scope = scope; } + + FungusScript fungusScript = FungusEditorWindow.GetFungusScript(); + if (fungusScript != null) + { + bool highlight = false; + + // Is an executing command referencing this variable? + if (Application.isPlaying) + { + if (fungusScript.executingSequence != null && + fungusScript.executingSequence.activeCommand != null) + { + if (fungusScript.executingSequence.activeCommand.HasReference(variable)) + { + highlight = true; + } + } + } + else + { + // Is an expanded command referencing this variable? + if (fungusScript.selectedSequence != null) + { + FungusCommand[] commands = fungusScript.selectedSequence.GetComponents(); + foreach (FungusCommand command in commands) + { + if (command.expanded && + command.HasReference(variable)) + { + highlight = true; + } + } + } + } + + if (highlight) + { + GLDraw.DrawBox(position, Color.green, 2); + } + } } public virtual float GetItemHeight(int index) { diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index 108a1737..db0c4538 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -98,6 +98,11 @@ namespace Fungus.Script public virtual void GetConnectedSequences(ref List connectedSequences) {} + + public virtual bool HasReference(FungusVariable variable) + { + return false; + } public virtual string GetSummary() { diff --git a/Assets/Fungus/VisualScripting/If.cs b/Assets/Fungus/VisualScripting/If.cs index 61843d2c..de3f0c52 100644 --- a/Assets/Fungus/VisualScripting/If.cs +++ b/Assets/Fungus/VisualScripting/If.cs @@ -191,6 +191,11 @@ namespace Fungus.Script return description; } + + public override bool HasReference(FungusVariable variable) + { + return (variable == this.variable); + } } } \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Set.cs b/Assets/Fungus/VisualScripting/Set.cs index a28ba58c..e6ea603a 100644 --- a/Assets/Fungus/VisualScripting/Set.cs +++ b/Assets/Fungus/VisualScripting/Set.cs @@ -170,6 +170,11 @@ namespace Fungus.Script return description; } + + public override bool HasReference(FungusVariable variable) + { + return (variable == this.variable); + } } }