Browse Source

Highlight active variable

master
chrisgregan 11 years ago
parent
commit
f1ecf17182
  1. 40
      Assets/Fungus/Editor/FungusScript/FungusVariableListAdaptor.cs
  2. 5
      Assets/Fungus/VisualScripting/FungusCommand.cs
  3. 5
      Assets/Fungus/VisualScripting/If.cs
  4. 5
      Assets/Fungus/VisualScripting/Set.cs

40
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<FungusCommand>();
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) {

5
Assets/Fungus/VisualScripting/FungusCommand.cs

@ -98,6 +98,11 @@ namespace Fungus.Script
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences)
{}
public virtual bool HasReference(FungusVariable variable)
{
return false;
}
public virtual string GetSummary()
{

5
Assets/Fungus/VisualScripting/If.cs

@ -191,6 +191,11 @@ namespace Fungus.Script
return description;
}
public override bool HasReference(FungusVariable variable)
{
return (variable == this.variable);
}
}
}

5
Assets/Fungus/VisualScripting/Set.cs

@ -170,6 +170,11 @@ namespace Fungus.Script
return description;
}
public override bool HasReference(FungusVariable variable)
{
return (variable == this.variable);
}
}
}

Loading…
Cancel
Save