Browse Source

Fixed pasting multiple copies of same command

master
chrisgregan 11 years ago
parent
commit
b2afbbbeff
  1. 6
      Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs
  2. 8
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  3. 4
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  4. 2
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  5. 11
      Assets/Fungus/FungusScript/Scripts/CommandCopyBuffer.cs
  6. 8
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  7. 2
      Assets/Fungus/FungusScript/Scripts/Sequence.cs

6
Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs

@ -90,8 +90,8 @@ namespace Fungus
} }
Command newCommand = Undo.AddComponent<Comment>(sequence.gameObject) as Command; Command newCommand = Undo.AddComponent<Comment>(sequence.gameObject) as Command;
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
fungusScript.selectedCommands.Add(newCommand); fungusScript.AddSelectedCommand(newCommand);
return newCommand; return newCommand;
} }
@ -233,7 +233,7 @@ namespace Fungus
} }
else else
{ {
fungusScript.selectedCommands.Add(command); fungusScript.AddSelectedCommand(command);
} }
GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus) GUIUtility.keyboardControl = 0; // Fix for textarea not refeshing (change focus)
} }

8
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -35,12 +35,12 @@ namespace Fungus
{ {
if (fungusScript.executingSequence == null) if (fungusScript.executingSequence == null)
{ {
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
} }
else else
{ {
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
fungusScript.selectedCommands.Add(fungusScript.executingSequence.activeCommand); fungusScript.AddSelectedCommand(fungusScript.executingSequence.activeCommand);
EditorUtility.SetDirty(fungusScript); EditorUtility.SetDirty(fungusScript);
} }
} }
@ -85,7 +85,7 @@ namespace Fungus
{ {
if (fungusScript.selectedCommands[0] == null) if (fungusScript.selectedCommands[0] == null)
{ {
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
} }
else else
{ {

4
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -87,7 +87,7 @@ namespace Fungus
Undo.DestroyObjectImmediate(deleteSequence); Undo.DestroyObjectImmediate(deleteSequence);
fungusScript.selectedSequence = null; fungusScript.selectedSequence = null;
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
} }
deleteList.Clear(); deleteList.Clear();
@ -673,7 +673,7 @@ namespace Fungus
Undo.RecordObject(fungusScript, "Select All"); Undo.RecordObject(fungusScript, "Select All");
foreach (Command command in fungusScript.selectedSequence.commandList) foreach (Command command in fungusScript.selectedSequence.commandList)
{ {
fungusScript.selectedCommands.Add(command); fungusScript.AddSelectedCommand(command);
} }
} }

2
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -294,7 +294,7 @@ namespace Fungus
sequence.GetFungusScript().ClearSelectedCommands(); sequence.GetFungusScript().ClearSelectedCommands();
Command newCommand = Undo.AddComponent(sequence.gameObject, commandOperation.commandType) as Command; Command newCommand = Undo.AddComponent(sequence.gameObject, commandOperation.commandType) as Command;
sequence.GetFungusScript().selectedCommands.Add(newCommand); sequence.GetFungusScript().AddSelectedCommand(newCommand);
// Let command know it has just been added to the sequence // Let command know it has just been added to the sequence
newCommand.OnCommandAdded(sequence); newCommand.OnCommandAdded(sequence);

11
Assets/Fungus/FungusScript/Scripts/CommandCopyBuffer.cs

@ -19,15 +19,16 @@ namespace Fungus
// Static variables are not serialized (e.g. when playing in the editor) // Static variables are not serialized (e.g. when playing in the editor)
// We need to reaquire the static reference to the game object in this case // We need to reaquire the static reference to the game object in this case
GameObject go = GameObject.Find("_CommandCopyBuffer"); GameObject go = GameObject.Find("_CommandCopyBuffer");
if (go != null) if (go == null)
{ {
instance = go.GetComponent<CommandCopyBuffer>(); go = new GameObject("_CommandCopyBuffer");
go.hideFlags = HideFlags.HideAndDontSave;
} }
else
instance = go.GetComponent<CommandCopyBuffer>();
if (instance == null)
{ {
go = new GameObject("_CommandCopyBuffer");
instance = go.AddComponent<CommandCopyBuffer>(); instance = go.AddComponent<CommandCopyBuffer>();
go.hideFlags = HideFlags.HideInHierarchy;
} }
} }

8
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

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

2
Assets/Fungus/FungusScript/Scripts/Sequence.cs

@ -140,7 +140,7 @@ namespace Fungus
activeCommand = null; activeCommand = null;
fungusScript.executingSequence = null; fungusScript.executingSequence = null;
fungusScript.selectedSequence = null; fungusScript.selectedSequence = null;
fungusScript.selectedCommands.Clear(); fungusScript.ClearSelectedCommands();
} }
public virtual List<Sequence> GetConnectedSequences() public virtual List<Sequence> GetConnectedSequences()

Loading…
Cancel
Save