Browse Source

Fixed whitespace trimming only after {wc} & {c} tags

master
chrisgregan 9 years ago
parent
commit
d748a7d5e7
  1. 20
      Assets/Fungus/UI/Scripts/Writer.cs

20
Assets/Fungus/UI/Scripts/Writer.cs

@ -368,13 +368,15 @@ namespace Fungus
exitFlag = false; exitFlag = false;
isWriting = true; isWriting = true;
TextTagParser.TokenType previousTokenType = TextTagParser.TokenType.Invalid;
foreach (TextTagParser.Token token in tokens) foreach (TextTagParser.Token token in tokens)
{ {
switch (token.type) switch (token.type)
{ {
case TextTagParser.TokenType.Words: case TextTagParser.TokenType.Words:
yield return StartCoroutine(DoWords(token.paramList)); yield return StartCoroutine(DoWords(token.paramList, previousTokenType));
break; break;
case TextTagParser.TokenType.BoldStart: case TextTagParser.TokenType.BoldStart:
@ -541,7 +543,9 @@ namespace Fungus
} }
break; break;
} }
previousTokenType = token.type;
if (exitFlag) if (exitFlag)
{ {
break; break;
@ -561,14 +565,22 @@ namespace Fungus
} }
} }
protected virtual IEnumerator DoWords(List<string> paramList) protected virtual IEnumerator DoWords(List<string> paramList, TextTagParser.TokenType previousTokenType)
{ {
if (!CheckParamCount(paramList, 1)) if (!CheckParamCount(paramList, 1))
{ {
yield break; yield break;
} }
string param = paramList[0].TrimStart(' ', '\t', '\r', '\n'); string param = paramList[0];
// Trim whitespace after a {wc} or {c} tag
if (previousTokenType == TextTagParser.TokenType.WaitForInputAndClear ||
previousTokenType == TextTagParser.TokenType.Clear)
{
param = param.TrimStart(' ', '\t', '\r', '\n');
}
string startText = text; string startText = text;
string openText = OpenMarkup(); string openText = OpenMarkup();
string closeText = CloseMarkup(); string closeText = CloseMarkup();

Loading…
Cancel
Save