Browse Source

Change #72 Replace End If command with End command

master
chrisgregan 10 years ago
parent
commit
a5857c6abb
  1. 7
      Assets/Fungus/FungusScript/Scripts/Command.cs
  2. 5
      Assets/Fungus/FungusScript/Scripts/Commands/Else.cs
  3. 29
      Assets/Fungus/FungusScript/Scripts/Commands/End.cs
  4. 8
      Assets/Fungus/FungusScript/Scripts/Commands/End.cs.meta
  5. 5
      Assets/Fungus/FungusScript/Scripts/Commands/EndIf.cs
  6. 5
      Assets/Fungus/FungusScript/Scripts/Commands/If.cs

7
Assets/Fungus/FungusScript/Scripts/Command.cs

@ -8,6 +8,13 @@ namespace Fungus
public class CommandInfoAttribute : Attribute public class CommandInfoAttribute : Attribute
{ {
/**
* Metadata atribute for the Command class.
* @param category The category to place this command in.
* @param commandName The display name of the command.
* @param helpText Help information to display in the inspector.
* @param priority If two command classes have the same name, the one with highest priority is listed. Negative priority removess the command from the list.
*/
public CommandInfoAttribute(string category, string commandName, string helpText, int priority = 0) public CommandInfoAttribute(string category, string commandName, string helpText, int priority = 0)
{ {
this.Category = category; this.Category = category;

5
Assets/Fungus/FungusScript/Scripts/Commands/Else.cs

@ -17,7 +17,7 @@ namespace Fungus
return; return;
} }
// Find the next EndIf command at the same indent level as this Else command // Find the next End command at the same indent level as this Else command
bool foundThisCommand = false; bool foundThisCommand = false;
int indent = indentLevel; int indent = indentLevel;
foreach(Command command in parentSequence.commandList) foreach(Command command in parentSequence.commandList)
@ -26,7 +26,8 @@ namespace Fungus
command.indentLevel == indent) command.indentLevel == indent)
{ {
System.Type type = command.GetType(); System.Type type = command.GetType();
if (type == typeof(EndIf)) if (type == typeof(EndIf) || // Legacy support for old EndIf command
type == typeof(End))
{ {
// Execute command immediately after the EndIf command // Execute command immediately after the EndIf command
Continue(command); Continue(command);

29
Assets/Fungus/FungusScript/Scripts/Commands/End.cs

@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus
{
[CommandInfo("Scripting",
"End",
"Marks the end of a conditional block.")]
[AddComponentMenu("")]
public class End : Command
{
public override void OnEnter()
{
Continue();
}
public override int GetPreIndent()
{
return -1;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
}
}

8
Assets/Fungus/FungusScript/Scripts/Commands/End.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 93cb9773f2ca04e2bbf7a68ccfc23267
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

5
Assets/Fungus/FungusScript/Scripts/Commands/EndIf.cs

@ -4,9 +4,10 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
// Note: The End If command is deprecated, use the End command instead.
[CommandInfo("Scripting", [CommandInfo("Scripting",
"End If", "End",
"Marks the end of an If statement block.")] "Marks the end of a conditional block.", -1)]
[AddComponentMenu("")] [AddComponentMenu("")]
public class EndIf : Command public class EndIf : Command
{ {

5
Assets/Fungus/FungusScript/Scripts/Commands/If.cs

@ -156,7 +156,8 @@ namespace Fungus
{ {
System.Type type = command.GetType(); System.Type type = command.GetType();
if (type == typeof(Else) || if (type == typeof(Else) ||
type == typeof(EndIf)) type == typeof(EndIf) || // Legacy support for old EndIf command
type == typeof(End))
{ {
// Execute command immediately after the Else or EndIf command // Execute command immediately after the Else or EndIf command
Continue(command); Continue(command);
@ -169,7 +170,7 @@ namespace Fungus
} }
} }
// No matching EndIf command found, so just stop the sequence // No matching End command found, so just stop the sequence
Stop(); Stop();
} }
} }

Loading…
Cancel
Save