Example #1
0
 public static ChatText NewFancyText(string prefix, TextAttribute color, ChatText text)
 {
     return(new ChatText(prefix, color)
     {
         Next = text
     });
 }
Example #2
0
        public void SetNext(ChatText next)
        {
            var t = this;

            while (t.Next != null)
            {
                t = t.Next;
            }
            t.Next = next;
        }
Example #3
0
        public static ChatText ToChatText(string text)
        {
            ChatText chatText = null;
            var      list     = new List <TextAttribute>();
            var      sb       = new StringBuilder();

            for (var i = 0; i < text.Length; i++)
            {
                var c = text[i];
                if (c == ColorChar && i + 1 < text.Length && TextColor.IsColorChar(text[i + 1]))
                {
                    if (sb.Length > 0)
                    {
                        if (chatText == null)
                        {
                            chatText = new ChatText(sb.ToString(), list.ToArray());
                        }
                        else
                        {
                            chatText.SetNext(new ChatText(sb.ToString(), list.ToArray()));
                        }
                        sb.Clear();
                        list.Clear();
                    }
                    list.Add(TextColor.GetFromChar(text[++i]));
                }
                else
                {
                    sb.Append(c);
                }
            }
            if (chatText == null)
            {
                chatText = new ChatText(sb.ToString(), list.ToArray());
            }
            else
            {
                chatText.SetNext(new ChatText(sb.ToString(), list.ToArray()));
            }

            return(chatText);
        }