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;
        }
Beispiel #2
0
		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;


		}