예제 #1
0
        protected internal override void Draw(int X, int Y)
        {
            base.Draw(X, Y);
            int num1  = X + 2;
            int num2  = this.m_Height - 2;
            int count = Engine.m_Journal.Count;
            int num3  = (int)this.m_Scroller.GetValue();

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

            for (int index = num3; index >= 0 && index < count; --index)
            {
                JournalEntry journalEntry = (JournalEntry)Engine.m_Journal[index];
                Texture      t;
                if (journalEntry.Width != this.m_CropWidth)
                {
                    string String = Engine.WrapText(journalEntry.Text, this.m_CropWidth, (IFont)uniFont);
                    t = uniFont.GetString(String, journalEntry.Hue);
                    journalEntry.Width = this.m_CropWidth;
                    journalEntry.Image = t;
                }
                else
                {
                    t = journalEntry.Image;
                }
                if (t != null && !t.IsEmpty())
                {
                    int num4 = num2 - t.Height;
                    if (num4 < 3)
                    {
                        t.DrawClipped(num1, Y + num4, Clipper.TemporaryInstance(X, Y + 1, this.Width, this.Height));
                        break;
                    }
                    GJournal.m_vCache.Draw(t, num1, Y + num4);
                    num2 = num4 - 4;
                }
            }
        }
예제 #2
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 gserverBackground = new GServerBackground(this, x, y, width, height, 3004, true);
                    GHtmlLabel        ghtmlLabel        = new GHtmlLabel(text, uniFont, color, gserverBackground.OffsetX - 2, gserverBackground.OffsetY - 1, gserverBackground.UseWidth);
                    ghtmlLabel.Scissor(0, 0, ghtmlLabel.Width, gserverBackground.UseHeight);
                    gserverBackground.Children.Add((Gump)ghtmlLabel);
                    this.Pages(thisPage).Add((Gump)gserverBackground);
                }
                else
                {
                    GHtmlLabel ghtmlLabel = new GHtmlLabel(text, uniFont, color, x - 2, y - 1, width);
                    ghtmlLabel.Scissor(0, 0, ghtmlLabel.Width, height);
                    this.Pages(thisPage).Add((Gump)ghtmlLabel);
                }
            }
            else
            {
                width -= 15;
                GHtmlLabel ghtmlLabel;
                int        num;
                if (hasBack)
                {
                    GServerBackground gserverBackground = new GServerBackground(this, x, y, width, height, 3004, true);
                    ghtmlLabel = new GHtmlLabel(text, uniFont, color, gserverBackground.OffsetX - 2, gserverBackground.OffsetY - 1, gserverBackground.UseWidth);
                    ghtmlLabel.Scissor(0, 0, ghtmlLabel.Width, num = gserverBackground.UseHeight);
                    gserverBackground.Children.Add((Gump)ghtmlLabel);
                    this.Pages(thisPage).Add((Gump)gserverBackground);
                }
                else
                {
                    ghtmlLabel = new GHtmlLabel(text, uniFont, color, x - 2, y - 1, width);
                    ghtmlLabel.Scissor(0, 0, ghtmlLabel.Width, num = height);
                    this.Pages(thisPage).Add((Gump)ghtmlLabel);
                }
                if (height >= 27 && ghtmlLabel.Height > num)
                {
                    this.Pages(thisPage).Add((Gump) new GImage(257, x + width, y));
                    this.Pages(thisPage).Add((Gump) new GImage((int)byte.MaxValue, x + width, y + height - 32));
                    int y1 = y + 30;
                    while (y1 + 32 < y + height)
                    {
                        this.Pages(thisPage).Add((Gump) new GImage(256, x + width, y1));
                        y1 += 30;
                    }
                    GVSlider gvSlider = new GVSlider(254, x + width + 1, y + 1 + 12, 13, height - 2 - 24, 0.0, 0.0, (double)(ghtmlLabel.Height - num), 1.0);
                    gvSlider.SetTag("yBase", (object)ghtmlLabel.Y);
                    gvSlider.SetTag("toScroll", (object)ghtmlLabel);
                    gvSlider.SetTag("viewHeight", (object)num);
                    gvSlider.OnValueChange = new OnValueChange(this.OnScroll);
                    this.Pages(thisPage).Add((Gump)gvSlider);
                    this.Pages(thisPage).Add((Gump) new GHotspot(x + width, y, 15, height, (Gump)gvSlider));
                }
                else
                {
                    this.Pages(thisPage).Add((Gump) new GImage(257, x + width, y));
                    this.Pages(thisPage).Add((Gump) new GImage((int)byte.MaxValue, x + width, y + height - 32));
                    int y1 = y + 30;
                    while (y1 + 32 < y + height)
                    {
                        this.Pages(thisPage).Add((Gump) new GImage(256, x + width, y1));
                        y1 += 30;
                    }
                    this.Pages(thisPage).Add((Gump) new GImage(254, Hues.Grayscale, x + width + 1, y + 1));
                }
            }
        }
예제 #3
0
        public void Update(string text, UnicodeFont initialFont, int initialColor)
        {
            int      width1    = this.m_Width;
            Stack    stack1    = new Stack();
            FontInfo fontInfo1 = new FontInfo(initialFont, initialColor);
            int      num1      = 0;
            int      num2      = 0;
            Stack    stack2    = new Stack();
            Stack    stack3    = new Stack();

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

            for (int index1 = 0; index1 < elements.Length; ++index1)
            {
                HtmlElement   htmlElement   = elements[index1];
                FontInfo      fontInfo2     = stack1.Count > 0 ? (FontInfo)stack1.Peek() : fontInfo1;
                HtmlAlignment htmlAlignment = stack2.Count > 0 ? (HtmlAlignment)stack2.Peek() : HtmlAlignment.Normal;
                string        url           = stack3.Count > 0 ? (string)stack3.Peek() : (string)null;
                switch (htmlElement.Type)
                {
                case ElementType.Text:
                    string text1 = htmlElement.Name;
                    bool   flag  = false;
                    while (text1.Length > 0)
                    {
                        int num5 = num3;
                        switch (htmlAlignment & (HtmlAlignment)255)
                        {
                        case HtmlAlignment.Center:
                            int stringWidth1 = fontInfo2.Font.GetStringWidth(text1);
                            if (stringWidth1 > width1)
                            {
                                string[] strArray = Engine.WrapText(text1, width1, (IFont)fontInfo2.Font).Split('\n');
                                stringWidth1 = fontInfo2.Font.GetStringWidth(strArray[0]);
                            }
                            num5 = (width1 - (stringWidth1 - 1) + 1) / 2;
                            break;

                        case HtmlAlignment.Left:
                            num5 = (int)htmlAlignment >> 8;
                            break;

                        case HtmlAlignment.Right:
                            int stringWidth2 = fontInfo2.Font.GetStringWidth(text1);
                            if (stringWidth2 > width1)
                            {
                                string[] strArray = Engine.WrapText(text1, width1, (IFont)fontInfo2.Font).Split('\n');
                                stringWidth2 = fontInfo2.Font.GetStringWidth(strArray[0]);
                            }
                            num5 = ((int)htmlAlignment >> 8) - stringWidth2;
                            break;
                        }
                        string[] strArray1 = text1.Split(' ');
                        int      width2    = width1 - num5;
                        if (!flag && fontInfo2.Font.GetStringWidth(strArray1[0]) > width2)
                        {
                            flag  = true;
                            num3  = 0;
                            num4 += 18;
                        }
                        else
                        {
                            flag = false;
                            string[] strArray2 = Engine.WrapText(text1, width2, (IFont)fontInfo2.Font).Split('\n');
                            string   str       = strArray2[0];
                            if (strArray2.Length > 1)
                            {
                                str = str.TrimEnd();
                            }
                            GLabel glabel = url == null ? new GLabel(str, (IFont)fontInfo2.Font, fontInfo2.Hue, num5, num4) : (GLabel) new GHyperLink(url, str, (IFont)fontInfo2.Font, num5, num4);
                            if (url == null)
                            {
                                glabel.Underline = num1 > 0;
                            }
                            this.m_Children.Add((Gump)glabel);
                            if (strArray2.Length > 1)
                            {
                                text1 = text1.Remove(0, strArray2[0].Length);
                                num3  = 0;
                                num4 += 18;
                            }
                            else
                            {
                                num3 = glabel.X + glabel.Width - 1;
                                break;
                            }
                        }
                    }
                    break;

                case ElementType.Start:
                    switch (htmlElement.Name.ToLower())
                    {
                    case "br":
                        num3  = 0;
                        num4 += 18;
                        continue;

                    case "u":
                        ++num1;
                        continue;

                    case "i":
                        ++num2;
                        continue;

                    case "a":
                        string attribute1 = htmlElement.GetAttribute("href");
                        if (attribute1 != null && !attribute1.StartsWith("?"))
                        {
                            stack3.Push((object)attribute1);
                            continue;
                        }
                        continue;

                    case "basefont":
                        string attribute2 = htmlElement.GetAttribute("color");
                        if (attribute2 != null)
                        {
                            int color = 0;
                            if (attribute2.StartsWith("#"))
                            {
                                color = Convert.ToInt32(attribute2.Substring(1), 16);
                            }
                            else
                            {
                                for (int index2 = 0; index2 < GHtmlLabel.m_ColorTable.GetLength(0); ++index2)
                                {
                                    if (attribute2.ToLower() == (string)GHtmlLabel.m_ColorTable[index2, 0])
                                    {
                                        color = (int)GHtmlLabel.m_ColorTable[index2, 1];
                                        break;
                                    }
                                }
                            }
                            stack1.Push((object)new FontInfo(fontInfo2.Font, color));
                            continue;
                        }
                        continue;

                    case "center":
                        stack2.Push((object)HtmlAlignment.Center);
                        continue;

                    case "div":
                        string attribute3 = htmlElement.GetAttribute("align");
                        if (attribute3 == null)
                        {
                            string attribute4 = htmlElement.GetAttribute("alignleft");
                            if (attribute4 != null)
                            {
                                try
                                {
                                    int num5 = int.Parse(attribute4);
                                    stack2.Push((object)(HtmlAlignment)(2 | num5 << 8));
                                }
                                catch
                                {
                                }
                            }
                            string attribute5 = htmlElement.GetAttribute("alignright");
                            if (attribute5 != null)
                            {
                                try
                                {
                                    int num5 = int.Parse(attribute5);
                                    stack2.Push((object)(HtmlAlignment)(3 | num5 << 8));
                                    continue;
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            switch (attribute3.ToLower())
                            {
                            case "center":
                                stack2.Push((object)HtmlAlignment.Center);
                                continue;

                            case "right":
                                stack2.Push((object)(HtmlAlignment)(3 | width1 << 8));
                                continue;

                            case "left":
                                stack2.Push((object)HtmlAlignment.Left);
                                continue;

                            default:
                                continue;
                            }
                        }

                    default:
                        continue;
                    }

                case ElementType.End:
                    switch (htmlElement.Name.ToLower())
                    {
                    case "u":
                        --num1;
                        if (num1 < 0)
                        {
                            num1 = 0;
                            continue;
                        }
                        continue;

                    case "i":
                        --num2;
                        if (num2 < 0)
                        {
                            num2 = 0;
                            continue;
                        }
                        continue;

                    case "a":
                        if (stack3.Count > 0)
                        {
                            stack3.Pop();
                            continue;
                        }
                        continue;

                    case "basefont":
                        if (stack1.Count > 0)
                        {
                            stack1.Pop();
                            continue;
                        }
                        continue;

                    case "div":
                    case "center":
                        if (stack2.Count > 0)
                        {
                            stack2.Pop();
                            continue;
                        }
                        continue;

                    default:
                        continue;
                    }
                }
            }
            this.m_Height = num4 + 18;
        }
예제 #4
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);
 }
예제 #5
0
 public UnicodeFontFactory(UnicodeFont font, int flags)
 {
     this.m_Font  = font;
     this.m_Flags = flags;
 }