Ejemplo n.º 1
0
        protected override void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            base.CompileOptions(toolbar, clicked, loc, opts);

            var user = toolbar.State.User;

            if (!CanEdit && user.AccessLevel < Toolbars.Access)
            {
                return;
            }

            opts.Replace(
                "Set Value",
                new ListGumpEntry(
                    "Set URL",
                    b => new InputDialogGump(user, toolbar)
            {
                Title     = "Set URL",
                Html      = "Set the URL for this Link entry.",
                InputText = Value,
                Callback  = (cb, text) =>
                {
                    Value = text;
                    toolbar.Refresh(true);
                }
            }.Send(),
                    toolbar.HighlightHue));
        }
Ejemplo n.º 2
0
        protected override void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            base.CompileOptions(toolbar, clicked, loc, opts);

            PlayerMobile user = toolbar.User;

            if (!CanEdit && user.AccessLevel < Toolbars.Access)
            {
                return;
            }

            opts.Replace(
                "Set Value",
                new ListGumpEntry(
                    "Set Command",
                    b => SuperGump.Send(
                        new InputDialogGump(user, toolbar)
            {
                Title     = "Set Command",
                Html      = "Set the command for this Command entry.",
                InputText = base.Value,
                Callback  = (cb, text) =>
                {
                    Value = text;
                    toolbar.Refresh(true);
                }
            }),
                    toolbar.HighlightHue));

            opts.AppendEntry(
                new ListGumpEntry(
                    "Set Args",
                    b => SuperGump.Send(
                        new InputDialogGump(user, toolbar)
            {
                Title     = "Set Command Arguments",
                Html      = "Set the Arguments for this Command entry.\nSeparate your entries with a semi-colon- ;",
                InputText = String.Join(";", Args),
                Callback  = (cb, text) =>
                {
                    Args.Clear();
                    Args.AddRange(text.Split(';'));
                    toolbar.Refresh(true);
                }
            }),
                    toolbar.HighlightHue));
        }
Ejemplo n.º 3
0
        protected override void CompileOptions(MenuGumpOptions list)
        {
            list.AppendEntry(new ListGumpEntry("None", b => SetDay(b, ScheduleDays.None)));
            list.AppendEntry(new ListGumpEntry("All", b => SetDay(b, ScheduleDays.All)));
            list.AppendEntry(new ListGumpEntry("Monday", b => SetDay(b, ScheduleDays.Monday)));
            list.AppendEntry(new ListGumpEntry("Tuesday", b => SetDay(b, ScheduleDays.Tuesday)));
            list.AppendEntry(new ListGumpEntry("Wednesday", b => SetDay(b, ScheduleDays.Wednesday)));
            list.AppendEntry(new ListGumpEntry("Thursday", b => SetDay(b, ScheduleDays.Thursday)));
            list.AppendEntry(new ListGumpEntry("Friday", b => SetDay(b, ScheduleDays.Friday)));
            list.AppendEntry(new ListGumpEntry("Saturday", b => SetDay(b, ScheduleDays.Saturday)));
            list.AppendEntry(new ListGumpEntry("Sunday", b => SetDay(b, ScheduleDays.Sunday)));

            base.CompileOptions(list);

            list.Replace("Cancel", new ListGumpEntry("Done", Cancel));
        }
Ejemplo n.º 4
0
		protected override void CompileOptions(MenuGumpOptions list)
		{
			list.AppendEntry(new ListGumpEntry("None", b => SetDay(b, ScheduleDays.None)));
			list.AppendEntry(new ListGumpEntry("All", b => SetDay(b, ScheduleDays.All)));
			list.AppendEntry(new ListGumpEntry("Monday", b => SetDay(b, ScheduleDays.Monday)));
			list.AppendEntry(new ListGumpEntry("Tuesday", b => SetDay(b, ScheduleDays.Tuesday)));
			list.AppendEntry(new ListGumpEntry("Wednesday", b => SetDay(b, ScheduleDays.Wednesday)));
			list.AppendEntry(new ListGumpEntry("Thursday", b => SetDay(b, ScheduleDays.Thursday)));
			list.AppendEntry(new ListGumpEntry("Friday", b => SetDay(b, ScheduleDays.Friday)));
			list.AppendEntry(new ListGumpEntry("Saturday", b => SetDay(b, ScheduleDays.Saturday)));
			list.AppendEntry(new ListGumpEntry("Sunday", b => SetDay(b, ScheduleDays.Sunday)));

			base.CompileOptions(list);

			list.Replace("Cancel", new ListGumpEntry("Done", Cancel));
		}
Ejemplo n.º 5
0
        protected override void CompileOptions(MenuGumpOptions list)
        {
            list.AppendEntry("None", b => SetMonth(b, ScheduleMonths.None));
            list.AppendEntry("All", b => SetMonth(b, ScheduleMonths.All));
            list.AppendEntry("January", b => SetMonth(b, ScheduleMonths.January));
            list.AppendEntry("February", b => SetMonth(b, ScheduleMonths.February));
            list.AppendEntry("March", b => SetMonth(b, ScheduleMonths.March));
            list.AppendEntry("April", b => SetMonth(b, ScheduleMonths.April));
            list.AppendEntry("May", b => SetMonth(b, ScheduleMonths.May));
            list.AppendEntry("June", b => SetMonth(b, ScheduleMonths.June));
            list.AppendEntry("July", b => SetMonth(b, ScheduleMonths.July));
            list.AppendEntry("August", b => SetMonth(b, ScheduleMonths.August));
            list.AppendEntry("September", b => SetMonth(b, ScheduleMonths.September));
            list.AppendEntry("October", b => SetMonth(b, ScheduleMonths.October));
            list.AppendEntry("November", b => SetMonth(b, ScheduleMonths.November));
            list.AppendEntry("December", b => SetMonth(b, ScheduleMonths.December));

            base.CompileOptions(list);

            list.Replace("Cancel", "Done", Cancel);
        }
Ejemplo n.º 6
0
		protected override void CompileOptions(MenuGumpOptions list)
		{
			list.AppendEntry(new ListGumpEntry("None", b => SetMonth(b, ScheduleMonths.None)));
			list.AppendEntry(new ListGumpEntry("All", b => SetMonth(b, ScheduleMonths.All)));
			list.AppendEntry(new ListGumpEntry("January", b => SetMonth(b, ScheduleMonths.January)));
			list.AppendEntry(new ListGumpEntry("February", b => SetMonth(b, ScheduleMonths.February)));
			list.AppendEntry(new ListGumpEntry("March", b => SetMonth(b, ScheduleMonths.March)));
			list.AppendEntry(new ListGumpEntry("April", b => SetMonth(b, ScheduleMonths.April)));
			list.AppendEntry(new ListGumpEntry("May", b => SetMonth(b, ScheduleMonths.May)));
			list.AppendEntry(new ListGumpEntry("June", b => SetMonth(b, ScheduleMonths.June)));
			list.AppendEntry(new ListGumpEntry("July", b => SetMonth(b, ScheduleMonths.July)));
			list.AppendEntry(new ListGumpEntry("August", b => SetMonth(b, ScheduleMonths.August)));
			list.AppendEntry(new ListGumpEntry("September", b => SetMonth(b, ScheduleMonths.September)));
			list.AppendEntry(new ListGumpEntry("October", b => SetMonth(b, ScheduleMonths.October)));
			list.AppendEntry(new ListGumpEntry("November", b => SetMonth(b, ScheduleMonths.November)));
			list.AppendEntry(new ListGumpEntry("December", b => SetMonth(b, ScheduleMonths.December)));

			base.CompileOptions(list);

			list.Replace("Cancel", new ListGumpEntry("Done", Cancel));
		}
Ejemplo n.º 7
0
        protected override void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            base.CompileOptions(toolbar, clicked, loc, opts);

            var user = toolbar.State.User;

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                opts.Replace(
                    "Set Value",
                    new ListGumpEntry(
                        "Set Spell",
                        b =>
                {
                    toolbar.Refresh(true);
                    MenuGump menu1 = null;
                    var menuOpts1  = new MenuGumpOptions();

                    foreach (var kvp1 in SpellUtility.TreeStructure)
                    {
                        var circle = kvp1.Key;
                        var types  = kvp1.Value;

                        menuOpts1.AppendEntry(
                            new ListGumpEntry(
                                circle,
                                b2 =>
                        {
                            var menuOpts2 = new MenuGumpOptions();

                            foreach (var kvp2 in types)
                            {
                                var id   = SpellRegistry.GetRegistryNumber(kvp2.Key);
                                var si   = kvp2.Value;
                                var book = Spellbook.Find(user, id);

                                if (book != null && book.HasSpell(id))
                                {
                                    menuOpts2.AppendEntry(
                                        new ListGumpEntry(
                                            si.Name,
                                            menu2Button =>
                                    {
                                        SpellID = id;
                                        Value   = si.Name;
                                        Label   = String.Empty;
                                        toolbar.Refresh(true);
                                    },
                                            (SpellID == id) ? toolbar.HighlightHue : toolbar.TextHue));
                                }
                            }

                            if (menu1 != null)
                            {
                                SuperGump.Send(new MenuGump(user, clicked.Parent, menuOpts2, clicked));
                            }
                        }));
                    }

                    menu1 = new MenuGump(user, clicked.Parent, menuOpts1, clicked);
                    SuperGump.Send(menu1);
                },
                        toolbar.HighlightHue));
            }
        }
Ejemplo n.º 8
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            if (Selected == null)
            {
                return;
            }

            if (User.AccessLevel >= Voting.Access)
            {
                list.AppendEntry(new ListGumpEntry("Clear History", ClearHistory, HighlightHue));
                list.AppendEntry(new ListGumpEntry("Delete Profile", DeleteProfile, HighlightHue));

                if (TechnicalView)
                {
                    list.Replace(
                        "Technical View",
                        new ListGumpEntry(
                            "Standard View",
                            b =>
                    {
                        TechnicalView = false;
                        Refresh(true);
                    },
                            HighlightHue));
                }
                else
                {
                    list.Replace(
                        "Standard View",
                        new ListGumpEntry(
                            "Technical View",
                            b =>
                    {
                        TechnicalView = true;
                        Refresh(true);
                    },
                            HighlightHue));
                }
            }

            list.AppendEntry(
                new ListGumpEntry(
                    "Show Recent",
                    b =>
            {
                HistoryDate = null;
                Refresh(true);
            }));

            list.AppendEntry(
                new ListGumpEntry(
                    "Show Today",
                    b =>
            {
                HistoryDate = DateTime.UtcNow;
                Refresh(true);
            }));

            list.AppendEntry(
                new ListGumpEntry(
                    "Select Date",
                    b => Send(
                        new InputDateDialogGump(User, Refresh())
            {
                Title        = "Select Date",
                Html         = "Type the date you wish to view history for.",
                InputDate    = HistoryDate,
                MaxDate      = DateTime.UtcNow,
                CallbackDate = (b1, d) =>
                {
                    if (d.HasValue)
                    {
                        HistoryDate = d.Value;
                    }
                    else
                    {
                        User.SendMessage(0x22, "No valid date was given.");
                    }

                    Refresh(true);
                }
            })));

            list.AppendEntry(new ListGumpEntry("Help", ShowHelp));

            base.CompileMenuOptions(list);
        }
        protected override void CompileOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (User.AccessLevel >= AutoPvP.Access)
            {
                if (Restrictions.IsRestricted(Key))
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Set Unrestricted",
                            button =>
                    {
                        Restrictions.SetRestricted(Key, false);
                        Refresh(true);
                    },
                            ErrorHue));
                }
                else
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Set Restricted",
                            button =>
                    {
                        Restrictions.SetRestricted(Key, true);
                        Refresh(true);
                    },
                            HighlightHue));
                }

                if (!Locked && User.AccessLevel >= AutoPvP.Access)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Delete",
                            button =>
                    {
                        if (UseConfirmDialog)
                        {
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    Refresh(),
                                    title: "Delete Entry?",
                                    html:
                                    "All data associated with this entry will be deleted.\nThis action can not be reversed!\nDo you want to continue?",
                                    onAccept: OnConfirmDelete));
                        }
                        else
                        {
                            OnConfirmDelete(button);
                        }
                    }));
                }
            }

            base.CompileOptions(list);

            list.Replace("Cancel", new ListGumpEntry("Done", Cancel));
        }
Ejemplo n.º 10
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (CanGlobalEdit())
            {
                if (GlobalEdit)
                {
                    list.AppendEntry("End Global Edit", b => EndGlobalEdit(), ErrorHue);

                    list.AppendEntry("Edit Defaults", b => User.SendGump(new PropertiesGump(User, Toolbars.CMOptions)), HighlightHue);

                    list.AppendEntry(
                        "Reset Global Entries",
                        b => new ConfirmDialogGump(User, this)
                    {
                        Title = "Reset Global Entries",
                        Html  = "Applying global defaults will copy the global toolbar to all existing toolbars.\n" +
                                "This will overwrite any custom entries that exist.\n\nDo you want to continue?",
                        AcceptHandler = db =>
                        {
                            Toolbars.SetGlobalEntries();
                            Refresh(true);
                        }
                    }.Send(),
                        HighlightHue);

                    list.AppendEntry(
                        "Reset Global Themes",
                        b => new ConfirmDialogGump(User, this)
                    {
                        Title = "Reset Global Themes",
                        Html  = "Applying global theme will reset the theme of all existing toolbars.\n\n" +                                //
                                "Do you want to continue?",
                        AcceptHandler = db =>
                        {
                            Toolbars.SetGlobalTheme();
                            Refresh(true);
                        }
                    }.Send(),
                        HighlightHue);

                    list.AppendEntry(
                        "Reset Global Positions",
                        b => new ConfirmDialogGump(
                            User,
                            this,
                            title: "Reset Global Positions",
                            html: "Applying global position will reset the position of all existing toolbars.\n\n" +                             //
                            "Do you want to continue?",
                            onAccept: db =>
                    {
                        Toolbars.SetGlobalPosition();
                        Refresh(true);
                    }).Send(),
                        HighlightHue);

                    list.AppendEntry(
                        "Reset Global Sizes",
                        b => new ConfirmDialogGump(User, this)
                    {
                        Title = "Reset Global Sizes",
                        Html  = "Applying global size will reset the size of all existing toolbars.\n" +
                                "Any entries located beyond the new size will be lost.\n\n" +                                    //
                                "Do you want to continue?",
                        AcceptHandler = db =>
                        {
                            Toolbars.SetGlobalSize();
                            Refresh(true);
                        }
                    }.Send(),
                        HighlightHue);
                }
                else
                {
                    list.AppendEntry("Begin Global Edit", b => BeginGlobalEdit(), HighlightHue);
                }
            }

            list.AppendEntry(
                "Load Defaults",
                b => new ConfirmDialogGump(User, this)
            {
                Title = "Load Defaults",
                Html  = "Loadng defaults will overwrite any custom entries that exist in your toolbar.\n\n" +                        //
                        "Do you want to continue?",
                AcceptHandler = db =>
                {
                    State.SetDefaultEntries();
                    Refresh(true);
                }
            }.Send(),
                HighlightHue);

            list.AppendEntry(
                "Set Position",
                b => new OffsetSelectorGump(
                    User,
                    this,
                    new Point(State.X, State.Y),
                    (self, oldValue) =>
            {
                X = State.X = self.Value.X;
                Y = State.Y = self.Value.Y;
                Refresh(true);
            }).Send(),
                HighlightHue);

            list.AppendEntry(
                "Set Size",
                b =>
            {
                var html = String.Format(
                    "Set the size for your toolbar.\nFormat: Width,Height\nWidth Range: {0}\nHeight Range: {1}\n\nIf you shrink the size, any entires located beyond the new size will be lost.",
                    String.Format("{0}-{1}", Toolbars.CMOptions.DefaultWidth, Toolbars.DefaultEntries.Width),
                    String.Format("{0}-{1}", Toolbars.CMOptions.DefaultHeight, Toolbars.DefaultEntries.Height));

                new InputDialogGump(User, this)
                {
                    Title     = "Set Size",
                    Html      = html,
                    InputText = String.Format("{0},{1}", State.Width, State.Height),
                    Callback  = (cb, text) =>
                    {
                        int w = State.Width, h = State.Height;

                        if (text.IndexOf(",", StringComparison.Ordinal) != -1)
                        {
                            var split = text.Split(',');

                            if (split.Length >= 2)
                            {
                                if (Int32.TryParse(split[0], out w))
                                {
                                    if (w < Toolbars.CMOptions.DefaultWidth)
                                    {
                                        w = Toolbars.CMOptions.DefaultWidth;
                                    }
                                    else if (!GlobalEdit && w > Toolbars.DefaultEntries.Width)
                                    {
                                        w = Toolbars.DefaultEntries.Width;
                                    }
                                }
                                else
                                {
                                    w = State.Width;
                                }

                                if (Int32.TryParse(split[1], out h))
                                {
                                    if (h < Toolbars.CMOptions.DefaultHeight)
                                    {
                                        h = Toolbars.CMOptions.DefaultHeight;
                                    }
                                    else if (!GlobalEdit && h > Toolbars.DefaultEntries.Height)
                                    {
                                        h = Toolbars.DefaultEntries.Height;
                                    }
                                }
                                else
                                {
                                    h = State.Height;
                                }
                            }
                        }

                        State.Resize(w, h);
                        Refresh(true);
                    }
                }.Send();
            },
                HighlightHue);

            list.AppendEntry(
                "Set Theme",
                b =>
            {
                var opts = new MenuGumpOptions();

                var themes = default(ToolbarTheme).EnumerateValues <ToolbarTheme>(false);

                foreach (var themeID in themes)
                {
                    if (State.Theme == themeID)
                    {
                        continue;
                    }

                    var id    = themeID;
                    var theme = ToolbarThemes.GetTheme(themeID);

                    opts.AppendEntry(
                        theme.Name,
                        tb =>
                    {
                        State.Theme = id;
                        Refresh(true);
                    },
                        HighlightHue);
                }

                new MenuGump(User, this, opts, b).Send();
            },
                HighlightHue);

            base.CompileMenuOptions(list);

            list.RemoveEntry("New Search");
            list.RemoveEntry("Clear Search");

            list.Replace("Refresh", "Exit", b => Close(b));
        }
Ejemplo n.º 11
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            if (Selected != null)
            {
                if (User.AccessLevel >= MOTD.Access)
                {
                    if (!Selected.Published)
                    {
                        list.Replace(
                            "Unpublish Message",
                            new ListGumpEntry(
                                "Publish Message",
                                subButton =>
                        {
                            if (Selected != null)
                            {
                                Selected.Published = true;
                            }

                            Refresh(true);
                        },
                                HighlightHue));
                    }
                    else
                    {
                        list.Replace(
                            "Publish Message",
                            new ListGumpEntry(
                                "Unpublish Message",
                                subButton =>
                        {
                            if (Selected != null)
                            {
                                Selected.Published = false;
                            }

                            Refresh(true);
                        },
                                ErrorHue));
                    }

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Author",
                            subButton => Send(
                                new InputDialogGump(User, this)
                    {
                        Title    = "Message Author",
                        Html     = "Enter an author name for your message.\n255 characters max.",
                        Limit    = 255,
                        Callback = (subBtn, input) =>
                        {
                            Selected.Author = input;
                            Refresh(true);
                        }
                    }),
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Title",
                            subButton => Send(
                                new InputDialogGump(User, this)
                    {
                        Title    = "Message Title",
                        Html     = "Enter a title for your message.\n255 characters max.",
                        Limit    = 255,
                        Callback = (subBtn, input) =>
                        {
                            Selected.Title = input;
                            Refresh(true);
                        }
                    }),
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Edit Content",
                            subButton =>
                    {
                        if (Selected.Content.Length <= 512)
                        {
                            if (Parent is MOTDMessageContentEditGump)
                            {
                                ((MOTDMessageContentEditGump)Parent).Refresh(true);
                            }
                            else
                            {
                                Send(new MOTDMessageContentEditGump(User, Hide(true), Selected));
                            }
                        }
                        else
                        {
                            Send(
                                new NoticeDialogGump(User, this)
                            {
                                Title = "Can't Continue!",
                                Html  =
                                    "The content for the selected message is too long to be edited in-game!\nYou need to edit MOTD.xml in the MOTD saves directory."
                            });
                        }
                    },
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Delete Message",
                            subButton =>
                    {
                        if (Selected != null)
                        {
                            Selected.Delete();
                        }

                        Close();
                    },
                            ErrorHue));
                }
            }

            base.CompileMenuOptions(list);
        }
Ejemplo n.º 12
0
        protected virtual void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            PlayerMobile user = toolbar.User;

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                if (!toolbar.GlobalEdit)
                {
                    opts.AppendEntry(
                        new ListGumpEntry(
                            "Load Default",
                            b => SuperGump.Send(
                                new ConfirmDialogGump(user, toolbar)
                    {
                        Title         = "Load Default",
                        Html          = "Loading the default entry will overwrite your custom entry.\n\nDo you want to continue?",
                        AcceptHandler = db =>
                        {
                            ToolbarEntry def = Toolbars.DefaultEntries.GetContent(loc.X, loc.Y);

                            toolbar.State.SetContent(loc.X, loc.Y, def != null ? def.Clone() : null);
                            toolbar.Refresh(true);
                        }
                    }),
                            toolbar.HighlightHue));
                }

                opts.AppendEntry(
                    new ListGumpEntry(
                        "Reset",
                        b =>
                {
                    Reset(toolbar);
                    toolbar.Refresh(true);
                },
                        toolbar.HighlightHue));
            }

            if (CanDelete || user.AccessLevel >= Toolbars.Access)
            {
                opts.AppendEntry(
                    new ListGumpEntry(
                        "Delete",
                        b =>
                {
                    toolbar.State.SetContent(loc.X, loc.Y, null);
                    toolbar.Refresh(true);
                },
                        toolbar.HighlightHue));
            }

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                opts.AppendEntry(
                    new ListGumpEntry(
                        "Set Value",
                        b => SuperGump.Send(
                            new InputDialogGump(user, toolbar)
                {
                    Title     = "Set Value",
                    Html      = "Set the value of this entry.",
                    InputText = Value,
                    Callback  = (cb, text) =>
                    {
                        Value = text;
                        toolbar.Refresh(true);
                    }
                }),
                        toolbar.HighlightHue));

                opts.AppendEntry(
                    new ListGumpEntry(
                        "Set Label",
                        b => SuperGump.Send(
                            new InputDialogGump(user, toolbar)
                {
                    Title     = "Set Label",
                    Html      = "Set the label of this entry.",
                    InputText = Label,
                    Callback  = (cb, text) =>
                    {
                        Label = text;
                        toolbar.Refresh(true);
                    }
                }),
                        toolbar.HighlightHue));

                opts.AppendEntry(
                    new ListGumpEntry(
                        "Set Label Color",
                        b =>
                {
                    int rrr = 255, ggg = 255, bbb = 255;

                    if (LabelColor != null)
                    {
                        rrr = LabelColor.Value.R;
                        ggg = LabelColor.Value.G;
                        bbb = LabelColor.Value.B;
                    }

                    SuperGump.Send(
                        new InputDialogGump(user, toolbar)
                    {
                        Title     = "Set Label Color",
                        Html      = "Set the label color for this entry.\nFormat 1: NamedColor (EG; Red)\nFormat 2: RRR,GGG,BBB",
                        InputText = String.Format("{0:D3},{1:D3},{2:D3}", rrr, ggg, bbb),
                        Callback  = (cb, text) =>
                        {
                            if (!String.IsNullOrWhiteSpace(text))
                            {
                                if (text.IndexOf(',') != -1)
                                {
                                    var args = text.Split(',');

                                    if (args.Length >= 3)
                                    {
                                        Int32.TryParse(args[0], out rrr);
                                        Int32.TryParse(args[1], out ggg);
                                        Int32.TryParse(args[2], out bbb);

                                        rrr = Math.Min(255, Math.Max(0, rrr));
                                        ggg = Math.Min(255, Math.Max(0, ggg));
                                        bbb = Math.Min(255, Math.Max(0, bbb));

                                        LabelColor = Color.FromArgb(rrr, ggg, bbb);
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        LabelColor = Color.FromName(text);
                                    }
                                    catch
                                    { }
                                }
                            }

                            toolbar.Refresh(true);
                        }
                    });
                },
                        toolbar.HighlightHue));

                if (Highlight)
                {
                    opts.Replace(
                        "Highlight",
                        new ListGumpEntry(
                            "Unhighlight",
                            b =>
                    {
                        Highlight = false;
                        toolbar.Refresh(true);
                    },
                            toolbar.ErrorHue));
                }
                else
                {
                    opts.Replace(
                        "Unhighlight",
                        new ListGumpEntry(
                            "Highlight",
                            b =>
                    {
                        Highlight = true;
                        toolbar.Refresh(true);
                    },
                            toolbar.HighlightHue));
                }
            }

            if (user.AccessLevel < Toolbars.Access)
            {
                return;
            }

            opts.AppendEntry(
                new ListGumpEntry(
                    "Open Props",
                    b => SuperGump.Send(
                        new NoticeDialogGump(user, toolbar)
            {
                Title = "Props Note",
                Html  =
                    "Editing the properties of an entry this way requires a hard refresh.\nExit and re-open the Toolbar when you make any changes.",
                AcceptHandler = cb =>
                {
                    toolbar.Refresh(true);

                    PropertiesGump pg = new PropertiesGump(user, this)
                    {
                        X = b.X,
                        Y = b.Y
                    };
                    user.SendGump(pg);
                }
            }),
                    toolbar.HighlightHue));

            if (toolbar.GlobalEdit && toolbar.CanGlobalEdit())
            {
                opts.AppendEntry(
                    new ListGumpEntry(
                        "Global Apply",
                        b => SuperGump.Send(
                            new ConfirmDialogGump(user, toolbar)
                {
                    Title = "Global Apply",
                    Html  =
                        "Applying this entry globally will overwrite any custom entries at the entry location on all existing toolbars.\n\nDo you want to continue?",
                    AcceptHandler = db =>
                    {
                        ToolbarEntry def = Toolbars.DefaultEntries.GetContent(loc.X, loc.Y);

                        foreach (ToolbarState tbs in Toolbars.Profiles.Values)
                        {
                            try
                            {
                                tbs.SetContent(loc.X, loc.Y, def != null ? def.Clone() : null);

                                SuperGump tb = tbs.GetToolbarGump();

                                if (tb != null && tb.IsOpen)
                                {
                                    tb.Refresh(true);
                                }
                            }
                            catch
                            { }
                        }
                    }
                }),
                        toolbar.HighlightHue));
            }
        }
Ejemplo n.º 13
0
        protected override void CompileOptions(ToolbarGump toolbar, GumpButton clicked, Point loc, MenuGumpOptions opts)
        {
            if (toolbar == null)
            {
                return;
            }

            base.CompileOptions(toolbar, clicked, loc, opts);

            var user = toolbar.State.User;

            if (!CanEdit && user.AccessLevel < Toolbars.Access)
            {
                return;
            }

            opts.AppendEntry(
                new ListGumpEntry(
                    "Set Type",
                    b =>
            {
                var tOpts = new MenuGumpOptions();

                if (TextType != MessageType.Regular)
                {
                    tOpts.AppendEntry(
                        new ListGumpEntry(
                            "Regular",
                            tb =>
                    {
                        TextType = MessageType.Regular;
                        toolbar.Refresh(true);
                    }));
                }

                if (TextType != MessageType.Whisper)
                {
                    tOpts.AppendEntry(
                        new ListGumpEntry(
                            "Whisper",
                            tb =>
                    {
                        TextType = MessageType.Whisper;
                        toolbar.Refresh(true);
                    }));
                }

                if (TextType != MessageType.Yell)
                {
                    tOpts.AppendEntry(
                        new ListGumpEntry(
                            "Yell",
                            tb =>
                    {
                        TextType = MessageType.Yell;
                        toolbar.Refresh(true);
                    }));
                }

                SuperGump.Send(new MenuGump(user, clicked.Parent, tOpts, clicked));
            },
                    toolbar.HighlightHue));

            opts.Replace(
                "Set Value",
                new ListGumpEntry(
                    "Set Phrase",
                    b =>
                    SuperGump.Send(
                        new InputDialogGump(
                            user,
                            toolbar,
                            title: "Set Phrase",
                            html: "Set the text for this Phrase entry.",
                            input: Value,
                            callback: (cb, text) =>
            {
                Value = text;
                toolbar.Refresh(true);
            })),
                    toolbar.HighlightHue));
        }
Ejemplo n.º 14
0
        protected override void SelectEntry(GumpButton button, CoreModuleInfo entry)
        {
            base.SelectEntry(button, entry);

            if (button == null || entry == null)
            {
                return;
            }

            var list = new MenuGumpOptions();

            list.AppendEntry(
                new ListGumpEntry(
                    "Properties",
                    b =>
            {
                Refresh(true);
                User.SendGump(new PropertiesGump(User, entry));
            },
                    HighlightHue));

            if (entry.Enabled)
            {
                list.Replace(
                    "Enable",
                    new ListGumpEntry(
                        "Disable",
                        b =>
                        Send(
                            new ConfirmDialogGump(
                                User,
                                this,
                                title: "Disable Module?",
                                html: "Disable Module: " + entry.Name + "\nDo you want to continue?",
                                onAccept: a =>
                {
                    entry.Enabled = false;
                    Refresh(true);
                },
                                onCancel: Refresh)),
                        HighlightHue));
            }
            else
            {
                list.Replace(
                    "Disable",
                    new ListGumpEntry(
                        "Enable",
                        b =>
                        Send(
                            new ConfirmDialogGump(
                                User,
                                this,
                                title: "Enable Module?",
                                html: "Enable Module: '" + entry.Name + "'\nDo you want to continue?",
                                onAccept: a =>
                {
                    entry.Enabled = true;
                    Refresh(true);
                },
                                onCancel: Refresh)),
                        HighlightHue));
            }

            if (entry.Enabled)
            {
                if (entry.Debug)
                {
                    list.Replace(
                        "Enable Debug",
                        new ListGumpEntry(
                            "Debug Disable",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Disable Module Debugging?",
                                    html: "Disable Module Debugging: " + entry.Name + "\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        entry.Debug = false;
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }
                else
                {
                    list.Replace(
                        "Disable Debug",
                        new ListGumpEntry(
                            "Enable Debug",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Enable Module Debugging?",
                                    html: "Enable Module Debugging: '" + entry.Name + "'\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        entry.Debug = true;
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }

                if (entry.SaveSupported)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Save",
                            b =>
                    {
                        VitaNexCore.SaveModule(entry);
                        Refresh(true);
                    },
                            HighlightHue));
                }
                else
                {
                    list.RemoveEntry("Save");
                }

                if (entry.LoadSupported)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Load",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Load Module Data?",
                                    html:
                                    "Loading a modules' saved data after it has been started may yield unexpected results.\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        VitaNexCore.LoadModule(entry);
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }
                else
                {
                    list.RemoveEntry("Load");
                }
            }
            else
            {
                list.RemoveEntry("Save");
                list.RemoveEntry("Load");
                list.RemoveEntry("Enable Debug");
                list.RemoveEntry("Disable Debug");
            }

            Send(new MenuGump(User, Refresh(), list, button));
        }
Ejemplo n.º 15
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            list.Clear();

            if (CanGlobalEdit())
            {
                if (GlobalEdit)
                {
                    list.AppendEntry(new ListGumpEntry("End Global Edit", b => EndGlobalEdit(), ErrorHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Set Default Size",
                            b =>
                            Send(
                                new InputDialogGump(
                                    User,
                                    this,
                                    title: "Set Default Size",
                                    html:
                                    "Set the global default size for all toolbars.\nFormat: Width,Height\n\nIf you shrink the size, any entires located beyond the new size will be lost.",
                                    input: String.Format("{0},{1}", Toolbars.CMOptions.DefaultWidth, Toolbars.CMOptions.DefaultHeight),
                                    callback: (cb, text) =>
                    {
                        int w = Toolbars.CMOptions.DefaultWidth, h = Toolbars.CMOptions.DefaultHeight;

                        if (text.IndexOf(",", StringComparison.Ordinal) != -1)
                        {
                            var split = text.Split(',');

                            if (!Int32.TryParse(split[0], out w))
                            {
                                w = Toolbars.CMOptions.DefaultWidth;
                            }

                            if (!Int32.TryParse(split[1], out h))
                            {
                                h = Toolbars.CMOptions.DefaultHeight;
                            }
                        }

                        Toolbars.CMOptions.DefaultWidth  = w;
                        Toolbars.CMOptions.DefaultHeight = h;
                        Refresh(true);
                    })),
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Reset Global Entries",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Reset Global Entries",
                                    html:
                                    "Applying global defaults will copy the global toolbar to all existing toolbars.\nThis will overwrite any custom entries that exist.\n\nDo you want to continue?",
                                    onAccept: db =>
                    {
                        Toolbars.SetGlobalEntries();
                        Refresh(true);
                    })),
                            HighlightHue));

                    list.AppendEntry(
                        new ListGumpEntry(
                            "Reset Global Sizes",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Reset Global Sizes",
                                    html:
                                    "Applying global size will reset the size of all existing toolbars.\nAny entries located beyond the new size will be lost.\n\nDo you want to continue?",
                                    onAccept: db =>
                    {
                        Toolbars.SetGlobalSize();
                        Refresh(true);
                    })),
                            HighlightHue));
                }
                else
                {
                    list.AppendEntry(new ListGumpEntry("Begin Global Edit", b => BeginGlobalEdit(), HighlightHue));
                }
            }

            list.AppendEntry(
                new ListGumpEntry(
                    "Load Defaults",
                    b =>
                    Send(
                        new ConfirmDialogGump(
                            User,
                            this,
                            title: "Load Defaults",
                            html:
                            "Loadng the defaults will overwrite any custom entries that exist in your toolbar.\n\nDo you want to continue?",
                            onAccept: db =>
            {
                State.SetDefaultEntries();
                Refresh(true);
            })),
                    HighlightHue));

            list.AppendEntry(
                new ListGumpEntry(
                    "Set Position",
                    b => Send(
                        new OffsetSelectorGump(
                            User,
                            this,
                            new Point(State.X, State.Y),
                            (self, oldValue) =>
            {
                State.X = self.Value.X;
                State.Y = self.Value.Y;
                X       = State.X;
                Y       = State.Y;
                Refresh(true);
            })),
                    HighlightHue));

            list.AppendEntry(
                new ListGumpEntry(
                    "Set Size",
                    b =>
            {
                string html =
                    String.Format(
                        "Set the size for your toolbar.\nFormat: Width,Height\nWidth Range: {0}\nHeight Range: {1}\n\nIf you shrink the size, any entires located beyond the new size will be lost.",
                        String.Format("{0}-{1}", Toolbars.CMOptions.DefaultWidth, Toolbars.DefaultEntries.Width),
                        String.Format("{0}-{1}", Toolbars.CMOptions.DefaultHeight, Toolbars.DefaultEntries.Height));

                Send(
                    new InputDialogGump(
                        User,
                        this,
                        title: "Set Size",
                        html: html,
                        input: String.Format("{0},{1}", State.Width, State.Height),
                        callback: (cb, text) =>
                {
                    int w = State.Width, h = State.Height;

                    if (text.IndexOf(",", StringComparison.Ordinal) != -1)
                    {
                        var split = text.Split(',');

                        if (split.Length >= 2)
                        {
                            if (Int32.TryParse(split[0], out w))
                            {
                                if (w < Toolbars.CMOptions.DefaultWidth)
                                {
                                    w = Toolbars.CMOptions.DefaultWidth;
                                }
                                else if (!GlobalEdit && w > Toolbars.DefaultEntries.Width)
                                {
                                    w = Toolbars.DefaultEntries.Width;
                                }
                            }
                            else
                            {
                                w = State.Width;
                            }

                            if (Int32.TryParse(split[1], out h))
                            {
                                if (h < Toolbars.CMOptions.DefaultHeight)
                                {
                                    h = Toolbars.CMOptions.DefaultHeight;
                                }
                                else if (!GlobalEdit && h > Toolbars.DefaultEntries.Height)
                                {
                                    h = Toolbars.DefaultEntries.Height;
                                }
                            }
                            else
                            {
                                h = State.Height;
                            }
                        }
                    }

                    State.Resize(w, h);
                    Refresh(true);
                }));
            },
                    HighlightHue));

            list.AppendEntry(
                new ListGumpEntry(
                    "Set Theme",
                    b =>
            {
                MenuGumpOptions opts = new MenuGumpOptions();
                var themes           = Enum.GetValues(typeof(ToolbarTheme)).Cast <ToolbarTheme>();

                foreach (var themeID in themes)
                {
                    if (State.Theme == themeID)
                    {
                        continue;
                    }

                    ToolbarTheme id        = themeID;
                    ToolbarThemeBase theme = ToolbarThemes.GetTheme(themeID);
                    opts.AppendEntry(
                        new ListGumpEntry(
                            theme.Name,
                            tb =>
                    {
                        State.Theme = id;
                        Refresh(true);
                    },
                            HighlightHue));
                }

                Send(new MenuGump(User, this, opts, b));
            },
                    HighlightHue));

            base.CompileMenuOptions(list);

            list.RemoveEntry("New Search");
            list.RemoveEntry("Clear Search");

            list.Replace("Refresh", new ListGumpEntry("Exit", Close));
        }