Esempio n. 1
0
        public void AddTemplateButton(int x, int y, int w, Template t, string name, string text, TimerStateCallback callback, object arg, bool over)
        {
            int id = UniqueButton();

            ButtonPlus button = new ButtonPlus(x, y, 0x0, 0x0, id, name, callback, arg);

            button.Template = t;
            Add(button);
            c_Buttons[id] = button;

            HtmlPlus html = new HtmlPlus(x, y, w, 21, text, false, false, over);

            html.Template = t;
            Add(html);

            ButtonTemplate.ApplyTemplate(button, html, t);
        }
Esempio n. 2
0
        private void ModifyGump()
        {
            try{
                AddPage(0);

                int            maxWidth  = 0;
                int            maxHeight = 0;
                GumpBackground bg;

                foreach (GumpEntry entry in Entries)
                {
                    if (entry is GumpBackground)
                    {
                        bg = (GumpBackground)entry;

                        if (bg.X + bg.Width > maxWidth)
                        {
                            maxWidth = bg.X + bg.Width;
                        }
                        if (bg.Y + bg.Height > maxHeight)
                        {
                            maxHeight = bg.Y + bg.Height;
                        }
                    }
                }

                AddImage(maxWidth, maxHeight, 0x28DC, 0x387);
                AddItem(maxWidth, maxHeight, 0xFC1);
                AddButton(maxWidth + 2, maxHeight + 16, 0x93A, 0x93A, "Gump Art", new TimerCallback(GumpArt));

                if (!GumpInfo.HasMods(c_Owner, GetType()))
                {
                    return;
                }

                GumpInfo  info  = GumpInfo.GetInfo(c_Owner, GetType());
                ArrayList backs = new ArrayList();

                foreach (GumpEntry entry in new ArrayList(Entries))
                {
                    if (entry is GumpBackground)
                    {
                        if (info.Background != -1)
                        {
                            ((GumpBackground)entry).GumpID = info.Background;
                        }

                        backs.Add(entry);
                    }
                    else if (entry is GumpAlphaRegion && !info.DefaultTrans && !info.Transparent)
                    {
                        ((GumpAlphaRegion)entry).Width  = 0;
                        ((GumpAlphaRegion)entry).Height = 0;
                    }
                    else if (entry is HtmlPlus)
                    {
                        if ((int)((HtmlPlus)entry).Template != -1)
                        {
                            ButtonTemplate.RemoveTemplate((HtmlPlus)entry, ((HtmlPlus)entry).Template);
                            ButtonTemplate.ApplyTemplate((HtmlPlus)entry, info.Template);
                        }

                        if (!((HtmlPlus)entry).Override || info.TextColorRGB == "")
                        {
                            continue;
                        }

                        string text   = ((HtmlPlus)entry).Text;
                        int    num    = 0;
                        int    length = 0;
                        char[] chars;

                        if (text == null)
                        {
                            continue;
                        }

                        while ((num = text.ToLower().IndexOf("<basefont")) != -1 || (num = text.ToLower().IndexOf("</font")) != -1)
                        {
                            length = 0;
                            chars  = text.ToCharArray();

                            for (int i = num; i < chars.Length; ++i)
                            {
                                if (chars[i] == '>')
                                {
                                    length = i - num + 1;
                                    break;
                                }
                            }

                            if (length == 0)
                            {
                                break;
                            }

                            text = text.Substring(0, num) + text.Substring(num + length, text.Length - num - length);
                        }

                        ((HtmlPlus)entry).Text = info.TextColor + text;
                    }
                    else if (entry is ButtonPlus && (int)((ButtonPlus)entry).Template != -1)
                    {
                        ButtonTemplate.RemoveTemplate((ButtonPlus)entry, ((ButtonPlus)entry).Template);
                        ButtonTemplate.ApplyTemplate((ButtonPlus)entry, info.Template);
                    }
                }

                if (!info.DefaultTrans && info.Transparent)
                {
                    foreach (GumpBackground back in backs)
                    {
                        AddAlphaRegion(back.X, back.Y, back.Width, back.Height);
                    }
                }

                SortEntries();
            }catch { Errors.Report("GumpPlus-> ModifyGump-> " + GetType()); }
        }