Inheritance: GumpEntry
Example #1
0
		protected virtual void OnAccept(GumpButton button)
		{
			if (AcceptHandler != null)
			{
				AcceptHandler(button);
			}
		}
Example #2
0
		protected virtual void OnCancel(GumpButton button)
		{
			if (CancelHandler != null)
			{
				CancelHandler(button);
			}
		}
Example #3
0
		public virtual void HandleButtonClick(GumpButton button)
		{
			DateTime now = DateTime.UtcNow;

			DoubleClicked = LastButtonClicked != null && now < LastButtonClick + DClickInterval &&
							(LastButtonClicked == button || LastButtonClicked.ButtonID == button.ButtonID ||
							 (LastButtonClicked.Parent == button.Parent && LastButtonClicked.X == button.X && LastButtonClicked.Y == button.Y &&
							  LastButtonClicked.Type == button.Type && LastButtonClicked.Param == button.Param));

			LastButtonClicked = button;
			LastButtonClick = now;

			OnClick();

			OnClick(button);

			if (DoubleClicked)
			{
				OnDoubleClick(button);
			}

			if (ButtonHandler != null)
			{
				ButtonHandler(button);
			}
			else if (Buttons[button] != null)
			{
				Buttons[button](button);
			}
		}
		protected override void OnAccept(GumpButton button)
		{
			if (String.IsNullOrWhiteSpace(InputText) ||
				!NameVerification.Validate(InputText, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
			{
				Html = ("The name \"" + InputText + "\" is invalid.\n\n").WrapUOHtmlColor(Color.OrangeRed, HtmlColor) +
					   "It appears that another character is already using the name \"" + //
					   User.RawName.WrapUOHtmlColor(Color.LawnGreen, HtmlColor) + "\"!\n\n" + //
					   "Please enter a new name for your character...";

				InputText = NameList.RandomName(User.Female ? "female" : "male");

				Refresh(true);
				return;
			}

			if (InputText == User.RawName ||
				PlayerNames.FindPlayers(InputText, p => p != User && p.GameTime > User.GameTime).Any())
			{
				Html = "It appears that another character is already using the name \"" + //
					   InputText.WrapUOHtmlColor(Color.LawnGreen, HtmlColor) + "\"!\n\n" + //
					   "Please enter a new name for your character...";

				InputText = NameList.RandomName(User.Female ? "female" : "male");

				Refresh(true);
				return;
			}

			User.RawName = InputText;

			PlayerNames.Register(User);

			base.OnAccept(button);
		}
Example #5
0
		public virtual void HandleButtonClick(GumpButton button)
		{
			var now = DateTime.UtcNow;
			var lbc = LastButtonClicked;
			var lbt = LastButtonClick + DClickInterval;

			DoubleClicked = lbc != null && now <= lbt &&
							(lbc == button || lbc.ButtonID == button.ButtonID ||
							 (lbc.Parent == button.Parent && lbc.X == button.X && lbc.Y == button.Y && lbc.Type == button.Type &&
							  lbc.Param == button.Param));

			LastButtonClicked = button;
			LastButtonClick = now;

			OnClick();
			OnClick(button);

			if (DoubleClicked)
			{
				OnDoubleClick(button);
			}

			if (ButtonHandler != null)
			{
				ButtonHandler(button);
			}
			else if (Buttons[button] != null)
			{
				Buttons[button](button);
			}
		}
Example #6
0
		protected override void OnAccept(GumpButton button)
		{
			if (Callback != null)
			{
				Callback(button, InputText);
			}

			base.OnAccept(button);
		}
Example #7
0
        public SaveCancelGumpling(Int32 x, Int32 y, GumpResponse saveCallback, GumpResponse cancelCallback) : base(x, y)
        {
            GumpButton button = new GumpButton(0, 0, 0x1452, 0x1453, -1, GumpButtonType.Reply, 0, saveCallback);
            button.OnGumpResponse += button_OnSave;
            Add(button);

            button = new GumpButton(85, 0, 0x1450, 0x1451, (cancelCallback == null ? 0 : -1), GumpButtonType.Reply, 0, cancelCallback);
            button.OnGumpResponse += button_OnCancel;
            Add(button);
        }
Example #8
0
		public ScheduleDaysMenuGump(
			PlayerMobile user, Schedule schedule, Gump parent = null, GumpButton clicked = null, bool useConfirm = true)
			: base(user, parent, clicked: clicked)
		{
			Schedule = schedule;
			UseConfirmDialog = useConfirm;

			CanMove = false;
			CanResize = false;
		}
Example #9
0
		protected override void OnAccept(GumpButton button)
		{
			base.OnAccept(button);

			if (Battle != null && !Battle.Deleted)
			{
				Battle.AcceptInvite(User);
			}

			Close(true);
		}
Example #10
0
		protected override void OnCancel(GumpButton button)
		{
			base.OnCancel(button);

			if (Battle != null && !Battle.Deleted)
			{
				Battle.DeclineInvite(User);
			}

			Close(true);
		}
Example #11
0
		protected virtual void OnConfirmDelete(GumpButton button)
		{
			if (Selected == null)
			{
				Close();
				return;
			}

			Schedule.Info.Times.Remove(Time);
			Schedule.InvalidateNextTick(DateTime.UtcNow);
			Close();
		}
        public LabelAddRemoveGumpling(Int32 index, Int32 x, Int32 y, Int32 entryWidth, String entryName, Int32 entryHue, GumpResponse editCallback, GumpResponse removeCallback) : base(x, y)
        {
            _Index = index;

            Add(new GumpImageTiled(0, 0, entryWidth, 23, 0xA40));
            Add(new GumpImageTiled(1, 1, entryWidth - 2, 21, 0xBBC));
            Add(new GumpLabelCropped(5, 1, entryWidth - 10, 16, entryHue, entryName));

            GumpButton editButton = new GumpButton(entryWidth + 5, 0, 0xFBD, 0xFBF, -1, GumpButtonType.Reply, 0, editCallback);
            editButton.OnGumpResponse += editButton_OnGumpResponse;
            Add(editButton);

            GumpButton removeButton = new GumpButton(entryWidth + 35, 0, 0xFB4, 0xFB6, -1, GumpButtonType.Reply, 0, removeCallback);
            removeButton.OnGumpResponse += removeButton_OnGumpResponse;
            Add(removeButton);
        }
Example #13
0
		public ScheduleTimeListEntryGump(
			PlayerMobile user,
			Schedule schedule,
			Gump parent = null,
			GumpButton clicked = null,
			TimeSpan? time = null,
			bool useConfirm = true)
			: base(user, parent, clicked: clicked)
		{
			Schedule = schedule;
			Time = time ?? TimeSpan.Zero;
			UseConfirmDialog = useConfirm;

			CanMove = false;
			CanResize = false;
		}
Example #14
0
		protected void AddButton(GumpButton entry, Action<GumpButton> handler)
		{
			if (entry == null || !CanDisplay(entry))
			{
				return;
			}

			if (!Buttons.ContainsKey(entry))
			{
				Buttons.Add(entry, handler);
			}
			else
			{
				Buttons[entry] = handler;
			}

			Add(entry);
		}
Example #15
0
		protected virtual void SetDay(GumpButton button, ScheduleDays day)
		{
			if (Schedule == null)
			{
				Close();
				return;
			}

			switch (day)
			{
				case ScheduleDays.None:
					Schedule.Info.Days = ScheduleDays.None;
					break;
				case ScheduleDays.All:
					Schedule.Info.Days = ScheduleDays.All;
					break;
				default:
					Schedule.Info.Days ^= day;
					break;
			}

			Schedule.InvalidateNextTick(DateTime.UtcNow);
			Refresh(true);
		}
Example #16
0
		protected override void OnAccept(GumpButton button)
		{
			Confirmed = true;
			base.OnAccept(button);
		}
Example #17
0
		protected override void OnCancel(GumpButton button)
		{
			Confirmed = false;
			base.OnCancel(button);
		}
Example #18
0
 public void AddCallbackButton(int x, int y, int buttonIDnormal, int buttonIDpushed, int id, GumpButtonType type, int page, Action<GumpButton> callback)
 {
     GumpButton b = new GumpButton(x, y, buttonIDnormal, buttonIDpushed, id, type, page);
     ButtonCallbacks[b] = callback;
     Add(b);
 }
        protected override void OnCancel(GumpButton button)
        {
            base.OnCancel(button);

            if(LockMode)
            {
                Close();
            }
        }
        protected override void OnAccept(GumpButton button)
        {
            base.OnAccept(button);

            if(LockMode)
            {
                Close();
                return;
            }

            if(String.IsNullOrWhiteSpace(TemplateName))
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                    {
                        Title = "Choose a Template Name",
                        Html = "Your template must have a name!",
                        AcceptHandler = b => Refresh(true)
                    });
                return;
            }

            if(TemplateSkills.Length < 7)
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                    {
                        Title = "Choose 7 Skills",
                        Html = "You must choose 7 unique skills to create a template.",
                        AcceptHandler = b => Refresh(true)
                    });
                return;
            }

            if(TemplateStr <= 0 || TemplateDex <= 0 || TemplateInt <= 0)
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                    {
                        Title = "Choose 3 Stats",
                        Html = "You must specify your three character stats.",
                        AcceptHandler = b => Refresh(true)
                    });
                return;
            }

            if(TemplateStr + TemplateDex + TemplateInt > 225)
            {
                Send(
                    new NoticeDialogGump(User, Hide(true))
                    {
                        Title = "Stat Failure",
                        Html =
                            "Either one of your stats is above the 100 limit, " +
                            "or you have exceeded the overall limit of 225 stat points with your current allocation.",
                        AcceptHandler = b => Refresh(true)
                    });
                return;
            }

            Dictionary<SkillName, double> skills = Profile.Owner.Skills.Not(sk => sk == null)
                .ToDictionary(sk => sk.SkillName, sk => TemplateSkills.Contains(sk.SkillName) ? 100.0 : 0.0);
            var stats = new Dictionary<StatType, int>
            {
                {
                    StatType.Str, TemplateStr
                },
                {
                    StatType.Dex, TemplateDex
                },
                {
                    StatType.Int, TemplateInt
                }
            };

            if(EditMode)
            {
                Template.Name = TemplateName;
                Template.Notes = TemplateNotes;
                Template.Skills = skills;
                Template.Stats = stats;

                Profile.Add(Template);
            }
            else
            {
                Template = Profile.Create(TemplateName, TemplateNotes, skills, stats);
                if(Profile.Selected == null)
                    Profile.Select(Template);
            }
            Close();
        }
Example #21
0
		protected void OnClaim(GumpButton b)
		{
			Profile.Claim(Transaction, User, User);
			Refresh(true);
		}
Example #22
0
		public virtual void OnCancel(GumpButton b)
		{
			var ui = UI;

			switch (ui.Mode)
			{
				case RuneCodex.UICache.ViewMode.Categories:
					Close();
					break;
				case RuneCodex.UICache.ViewMode.Entries:
					{
						ui.Mode = RuneCodex.UICache.ViewMode.Categories;
						Refresh(true);
					}
					break;
			}
		}
Example #23
0
		protected void OnBack(GumpButton b)
		{
			Close();
		}
Example #24
0
		public virtual void Maximize(GumpButton b)
		{
			Minimized = false;
			Refresh(true);
		}
Example #25
0
		protected virtual void OnSelectPoint(GumpButton b)
		{
			Value = new Point(b.X, b.Y);
		}
Example #26
0
		protected override void OnCancel(GumpButton button)
		{
			InputText = String.Empty;

			base.OnCancel(button);
		}
Example #27
0
        protected Packet Compile(NetState ns, bool convertToViewer = false)
        {
            IGumpWriter disp;

            if (ns != null && ns.Unpack)
            {
                disp = new DisplayGumpPacked(this);
            }
            else
            {
                disp = new DisplayGumpFast(this);
            }

            if (!this._Dragable)
            {
                disp.AppendLayout(_NoMove);
            }

            if (!this._Closable)
            {
                disp.AppendLayout(_NoClose);
            }

            if (!this._Disposable)
            {
                disp.AppendLayout(_NoDispose);
            }

            if (!this._Resizable)
            {
                disp.AppendLayout(_NoResize);
            }

            int count = this._Entries.Count;

            for (int i = 0; i < count; ++i)
            {
                GumpEntry e = this._Entries[i];

                disp.AppendLayout(_BeginLayout);

                if (!convertToViewer)
                {
                    e.AppendTo(disp);
                }
                else
                {
                    GumpButton button = e as GumpButton;

                    if (button != null)
                    {
                        new GumpImage(button.X, button.Y, button.NormalID).AppendTo(disp);
                    }
                    else
                    {
                        GumpImageTileButton tileButton = e as GumpImageTileButton;

                        if (tileButton != null)
                        {
                            new GumpImageTiled(tileButton.X, tileButton.Y, tileButton.Width, tileButton.Height,
                                               tileButton.NormalID).AppendTo(disp);
                        }
                        else
                        {
                            GumpRadio radio = e as GumpRadio;

                            if (radio != null)
                            {
                                new GumpImage(radio.X, radio.Y, radio.InitialState ? radio.ActiveID : radio.InactiveID)
                                .AppendTo(disp);
                            }
                            else
                            {
                                GumpCheck check = e as GumpCheck;

                                if (check != null)
                                {
                                    new GumpImage(check.X, check.Y,
                                                  check.InitialState ? check.ActiveID : check.InactiveID).AppendTo(disp);
                                }
                                // Process text fields
                            }
                        }
                    }
                }

                disp.AppendLayout(_EndLayout);
            }

            disp.WriteStrings(this._Strings);

            disp.Flush();

            this._TextEntries = disp.TextEntries;
            this._Switches    = disp.Switches;

            return(disp as Packet);
        }
Example #28
0
        /// <summary>
        /// Honestly...I don't know why this is here.
        /// </summary>
        /// <param name="page">The gump to reference.</param>
        /// <returns>A string of the specially formatted gump entries.</returns>
        public string Compile(Gump page)
        {
            string ret = "";

            switch (m_Style)
            {
            case "details":
                if (m_Background)
                {
                    ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", m_X, m_Y, m_Width, m_Height, m_BackgroundID);
                }
                int colWidth = Width / m_ColCount;
                int i        = 0;
                int xbase    = m_X;
                while (i < columnValues.Count && i < m_ParentList.columns)
                {
                    xbase = m_X + (i * colWidth);
                    object obj = columnValues[i];
                    if (obj is string)
                    {
                        string caption = (string)obj;
                        if (caption.Contains("</"))
                        {
                            ret += String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X + (i * colWidth), m_Y, colWidth, m_Height, page.Intern(caption), false, false);
                        }
                        else
                        {
                            ret += String.Format("{{ text {0} {1} {2} {3} }}", m_X + (i * colWidth), m_Y, skin.NormalText, page.Intern(caption));
                        }
                    }
                    else if (obj is GumpButton)
                    {
                        GumpButton btn = (GumpButton)obj;
                        ret += String.Format("{{ button {0} {1} {2} {3} {4} {5} {6} }}", xbase, m_Y, btn.NormalID, btn.PressedID, (int)btn.Type, btn.Param, btn.ButtonID);
                    }
                    else if (obj is GumpCheck)
                    {
                        GumpCheck chk = (GumpCheck)obj;
                        ret += String.Format("{{ checkbox {0} {1} {2} {3} {4} {5} }}", xbase, m_Y, chk.ActiveID, chk.InactiveID, chk.InitialState, chk.SwitchID);
                    }
                    ret += String.Format("{{gumppictiled {0} {1} {2} {3} {4} }}", m_X + (i * colWidth), m_Y, skin.EntryDividerWidth, skin.EntryDividerHeight, skin.EntryDividerID);
                    i++;
                }
                break;

            case "icons":
                string caption2 = (string)columnValues[captionID];
                if (caption2.Contains("</"))
                {
                    ret += String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y + skin.EntryCaptionPositionY, skin.EntryCaptionWidth, skin.EntryCaptionHeight, page.Intern(caption2), false, false);
                }
                else
                {
                    ret += String.Format("{{ text {0} {1} {2} {3} }}", m_X, m_Y + skin.EntryCaptionPositionY, skin.NormalText, page.Intern(caption2));
                }
                int id = skin.EntryDefaultIcon;
                ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", m_X, m_Y, m_Width, m_Height, m_BackgroundID);
                if (arguments.ContainsKey("icon"))
                {
                    id = (int)arguments["icon"];
                }
                ret += String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", ((skin.EntryCaptionWidth - m_X) - skin.EntryIconWidth) / 2, m_Y + skin.EntryIconY, skin.EntryIconWidth, skin.EntryIconHeight, id);
                GumpButton btn2 = null;
                if (arguments.ContainsKey("button"))
                {
                    btn2 = (GumpButton)arguments["button"];
                    ret += String.Format("{{ buttontileart {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} }}", m_X, m_Y, skin.EntryButtonUnderlay, skin.EntryButtonUnderlay, (int)btn2.Type, btn2.Param, btn2.ButtonID, skin.EntryButtonUnderlay, skin.DefaultBackgroundColor, skin.EntryIconWidth, skin.EntryIconHeight);
                }
                break;
            }
            if (m_Tooltip)
            {
                ret += String.Format("{{ tooltip {0} }}", TooltipID);
            }
            return(ret);
        }
Example #29
0
		public virtual void OnAccept(GumpButton b)
		{
			var ui = UI;

			ui.Mode = RuneCodex.UICache.ViewMode.Entries;
			Refresh(true);
		}
Example #30
0
        /// <summary>
        /// The main method for putting the entry on the page. This method is accessed from the GumpList class when CommitList() is called.
        /// </summary>
        /// <param name="page">The gump to which the entry should be appended.</param>
        public void AppendTo(Gump page)
        {
            m_ColCount = columnValues.Count < m_ParentList.columns? columnValues.Count: m_ParentList.columns;
            if (m_ColCount == 0)
            {
                return;
            }
            if (m_Background)
            {
                GumpImageTiled b = new GumpImageTiled(m_X, m_Y, m_Width, m_Height, m_BackgroundID);
                page.Add(b);
            }
            if (m_Style == "details")
            {
                m_ParentList.DebugWrite("Details mode.");
                int i = 0;
                //int columnval = -1;

                int colWidth = Width / m_ColCount;
                int xbase    = m_X;
                while (i < columnValues.Count && i < m_ParentList.columns)
                {
                    colWidth = getWidthOfColumn(i);
                    xbase    = m_X + getCurrentXLocation(i + 1);
                    m_ParentList.DebugWrite("Appending Columns.");
                    try
                    {
                        object o = columnValues[i];
                        if (o is GumpButton)
                        {
                            GumpButton btn = (GumpButton)o;
                            btn.X = xbase + skin.ListColumnIndent;
                            btn.Y = m_Y;
                            page.Add(btn);
                        }
                        else if (o is GumpCheck)
                        {
                            GumpCheck c = (GumpCheck)o;
                            c.X = xbase + skin.ListColumnIndent;
                            c.Y = m_Y;
                            page.Add(c);
                        }
                        else if (o is GumpTextEntry)
                        {
                            GumpTextEntry t = (GumpTextEntry)o;
                            t.X      = xbase + skin.ListColumnIndent;
                            t.Y      = m_Y;
                            t.Width  = colWidth;
                            t.Height = m_Height;
                            page.Add(t);
                        }
                        else if (o is string)
                        {
                            string s = (string)o;
                            m_ParentList.DebugWrite("stringy! " + s);
                            if (s.Contains("</"))
                            {
                                GumpHtml h = new GumpHtml(xbase + skin.ListColumnIndent, m_Y, colWidth, m_Height, s, false, false);
                                h.Parent = page;
                                page.Add(h);
                            }
                            else
                            {
                                m_ParentList.DebugWrite("text");
                                GumpLabel g = new GumpLabel(xbase + skin.ListColumnIndent, m_Y, skin.NormalText, s);
                                g.Parent = page;
                                page.Add(g);
                            }
                        }
                        i++;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Problem in AppendTo - " + e);
                        i = columnValues.Count;
                    }
                    if (m_Dividers)
                    {
                        GumpImageTiled t = new GumpImageTiled(xbase + colWidth, m_Y, skin.EntryDividerWidth, skin.EntryDividerHeight, skin.EntryDividerID);
                        page.Add(t);
                    }
                }
                m_ParentList.DebugWrite("Done, details.");
            }
            else if (m_Style == "icons")
            {
                m_ParentList.DebugWrite("Icons mode.");
                Hashtable table = (Hashtable)columnValues[0];
                string    s     = (string)table["caption"];
                if (m_Background)
                {
                    GumpImageTiled t = new GumpImageTiled(m_X, m_Y, m_Width, m_Height, m_BackgroundID);
                    page.Add(t);
                }
                GumpButton button;
                if (arguments.ContainsKey("button"))
                {
                    button = (GumpButton)arguments["button"];
                    page.Add(button);
                }
                else
                {
                    return;
                }

                int       icon = arguments["icon"] != null ? (int)arguments["icon"] : skin.EntryDefaultIcon;
                GumpImage im   = new GumpImage((skin.EntryCaptionWidth - m_X) - skin.EntryIconWidth / 2, m_Y + skin.EntryIconY, icon);
                page.Add(im);
                if (s.Contains("</"))
                {
                    GumpHtml h = new GumpHtml(m_X, m_Y, m_Width, m_Height, s, false, false);
                    h.Parent = page;
                    page.Add(h);
                }
                else
                {
                    GumpLabel g = new GumpLabel(m_X, m_Y + skin.EntryCaptionPositionY, skin.NormalText, s);
                    g.Parent = page;
                    page.Add(g);
                }
            }
            else
            {
                Console.WriteLine("Unknown style: " + m_Style);
            }
        }
Example #31
0
		public virtual void Write(string name, GumpButton e)
		{
			CreateElement(e);
			SetAttribute("name", name);
			SetAttribute("x", e.X);
			SetAttribute("y", e.Y);
			SetAttribute("buttonid", e.ButtonID);
			SetAttribute("normalid", e.NormalID);
			SetAttribute("pressedid", e.PressedID);
			SetAttribute("type", e.Type);
			SetAttribute("param", e.Param);
			Append();
		}
Example #32
0
		public virtual void Minimize(GumpButton b)
		{
			Minimized = true;
			Refresh(true);
		}
Example #33
0
		protected void OnGift(GumpButton b)
		{
			Send(new DonationGiftGump(User, Hide(true), Profile, Transaction));
		}