Exemple #1
0
 public void AddTextMessage(string Name, string Message, IFont Font, IHue Hue, bool unremovable)
 {
     if (!this.m_Ignored && (!Message.StartsWith("[Party]->[") || (Message.IndexOf("KUOC_") < 0)))
     {
         if ((Font is Font) && Message.StartsWith("(Guard, "))
         {
             this.m_IsFactionGuard = true;
         }
         string text = null;
         if (Name.Length > 0)
         {
             text = Name + ": " + Message;
         }
         else
         {
             text = Message;
         }
         if (Message.Length > 0)
         {
             Engine.AddToJournal(new JournalEntry(text, Hue, this.m_Serial));
             Message = Engine.WrapText(Message, 200, Font).TrimEnd(new char[0]);
             if (Message.Length > 0)
             {
                 MessageManager.AddMessage(new GDynamicMessage(unremovable, this, Message, Font, Hue));
             }
         }
     }
 }
Exemple #2
0
 public override void Refresh()
 {
     if (base.m_Invalidated)
     {
         base.m_Image = base.m_Font.GetString(Engine.WrapText(base.m_Text, this.m_WrapWidth, base.m_Font), base.m_Hue);
         if (base.m_Draw = (base.m_Image != null) && !base.m_Image.IsEmpty())
         {
             base.m_Width  = base.m_Image.Width;
             base.m_Height = base.m_Image.Height;
         }
         base.m_Invalidated = false;
         if (base.m_vCache != null)
         {
             base.m_vCache.Invalidate();
         }
     }
 }
Exemple #3
0
        protected internal override void Draw(int X, int Y)
        {
            base.Draw(X, Y);
            int x     = X + 2;
            int num2  = base.m_Height - 2;
            int count = Engine.m_Journal.Count;
            int num4  = (int)this.m_Scroller.GetValue();

            if (num4 >= count)
            {
                num4 = count - 1;
            }
            UnicodeFont uniFont = Engine.GetUniFont(3);

            for (int i = num4; (i >= 0) && (i < count); i--)
            {
                Texture      image;
                JournalEntry entry = (JournalEntry)Engine.m_Journal[i];
                if (entry.Width != this.m_CropWidth)
                {
                    string str = Engine.WrapText(entry.Text, this.m_CropWidth, uniFont);
                    image       = uniFont.GetString(str, entry.Hue);
                    entry.Width = this.m_CropWidth;
                    entry.Image = image;
                }
                else
                {
                    image = entry.Image;
                }
                if ((image != null) && !image.IsEmpty())
                {
                    num2 -= image.Height;
                    if (num2 < 3)
                    {
                        image.DrawClipped(x, Y + num2, Clipper.TemporaryInstance(X, Y + 1, this.Width, this.Height));
                        break;
                    }
                    m_vCache.Draw(image, x, Y + num2);
                    num2 -= 4;
                }
            }
        }
Exemple #4
0
        public void AddTextMessage(string Name, string Message, IFont Font, IHue Hue, bool unremovable)
        {
            this.m_LastTextHue = Hue;
            this.m_LastText    = Message;
            string text = null;

            if (Name.Length > 0)
            {
                text = Name + ": " + Message;
            }
            else
            {
                text = Message;
            }
            if (Message.Length > 0)
            {
                Engine.AddToJournal(new JournalEntry(text, Hue, this.m_Serial));
                Message = Engine.WrapText(Message, 200, Font).TrimEnd(new char[0]);
                if (Message.Length > 0)
                {
                    MessageManager.AddMessage(new GDynamicMessage(unremovable, this, Message, Font, Hue));
                }
            }
        }
Exemple #5
0
        public void Update(string text, UnicodeFont initialFont, int initialColor)
        {
            int      width  = this.m_Width;
            Stack    stack  = new Stack();
            FontInfo info   = new FontInfo(initialFont, initialColor);
            int      num2   = 0;
            int      num3   = 0;
            Stack    stack2 = new Stack();
            Stack    stack3 = new Stack();

            text = text.Replace("\r", "");
            text = text.Replace("\n", "<br>");
            HtmlElement[] elements = HtmlElement.GetElements(text);
            int           num4     = 0;
            int           y        = 0;

            for (int i = 0; i < elements.Length; i++)
            {
                string        name;
                bool          flag;
                int           stringWidth;
                string        str7;
                string        str8;
                string        attribute;
                string        str10;
                HtmlElement   element   = elements[i];
                FontInfo      info2     = (stack.Count > 0) ? ((FontInfo)stack.Peek()) : info;
                HtmlAlignment alignment = (stack2.Count > 0) ? ((HtmlAlignment)stack2.Peek()) : HtmlAlignment.Normal;
                string        url       = (stack3.Count > 0) ? ((string)stack3.Peek()) : null;
                switch (element.Type)
                {
                case ElementType.Text:
                    name = element.Name;
                    flag = false;
                    goto Label_02F6;

                case ElementType.Start:
                {
                    str10 = element.Name.ToLower();
                    if (str10 != null)
                    {
                        str10 = string.IsInterned(str10);
                        if (str10 == "br")
                        {
                            num4 = 0;
                            y   += 0x12;
                        }
                        else
                        {
                            if (str10 == "u")
                            {
                                goto Label_03A3;
                            }
                            if (str10 == "i")
                            {
                                goto Label_03AC;
                            }
                            if (str10 == "a")
                            {
                                goto Label_03B7;
                            }
                            if (str10 == "basefont")
                            {
                                goto Label_03E5;
                            }
                            if (str10 == "center")
                            {
                                goto Label_048A;
                            }
                            if (str10 == "div")
                            {
                                goto Label_049C;
                            }
                        }
                    }
                    continue;
                }

                case ElementType.End:
                {
                    str10 = element.Name.ToLower();
                    if (str10 != null)
                    {
                        str10 = string.IsInterned(str10);
                        if (str10 == "u")
                        {
                            num2--;
                            if (num2 < 0)
                            {
                                num2 = 0;
                            }
                        }
                        else
                        {
                            if (str10 == "i")
                            {
                                goto Label_0610;
                            }
                            if (str10 == "a")
                            {
                                goto Label_0620;
                            }
                            if (str10 == "basefont")
                            {
                                goto Label_0634;
                            }
                            if ((str10 == "div") || (str10 == "center"))
                            {
                                goto Label_0646;
                            }
                        }
                    }
                    continue;
                }

                default:
                {
                    continue;
                }
                }
Label_00EB:
                stringWidth = num4;
                switch ((alignment & ((HtmlAlignment)0xff)))
                {
                case HtmlAlignment.Center:
                    stringWidth = info2.Font.GetStringWidth(name);
                    if (stringWidth > width)
                    {
                        string[] strArray = Engine.WrapText(name, width, info2.Font).Split(new char[] { '\n' });
                        stringWidth = info2.Font.GetStringWidth(strArray[0]);
                    }
                    stringWidth = ((width - (stringWidth - 1)) + 1) / 2;
                    break;

                case HtmlAlignment.Left:
                    stringWidth = ((int)alignment) >> 8;
                    break;

                case HtmlAlignment.Right:
                    stringWidth = info2.Font.GetStringWidth(name);
                    if (stringWidth > width)
                    {
                        string[] strArray2 = Engine.WrapText(name, width, info2.Font).Split(new char[] { '\n' });
                        stringWidth = info2.Font.GetStringWidth(strArray2[0]);
                    }
                    stringWidth = (((int)alignment) >> 8) - stringWidth;
                    break;
                }
                string[] strArray3 = name.Split(new char[] { ' ' });
                int      num8      = width - stringWidth;
                if (!flag && (info2.Font.GetStringWidth(strArray3[0]) > num8))
                {
                    flag = true;
                    num4 = 0;
                    y   += 0x12;
                }
                else
                {
                    flag      = false;
                    strArray3 = Engine.WrapText(name, num8, info2.Font).Split(new char[] { '\n' });
                    string str6 = strArray3[0];
                    if (strArray3.Length > 1)
                    {
                        str6 = str6.TrimEnd(new char[0]);
                    }
                    GLabel toAdd = (url == null) ? new GLabel(str6, info2.Font, info2.Hue, stringWidth, y) : new GHyperLink(url, str6, info2.Font, stringWidth, y);
                    if (url == null)
                    {
                        toAdd.Underline = num2 > 0;
                    }
                    base.m_Children.Add(toAdd);
                    if (strArray3.Length > 1)
                    {
                        name = name.Remove(0, strArray3[0].Length);
                        num4 = 0;
                        y   += 0x12;
                    }
                    else
                    {
                        num4 = (toAdd.X + toAdd.Width) - 1;
                        continue;
                    }
                }
Label_02F6:
                if (name.Length > 0)
                {
                    goto Label_00EB;
                }
                continue;
Label_03A3:
                num2++;
                continue;
Label_03AC:
                num3++;
                continue;
Label_03B7:
                str7 = element.GetAttribute("href");
                if ((str7 != null) && !str7.StartsWith("?"))
                {
                    stack3.Push(str7);
                }
                continue;
Label_03E5:
                str8 = element.GetAttribute("color");
                if (str8 == null)
                {
                    continue;
                }
                int color = 0;
                if (str8.StartsWith("#"))
                {
                    color = Convert.ToInt32(str8.Substring(1), 0x10);
                }
                else
                {
                    for (int j = 0; j < m_ColorTable.GetLength(0); j++)
                    {
                        if (str8.ToLower() == ((string)m_ColorTable[j, 0]))
                        {
                            color = (int)m_ColorTable[j, 1];
                            break;
                        }
                    }
                }
                stack.Push(new FontInfo(info2.Font, color));
                continue;
Label_048A:
                stack2.Push(HtmlAlignment.Center);
                continue;
Label_049C:
                attribute = element.GetAttribute("align");
                if (attribute == null)
                {
                    attribute = element.GetAttribute("alignleft");
                    if (attribute != null)
                    {
                        try
                        {
                            int num11 = int.Parse(attribute);
                            stack2.Push(HtmlAlignment.Left | ((HtmlAlignment)(num11 << 8)));
                        }
                        catch
                        {
                        }
                    }
                    attribute = element.GetAttribute("alignright");
                    if (attribute != null)
                    {
                        try
                        {
                            int num12 = int.Parse(attribute);
                            stack2.Push(HtmlAlignment.Right | ((HtmlAlignment)(num12 << 8)));
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    switch (attribute.ToLower())
                    {
                    case "center":
                        stack2.Push(HtmlAlignment.Center);
                        break;

                    case "right":
                        stack2.Push(HtmlAlignment.Right | ((HtmlAlignment)(width << 8)));
                        break;

                    case "left":
                        stack2.Push(HtmlAlignment.Left);
                        break;
                    }
                }
                continue;
Label_0610:
                num3--;
                if (num3 < 0)
                {
                    num3 = 0;
                }
                continue;
Label_0620:
                if (stack3.Count > 0)
                {
                    stack3.Pop();
                }
                continue;
Label_0634:
                if (stack.Count > 0)
                {
                    stack.Pop();
                }
                continue;
Label_0646:
                if (stack2.Count > 0)
                {
                    stack2.Pop();
                }
            }
            this.m_Height = y + 0x12;
        }