Exemplo n.º 1
0
        public void RemoveCustomTags_OnlyCustomRichTextTags_ReturnsEmpty( )
        {
            var textToType    = "<delay=5></delay><anim=3></anim><animation=sine></animation>";
            var generatedText = TextTagParser.RemoveCustomTags(textToType);

            var expectedText = string.Empty;

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 2
0
        public void RemoveCustomTags_EmptyString_ReturnsEmpty( )
        {
            var textToType    = string.Empty;
            var generatedText = TextTagParser.RemoveCustomTags(textToType);

            var expectedText = textToType;

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 3
0
        public void RemoveCustomTags_OnlyUnityRichTextTags_ReturnsUnityTags( )
        {
            var textToType    = "<b><i></i></b>";
            var generatedText = TextTagParser.RemoveCustomTags(textToType);

            var expectedText = textToType;

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 4
0
        public static void DrawTagHelpLabel()
        {
            string tagsText = TextTagParser.GetTagHelp();

            if (CustomTag.activeCustomTags.Count > 0)
            {
                tagsText += "\n\n\t-------- CUSTOM TAGS --------";
                List <Transform> activeCustomTagGroup = new List <Transform>();
                foreach (CustomTag ct in CustomTag.activeCustomTags)
                {
                    if (ct.transform.parent != null)
                    {
                        if (!activeCustomTagGroup.Contains(ct.transform.parent.transform))
                        {
                            activeCustomTagGroup.Add(ct.transform.parent.transform);
                        }
                    }
                    else
                    {
                        activeCustomTagGroup.Add(ct.transform);
                    }
                }
                foreach (Transform parent in activeCustomTagGroup)
                {
                    string    tagName        = parent.name;
                    string    tagStartSymbol = "";
                    string    tagEndSymbol   = "";
                    CustomTag parentTag      = parent.GetComponent <CustomTag>();
                    if (parentTag != null)
                    {
                        tagName        = parentTag.name;
                        tagStartSymbol = parentTag.TagStartSymbol;
                        tagEndSymbol   = parentTag.TagEndSymbol;
                    }
                    tagsText += "\n\n\t" + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
                    foreach (Transform child in parent)
                    {
                        tagName        = child.name;
                        tagStartSymbol = "";
                        tagEndSymbol   = "";
                        CustomTag childTag = child.GetComponent <CustomTag>();
                        if (childTag != null)
                        {
                            tagName        = childTag.name;
                            tagStartSymbol = childTag.TagStartSymbol;
                            tagEndSymbol   = childTag.TagEndSymbol;
                        }
                        tagsText += "\n\t      " + tagStartSymbol + " " + tagName + " " + tagEndSymbol;
                    }
                }
            }
            tagsText += "\n";
            float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth);

            EditorGUILayout.SelectableLabel(tagsText, GUI.skin.GetStyle("HelpBox"), GUILayout.MinHeight(pixelHeight));
        }
Exemplo n.º 5
0
        public void RemoveUnityTags_AllUnityTags_ReturnsNoTags( )
        {
            //"b", "i", "size", "color", "style" };
            var textToType    = "<b>a</b><i>b</i><size=40>c</size><color=red>d</color><style=C1>e</style>";
            var generatedText = TextTagParser.RemoveUnityTags(textToType);

            var expectedText = "abcde";

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 6
0
        public void RemoveUnityTags_SpriteTagWithValue_ReturnsTaglessText()
        {
            var builder       = new System.Text.StringBuilder();
            var textToType    = "This string has a <sprite index=0> sprite.";
            var generatedText = TextTagParser.RemoveUnityTags(textToType);

            var expectedText = "This string has a  sprite.";

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 7
0
        public static void DrawTagHelpLabel()
        {
            string tagsText = "";

            tagsText += "\n";
            tagsText += TextTagParser.GetTagHelp();

            float pixelHeight = EditorStyles.miniLabel.CalcHeight(new GUIContent(tagsText), EditorGUIUtility.currentViewWidth);

            EditorGUILayout.SelectableLabel(tagsText, GUI.skin.GetStyle("HelpBox"), GUILayout.MinHeight(pixelHeight));
        }
Exemplo n.º 8
0
        public void RemoveUnityTags_AllUnityTags_ReturnsNoTags()
        {
            var builder             = new System.Text.StringBuilder();
            var expectedTextBuilder = new System.Text.StringBuilder();

            for (int i = 0; i < UnityTags.Length; ++i)
            {
                var tag = UnityTags[i];
                builder.Append($"<{tag}>{i}</{tag}>");
                expectedTextBuilder.Append($"{i}");
            }

            var textToType    = builder.ToString();
            var generatedText = TextTagParser.RemoveUnityTags(textToType);

            var expectedText = expectedTextBuilder.ToString();

            Assert.AreEqual(expectedText, generatedText);
        }
Exemplo n.º 9
0
    public void TextTagParser_AudioWaitBug()
    {
        var textTagParser = new TextTagParser();

        // Parse an example string, generate correct sequence of tags
        List <TextTagParser.Token> 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 == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == "Play sound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Audio);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList[0] == "1");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == " Play loop");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioLoop);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Wait);
        Assert.That(tokens[i].paramList[0] == "3");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.Words);
        Assert.That(tokens[i].paramList[0] == " Stop");

        i++;
        Assert.That(tokens[i].type == TextTagParser.TokenType.AudioStop);
        Assert.That(tokens[i].paramList[0] == "BeepSound");

        Assert.That(tokens.Count == 8);
    }
Exemplo n.º 10
0
    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);
    }