Beispiel #1
0
        public void HandlePositionCommand(CommandEventArgs e)
        {
            PlayerMobile 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 tb = Toolbars.EnsureState(user).GetToolbarGump();

            SuperGump.Send(
                new OffsetSelectorGump(
                    user,
                    tb.Refresh(true),
                    Toolbars.GetOffset(user),
                    (self, oldValue) =>
            {
                Toolbars.SetOffset(self.User, self.Value);
                tb.X = self.Value.X;
                tb.Y = self.Value.Y;
                tb.Refresh(true);
            }));
        }
Beispiel #2
0
        public static void SetGlobalEntries()
        {
            VitaNexCore.TryCatch(
                () => Profiles.Values.ForEach(
                    state => VitaNexCore.TryCatch(
                        () =>
            {
                state.SetDefaultEntries();

                SuperGump tb = state.GetToolbarGump();

                if (tb != null && tb.IsOpen)
                {
                    tb.Refresh(true);
                }
            },
                        CMOptions.ToConsole)),
                CMOptions.ToConsole);
        }
Beispiel #3
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));
            }
        }