Пример #1
0
		protected virtual bool CanDisplay(GumpImageTileButton entry)
		{
			return entry != null;
		}
Пример #2
0
		public virtual void Write(string name, GumpImageTileButton e)
		{
			CreateElement(e);
			SetAttribute("name", name);
			SetAttribute("x", e.X);
			SetAttribute("y", e.Y);
			SetAttribute("width", e.Width);
			SetAttribute("height", e.Height);
			SetAttribute("itemid", e.ItemID);
			SetAttribute("buttonid", e.ButtonID);
			SetAttribute("normalid", e.NormalID);
			SetAttribute("pressedid", e.PressedID);
			SetAttribute("hue", e.Hue);
			SetAttribute("tooltip", e.LocalizedTooltip);
			Append();
		}
Пример #3
0
		protected virtual void OnDoubleClick(GumpImageTileButton entry)
		{ }
Пример #4
0
		public virtual void HandleTileButtonClick(GumpImageTileButton button)
		{
			var now = DateTime.UtcNow;
			var lbc = LastTileButtonClicked;
			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));

			LastTileButtonClicked = button;
			LastButtonClick = now;

			OnClick();
			OnClick(button);

			if (DoubleClicked)
			{
				OnDoubleClick(button);
			}

			if (TileButtonHandler != null)
			{
				TileButtonHandler(button);
			}
			else if (TileButtons[button] != null)
			{
				TileButtons[button](button);
			}
		}
Пример #5
0
		protected void AddImageTiledButton(GumpImageTileButton entry, Action<GumpImageTileButton> handler)
		{
			if (entry == null || !CanDisplay(entry))
			{
				return;
			}

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

			Add(entry);
		}
Пример #6
0
		public virtual void HandleTileButtonClick(GumpImageTileButton button)
		{
			DateTime now = DateTime.UtcNow;

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

			LastTileButtonClicked = button;
			LastButtonClick = now;

			OnClick(button);

			if (DoubleClicked)
			{
				OnDoubleClick(button);
			}

			if (TileButtonHandler != null)
			{
				TileButtonHandler(button);
			}
			else if (TileButtons[button] != null)
			{
				TileButtons[button](button);
			}
		}
Пример #7
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);
        }