From 6afa1e95715f9429cc28aa1fda842732787d2023 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 23 Jun 2014 12:03:49 +0100 Subject: [PATCH] Moved Say & AddOption commands to new DialogCommands class. --- Assets/Fungus/Legacy/PageCommands.cs | 51 +--------------- .../Fungus/Scripts/Commands/DialogCommands.cs | 59 +++++++++++++++++++ .../Scripts/Commands/DialogCommands.cs.meta | 8 +++ 3 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 Assets/Fungus/Scripts/Commands/DialogCommands.cs create mode 100644 Assets/Fungus/Scripts/Commands/DialogCommands.cs.meta diff --git a/Assets/Fungus/Legacy/PageCommands.cs b/Assets/Fungus/Legacy/PageCommands.cs index 09c33384..764cfbfe 100644 --- a/Assets/Fungus/Legacy/PageCommands.cs +++ b/Assets/Fungus/Legacy/PageCommands.cs @@ -135,53 +135,6 @@ namespace Fungus } } - /** - * Writes story text to the page. - * A continue icon is displayed when the text has fully appeared. - */ - public class Say : CommandQueue.Command - { - string storyText; - - public Say(string _storyText) - { - storyText = _storyText; - } - - public override void Execute(CommandQueue commandQueue, Action onComplete) - { - IDialog sayDialog = Game.GetInstance().GetDialog(); - sayDialog.Say(storyText, onComplete); - } - } - - /** - * Adds an option button to the current list of options. - * Use the Choose command to display added options. - */ - public class AddOption : CommandQueue.Command - { - string optionText; - Action optionAction; - - public AddOption(string _optionText, Action _optionAction) - { - optionText = _optionText; - optionAction = _optionAction; - } - - public override void Execute(CommandQueue commandQueue, Action onComplete) - { - IDialog characterDialog = Game.GetInstance().GetDialog(); - characterDialog.AddOption(optionText, optionAction); - - if (onComplete != null) - { - onComplete(); - } - } - } - /** * Displays all previously added options. */ @@ -197,7 +150,7 @@ namespace Fungus public override void Execute(CommandQueue commandQueue, Action onComplete) { IDialog dialog = Game.GetInstance().GetDialog(); - + PageController pageController = dialog as PageController; if (pageController != null) { @@ -209,7 +162,7 @@ namespace Fungus // Support for modern IDialog interface dialog.Say(chooseText, null); } - + // Choose always clears the commandQueue, so there's no need to call onComplete() } } diff --git a/Assets/Fungus/Scripts/Commands/DialogCommands.cs b/Assets/Fungus/Scripts/Commands/DialogCommands.cs new file mode 100644 index 00000000..1904243e --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/DialogCommands.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using System; +using System.Collections; + +namespace Fungus +{ + /** + * Command classes have their own namespace to prevent them popping up in code completion. + */ + namespace Command + { + /** + * Writes story text to the page. + * A continue icon is displayed when the text has fully appeared. + */ + public class Say : CommandQueue.Command + { + string storyText; + + public Say(string _storyText) + { + storyText = _storyText; + } + + public override void Execute(CommandQueue commandQueue, Action onComplete) + { + IDialog sayDialog = Game.GetInstance().GetDialog(); + sayDialog.Say(storyText, onComplete); + } + } + + /** + * Adds an option button to the current list of options. + * Use the Choose command to display added options. + */ + public class AddOption : CommandQueue.Command + { + string optionText; + Action optionAction; + + public AddOption(string _optionText, Action _optionAction) + { + optionText = _optionText; + optionAction = _optionAction; + } + + public override void Execute(CommandQueue commandQueue, Action onComplete) + { + IDialog characterDialog = Game.GetInstance().GetDialog(); + characterDialog.AddOption(optionText, optionAction); + + if (onComplete != null) + { + onComplete(); + } + } + } + } +} diff --git a/Assets/Fungus/Scripts/Commands/DialogCommands.cs.meta b/Assets/Fungus/Scripts/Commands/DialogCommands.cs.meta new file mode 100644 index 00000000..3ef1615f --- /dev/null +++ b/Assets/Fungus/Scripts/Commands/DialogCommands.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e6a6caa973fb4fd784890f53106004d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: