Exemple #1
0
        public ToolbarGump(ToolbarState state, Color?headerColor = null, ToolbarTheme theme = ToolbarTheme.Default)
            : base(state.User, null, state.X, state.Y, null, null, DefaultToolbarTitle)
        {
            State       = state;
            HeaderColor = headerColor ?? Color.DarkBlue;
            GlobalEdit  = false;
            Theme       = ToolbarThemes.GetTheme(theme);

            CanSearch  = false;
            CanMove    = false;
            CanDispose = false;
            CanClose   = false;
            CanResize  = false;
        }
Exemple #2
0
 protected override void Compile()
 {
     Theme = ToolbarThemes.GetTheme(State.Theme);
     base.Compile();
 }
Exemple #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));
        }
Exemple #4
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));
        }