Browse Source

Moved text substitution step to Dialog commands.

master
chrisgregan 11 years ago
parent
commit
722714a0e1
  1. 7
      Assets/Fungus/Legacy/PageCommands.cs
  2. 9
      Assets/Fungus/Legacy/PageController.cs
  3. 14
      Assets/Fungus/Scripts/Commands/DialogCommands.cs
  4. 13
      Assets/Fungus/Scripts/Dialog.cs

7
Assets/Fungus/Legacy/PageCommands.cs

@ -149,18 +149,19 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
IDialog dialog = Game.GetInstance().GetDialog();
string subbedText = Game.stringTable.SubstituteStrings(chooseText);
IDialog dialog = Game.GetInstance().GetDialog();
PageController pageController = dialog as PageController;
if (pageController != null)
{
// Legacy support for old Pages system
pageController.Choose(chooseText);
pageController.Choose(subbedText);
}
else
{
// Support for modern IDialog interface
dialog.Say(chooseText, null);
dialog.Say(subbedText, null);
}
// Choose always clears the commandQueue, so there's no need to call onComplete()

9
Assets/Fungus/Legacy/PageController.cs

@ -273,9 +273,8 @@ namespace Fungus
}
mode = Mode.Say;
string subbedText = Game.stringTable.SubstituteStrings(sayText);
continueAction = sayAction;
WriteStory(subbedText);
WriteStory(sayText);
}
public void ClearOptions()
@ -285,15 +284,13 @@ namespace Fungus
public void AddOption(string optionText, Action optionAction)
{
string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText));
options.Add(new Option(subbedText, optionAction));
options.Add(new Option(optionText, optionAction));
}
public void Choose(string _chooseText)
{
mode = Mode.Choose;
string subbedText = Game.stringTable.SubstituteStrings(_chooseText);
WriteStory(subbedText);
WriteStory(_chooseText);
}
public void SetTimeout(float _timeoutDuration, Action _timeoutAction)

14
Assets/Fungus/Scripts/Commands/DialogCommands.cs

@ -15,17 +15,19 @@ namespace Fungus
*/
public class Say : CommandQueue.Command
{
string storyText;
string sayText;
public Say(string _storyText)
public Say(string _sayText)
{
storyText = _storyText;
sayText = _sayText;
}
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
string subbedText = Game.stringTable.SubstituteStrings(sayText);
IDialog sayDialog = Game.GetInstance().GetDialog();
sayDialog.Say(storyText, onComplete);
sayDialog.Say(subbedText, onComplete);
}
}
@ -47,7 +49,9 @@ namespace Fungus
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
IDialog characterDialog = Game.GetInstance().GetDialog();
characterDialog.AddOption(optionText, optionAction);
string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText));
characterDialog.AddOption(subbedText, optionAction);
if (onComplete != null)
{

13
Assets/Fungus/Scripts/Dialog.cs

@ -362,16 +362,16 @@ namespace Fungus
public void Say(string _sayText, Action sayAction)
{
string subbedText = Game.stringTable.SubstituteStrings(_sayText);
string copyText = _sayText;
// Hack: Handle Say(""); by writing a single space character.
if (subbedText.Length == 0)
if (copyText.Length == 0)
{
subbedText = " ";
copyText = " ";
}
continueAction = sayAction;
previousSayText = subbedText;
previousSayText = copyText;
if (timeoutDuration > 0 &&
options.Count > 0)
@ -380,7 +380,7 @@ namespace Fungus
timeoutTimer = timeoutDuration;
}
WriteSayText(subbedText);
WriteSayText(copyText);
}
void WriteSayText(string _sayText)
@ -489,8 +489,7 @@ namespace Fungus
public void AddOption(string optionText, Action optionAction)
{
string subbedText = Game.stringTable.FormatLinkText(Game.stringTable.SubstituteStrings(optionText));
options.Add(new Option(subbedText, optionAction));
options.Add(new Option(optionText, optionAction));
}
public void SetTimeout(float _timeoutDuration, Action _timeoutAction)

Loading…
Cancel
Save