Esempio n. 1
0
			//epic
		public ButtonSet(CommitGumpBase gump, Type enumType,
				 int Columns, int XSpacer,
				 int YSpacer, int OnImage,
				 int OffImage, int StartX,
				 int StartY, int ButtonIdOffset,
				 QueryButtonStatusDelegate queryStatusMethod, ButtonPressedDelegate pressMethod, QueryLabelColourDelegate queryColourMethod
			)	
		{
			if (!enumType.IsEnum) return;
			if (Enum.GetUnderlyingType(enumType) != typeof(int)) return;
			m_Gump = gump;
			m_Columns = Columns;
			m_XSpacer = XSpacer;
			m_YSpacer = YSpacer;
			m_OnImage = OnImage;
			m_OffImage = OffImage;
			m_StartX = StartX;
			m_StartY = StartY;
			m_ButtonIdOffset = ButtonIdOffset;
			m_QueryButtonStatus = queryStatusMethod;
			m_ButtonPress = pressMethod;
			m_QueryButtonTextColour = queryColourMethod;

			foreach (int val in Enum.GetValues(enumType))
				_setData.Add(val, Enum.GetName(enumType, val));
			
			((ICommitGumpEntity)this).Create();

		
		}
Esempio n. 2
0
		//epic
		public ButtonSet(	 CommitGumpBase gump, List<String> items,
				 int Columns,			int XSpacer, 
				 int YSpacer,			int OnImage, 
				 int OffImage,		int StartX, 
				 int StartY,			int ButtonIdOffset,
				 QueryButtonStatusDelegate queryStatusMethod, ButtonPressedDelegate pressMethod, QueryLabelColourDelegate queryColourMethod
			)
		{
			m_Gump = gump;
			m_Columns = Columns;
			m_XSpacer = XSpacer; 
			m_YSpacer = YSpacer;
			m_OnImage = OnImage; 
			m_OffImage = OffImage; 
			m_StartX = StartX; 
			m_StartY = StartY;
			m_ButtonIdOffset = ButtonIdOffset;
			m_QueryButtonStatus = queryStatusMethod;
			m_ButtonPress = pressMethod;
			m_QueryButtonTextColour = queryColourMethod;
			int id = 0;
			foreach (string s in items)
			{
				_setData.Add(id, s);
				++id;					 //LOCAL id - this is used with the offset for the gump.  The point here is so the calee doesn't have to care about IDs.
			}
			items.Clear();

			((ICommitGumpEntity)this).Create();
		}
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 0)
            {
                return;
            }

            GumpReturnType current = m_GumpReturnType = GumpReturnType.None;

            //First bubble response to the current page as it takes priority over the master
            if (CurrentPage != null)
            {
                current = CurrentPage.OnResponse(sender, info);
                if (current != GumpReturnType.None)
                {
                    m_GumpReturnType = current;
                }
            }
            //Bubble to master page
            if (MasterPage != null)
            {
                current = MasterPage.OnResponse(sender, info);
                if (current != GumpReturnType.None)
                {
                    m_GumpReturnType = current;
                }
            }

            //On a cancel simply return!
            if (m_GumpReturnType == GumpReturnType.Cancel)
            {
                return;
            }

            //On a OK, instantiate an instance of each entity in the register with the session data and call commit
            if (m_GumpReturnType == GumpReturnType.OK)
            {
                //Commit
                foreach (KeyValuePair <int, Type> kvp in m_EntityRegister)
                {
                    try
                    {
                        ICommitGumpEntity entity = Activator.CreateInstance(kvp.Value, this) as ICommitGumpEntity;
                        if (entity != null)
                        {
                            if (entity.Validate())
                            {
                                entity.CommitChanges();
                            }
                        }
                    }
                    catch
                    {
                        //TODO: announce fail
                    }
                }
            }
            // None is a continuation - save the current page's state and continue
            else if (m_GumpReturnType == GumpReturnType.None)
            {
                if (CurrentPage != null)
                {
                    CurrentPage.SaveStateInfo();
                }

                //Continue by creating a new gump of whatever this type is with reflection
                CommitGumpBase gump = null;
                try
                {
                    gump = Activator.CreateInstance(this.GetType(), m_Page, m_GumpSession, m_From) as CommitGumpBase;
                }
                catch
                {
                }

                if (gump != null)
                {
                    sender.Mobile.SendGump(gump);
                }
            }

            return;
        }