|
|
@ -87,10 +87,13 @@ namespace Fungus |
|
|
|
protected StringBuilder leftString = new StringBuilder(1024); |
|
|
|
protected StringBuilder leftString = new StringBuilder(1024); |
|
|
|
protected StringBuilder rightString = new StringBuilder(1024); |
|
|
|
protected StringBuilder rightString = new StringBuilder(1024); |
|
|
|
protected StringBuilder outputString = new StringBuilder(1024); |
|
|
|
protected StringBuilder outputString = new StringBuilder(1024); |
|
|
|
|
|
|
|
protected StringBuilder readAheadString = new StringBuilder(1024); |
|
|
|
|
|
|
|
|
|
|
|
protected string hiddenColorOpen = ""; |
|
|
|
protected string hiddenColorOpen = ""; |
|
|
|
protected string hiddenColorClose = ""; |
|
|
|
protected string hiddenColorClose = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected int visibleCharacterCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Awake() |
|
|
|
protected virtual void Awake() |
|
|
|
{ |
|
|
|
{ |
|
|
|
GameObject go = targetTextObject; |
|
|
|
GameObject go = targetTextObject; |
|
|
@ -257,6 +260,8 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
TokenType previousTokenType = TokenType.Invalid; |
|
|
|
TokenType previousTokenType = TokenType.Invalid; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
visibleCharacterCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tokens.Count; ++i) |
|
|
|
for (int i = 0; i < tokens.Count; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Pause between tokens if Paused is set |
|
|
|
// Pause between tokens if Paused is set |
|
|
@ -270,6 +275,24 @@ namespace Fungus |
|
|
|
// Notify listeners about new token |
|
|
|
// Notify listeners about new token |
|
|
|
WriterSignals.DoTextTagToken(this, token, i, tokens.Count); |
|
|
|
WriterSignals.DoTextTagToken(this, token, i, tokens.Count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the read ahead string buffer. This contains the text for any |
|
|
|
|
|
|
|
// Word tags which are further ahead in the list. |
|
|
|
|
|
|
|
readAheadString.Length = 0; |
|
|
|
|
|
|
|
for (int j = i + 1; j < tokens.Count; ++j) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var readAheadToken = tokens[j]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (readAheadToken.type == TokenType.Words && |
|
|
|
|
|
|
|
readAheadToken.paramList.Count == 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
readAheadString.Append(readAheadToken.paramList[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (readAheadToken.type == TokenType.WaitForInputAndClear) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (token.type) |
|
|
|
switch (token.type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case TokenType.Words: |
|
|
|
case TokenType.Words: |
|
|
@ -489,7 +512,14 @@ namespace Fungus |
|
|
|
param = param.TrimStart(' ', '\t', '\r', '\n'); |
|
|
|
param = param.TrimStart(' ', '\t', '\r', '\n'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string startText = Text; |
|
|
|
// Start with the visible portion of any existing displayed text. |
|
|
|
|
|
|
|
string startText = ""; |
|
|
|
|
|
|
|
if (visibleCharacterCount > 0 && |
|
|
|
|
|
|
|
visibleCharacterCount <= Text.Length) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
startText = Text.Substring(0, visibleCharacterCount); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UpdateOpenMarkup(); |
|
|
|
UpdateOpenMarkup(); |
|
|
|
UpdateCloseMarkup(); |
|
|
|
UpdateCloseMarkup(); |
|
|
|
|
|
|
|
|
|
|
@ -588,9 +618,13 @@ namespace Fungus |
|
|
|
outputString.Append(leftString); |
|
|
|
outputString.Append(leftString); |
|
|
|
outputString.Append(closeString); |
|
|
|
outputString.Append(closeString); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Track how many visible characters are currently displayed so |
|
|
|
|
|
|
|
// we can easily extract the visible portion again later. |
|
|
|
|
|
|
|
visibleCharacterCount = outputString.Length; |
|
|
|
|
|
|
|
|
|
|
|
// Make right hand side text hidden |
|
|
|
// Make right hand side text hidden |
|
|
|
if (SupportsRichText() && |
|
|
|
if (SupportsRichText() && |
|
|
|
rightString.Length > 0) |
|
|
|
rightString.Length + readAheadString.Length > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Ensure the hidden color strings are populated |
|
|
|
// Ensure the hidden color strings are populated |
|
|
|
if (hiddenColorOpen.Length == 0) |
|
|
|
if (hiddenColorOpen.Length == 0) |
|
|
@ -600,6 +634,7 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
outputString.Append(hiddenColorOpen); |
|
|
|
outputString.Append(hiddenColorOpen); |
|
|
|
outputString.Append(rightString); |
|
|
|
outputString.Append(rightString); |
|
|
|
|
|
|
|
outputString.Append(readAheadString); |
|
|
|
outputString.Append(hiddenColorClose); |
|
|
|
outputString.Append(hiddenColorClose); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|