コード例 #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.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 = 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));
        }
コード例 #2
0
ファイル: ToolbarCommand.cs プロジェクト: LordEnigma/UO
        public override void Reset(ToolbarGump toolbar)
        {
            base.Reset(toolbar);

            if (toolbar == null)
            {
                return;
            }

            PlayerMobile user = toolbar.User;

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                Args.Clear();
            }
        }
コード例 #3
0
ファイル: ToolbarEntry.cs プロジェクト: LordEnigma/UO
        public virtual void Reset(ToolbarGump state)
        {
            if (state == null)
            {
                return;
            }

            PlayerMobile user = state.User;

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

            Value      = String.Empty;
            Label      = null;
            LabelColor = null;
        }
コード例 #4
0
ファイル: ToolbarEntry.cs プロジェクト: LordEnigma/UO
        public virtual void Edit(ToolbarGump toolbar, Point loc, GumpButton clicked)
        {
            if (toolbar == null)
            {
                return;
            }

            PlayerMobile user = toolbar.State.User;

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

            if (CanEdit || user.AccessLevel >= Toolbars.Access)
            {
                SuperGump.Send(new MenuGump(user, toolbar.Refresh(), GetOptions(toolbar, clicked, loc), clicked));
            }
        }
コード例 #5
0
ファイル: ToolbarSpell.cs プロジェクト: thehaunted88/Core
        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));
            }
        }
コード例 #6
0
ファイル: ToolbarEntry.cs プロジェクト: LordEnigma/UO
        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));
            }
        }
コード例 #7
0
ファイル: ToolbarPhrase.cs プロジェクト: zerodowned/Core
        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));
        }