Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
 public virtual void Refresh()
 {
     if (this.m_Invalidated)
     {
         UnicodeFont font = this.m_Font as UnicodeFont;
         bool        flag = (font != null) && font.Underline;
         int         num  = (font == null) ? 0 : font.SpaceWidth;
         if (font != null)
         {
             font.Underline = this.m_Underline;
         }
         if ((font != null) && (this.m_SpaceWidth > 0))
         {
             font.SpaceWidth = this.m_SpaceWidth;
         }
         this.m_Image = this.m_Font.GetString(this.m_Text, this.m_Hue);
         if ((this.m_Image != null) && !this.m_Image.IsEmpty())
         {
             this.m_Width  = this.m_Image.Width;
             this.m_Height = this.m_Image.Height;
             this.m_Draw   = true;
         }
         else
         {
             this.m_Draw = false;
         }
         this.m_Invalidated = false;
         if (this.m_vCache != null)
         {
             this.m_vCache.Invalidate();
         }
         if (font != null)
         {
             font.Underline = flag;
         }
         if (font != null)
         {
             font.SpaceWidth = num;
         }
     }
 }
Ejemplo n.º 3
0
        public GBuyGump(int serial, BuyInfo[] info) : base(0x870, 15, 15)
        {
            base.m_GUID   = string.Format("GBuyGump-{0}", serial);
            this.m_Serial = serial;
            this.m_Info   = info;
            UnicodeFont uniFont = Engine.GetUniFont(3);
            IHue        hue     = Hues.Load(0x288);

            Array.Sort(info);
            int y = 0x42;

            for (int i = 0; i < info.Length; i++)
            {
                bool    seperate             = i != (info.Length - 1);
                BuyInfo si                   = info[i];
                GBuyGump_InventoryItem toAdd = new GBuyGump_InventoryItem(this, si, y, seperate);
                base.m_Children.Add(toAdd);
                si.InventoryGump = toAdd;
                y += toAdd.Height;
                if (seperate)
                {
                    y += 0x10;
                }
            }
            if (y > 230)
            {
                GVSlider slider = new GVSlider(0x828, 0xed, 0x51, 0x22, 0x5c, 0.0, 0.0, (double)(y - 230), 1.0)
                {
                    OnValueChange = new OnValueChange(this.Slider_OnValueChange)
                };
                base.m_Children.Add(slider);
                base.m_Children.Add(new GHotspot(0xed, 0x42, 0x22, 0x7a, slider));
            }
            base.m_NonRestrictivePicking = true;
            this.m_OfferMenu             = new GBuyGump_OfferMenu(this);
            base.m_Children.Add(this.m_OfferMenu);
            base.m_X = (Engine.ScreenWidth - (this.m_OfferMenu.X + this.m_OfferMenu.Width)) / 2;
            base.m_Y = (Engine.ScreenHeight - (this.m_OfferMenu.Y + this.m_OfferMenu.Height)) / 2;
        }
Ejemplo n.º 4
0
 public FontInfo(UnicodeFont font, int color)
 {
     this.m_Font  = font;
     this.m_Color = color;
     this.m_Hue   = new Hues.HFill(color);
 }
Ejemplo n.º 5
0
        private void ProcessHtmlGump(int thisPage, int x, int y, int width, int height, string text, bool hasBack, bool hasScroll, int color)
        {
            UnicodeFont uniFont = Engine.GetUniFont(1);

            if (!hasScroll)
            {
                if (hasBack)
                {
                    GServerBackground toAdd = new GServerBackground(this, x, y, width, height, 0xbbc, true);
                    GHtmlLabel        label = new GHtmlLabel(text, uniFont, color, toAdd.OffsetX - 2, toAdd.OffsetY - 1, toAdd.UseWidth);
                    label.Scissor(0, 0, label.Width, toAdd.UseHeight);
                    toAdd.Children.Add(label);
                    this.Pages(thisPage).Add(toAdd);
                }
                else
                {
                    GHtmlLabel label2 = new GHtmlLabel(text, uniFont, color, x - 2, y - 1, width);
                    label2.Scissor(0, 0, label2.Width, height);
                    this.Pages(thisPage).Add(label2);
                }
            }
            else
            {
                GHtmlLabel label3;
                int        num;
                width -= 15;
                if (hasBack)
                {
                    GServerBackground background2 = new GServerBackground(this, x, y, width, height, 0xbbc, true);
                    label3 = new GHtmlLabel(text, uniFont, color, background2.OffsetX - 2, background2.OffsetY - 1, background2.UseWidth);
                    label3.Scissor(0, 0, label3.Width, num = background2.UseHeight);
                    background2.Children.Add(label3);
                    this.Pages(thisPage).Add(background2);
                }
                else
                {
                    label3 = new GHtmlLabel(text, uniFont, color, x - 2, y - 1, width);
                    label3.Scissor(0, 0, label3.Width, num = height);
                    this.Pages(thisPage).Add(label3);
                }
                if ((height >= 0x1b) && (label3.Height > num))
                {
                    this.Pages(thisPage).Add(new GImage(0x101, x + width, y));
                    this.Pages(thisPage).Add(new GImage(0xff, x + width, (y + height) - 0x20));
                    for (int i = y + 30; (i + 0x20) < (y + height); i += 30)
                    {
                        this.Pages(thisPage).Add(new GImage(0x100, x + width, i));
                    }
                    GVSlider slider = new GVSlider(0xfe, (x + width) + 1, (y + 1) + 12, 13, (height - 2) - 0x18, 0.0, 0.0, (double)(label3.Height - num), 1.0);
                    slider.SetTag("yBase", label3.Y);
                    slider.SetTag("toScroll", label3);
                    slider.SetTag("viewHeight", num);
                    slider.OnValueChange = new OnValueChange(this.OnScroll);
                    this.Pages(thisPage).Add(slider);
                    this.Pages(thisPage).Add(new GHotspot(x + width, y, 15, height, slider));
                }
                else
                {
                    this.Pages(thisPage).Add(new GImage(0x101, x + width, y));
                    this.Pages(thisPage).Add(new GImage(0xff, x + width, (y + height) - 0x20));
                    for (int j = y + 30; (j + 0x20) < (y + height); j += 30)
                    {
                        this.Pages(thisPage).Add(new GImage(0x100, x + width, j));
                    }
                    this.Pages(thisPage).Add(new GImage(0xfe, Hues.Grayscale, (x + width) + 1, y + 1));
                }
            }
        }
Ejemplo n.º 6
0
 public static UnicodeFont GetUniFont(int id)
 {
     if ((id < 0) || (id >= 3))
     {
         id = 1;
     }
     UnicodeFont font = m_UniFont[id];
     if (font == null)
     {
         font = m_UniFont[id] = new UnicodeFont(id);
     }
     return font;
 }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
            protected override unsafe void CoreProcessImage(int width, int height, int stride, ushort *pLine, ushort *pLineEnd, ushort *pImageEnd, int lineDelta, int lineEndDelta)
            {
                string str        = this.m_String;
                int    num        = 0;
                int    num2       = 1;
                int    spaceWidth = this.m_Font.SpaceWidth;
                bool   flag       = false;
                int    byteCount  = width * height;

                byte[] buffer = m_Buffer;
                if ((buffer == null) || (byteCount > buffer.Length))
                {
                    m_Buffer = buffer = new byte[byteCount];
                }
                bool flag2 = ((this.m_Hue.HueID() & 0x3fff) != 1) && !(this.m_Hue is Hues.HFill);

                fixed(byte *numRef = buffer)
                {
                    UnicodeFont.RtlZeroMemory((void *)numRef, byteCount);
                    for (int i = 0; i < str.Length; i++)
                    {
                        char c = str[i];
                        switch (c)
                        {
                        case '\t':
                        {
                            flag = false;
                            num += 0x18;
                            continue;
                        }

                        case '\n':
                        case '\r':
                        {
                            if (!flag)
                            {
                                num   = 0;
                                num2 += 0x12;
                                flag  = true;
                            }
                            continue;
                        }

                        case ' ':
                        {
                            flag = false;
                            num += spaceWidth;
                            continue;
                        }
                        }
                        flag = false;
                        CharacterBits character = this.GetCharacter(c, true);
                        num += 1 + character.m_xOffset;
                        fixed(byte *numRef2 = character.m_Bits)
                        {
                            byte *numPtr  = numRef2;
                            byte *numPtr2 = (numRef + ((num2 + character.m_yOffset) * width)) + ((num + character.m_xWidth) - 1);
                            int   num6    = 0x20 - character.m_xWidth;
                            int   num7    = (character.m_xWidth + 7) >> 3;
                            int   num10   = 0;

                            while (num10 < character.m_yHeight)
                            {
                                uint num11 = *((uint *)numPtr);
                                num11 = ((uint)((((num11 & 0xff) << 0x18) | ((num11 & 0xff00) << 8)) | ((num11 & 0xff0000) >> 8))) | ((num11 >> 0x18) & 0xff);
                                num11 = num11 >> num6;
                                byte *numPtr3 = numPtr2;
                                if (flag2)
                                {
                                    int  num8  = (num + character.m_xWidth) - 1;
                                    int  num9  = (num2 + character.m_yOffset) + num10;
                                    bool flag3 = num9 <= 0;
                                    bool flag4 = num9 >= (height - 1);
                                    if (!flag3 && !flag4)
                                    {
                                        while (num11 != 0)
                                        {
                                            if ((num11 & 1) != 0)
                                            {
                                                bool flag5 = num8 <= 0;
                                                bool flag6 = num8 >= (width - 1);
                                                if (!flag5)
                                                {
                                                    byte *numPtr1 = numPtr3 - 1;
                                                    numPtr1[0] = (byte)(numPtr1[0] | 0x80);
                                                }
                                                if (!flag6)
                                                {
                                                    byte *numPtr6 = numPtr3 + 1;
                                                    numPtr6[0] = (byte)(numPtr6[0] | 0x80);
                                                }
                                                byte *numPtr7 = numPtr3 - width;
                                                numPtr7[0] = (byte)(numPtr7[0] | 0x80);
                                                numPtr3[0] = (byte)(numPtr3[0] | 2);
                                                byte *numPtr8 = numPtr3 + width;
                                                numPtr8[0] = (byte)(numPtr8[0] | 0x80);
                                            }
                                            numPtr3--;
                                            num8--;
                                            num11 = num11 >> 1;
                                        }
                                    }
                                    else if (flag3 && !flag4)
                                    {
                                        while (num11 != 0)
                                        {
                                            if ((num11 & 1) != 0)
                                            {
                                                bool flag7 = num8 <= 0;
                                                bool flag8 = num8 >= (width - 1);
                                                if (!flag7)
                                                {
                                                    byte *numPtr9 = numPtr3 - 1;
                                                    numPtr9[0] = (byte)(numPtr9[0] | 0x80);
                                                }
                                                if (!flag8)
                                                {
                                                    byte *numPtr10 = numPtr3 + 1;
                                                    numPtr10[0] = (byte)(numPtr10[0] | 0x80);
                                                }
                                                numPtr3[0] = (byte)(numPtr3[0] | 2);
                                                byte *numPtr11 = numPtr3 + width;
                                                numPtr11[0] = (byte)(numPtr11[0] | 0x80);
                                            }
                                            numPtr3--;
                                            num8--;
                                            num11 = num11 >> 1;
                                        }
                                    }
                                    else if (!flag3 && flag4)
                                    {
                                        while (num11 != 0)
                                        {
                                            if ((num11 & 1) != 0)
                                            {
                                                bool flag9  = num8 <= 0;
                                                bool flag10 = num8 >= (width - 1);
                                                if (!flag9)
                                                {
                                                    byte *numPtr12 = numPtr3 - 1;
                                                    numPtr12[0] = (byte)(numPtr12[0] | 0x80);
                                                }
                                                if (!flag10)
                                                {
                                                    byte *numPtr13 = numPtr3 + 1;
                                                    numPtr13[0] = (byte)(numPtr13[0] | 0x80);
                                                }
                                                byte *numPtr14 = numPtr3 - width;
                                                numPtr14[0] = (byte)(numPtr14[0] | 0x80);
                                                numPtr3[0]  = (byte)(numPtr3[0] | 2);
                                            }
                                            numPtr3--;
                                            num8--;
                                            num11 = num11 >> 1;
                                        }
                                    }
                                    else
                                    {
                                        while (num11 != 0)
                                        {
                                            if ((num11 & 1) != 0)
                                            {
                                                bool flag11 = num8 <= 0;
                                                bool flag12 = num8 >= (width - 1);
                                                if (!flag11)
                                                {
                                                    byte *numPtr15 = numPtr3 - 1;
                                                    numPtr15[0] = (byte)(numPtr15[0] | 0x80);
                                                }
                                                if (!flag12)
                                                {
                                                    byte *numPtr16 = numPtr3 + 1;
                                                    numPtr16[0] = (byte)(numPtr16[0] | 0x80);
                                                }
                                                numPtr3[0] = (byte)(numPtr3[0] | 2);
                                            }
                                            numPtr3--;
                                            num8--;
                                            num11 = num11 >> 1;
                                        }
                                    }
                                }
                                else
                                {
                                    while (num11 != 0)
                                    {
                                        if ((num11 & 1) != 0)
                                        {
                                            numPtr3[0] = (byte)(numPtr3[0] | 2);
                                        }
                                        numPtr3--;
                                        num11 = num11 >> 1;
                                    }
                                }
                                num10++;
                                numPtr2 += width;
                                numPtr  += num7;
                            }
                        }

                        num += character.m_xWidth;
                    }
                    int   num12     = width;
                    int   num13     = height;
                    int   num14     = 0;
                    int   num15     = 0;
                    bool  underline = this.m_Font.Underline;
                    byte *numPtr4   = numRef;

                    fixed(short *numRef3 = UnicodeFont.m_Colors)
                    {
                        fixed(short *numRef4 = UnicodeFont.m_HuedColors)
                        {
                            ushort *numPtr5 = (ushort *)numRef4;

                            this.m_Hue.CopyPixels((void *)(numRef3 + 1), (void *)(numPtr5 + 1), 0x20);
                            this.m_Hue.CopyPixels((void *)(numRef3 + 0x81), (void *)(numPtr5 + 0x81), 0x20);
                            for (int j = 0; j < height; j++)
                            {
                                for (int k = 0; k < width; k++)
                                {
                                    if (numPtr4[0] != 0)
                                    {
                                        if (k < num12)
                                        {
                                            num12 = k;
                                        }
                                        if (k > num14)
                                        {
                                            num14 = k;
                                        }
                                        if (j < num13)
                                        {
                                            num13 = j;
                                        }
                                        if (j > num15)
                                        {
                                            num15 = j;
                                        }
                                    }
                                    if (underline && ((j % 0x12) == 15))
                                    {
                                        numPtr4[0] = 0x10;
                                    }
                                    pLine++;
                                    pLine[0] = numPtr5[*(numPtr4++)];
                                }
                                pLine += lineDelta;
                            }
                        }
                    }

                    this.m_xMin = num12;
                    this.m_yMin = num13;
                    this.m_xMax = num14;
                    this.m_yMax = num15;
                }
            }
Ejemplo n.º 9
0
 public GHtmlLabel(string text, UnicodeFont initialFont, int initialColor, int x, int y, int width)
     : base(x, y)
 {
     this.m_Width = width;
     this.Update(text, initialFont, initialColor);
 }
Ejemplo n.º 10
0
 public UnicodeFontFactory(UnicodeFont font)
 {
     this.m_Font = font;
 }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
 public GHtmlLabel(string text, UnicodeFont initialFont, int initialColor, int x, int y, int width) : base(x, y)
 {
     this.m_Width = width;
     this.Update(text, initialFont, initialColor);
 }
Ejemplo n.º 13
0
 public FontInfo(UnicodeFont font, int color)
 {
     this.m_Font = font;
     this.m_Color = color;
     this.m_Hue = new Hues.HFill(color);
 }
Ejemplo n.º 14
0
 public UnicodeFontFactory(UnicodeFont font)
 {
     this.m_Font = font;
 }