Exemplo n.º 1
0
        public void HandlePositionCommand(CommandEventArgs e)
        {
            var user = e.Mobile as PlayerMobile;

            if (user == null || user.Deleted || user.NetState == null || !ModuleEnabled)
            {
                return;
            }

            if (user.AccessLevel < Access)
            {
                if (user.AccessLevel > AccessLevel.Player)
                {
                    user.SendMessage("You do not have access to that command.");
                }

                return;
            }

            var tb = Toolbars.EnsureState(user).GetToolbarGump();

            SuperGump.Send(
                new OffsetSelectorGump(
                    user,
                    tb.Refresh(true),
                    Toolbars.GetOffset(user),
                    (self, oldValue) =>
            {
                Toolbars.SetOffset(user, self.Value);
                tb.X = self.Value.X;
                tb.Y = self.Value.Y;
                tb.Refresh(true);
            }));
        }
Exemplo n.º 2
0
        public virtual void EndGlobalEdit()
        {
            if (State == Toolbars.DefaultEntries)
            {
                State.User = null;
                State      = Toolbars.EnsureState(User as PlayerMobile);
            }

            GlobalEdit = false;
            Refresh(true);
        }
Exemplo n.º 3
0
 protected virtual void ShowPositionSelect(GumpButton b)
 {
     Send(
         new OffsetSelectorGump(
             User,
             Refresh(true),
             Toolbars.GetOffset(User),
             (self, oldValue) =>
     {
         Toolbars.SetOffset(self.User, self.Value);
         X = self.Value.X;
         Y = self.Value.Y;
         Refresh(true);
     }));
 }
Exemplo n.º 4
0
        public void HandlePopupCommand(CommandEventArgs e)
        {
            var user = e.Mobile as PlayerMobile;

            if (user == null || user.Deleted || user.NetState == null || !ModuleEnabled)
            {
                return;
            }

            if (user.AccessLevel < Access)
            {
                if (user.AccessLevel > AccessLevel.Player)
                {
                    user.SendMessage("You do not have access to that command.");
                }

                return;
            }

            SuperGump.Send(Toolbars.EnsureState(user).GetToolbarGump());
        }
Exemplo n.º 5
0
        protected virtual void ShowPositionSelect(GumpButton b)
        {
            if (!(User is PlayerMobile))
            {
                return;
            }

            var user = (PlayerMobile)User;

            new OffsetSelectorGump(
                user,
                Refresh(true),
                Toolbars.GetOffset(user),
                (self, oldValue) =>
            {
                Toolbars.SetOffset(user, self.Value);
                X = self.Value.X;
                Y = self.Value.Y;
                Refresh(true);
            }).Send();
        }
Exemplo n.º 6
0
        public virtual void SetDefaultEntries()
        {
            SetDefaultSize();

            if (this == Toolbars.DefaultEntries)
            {
                Toolbars.LoadDefaultEntries();
                return;
            }

            for (int x = 0; x < Toolbars.DefaultEntries.Width; x++)
            {
                for (int y = 0; y < Toolbars.DefaultEntries.Height; y++)
                {
                    ToolbarEntry entry = Toolbars.DefaultEntries[x, y];

                    if (entry != null && entry.ValidateState(this))
                    {
                        SetContent(x, y, entry.Clone());
                    }
                }
            }
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
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));
        }