|
|
@ -5,7 +5,7 @@ |
|
|
|
using UnityEngine.UI; |
|
|
|
using UnityEngine.UI; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Text; |
|
|
|
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ namespace Fungus |
|
|
|
/// <summary> Writing has resumed after a pause. </summary> |
|
|
|
/// <summary> Writing has resumed after a pause. </summary> |
|
|
|
Resume, |
|
|
|
Resume, |
|
|
|
/// <summary> Writing has ended. </summary> |
|
|
|
/// <summary> Writing has ended. </summary> |
|
|
|
End |
|
|
|
End, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -80,6 +80,32 @@ namespace Fungus |
|
|
|
protected bool inputFlag; |
|
|
|
protected bool inputFlag; |
|
|
|
protected bool exitFlag; |
|
|
|
protected bool exitFlag; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//holds number of Word tokens in the currently running Write |
|
|
|
|
|
|
|
public int WordTokensFound { get; protected set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Updated during writing of Word tokens, when processed tips over found, fires NotifyAllWordsWritten |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public virtual int WordTokensProcessed |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return wordTokensProcessed; } |
|
|
|
|
|
|
|
protected set |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(wordTokensProcessed < WordTokensFound && value >= WordTokensFound) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
NotifyAllWordsWritten(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
wordTokensProcessed = value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//holds count of number of Word tokens completed |
|
|
|
|
|
|
|
protected int wordTokensProcessed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Does the currently processing list of Tokens have Word Tokens that are not yet processed |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public bool HasWordsRemaining { get { return WordTokensProcessed < WordTokensFound; } } |
|
|
|
|
|
|
|
|
|
|
|
protected List<IWriterListener> writerListeners = new List<IWriterListener>(); |
|
|
|
protected List<IWriterListener> writerListeners = new List<IWriterListener>(); |
|
|
|
|
|
|
|
|
|
|
|
protected StringBuilder openString = new StringBuilder(256); |
|
|
|
protected StringBuilder openString = new StringBuilder(256); |
|
|
@ -125,7 +151,7 @@ namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Cache the hidden color string |
|
|
|
// Cache the hidden color string |
|
|
|
Color32 c = hiddenTextColor; |
|
|
|
Color32 c = hiddenTextColor; |
|
|
|
hiddenColorOpen = String.Format("<color=#{0:X2}{1:X2}{2:X2}{3:X2}>", c.r, c.g, c.b, c.a); |
|
|
|
hiddenColorOpen = string.Format("<color=#{0:X2}{1:X2}{2:X2}{3:X2}>", c.r, c.g, c.b, c.a); |
|
|
|
hiddenColorClose = "</color>"; |
|
|
|
hiddenColorClose = "</color>"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -221,19 +247,21 @@ namespace Fungus |
|
|
|
value = defaultValue; |
|
|
|
value = defaultValue; |
|
|
|
if (paramList.Count > index) |
|
|
|
if (paramList.Count > index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Single.TryParse(paramList[index], out value); |
|
|
|
float.TryParse(paramList[index], out value); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual IEnumerator ProcessTokens(List<TextTagToken> tokens, bool stopAudio, Action onComplete) |
|
|
|
protected virtual IEnumerator ProcessTokens(List<TextTagToken> tokens, bool stopAudio, System.Action onComplete) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Reset control members |
|
|
|
// Reset control members |
|
|
|
boldActive = false; |
|
|
|
boldActive = false; |
|
|
|
italicActive = false; |
|
|
|
italicActive = false; |
|
|
|
colorActive = false; |
|
|
|
colorActive = false; |
|
|
|
sizeActive = false; |
|
|
|
sizeActive = false; |
|
|
|
|
|
|
|
WordTokensFound = tokens.Count(x => x.type == TokenType.Words); |
|
|
|
|
|
|
|
WordTokensProcessed = 0; |
|
|
|
colorText = ""; |
|
|
|
colorText = ""; |
|
|
|
sizeValue = 16f; |
|
|
|
sizeValue = 16f; |
|
|
|
currentPunctuationPause = punctuationPause; |
|
|
|
currentPunctuationPause = punctuationPause; |
|
|
@ -282,6 +310,7 @@ namespace Fungus |
|
|
|
{ |
|
|
|
{ |
|
|
|
case TokenType.Words: |
|
|
|
case TokenType.Words: |
|
|
|
yield return StartCoroutine(DoWords(token.paramList, previousTokenType)); |
|
|
|
yield return StartCoroutine(DoWords(token.paramList, previousTokenType)); |
|
|
|
|
|
|
|
WordTokensProcessed++; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case TokenType.BoldStart: |
|
|
|
case TokenType.BoldStart: |
|
|
@ -636,7 +665,7 @@ namespace Fungus |
|
|
|
// Look ahead to find next whitespace or end of string |
|
|
|
// Look ahead to find next whitespace or end of string |
|
|
|
for (int j = i; j < inputString.Length + 1; ++j) |
|
|
|
for (int j = i; j < inputString.Length + 1; ++j) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (j == inputString.Length || Char.IsWhiteSpace(inputString[j])) |
|
|
|
if (j == inputString.Length || char.IsWhiteSpace(inputString[j])) |
|
|
|
{ |
|
|
|
{ |
|
|
|
leftString.Length = j; |
|
|
|
leftString.Length = j; |
|
|
|
rightString.Remove(0, j); |
|
|
|
rightString.Remove(0, j); |
|
|
@ -694,7 +723,7 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float duration = 1f; |
|
|
|
float duration = 1f; |
|
|
|
if (!Single.TryParse(param, out duration)) |
|
|
|
if (!float.TryParse(param, out duration)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
duration = 1f; |
|
|
|
duration = 1f; |
|
|
|
} |
|
|
|
} |
|
|
@ -847,6 +876,15 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void NotifyAllWordsWritten() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < writerListeners.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var writerListener = writerListeners[i]; |
|
|
|
|
|
|
|
writerListener.OnAllWordsWritten(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void NotifyEnd(bool stopAudio) |
|
|
|
protected virtual void NotifyEnd(bool stopAudio) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriterSignals.DoWriterState(this, WriterState.End); |
|
|
|
WriterSignals.DoWriterState(this, WriterState.End); |
|
|
@ -907,7 +945,7 @@ namespace Fungus |
|
|
|
/// <param name="waitForVO">Wait for the Voice over to complete before proceeding</param> |
|
|
|
/// <param name="waitForVO">Wait for the Voice over to complete before proceeding</param> |
|
|
|
/// <param name="audioClip">Audio clip to play when text starts writing.</param> |
|
|
|
/// <param name="audioClip">Audio clip to play when text starts writing.</param> |
|
|
|
/// <param name="onComplete">Callback to call when writing is finished.</param> |
|
|
|
/// <param name="onComplete">Callback to call when writing is finished.</param> |
|
|
|
public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, Action onComplete) |
|
|
|
public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, System.Action onComplete) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (clear) |
|
|
|
if (clear) |
|
|
|
{ |
|
|
|
{ |
|
|
|