desktop-maesty/steve
5 years ago
16 changed files with 27052 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: f23bed438013a47438010dafdc996ae4 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 66eda60c3533ab546af7641d0d3c8c48 |
||||||
|
folderAsset: yes |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,69 @@ |
|||||||
|
using NUnit.Framework; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
public class FungusConversationParseTests |
||||||
|
{ |
||||||
|
private const string SimpleConv = |
||||||
|
@"john bored left: Oh, so that's how you use the Conversation command.
|
||||||
|
sherlock eyeroll right nowait: Yes, well done John. {w=1.5} |
||||||
|
You catch on quickly don't you? |
||||||
|
sherlock >>>: |
||||||
|
hide john ""offscreen left"": I sure do. |
||||||
|
|
||||||
|
-- This is a comment, it doesn't appear in the conversation |
||||||
|
";
|
||||||
|
private static readonly List<Fungus.ConversationManager.RawConversationItem> SimpleConvRes = new List<Fungus.ConversationManager.RawConversationItem>() |
||||||
|
{ |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "john", "bored", "left" }, text = "Oh, so that's how you use the Conversation command."}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "sherlock", "eyeroll", "right", "nowait" }, text = "Yes, well done John. {w=1.5}"}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ }, text = "You catch on quickly don't you?"}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "sherlock", ">>>" }, text = ""}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "hide", "john", "offscreen left" }, text = "I sure do."}, |
||||||
|
}; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FungusConversationPreParseSimple() |
||||||
|
{ |
||||||
|
var res = Fungus.ConversationManager.PreParse(SimpleConv); |
||||||
|
ValueCompareRawConversationItemLists(res, SimpleConvRes); |
||||||
|
} |
||||||
|
|
||||||
|
private void ValueCompareRawConversationItemLists(List<Fungus.ConversationManager.RawConversationItem> lhs, List<Fungus.ConversationManager.RawConversationItem> rhs) |
||||||
|
{ |
||||||
|
Assert.AreEqual(lhs.Count, rhs.Count, "Different number of results found."); |
||||||
|
|
||||||
|
for (int i = 0; i < lhs.Count; i++) |
||||||
|
{ |
||||||
|
Assert.AreEqual(lhs[i].text, rhs[i].text, "RawConItem " + i.ToString() + " has different text body."); |
||||||
|
Assert.AreEqual(lhs[i].sayParams.Length, rhs[i].sayParams.Length, "RawConItem " + i.ToString() + " have differing say param counts"); |
||||||
|
for (int j = 0; j < lhs[i].sayParams.Length; j++) |
||||||
|
{ |
||||||
|
Assert.AreEqual(lhs[i].sayParams[j], rhs[i].sayParams[j], "RawConItem " + i.ToString() + " param: " + j.ToString() + " content"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private const string MultiColonConv = |
||||||
|
@"sherlock left: Outragous!
|
||||||
|
john bashful: This is an overreaction Sherlock. |
||||||
|
sherlock: Colon to direct attention to a list. Colon to emphasize connecton between independent phrases. |
||||||
|
: To Buy: Eggs, Milk, Flour. |
||||||
|
sherlock irate right: In this world, there are only two tragedies: one is not getting what one wants, and the other is getting it. |
||||||
|
john smug:Love is blind: sometimes it keeps us from seeing the truth.";
|
||||||
|
private static readonly List<Fungus.ConversationManager.RawConversationItem> MultiColonConvRes = new List<Fungus.ConversationManager.RawConversationItem>() |
||||||
|
{ |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "sherlock", "left" }, text = "Outragous!"}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "john", "bashful" }, text = "This is an overreaction Sherlock."}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "sherlock" }, text = "Colon to direct attention to a list. Colon to emphasize connecton between independent phrases."}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ }, text = "To Buy: Eggs, Milk, Flour."}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "sherlock", "irate", "right" }, text = "In this world, there are only two tragedies: one is not getting what one wants, and the other is getting it."}, |
||||||
|
new Fungus.ConversationManager.RawConversationItem(){ sayParams = new string[]{ "john", "smug" }, text = "Love is blind: sometimes it keeps us from seeing the truth."}, |
||||||
|
}; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FungusConversationPreParseMultiColon() |
||||||
|
{ |
||||||
|
var res = Fungus.ConversationManager.PreParse(MultiColonConv); |
||||||
|
ValueCompareRawConversationItemLists(res, MultiColonConvRes); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 12c18ec6bfbb6af4d935d98619790eb7 |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,89 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using UnityEditor; |
||||||
|
using UnityEngine.TestTools; |
||||||
|
using NUnit.Framework; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
public class FungusPrioritySignalsTest { |
||||||
|
|
||||||
|
private int changeCallCount, startCallCount, endCallCount; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void CountsAndSignals() |
||||||
|
{ |
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityStart += FungusPrioritySignals_OnFungusPriorityStart; |
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityEnd += FungusPrioritySignals_OnFungusPriorityEnd; |
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityChange += FungusPrioritySignals_OnFungusPriorityChange; |
||||||
|
|
||||||
|
Assert.Zero(Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.DoIncreasePriorityDepth(); |
||||||
|
//one start, one change, no end, 1 depth |
||||||
|
Assert.AreEqual(0, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(1, changeCallCount); |
||||||
|
Assert.AreEqual(1, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.DoIncreasePriorityDepth(); |
||||||
|
//one start, 2 change, no end, 2 depth |
||||||
|
Assert.AreEqual(0, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(2, changeCallCount); |
||||||
|
Assert.AreEqual(2, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.DoIncreasePriorityDepth(); |
||||||
|
//one start, 3 change, no end, 3 depth |
||||||
|
Assert.AreEqual(0, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(3, changeCallCount); |
||||||
|
Assert.AreEqual(3, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.DoDecreasePriorityDepth(); |
||||||
|
//one start, 4 change, no end, 2 depth |
||||||
|
Assert.AreEqual(0, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(4, changeCallCount); |
||||||
|
Assert.AreEqual(2, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.DoDecreasePriorityDepth(); |
||||||
|
Fungus.FungusPrioritySignals.DoDecreasePriorityDepth(); |
||||||
|
//one start, 6 change, 1 end, 0 depth |
||||||
|
Assert.AreEqual(1, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(6, changeCallCount); |
||||||
|
Assert.AreEqual(0, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
|
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityStart -= FungusPrioritySignals_OnFungusPriorityStart; |
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityEnd -= FungusPrioritySignals_OnFungusPriorityEnd; |
||||||
|
Fungus.FungusPrioritySignals.OnFungusPriorityChange -= FungusPrioritySignals_OnFungusPriorityChange; |
||||||
|
|
||||||
|
//unsubbed so all the same |
||||||
|
Fungus.FungusPrioritySignals.DoIncreasePriorityDepth(); |
||||||
|
Fungus.FungusPrioritySignals.DoDecreasePriorityDepth(); |
||||||
|
//one start, 6 change, 1 end, 0 depth |
||||||
|
Assert.AreEqual(1, endCallCount); |
||||||
|
Assert.AreEqual(1, startCallCount); |
||||||
|
Assert.AreEqual(6, changeCallCount); |
||||||
|
Assert.AreEqual(0, Fungus.FungusPrioritySignals.CurrentPriorityDepth); |
||||||
|
} |
||||||
|
|
||||||
|
private void FungusPrioritySignals_OnFungusPriorityChange(int previousActiveDepth, int newActiveDepth) |
||||||
|
{ |
||||||
|
changeCallCount++; |
||||||
|
} |
||||||
|
|
||||||
|
private void FungusPrioritySignals_OnFungusPriorityEnd() |
||||||
|
{ |
||||||
|
endCallCount++; |
||||||
|
} |
||||||
|
|
||||||
|
private void FungusPrioritySignals_OnFungusPriorityStart() |
||||||
|
{ |
||||||
|
startCallCount++; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 4b20617e7666fda46bd85a41ce882f9d |
||||||
|
timeCreated: 1523182238 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,114 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using UnityEngine.TestTools; |
||||||
|
using NUnit.Framework; |
||||||
|
using System.Collections; |
||||||
|
|
||||||
|
public class FungusTextVariationSelectionTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void SimpleSequenceSelection() |
||||||
|
{ |
||||||
|
Fungus.TextVariationHandler.ClearHistory(); |
||||||
|
|
||||||
|
string startingText = @"This is test [a|b|c]"; |
||||||
|
string startingTextA = @"This is test a"; |
||||||
|
string startingTextB = @"This is test b"; |
||||||
|
string startingTextC = @"This is test c"; |
||||||
|
|
||||||
|
string res = string.Empty; |
||||||
|
|
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextA); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextB); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextC); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextC); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SimpleCycleSelection() |
||||||
|
{ |
||||||
|
Fungus.TextVariationHandler.ClearHistory(); |
||||||
|
|
||||||
|
string startingText = @"This is test [&a|b|c]"; |
||||||
|
string startingTextA = @"This is test a"; |
||||||
|
string startingTextB = @"This is test b"; |
||||||
|
string startingTextC = @"This is test c"; |
||||||
|
|
||||||
|
string res = string.Empty; |
||||||
|
|
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextA); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextB); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextC); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextA); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextB); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextC); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SimpleOnceSelection() |
||||||
|
{ |
||||||
|
Fungus.TextVariationHandler.ClearHistory(); |
||||||
|
|
||||||
|
string startingText = @"This is test [!a|b|c]"; |
||||||
|
string startingTextA = @"This is test a"; |
||||||
|
string startingTextB = @"This is test b"; |
||||||
|
string startingTextC = @"This is test c"; |
||||||
|
string startingTextD = @"This is test "; |
||||||
|
|
||||||
|
string res = string.Empty; |
||||||
|
|
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextA); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextB); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextC); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextD); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextD); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NestedSelection() |
||||||
|
{ |
||||||
|
Fungus.TextVariationHandler.ClearHistory(); |
||||||
|
|
||||||
|
string startingText = @"This is test [a||sub [~a|b]|[!b|[~c|d]]]"; |
||||||
|
string startingTextA = @"This is test a"; |
||||||
|
string startingTextBlank = @"This is test "; |
||||||
|
string startingTextSubA = @"This is test sub a"; |
||||||
|
string startingTextSubB = @"This is test sub b"; |
||||||
|
string startingTextB = @"This is test b"; |
||||||
|
string startingTextC = @"This is test c"; |
||||||
|
string startingTextD = @"This is test d"; |
||||||
|
|
||||||
|
string res = string.Empty; |
||||||
|
|
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextA); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextBlank); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
if(res != startingTextSubA && res != startingTextSubB) |
||||||
|
{ |
||||||
|
Assert.Fail(); |
||||||
|
} |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
Assert.AreEqual(res, startingTextB); |
||||||
|
res = Fungus.TextVariationHandler.SelectVariations(startingText); |
||||||
|
if (res != startingTextC && res != startingTextD) |
||||||
|
{ |
||||||
|
Assert.Fail(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 8769bf7410785704f95413bb0865079c |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,73 @@ |
|||||||
|
using System.Collections.Generic; |
||||||
|
using UnityEditor; |
||||||
|
using UnityEngine; |
||||||
|
|
||||||
|
namespace Fungus.EditorUtils |
||||||
|
{ |
||||||
|
#if UNITY_2019_2_OR_NEWER |
||||||
|
|
||||||
|
public static class GenerateEverythingMenuItem |
||||||
|
{ |
||||||
|
[MenuItem("Tools/Fungus/Utilities/Generate Everything Flowchart")] |
||||||
|
public static void GenerateEverythingFlowchart() |
||||||
|
{ |
||||||
|
var newGO = new GameObject("Flowchart w/ EVERYTHING"); |
||||||
|
var flow = newGO.AddComponent<Flowchart>(); |
||||||
|
|
||||||
|
var blockPos = Vector2.zero; |
||||||
|
var blockPosStep = new Vector2(0, 60); |
||||||
|
|
||||||
|
//adding a block for all event handlers |
||||||
|
foreach (var eventHandlerType in TypeCache.GetTypesWithAttribute<EventHandlerInfoAttribute>()) |
||||||
|
{ |
||||||
|
var block = flow.CreateBlock(blockPos); |
||||||
|
blockPos += blockPosStep; |
||||||
|
|
||||||
|
block.BlockName = eventHandlerType.Name; |
||||||
|
|
||||||
|
EventHandler newHandler = newGO.AddComponent(eventHandlerType) as EventHandler; |
||||||
|
newHandler.ParentBlock = block; |
||||||
|
block._EventHandler = newHandler; |
||||||
|
} |
||||||
|
|
||||||
|
//reset head |
||||||
|
blockPos = new Vector2(200, 0); |
||||||
|
|
||||||
|
//adding a block for each category, fill it with its commands |
||||||
|
var blockComCats = new Dictionary<string, Block>(); |
||||||
|
foreach (var commandType in TypeCache.GetTypesWithAttribute<CommandInfoAttribute>()) |
||||||
|
{ |
||||||
|
var commandTypeAttr = commandType.GetCustomAttributes(typeof(CommandInfoAttribute), false)[0] as CommandInfoAttribute; |
||||||
|
|
||||||
|
blockComCats.TryGetValue(commandTypeAttr.Category, out Block targetBlock); |
||||||
|
if (targetBlock == null) |
||||||
|
{ |
||||||
|
targetBlock = flow.CreateBlock(blockPos); |
||||||
|
blockPos += blockPosStep; |
||||||
|
|
||||||
|
targetBlock.BlockName = commandTypeAttr.Category; |
||||||
|
blockComCats[commandTypeAttr.Category] = targetBlock; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
var newCommand = newGO.AddComponent(commandType) as Command; |
||||||
|
newCommand.ParentBlock = targetBlock; |
||||||
|
newCommand.ItemId = flow.NextItemId(); |
||||||
|
|
||||||
|
// Let command know it has just been added to the block |
||||||
|
newCommand.OnCommandAdded(targetBlock); |
||||||
|
targetBlock.CommandList.Add(newCommand); |
||||||
|
} |
||||||
|
|
||||||
|
//add all variable types |
||||||
|
foreach (var varType in TypeCache.GetTypesWithAttribute<VariableInfoAttribute>()) |
||||||
|
{ |
||||||
|
Variable newVariable = newGO.AddComponent(varType) as Variable; |
||||||
|
newVariable.Key = flow.GetUniqueVariableKey(""); |
||||||
|
flow.Variables.Add(newVariable); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endif |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: a4db92e2e83406a4ca5ee454733c6f8a |
||||||
|
MonoImporter: |
||||||
|
externalObjects: {} |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,220 @@ |
|||||||
|
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
||||||
|
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
||||||
|
|
||||||
|
using System.Collections.Generic; |
||||||
|
using Fungus; |
||||||
|
|
||||||
|
#if UNITY_5_3_OR_NEWER |
||||||
|
|
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
[TestFixture] |
||||||
|
public class TextTagParserTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void TextTagParser_Parser() |
||||||
|
{ |
||||||
|
// Parse an example string, generate correct sequence of tags |
||||||
|
List<TextTagToken> tokens = TextTagParser.Tokenize("Words " + |
||||||
|
"{b}bold test{/b}" + |
||||||
|
"{i}italic test{/i}" + |
||||||
|
"{color=red}color test{/color}" + |
||||||
|
"{size=30}size test{/size}" + |
||||||
|
"{w}{w=0.5}" + |
||||||
|
"{wi}{wc}" + |
||||||
|
"{wp}{wp=0.5}{/wp}" + |
||||||
|
"{c}" + |
||||||
|
"{s}{s=60}{/s}" + |
||||||
|
"{x}{m=Message}" + |
||||||
|
"{vpunch=0.5}" + |
||||||
|
"{hpunch=0.5}" + |
||||||
|
"{punch=0.5}" + |
||||||
|
"{flash=0.5}" + |
||||||
|
"{audio=Sound}" + |
||||||
|
"{audioloop=Sound}" + |
||||||
|
"{audiopause=Sound}" + |
||||||
|
"{audiostop=Sound}"); |
||||||
|
|
||||||
|
int i = 0; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Words "); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.BoldStart); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "bold test"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.BoldEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.ItalicStart); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "italic test"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.ItalicEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.ColorStart); |
||||||
|
Assert.That(tokens[i].paramList[0] == "red"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "color test"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.ColorEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.SizeStart); |
||||||
|
Assert.That(tokens[i].paramList[0] == "30"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "size test"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.SizeEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Wait); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Wait); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.WaitForInputNoClear); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.WaitForInputAndClear); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.WaitOnPunctuationStart); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.WaitOnPunctuationStart); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.WaitOnPunctuationEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Clear); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.SpeedStart); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.SpeedStart); |
||||||
|
Assert.That(tokens[i].paramList[0] == "60"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.SpeedEnd); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Exit); |
||||||
|
Assert.That(tokens[i].paramList.Count == 0); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Message); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Message"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.VerticalPunch); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.HorizontalPunch); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Punch); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Flash); |
||||||
|
Assert.That(tokens[i].paramList[0] == "0.5"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Audio); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Sound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.AudioLoop); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Sound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.AudioPause); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Sound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.AudioStop); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Sound"); |
||||||
|
|
||||||
|
Assert.That(tokens.Count == 34); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void TextTagParser_AudioWaitBug() |
||||||
|
{ |
||||||
|
// Parse an example string, generate correct sequence of tags |
||||||
|
List<TextTagToken> tokens = TextTagParser.Tokenize("Play sound{audio=BeepSound}{w=1} Play loop{audioloop=BeepSound}{w=3} Stop{audiostop=BeepSound}"); |
||||||
|
|
||||||
|
int i = 0; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == "Play sound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Audio); |
||||||
|
Assert.That(tokens[i].paramList[0] == "BeepSound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Wait); |
||||||
|
Assert.That(tokens[i].paramList[0] == "1"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == " Play loop"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.AudioLoop); |
||||||
|
Assert.That(tokens[i].paramList[0] == "BeepSound"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Wait); |
||||||
|
Assert.That(tokens[i].paramList[0] == "3"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.Words); |
||||||
|
Assert.That(tokens[i].paramList[0] == " Stop"); |
||||||
|
|
||||||
|
i++; |
||||||
|
Assert.That(tokens[i].type == TokenType.AudioStop); |
||||||
|
Assert.That(tokens[i].paramList[0] == "BeepSound"); |
||||||
|
|
||||||
|
Assert.That(tokens.Count == 8); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: a9cea7ad00f8a4d8aa33b09722792171 |
||||||
|
timeCreated: 1436968375 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,7 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: fa2c348035b31d84eb5cf8a0cca9d4d2 |
||||||
|
DefaultImporter: |
||||||
|
externalObjects: {} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue