Пример #1
0
        public static List <TextSnippet> ParseMessage(string text, Color baseColor)
        {
            MatchCollection    matchCollection = ChatManager.Regexes.Format.Matches(text);
            List <TextSnippet> textSnippetList = new List <TextSnippet>();
            int startIndex = 0;

            foreach (Match match in matchCollection)
            {
                if (match.Index > startIndex)
                {
                    textSnippetList.Add(new TextSnippet(text.Substring(startIndex, match.Index - startIndex), baseColor, 1f));
                }
                startIndex = match.Index + match.Length;
                string      tagName = match.Groups["tag"].Value;
                string      text1   = match.Groups["text"].Value;
                string      options = match.Groups["options"].Value;
                ITagHandler handler = ChatManager.GetHandler(tagName);
                if (handler != null)
                {
                    textSnippetList.Add(handler.Parse(text1, baseColor, options));
                    textSnippetList[textSnippetList.Count - 1].TextOriginal = match.ToString();
                }
                else
                {
                    textSnippetList.Add(new TextSnippet(text1, baseColor, 1f));
                }
            }
            if (text.Length > startIndex)
            {
                textSnippetList.Add(new TextSnippet(text.Substring(startIndex, text.Length - startIndex), baseColor, 1f));
            }
            return(textSnippetList);
        }
Пример #2
0
        // Token: 0x06000C56 RID: 3158 RVA: 0x003D8758 File Offset: 0x003D6958
        public static List <TextSnippet> ParseMessage(string text, Color baseColor)
        {
            MatchCollection    arg_13_0 = ChatManager.Regexes.Format.Matches(text);
            List <TextSnippet> list     = new List <TextSnippet>();
            int num = 0;

            foreach (Match match in arg_13_0)
            {
                if (match.Index > num)
                {
                    list.Add(new TextSnippet(text.Substring(num, match.Index - num), baseColor, 1f));
                }
                num = match.Index + match.Length;
                string      arg_A4_0 = match.Groups["tag"].Value;
                string      value    = match.Groups["text"].Value;
                string      value2   = match.Groups["options"].Value;
                ITagHandler handler  = ChatManager.GetHandler(arg_A4_0);
                if (handler != null)
                {
                    list.Add(handler.Parse(value, baseColor, value2));
                    list[list.Count - 1].TextOriginal = match.ToString();
                }
                else
                {
                    list.Add(new TextSnippet(value, baseColor, 1f));
                }
            }
            if (text.Length > num)
            {
                list.Add(new TextSnippet(text.Substring(num, text.Length - num), baseColor, 1f));
            }
            return(list);
        }