Exemplo n.º 1
0
 void onCloseTargetClick(int x, int y, MouseButton button)
 {
     if (button == MouseButton.Right)
     {
         m_closeTarget.Dispose();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds or toggles the passed gump to the list of active gumps.
        /// </summary>
        /// <param name="gump">The gump to be opened or toggled.</param>
        /// <param name="x">C coordinate where new gump should be placed.</param>
        /// <param name="y">Y coordinate where new gump should be placed.</param>
        /// <param name="addType">By default, always adds the gump.
        /// If OnlyAllowOne, then any gumps of the same type that are active are disposed of, and the passed gump is added.
        /// If Toggle, then only adds the gump is another gump of the same type is not active; else, disposes of all gumps of the passed type, including the passed gump.</param>
        /// <returns>If the gump was added to the list of active gumps, then returns the added gump. If the gump was not added, returns null.</returns>
        public AControl AddControl(AControl gump, int x, int y, AddGumpType addType = AddGumpType.Always)
        {
            bool addGump = false;

            if (addType == AddGumpType.Always)
            {
                addGump = true;
            }
            else if (addType == AddGumpType.Toggle)
            {
                bool alreadyActive = false;
                foreach (AControl c in m_Controls)
                {
                    if (c.Equals(gump) && gump.Equals(c))
                    {
                        alreadyActive = true;
                        c.Dispose();
                    }
                }

                addGump = !alreadyActive;
            }
            else if (addType == AddGumpType.OnlyAllowOne)
            {
                foreach (AControl c in m_Controls)
                {
                    if (c.Equals(gump) && gump.Equals(c))
                    {
                        c.Dispose();
                    }
                }

                addGump = true;
            }

            if (addGump)
            {
                gump.Position = new Point(x, y);
                m_Controls.Add(gump);
                return(gump);
            }
            else
            {
                gump.Dispose();
                return(null);
            }
        }