Esempio n. 1
0
        protected virtual void OpenGump(Mobile m, TEntity t)
        {
            if (_Gump != null)
            {
                _Gump.Close();
                _Gump = null;
            }

            if (Names != null && Names.Count > 0)
            {
                m.SendMessage("Select a name from the registry...");

                var opts = new MenuGumpOptions();

                foreach (var name in Names.OrderByNatural())
                {
                    var n = name;

                    opts.AppendEntry(
                        new ListGumpEntry(
                            n,
                            () =>
                    {
                        _Gump = null;
                        ApplyName(m, t, n);
                    }));
                }

                var menu = new MenuGump(m as PlayerMobile, null, opts);

                menu.OnActionClose += HandleGumpClose;
                _Gump = menu.Send();
            }
            else
            {
                string name;
                int    limit;

                if (t is Item)
                {
                    name  = (t as Item).Name;
                    limit = 20;
                }
                else if (t is Mobile)
                {
                    name  = (t as Mobile).RawName;
                    limit = 20;
                }
                else
                {
                    name  = String.Empty;
                    limit = 0;
                }

                var dialog = new InputDialogGump(m as PlayerMobile)
                {
                    Title     = "",
                    Html      = "",
                    InputText = name,
                    Limit     = limit,
                    Callback  = (b, n) =>
                    {
                        _Gump = null;
                        ApplyName(m, t, n);
                    }
                };

                dialog.OnActionClose += HandleGumpClose;
                _Gump = dialog.Send();
            }
        }