Example #1
0
        protected override void CompileMenuOptions(MenuGumpOptions list)
        {
            var regions =
                Region.Regions.Not(r => r == null || !r.Registered || r is PvPRegion || r is RegionExtUtility.PreviewRegion)
                .Where(r => r.Contains(User.Location, User.Map))
                .ToArray();

            if (regions.Length > 0)
            {
                MenuGumpOptions opts = new MenuGumpOptions();

                regions.ForEach(
                    r => opts.AppendEntry(
                        new ListGumpEntry(
                            r.Name,
                            () =>
                {
                    ClearPreview();

                    bool prev = Preview;

                    Preview = false;
                    r.Area.ForEach(AddToList);
                    Preview = prev;

                    DisplayPreview();
                })));

                list.AppendEntry(new ListGumpEntry("Use Region...", b => Send(new MenuGump(User, Refresh(), opts, b))));
            }
            else
            {
                list.RemoveEntry("Use Region...");
            }

            base.CompileMenuOptions(list);
        }
Example #2
0
		protected override void CompileMenuOptions(MenuGumpOptions list)
		{
			var regions =
				Region.Regions.Not(r => r == null || !r.Registered || r is PvPRegion || r is RegionExtUtility.PreviewRegion)
					  .Where(r => r.Contains(User.Location, User.Map))
					  .ToArray();

			if (regions.Length > 0)
			{
				MenuGumpOptions opts = new MenuGumpOptions();

				regions.ForEach(
					r => opts.AppendEntry(
						new ListGumpEntry(
							r.Name,
							() =>
							{
								ClearPreview();

								bool prev = Preview;

								Preview = false;
								r.Area.ForEach(AddToList);
								Preview = prev;

								DisplayPreview();
							})));

				list.AppendEntry(new ListGumpEntry("Use Region...", b => Send(new MenuGump(User, Refresh(), opts, b))));
			}
			else
			{
				list.RemoveEntry("Use Region...");
			}

			base.CompileMenuOptions(list);
		}
Example #3
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));
        }
Example #4
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));
        }
Example #5
0
            protected override void CompileMenuOptions(MenuGumpOptions list)
            {
                list.AppendEntry(
                    new ListGumpEntry("Options", () => User.SendGump(new PropertiesGump(User, CSOptions)), HighlightHue));

                if (_CrashNotes.Count > 0 && CSOptions.EmailOptions.Valid)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Email Notes",
                            () => VitaNexCore.TryCatch(
                                () =>
                    {
                        Refresh();

                        using (SmtpClient smtp = CSOptions.EmailOptions)
                        {
                            using (MailMessage email = CSOptions.EmailOptions)
                            {
                                email.Subject    = String.Format("{0} Crash Notes", ServerList.ServerName);
                                email.IsBodyHtml = true;

                                var lines         = new String[_CrashNotes.Count * 2];
                                CrashNote[] notes = _CrashNotes.ToArray();

                                email.Body = String.Format("<h1>{0} Notes:</h1><hr/><br/>", _CrashNotes.Count.ToString("#,#"));

                                notes.For(
                                    (i, t) =>
                                {
                                    lines[i] = String.Format(
                                        "<a href=\"#{0}\">{1} {2}</a>", t.GetHashCode(), t.Date.ToSimpleString("D d M y - t@h-m@"), t.Mobile);
                                    lines[notes.Length - i] = String.Format(
                                        "<div id=\"{0}\"><h2>{1}</h2><h3>{2}</h3><p>{3}</p></div>",
                                        t.GetHashCode(),
                                        t.Date.ToSimpleString("D d M y - t@h-m@"),
                                        t.Mobile != null ? t.Mobile.ToString() : "Anon.",
                                        t.Note);
                                });

                                email.Body += String.Join("\n", lines);
                                smtp.Send(email);

                                User.SendMessage(85, "An email has been sent to {0}", CSOptions.EmailOptions.To);
                            }
                        }
                    },
                                CSOptions.ToConsole),
                            HighlightHue));
                }
                else
                {
                    list.RemoveEntry("Email Notes");
                }

                list.AppendEntry(
                    new ListGumpEntry(
                        "Mark All: Viewed",
                        () =>
                {
                    _CrashNotes.ForEach(t => t.Viewed = true);
                    User.SendMessage("All notes have been marked as viewed.");
                    Refresh(true);
                },
                        TextHue));

                list.AppendEntry(
                    new ListGumpEntry(
                        "Mark All: Not Viewed",
                        () =>
                {
                    _CrashNotes.ForEach(t => t.Viewed = false);
                    User.SendMessage("All notes have been marked as not viewed.");
                    Refresh(true);
                },
                        TextHue));

                list.AppendEntry(
                    new ListGumpEntry(
                        "Delete All",
                        () =>
                {
                    _CrashNotes.Clear();

                    User.SendMessage("All notes have been deleted.");
                    Refresh(true);
                },
                        ErrorHue));

                list.AppendEntry(
                    new ListGumpEntry(
                        "Delete Old",
                        () =>
                {
                    DateTime expire = DateTime.Now - TimeSpan.FromDays(7);

                    _CrashNotes.RemoveAll(t => t.Date <= expire);

                    User.SendMessage("All old notes have been deleted.");
                    Refresh(true);
                },
                        ErrorHue));

                base.CompileMenuOptions(list);
            }
Example #6
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));
        }