public static void ApplyTemplate(HtmlPlus html, Template t)
        {
            if ((int)t == -1)
            {
                return;
            }

            ButtonTemplate template = (ButtonTemplate)s_Templates[t];

            html.X = html.X + template.TextXOffset;
            html.Y = html.Y + template.TextYOffset;
        }
        public static void RemoveTemplate(ButtonPlus button, Template t)
        {
            if ((int)t == -1)
            {
                return;
            }

            ButtonTemplate template = (ButtonTemplate)s_Templates[t];

            button.X = button.X - template.BGXOffset;
            button.Y = button.Y - template.BGYOffset;
        }
        public static void ApplyTemplate(ButtonPlus button, Template t)
        {
            if ((int)t == -1)
            {
                return;
            }

            ButtonTemplate template = (ButtonTemplate)s_Templates[t];

            button.NormalID  = template.Background;
            button.PressedID = template.Background;
            button.X         = button.X + template.BGXOffset;
            button.Y         = button.Y + template.BGYOffset;
        }
Beispiel #4
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);
        }
Beispiel #5
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()); }
        }
Beispiel #6
0
        protected override void BuildGump()
        {
            string textcolor = c_Info.TextColor;

            if (c_Info.TextColorRGB == "")
            {
                textcolor = HTML.White;
            }

            AddBackground(0, 0, Width, Height, c_Info.Background == -1 ? 0x13BE : c_Info.Background);
            if (c_Info.Transparent && !c_Info.DefaultTrans)
            {
                AddAlphaRegion(0, 0, Width, Height);
            }

            AddHtml(0, 10, Width, 25, textcolor + "<CENTER>" + c_Info.Type.ToString(), false, false);

            AddButton(0, Height / 2 - 10, 0x15E3, 0x15E7, "Previous Template", new TimerCallback(PreviousTemplate));
            AddButton(Width - 20, Height / 2 - 10, 0x15E1, 0x15E5, "Next Template", new TimerCallback(NextTemplate));

            AddHtml(0, 30, Width / 2, 25, textcolor + "<DIV ALIGN=RIGHT>Background", false, false);
            AddButton(Width / 2 + 10, 30, 0x983, 0x983, "Background Up", new TimerCallback(BackgroundUp));
            AddButton(Width / 2 + 10, 40, 0x985, 0x985, "Background Down", new TimerCallback(BackgroundDown));
            if (c_Info.Background == -1)
            {
                AddHtml(Width / 2 + 30, 30, Width / 2 - 30, 25, textcolor + "(Default)", false, false);
            }

            AddHtml(0, 60, Width / 2, 25, textcolor + "<DIV ALIGN=RIGHT>Text Color (RGB)", false, false);
            AddImageTiled(Width / 2 + 20, 60, 100, 21, 0xBBA);
            AddTextField(Width / 2 + 20, 60, 100, 21, 0x480, 0, c_Info.TextColorRGB);
            AddButton(Width / 2 + 2, 62, 0x93A, 0x93A, "Text Color", new TimerCallback(TextColor));

            AddHtml(0, 90, Width, 25, textcolor + "<CENTER>Transparency", false, false);
            AddHtml(80, 110, 50, 25, textcolor + "On", false, false);
            AddButton(50, 110, !c_Info.DefaultTrans && c_Info.Transparent ? 0xD3 : 0xD2, !c_Info.DefaultTrans && c_Info.Transparent ? 0xD3 : 0xD2, "Transparent On", new TimerCallback(TransparentOn));
            AddHtml(140, 110, 50, 25, textcolor + "Off", false, false);
            AddButton(110, 110, !c_Info.DefaultTrans && !c_Info.Transparent ? 0xD3 : 0xD2, !c_Info.DefaultTrans && !c_Info.Transparent ? 0xD3 : 0xD2, "Transparent Off", new TimerCallback(TransparentOff));
            AddHtml(200, 110, 50, 25, textcolor + "Default", false, false);
            AddButton(170, 110, c_Info.DefaultTrans ? 0xD3 : 0xD2, c_Info.DefaultTrans ? 0xD3 : 0xD2, "Default Trans", new TimerCallback(DefaultTrans));

            AddHtml(0, 140, Width / 2, 25, textcolor + "<DIV ALIGN=RIGHT>Button Template", false, false);
            AddButton(Width / 2 + 10, 140, 0x983, 0x983, "Template Up", new TimerCallback(ButtonUp));
            AddButton(Width / 2 + 10, 150, 0x985, 0x985, "Template Down", new TimerCallback(ButtonDown));
            if ((int)c_Info.Template == -1)
            {
                AddHtml(Width / 2 + 30, 140, Width / 2 + 30, 25, textcolor + "Default", false, false);
            }
            else
            {
                if (ButtonTemplate.Templates[c_Info.Template] == null)
                {
                    return;
                }

                ButtonTemplate temp = (ButtonTemplate)ButtonTemplate.Templates[c_Info.Template];
                AddHtml(Width / 2 + 30 + temp.TextXOffset, 145 + temp.TextYOffset, 70, 25, textcolor + "<CENTER>Button", false, false);
                AddImage(Width / 2 + 30 + temp.BGXOffset, 145 + temp.BGYOffset, temp.Background);
            }

            AddHtml(90, 170, 150, 40, textcolor + "Remove this Template<br>(Use Defaults)", false, false);
            AddButton(60, 180, 0x93A, 0x93A, "Default", new TimerCallback(Default));
        }