Browse Source

Using concrete Block class for safety with editor code

master
Christopher 8 years ago
parent
commit
43d59a8059
  1. 6
      Assets/Fungus/Flowchart/Scripts/Block.cs
  2. 6
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  3. 2
      Assets/Fungus/Flowchart/Scripts/IBlock.cs
  4. 2
      Assets/Fungus/Flowchart/Scripts/IFlowchart.cs
  5. 4
      Assets/Fungus/Scripts/Editor/BlockEditor.cs
  6. 4
      Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs

6
Assets/Fungus/Flowchart/Scripts/Block.cs

@ -34,7 +34,7 @@ namespace Fungus
protected ExecutionState executionState; protected ExecutionState executionState;
protected ICommand activeCommand; protected Command activeCommand;
/// <summary> /// <summary>
// Index of last command executed before the current one. // Index of last command executed before the current one.
@ -116,7 +116,7 @@ namespace Fungus
public virtual EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } } public virtual EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } }
public virtual ICommand ActiveCommand { get { return activeCommand; } } public virtual Command ActiveCommand { get { return activeCommand; } }
public virtual float ExecutingIconTimer { get; set; } public virtual float ExecutingIconTimer { get; set; }
@ -207,7 +207,7 @@ namespace Fungus
previousActiveCommandIndex = activeCommand.CommandIndex; previousActiveCommandIndex = activeCommand.CommandIndex;
} }
ICommand command = commandList[i]; var command = commandList[i];
activeCommand = command; activeCommand = command;
if (flowchart.IsActive()) if (flowchart.IsActive())

6
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -780,11 +780,11 @@ namespace Fungus
selectedCommands.Clear(); selectedCommands.Clear();
} }
public virtual void AddSelectedCommand(ICommand command) public virtual void AddSelectedCommand(Command command)
{ {
if (!selectedCommands.Contains((Command)command)) if (!selectedCommands.Contains(command))
{ {
selectedCommands.Add((Command)command); selectedCommands.Add(command);
} }
} }

2
Assets/Fungus/Flowchart/Scripts/IBlock.cs

@ -47,7 +47,7 @@ namespace Fungus
/// <summary> /// <summary>
/// The currently executing command. /// The currently executing command.
/// </summary> /// </summary>
ICommand ActiveCommand { get; } Command ActiveCommand { get; }
/// <summary> /// <summary>
/// Timer for fading Block execution icon. /// Timer for fading Block execution icon.

2
Assets/Fungus/Flowchart/Scripts/IFlowchart.cs

@ -260,7 +260,7 @@ namespace Fungus
/// <summary> /// <summary>
/// Adds a command to the list of selected commands. /// Adds a command to the list of selected commands.
/// </summary> /// </summary>
void AddSelectedCommand(ICommand command); void AddSelectedCommand(Command command);
/// <summary> /// <summary>
/// Reset the commands and variables in the Flowchart. /// Reset the commands and variables in the Flowchart.

4
Assets/Fungus/Scripts/Editor/BlockEditor.cs

@ -732,7 +732,7 @@ namespace Fungus
flowchart.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
ICommand newCommand = Undo.AddComponent(((Block)block).gameObject, commandOperation.commandType) as Command; var newCommand = Undo.AddComponent(((Block)block).gameObject, commandOperation.commandType) as Command;
block.GetFlowchart().AddSelectedCommand(newCommand); block.GetFlowchart().AddSelectedCommand(newCommand);
newCommand.ParentBlock = block; newCommand.ParentBlock = block;
newCommand.ItemId = flowchart.NextItemId(); newCommand.ItemId = flowchart.NextItemId();
@ -1013,7 +1013,7 @@ namespace Fungus
if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count) if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count)
{ {
Command nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex]; var nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex];
block.GetFlowchart().AddSelectedCommand(nextCommand); block.GetFlowchart().AddSelectedCommand(nextCommand);
} }

4
Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs

@ -90,7 +90,7 @@ namespace Fungus
return null; return null;
} }
Command newCommand = Undo.AddComponent<Comment>(((Block)block).gameObject) as Command; var newCommand = Undo.AddComponent<Comment>(((Block)block).gameObject) as Command;
newCommand.ItemId = flowchart.NextItemId(); newCommand.ItemId = flowchart.NextItemId();
flowchart.ClearSelectedCommands(); flowchart.ClearSelectedCommands();
flowchart.AddSelectedCommand(newCommand); flowchart.AddSelectedCommand(newCommand);
@ -355,7 +355,7 @@ namespace Fungus
for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i) for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i)
{ {
Command selectedCommand = flowchart.SelectedBlock.CommandList[i]; var selectedCommand = flowchart.SelectedBlock.CommandList[i];
BlockEditor.actionList.Add ( delegate { BlockEditor.actionList.Add ( delegate {
flowchart.AddSelectedCommand(selectedCommand); flowchart.AddSelectedCommand(selectedCommand);
}); });

Loading…
Cancel
Save