Пример #1
0
        public static void Save()
        {
            if (m_List == null)
            {
                m_List = Load();
            }

            try
            {
                string path = Path.Combine(Core.BaseDirectory, "Data/pageresponse.cfg");

                using (StreamWriter op = new StreamWriter(path))
                {
                    for (int i = 0; i < m_List.Count; ++i)
                    {
                        PredefinedResponse resp = (PredefinedResponse)m_List[i];

                        op.WriteLine("{0}\t{1}", resp.Title, resp.Message);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
        public static PredefinedResponse Add(string title, string message)
        {
            var resp = new PredefinedResponse(title, message);

            List.Add(resp);
            Save();

            return(resp);
        }
Пример #3
0
        public static PredefinedResponse Add(string title, string message)
        {
            if (m_List == null)
            {
                m_List = Load();
            }

            PredefinedResponse resp = new PredefinedResponse(title, message);

            m_List.Add(resp);
            Save();

            return(resp);
        }
Пример #4
0
		public override void OnResponse( NetState sender, RelayInfo info )
		{
			if ( m_From.AccessLevel < AccessLevel.Administrator )
				return;

			if ( m_Response == null )
			{
				int index = info.ButtonID - 1;

				if ( index == 0 )
				{
					PredefinedResponse resp = new PredefinedResponse( "", "" );

					ArrayList list = PredefinedResponse.List;
					list.Add( resp );

					m_From.SendGump( new PredefGump( m_From, resp ) );
				}
				else
				{
					--index;

					int type = index % 3;
					index /= 3;

					ArrayList list = PredefinedResponse.List;

					if ( index >= 0 && index < list.Count )
					{
						PredefinedResponse resp = (PredefinedResponse)list[index];

						switch ( type )
						{
							case 0: // edit
							{
								m_From.SendGump( new PredefGump( m_From, resp ) );
								break;
							}
							case 1: // move up
							{
								if ( index > 0 )
								{
									list.RemoveAt( index );
									list.Insert( index - 1, resp );

									PredefinedResponse.Save();
									m_From.SendGump( new PredefGump( m_From, null ) );
								}

								break;
							}
							case 2: // move down
							{
								if ( index < (list.Count - 1) )
								{
									list.RemoveAt( index );
									list.Insert( index + 1, resp );

									PredefinedResponse.Save();
									m_From.SendGump( new PredefGump( m_From, null ) );
								}

								break;
							}
						}
					}
				}
			}
			else
			{
				ArrayList list = PredefinedResponse.List;

				switch ( info.ButtonID )
				{
					case 1:
					{
						list.Remove( m_Response );

						PredefinedResponse.Save();
						m_From.SendGump( new PredefGump( m_From, null ) );
						break;
					}
					case 2:
					{
						TextRelay te = info.GetTextEntry( 0 );

						if ( te != null )
							m_Response.Title = te.Text;

						PredefinedResponse.Save();
						m_From.SendGump( new PredefGump( m_From, m_Response ) );

						break;
					}
					case 3:
					{
						TextRelay te = info.GetTextEntry( 1 );

						if ( te != null )
							m_Response.Message = te.Text;

						PredefinedResponse.Save();
						m_From.SendGump( new PredefGump( m_From, m_Response ) );

						break;
					}
				}
			}
		}
Пример #5
0
		public PredefGump( Mobile from, PredefinedResponse response ) : base( 30, 30 )
		{
			m_From = from;
			m_Response = response;

			from.CloseGump( typeof( PredefGump ) );

			bool canEdit = ( from.AccessLevel >= AccessLevel.GameMaster );

			AddPage( 0 );

			if ( response == null )
			{
				AddImageTiled( 0, 0, 410, 448, 0xA40 );
				AddAlphaRegion( 1, 1, 408, 446 );

				AddHtml( 10, 10, 390, 20, Color( Center( "Predefined Responses" ), LabelColor32 ), false, false );

				ArrayList list = PredefinedResponse.List;

				AddPage( 1 );

				int i;

				for ( i = 0; i < list.Count; ++i )
				{
					if ( i >= 5 && (i % 5) == 0 )
					{
						AddButton( 368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1 );
						AddLabel( 298, 10, 2100, "Next Page" );
						AddPage( (i / 5) + 1 );
						AddButton( 12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5 );
						AddLabel( 48, 10, 2100, "Previous Page" );
					}

					PredefinedResponse resp = (PredefinedResponse)list[i];

					string html = String.Format( "<u>{0}</u><br>{1}", resp.Title, resp.Message );

					AddHtml( 12, 44 + ((i % 5) * 80), 350, 70, html, true, true );

					if ( canEdit )
					{
						AddButton( 370, 44 + ((i % 5) * 80) + 24, 0xFA5, 0xFA7, 2 + (i * 3), GumpButtonType.Reply, 0 );

						if ( i > 0 )
							AddButton( 377, 44 + ((i % 5) * 80) + 2, 0x15E0, 0x15E4, 3 + (i * 3), GumpButtonType.Reply, 0 );
						else
							AddImage( 377, 44 + ((i % 5) * 80) + 2, 0x25E4 );

						if ( i < (list.Count - 1) )
							AddButton( 377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + (i * 3), GumpButtonType.Reply, 0 );
						else
							AddImage( 377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x25E8 );
					}
				}

				if ( canEdit )
				{
					if ( i >= 5 && (i % 5) == 0 )
					{
						AddButton( 368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1 );
						AddLabel( 298, 10, 2100, "Next Page" );
						AddPage( (i / 5) + 1 );
						AddButton( 12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5 );
						AddLabel( 48, 10, 2100, "Previous Page" );
					}

					AddButton( 12, 44 + ((i % 5) * 80), 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0 );
					AddHtml( 45, 44 + ((i % 5) * 80), 200, 20, Color( "New Response", LabelColor32 ), false, false );
				}
			}
			else if ( canEdit )
			{
				AddImageTiled( 0, 0, 410, 250, 0xA40 );
				AddAlphaRegion( 1, 1, 408, 248 );

				AddHtml( 10, 10, 390, 20, Color( Center( "Predefined Response Editor" ), LabelColor32 ), false, false );

				AddButton( 10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0 );
				AddHtml( 45, 40, 200, 20, Color( "Remove", LabelColor32 ), false, false );

				AddButton( 10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
				AddHtml( 45, 70, 200, 20, Color( "Title:", LabelColor32 ), false, false );
				AddTextInput( 10, 90, 300, 20, 0, response.Title );

				AddButton( 10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
				AddHtml( 45, 120, 200, 20, Color( "Message:", LabelColor32 ), false, false );
				AddTextInput( 10, 140, 390, 100, 1, response.Message );
			}
		}
Пример #6
0
		public static PredefinedResponse Add( string title, string message )
		{
			if ( m_List == null )
				m_List = Load();

			PredefinedResponse resp = new PredefinedResponse( title, message );

			m_List.Add( resp );
			Save();

			return resp;
		}
Пример #7
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_From.AccessLevel < AccessLevel.Administrator)
            {
                return;
            }

            if (m_Response == null)
            {
                int index = info.ButtonID - 1;

                if (index == 0)
                {
                    PredefinedResponse resp = new PredefinedResponse("", "");

                    ArrayList list = PredefinedResponse.List;
                    list.Add(resp);

                    m_From.SendGump(new PredefGump(m_From, resp));
                }
                else
                {
                    --index;

                    int type = index % 3;
                    index /= 3;

                    ArrayList list = PredefinedResponse.List;

                    if (index >= 0 && index < list.Count)
                    {
                        PredefinedResponse resp = (PredefinedResponse)list[index];

                        switch (type)
                        {
                        case 0:     // edit
                        {
                            m_From.SendGump(new PredefGump(m_From, resp));
                            break;
                        }

                        case 1:     // move up
                        {
                            if (index > 0)
                            {
                                list.RemoveAt(index);
                                list.Insert(index - 1, resp);

                                PredefinedResponse.Save();
                                m_From.SendGump(new PredefGump(m_From, null));
                            }

                            break;
                        }

                        case 2:     // move down
                        {
                            if (index < (list.Count - 1))
                            {
                                list.RemoveAt(index);
                                list.Insert(index + 1, resp);

                                PredefinedResponse.Save();
                                m_From.SendGump(new PredefGump(m_From, null));
                            }

                            break;
                        }
                        }
                    }
                }
            }
            else
            {
                ArrayList list = PredefinedResponse.List;

                switch (info.ButtonID)
                {
                case 1:
                {
                    list.Remove(m_Response);

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, null));
                    break;
                }

                case 2:
                {
                    TextRelay te = info.GetTextEntry(0);

                    if (te != null)
                    {
                        m_Response.Title = te.Text;
                    }

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, m_Response));

                    break;
                }

                case 3:
                {
                    TextRelay te = info.GetTextEntry(1);

                    if (te != null)
                    {
                        m_Response.Message = te.Text;
                    }

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, m_Response));

                    break;
                }
                }
            }
        }
Пример #8
0
        public PredefGump(Mobile from, PredefinedResponse response)
            : base(30, 30)
        {
            m_From     = from;
            m_Response = response;

            from.CloseGump(typeof(PredefGump));

            bool canEdit = (from.AccessLevel >= AccessLevel.GameMaster);

            AddPage(0);

            if (response == null)
            {
                if (from.NetState.IsEnhancedClient)
                {
                    AddBackground(1, 1, 408, 446, 9300);
                }
                else
                {
                    AddImageTiled(0, 0, 410, 448, 0xA40);
                    AddAlphaRegion(1, 1, 408, 446);
                }

                AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32), false, false);

                ArrayList list = PredefinedResponse.List;

                AddPage(1);

                int i;

                for (i = 0; i < list.Count; ++i)
                {
                    if (i >= 5 && (i % 5) == 0)
                    {
                        AddButton(368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1);
                        AddLabel(298, 10, 2100, "Next Page");
                        AddPage((i / 5) + 1);
                        AddButton(12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5);
                        AddLabel(48, 10, 2100, "Previous Page");
                    }

                    PredefinedResponse resp = (PredefinedResponse)list[i];

                    string html = String.Format("<u>{0}</u><br>{1}", resp.Title, resp.Message);

                    AddHtml(12, 44 + ((i % 5) * 80), 350, 70, html, true, true);

                    if (canEdit)
                    {
                        AddButton(370, 44 + ((i % 5) * 80) + 24, 0xFA5, 0xFA7, 2 + (i * 3), GumpButtonType.Reply, 0);

                        if (i > 0)
                        {
                            AddButton(377, 44 + ((i % 5) * 80) + 2, 0x15E0, 0x15E4, 3 + (i * 3), GumpButtonType.Reply, 0);
                        }
                        else
                        {
                            AddImage(377, 44 + ((i % 5) * 80) + 2, 0x25E4);
                        }

                        if (i < (list.Count - 1))
                        {
                            AddButton(377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + (i * 3), GumpButtonType.Reply, 0);
                        }
                        else
                        {
                            AddImage(377, 44 + ((i % 5) * 80) + 70 - 2 - 16, 0x25E8);
                        }
                    }
                }

                if (canEdit)
                {
                    if (i >= 5 && (i % 5) == 0)
                    {
                        AddButton(368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, (i / 5) + 1);
                        AddLabel(298, 10, 2100, "Next Page");
                        AddPage((i / 5) + 1);
                        AddButton(12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5);
                        AddLabel(48, 10, 2100, "Previous Page");
                    }

                    AddButton(12, 44 + ((i % 5) * 80), 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);
                    AddHtml(45, 44 + ((i % 5) * 80), 200, 20, Color("New Response", LabelColor32), false, false);
                }
            }
            else if (canEdit)
            {
                AddImageTiled(0, 0, 410, 250, 0xA40);

                if (from.NetState.IsEnhancedClient)
                {
                    AddBackground(1, 1, 408, 248, 9300);
                }
                else
                {
                    AddAlphaRegion(1, 1, 408, 248);
                }

                AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32), false, false);

                AddButton(10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0);
                AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32), false, false);

                AddButton(10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
                AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32), false, false);
                AddTextInput(10, 90, 300, 20, 0, response.Title);

                AddButton(10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
                AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32), false, false);
                AddTextInput(10, 140, 390, 100, 1, response.Message);
            }
        }
Пример #9
0
        public PredefGump(Mobile from, PredefinedResponse response) : base(30, 30)
        {
            m_From     = from;
            m_Response = response;

            from.CloseGump <PredefGump>();;

            bool canEdit = @from.AccessLevel >= AccessLevel.GameMaster;

            AddPage(0);

            if (response == null)
            {
                AddImageTiled(0, 0, 410, 448, 0xA40);
                AddAlphaRegion(1, 1, 408, 446);

                AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32), false, false);

                ArrayList list = PredefinedResponse.List;

                AddPage(1);

                int i;

                for (i = 0; i < list.Count; ++i)
                {
                    if (i >= 5 && i % 5 == 0)
                    {
                        AddButton(368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, i / 5 + 1);
                        AddLabel(298, 10, 2100, "Next Page");
                        AddPage(i / 5 + 1);
                        AddButton(12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5);
                        AddLabel(48, 10, 2100, "Previous Page");
                    }

                    PredefinedResponse resp = (PredefinedResponse)list[i];

                    string html = $"<u>{resp.Title}</u><br>{resp.Message}";

                    AddHtml(12, 44 + i % 5 * 80, 350, 70, html, true, true);

                    if (canEdit)
                    {
                        AddButton(370, 44 + i % 5 * 80 + 24, 0xFA5, 0xFA7, 2 + i * 3, GumpButtonType.Reply, 0);

                        if (i > 0)
                        {
                            AddButton(377, 44 + i % 5 * 80 + 2, 0x15E0, 0x15E4, 3 + i * 3, GumpButtonType.Reply, 0);
                        }
                        else
                        {
                            AddImage(377, 44 + i % 5 * 80 + 2, 0x25E4);
                        }

                        if (i < list.Count - 1)
                        {
                            AddButton(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x15E2, 0x15E6, 4 + i * 3, GumpButtonType.Reply, 0);
                        }
                        else
                        {
                            AddImage(377, 44 + i % 5 * 80 + 70 - 2 - 16, 0x25E8);
                        }
                    }
                }

                if (canEdit)
                {
                    if (i >= 5 && i % 5 == 0)
                    {
                        AddButton(368, 10, 0xFA5, 0xFA7, 0, GumpButtonType.Page, i / 5 + 1);
                        AddLabel(298, 10, 2100, "Next Page");
                        AddPage(i / 5 + 1);
                        AddButton(12, 10, 0xFAE, 0xFB0, 0, GumpButtonType.Page, i / 5);
                        AddLabel(48, 10, 2100, "Previous Page");
                    }

                    AddButton(12, 44 + i % 5 * 80, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);
                    AddHtml(45, 44 + i % 5 * 80, 200, 20, Color("New Response", LabelColor32), false, false);
                }
            }
            else if (canEdit)
            {
                AddImageTiled(0, 0, 410, 250, 0xA40);
                AddAlphaRegion(1, 1, 408, 248);

                AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32), false, false);

                AddButton(10, 40, 0xFB1, 0xFB3, 1, GumpButtonType.Reply, 0);
                AddHtml(45, 40, 200, 20, Color("Remove", LabelColor32), false, false);

                AddButton(10, 70, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);
                AddHtml(45, 70, 200, 20, Color("Title:", LabelColor32), false, false);
                AddTextInput(10, 90, 300, 20, 0, response.Title);

                AddButton(10, 120, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0);
                AddHtml(45, 120, 200, 20, Color("Message:", LabelColor32), false, false);
                AddTextInput(10, 140, 390, 100, 1, response.Message);
            }
        }