/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on May-15-2012 07:15:30pm
Filepath: scripts\Engines\donation\DonationGump.cs
Lines of code: 195

Description: 

***********************************************************/


using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Mobiles;
using Server.Prompts;
using Server.Items;
using Server.Gumps;
using Server.Network;

namespace Server.DonationSystem
{
	public class DonationGump : Gump
	{
		private Mobile m_Owner;
		private int m_Section;
		
		private enum Buttons
		{
			Close,
			Rewards,
			Status,
			Next,
		}	
		
		
		public enum Section
		{
			StartPage=0,
			Rewards=1
		}
		
		private static List<DonationItem> m_Items = new List<DonationItem>();
		
		
		public static void Initialize()
		{
			InitList();
		}
		
		
		
		public DonationGump( Mobile from,int section) : base( 250, 50 )
		{
			m_Owner = from;			
		
			Closable = true;
			Disposable = true;
			Dragable = true;
			Resizable = false;
			
			AddPage( 0 );
			
			AddImage( 0, 0, 0x1F40 );			
			AddImageTiled( 20, 37, 300, 308, 0x1F42 );			
			AddImage( 20, 325, 0x1F43 );			
			AddImage( 35, 8, 0x39 );			
			AddImageTiled( 65, 8, 257, 10, 0x3A );			
			AddImage( 290, 8, 0x3B );			
			AddImage( 32, 33, 0x2635 );			
			AddImageTiled( 70, 55, 230, 2, 0x23C5 );
			
			AddHtml( 70, 35, 270, 20, "Server Donation System", false, false ); // Community Collection
			
	
			
			// add pages
			
			m_Index = 0;
			if(m_Page==0)m_Page = 1;	
			
			m_Section=section;
			
			switch ( (Section)m_Section )
			{
				case Section.StartPage: DisplayStartPage();break;
				case Section.Rewards:
				{
					while ( m_Index < m_Items.Count )
					DisplayRewardPage();
					
				}break;
			}
		}
		
		private static void InitList()
		{
			//Args:  				    NAME 						TYPE					PRICE 	ITEMID	[HUE]	[AMOUNT]
			//-----------------------------------------------------------------------------------------------------------------------
			
			//skill items:
			
			m_Items.Add(new DonationItem("Skill Gain Deed - 20pts",typeof(skilldeed),			250,		5360,	259,		20));
			m_Items.Add(new DonationItem("Skill Gain Deed - 120pts",typeof(skilldeed),			1000,	5360,	259,		120));
			m_Items.Add(new DonationItem("Skill Gain Deed - 500pts",typeof(skilldeed),			2000,	5360,	259,		500));
			m_Items.Add(new DonationItem("Skill Gain Deed - 720pts",typeof(skilldeed),			3500,	5360,	259,		720));
			m_Items.Add(new DonationItem("5 Charge Soulstone Fragment",typeof(SoulstoneFragment),500,	10915));	
			m_Items.Add(new DonationItem("Soulstone",typeof(SoulStone),						2500,	10915));				
			m_Items.Add(new DonationItem("Pet Bonding Deed",typeof(PetBondingDeed),			500,		5360,	572,		1));			
			
			
			//gold

			m_Items.Add(new DonationItem("100k gold",typeof(BankCheck),					100,		5360,	52,		100000));
			m_Items.Add(new DonationItem("1 Million Gold",typeof(BankCheck),				700,		5360,	52,		1000000));			
			m_Items.Add(new DonationItem("3 Million Gold",typeof(BankCheck),				1500,	5360,	52,		3000000));			

			
			//harvest items
			m_Items.Add(new DonationItem("Gargoyle Pickaxe - 100 uses",typeof(GargoylesPickaxe),		30,		0xE86,	0x973,		100));
			m_Items.Add(new DonationItem("Gargoyle Pickaxe - 1000 uses",typeof(GargoylesPickaxe),		350,		0xE86,	0x973,		1000));

			m_Items.Add(new DonationItem("Reaper's axe - 100 uses",typeof(ReapersAxe),		30,		0xF49,	0x973,		100));
			m_Items.Add(new DonationItem("Reaper's axe - 1000 uses",typeof(ReapersAxe),		350,		0xF49,	0x973,		1000));
			
			
			
			//ethereals:
			
			m_Items.Add(new DonationItem("Ethereal Beetle",typeof(EtherealBeetle),			1000,	9743));
			m_Items.Add(new DonationItem("Ethereal Charger",typeof(EtherealCharger),			1000,	11676));
			m_Items.Add(new DonationItem("Ethereal Cusidhe",typeof(EtherealCusidhe),			1000,	11670));
			m_Items.Add(new DonationItem("Ethereal Hiryu",typeof(EtherealHiryu),				1000,	10090));
			m_Items.Add(new DonationItem("Ethereal Horse",typeof(EtherealHorse),				1000,	8413));
			m_Items.Add(new DonationItem("Ethereal Kirin",typeof(EtherealKirin),				1000,	9632));
			m_Items.Add(new DonationItem("Ethereal Llama ",typeof(EtherealLlama),				1000,	8438));
			m_Items.Add(new DonationItem("Ethereal Ostard",typeof(EtherealOstard),			1000,	8501));
			m_Items.Add(new DonationItem("Ethereal Polar Bear",typeof(EtherealPolarBear),		1000,	8417));
			m_Items.Add(new DonationItem("Ethereal Reptalon",typeof(EtherealReptalon),			1000,	11669));
			m_Items.Add(new DonationItem("Ethereal Ridgeback",typeof(EtherealRidgeback),		1000,	9749));
			m_Items.Add(new DonationItem("Ethereal Swamp Dragon",typeof(EtherealSwampDragon),	1000,	9753));
			m_Items.Add(new DonationItem("Ethereal Unicorn",typeof(EtherealUnicorn),			1000,	9678));
			m_Items.Add(new DonationItem("Ethereal Zostrich",typeof(EtherealZostrich),			1000,	8502));
			m_Items.Add(new DonationItem("Ethereal Sea Horse",typeof(EtherealSeahorse),		2000,	9658));		

			
			
			//weapon/armor:
			
			m_Items.Add(new DonationItem("Shamino's Best Crossbow",typeof(ShaminoCrossbow),	2000,	9923,	1284,	1));
			m_Items.Add(new DonationItem("The Holy Sword",typeof(HolySword),					2000,	3937,	1154,	1));
			m_Items.Add(new DonationItem("Ancient Samurai Helm",typeof(SamuraiHelm),			2500,	9068,	0,		1));
			m_Items.Add(new DonationItem("Royal Leggings of Embers",typeof(LeggingsOfEmbers),	3000,	5137,	44,		1));


			
			//misc items:
	

			m_Items.Add(new DonationItem("Evil Furniture",typeof(EvilFurnitureDeed),			1000,	10840));	
			m_Items.Add(new DonationItem("Rose of Trinsic",typeof(RoseOfTrinsic),				1000,	9037));	
			m_Items.Add(new DonationItem("Bed of Nails",typeof(BedOfNailsDeed),				1500,	10882));	
			m_Items.Add(new DonationItem("Evil Painting",typeof(EvilPaintingDeed),			1500,	10853));	
			m_Items.Add(new DonationItem("Haunted Mirror",typeof(HauntedMirrorDeed),			1500,	10875));	
			m_Items.Add(new DonationItem("Mounted pixie",typeof(MountedPixieDeed),			1500,	10869));	
			m_Items.Add(new DonationItem("Sacrificial Altar",typeof(SacrificialAltarDeed),		1500,	10909));	
			m_Items.Add(new DonationItem("Tapestry of Sosaria",typeof(TapestryOfSosaria),		1500,	9039));	
			m_Items.Add(new DonationItem("Hearth Of Home Fire",typeof(HearthOfHomeFire),		2000,	5360));	
			m_Items.Add(new DonationItem("Portable Anvil",typeof(PortableAnvil),				2500,	4015));	
			m_Items.Add(new DonationItem("Portable forge",typeof(PortableForge),				2500,	4017));	
			
			
			

			
		}
		
		

		
		private int m_Index;
		private int m_Page=0;
		private int m_Max;
		
		
		public void DisplayStartPage()
		{			
			
			AddHtml( 50, 66, 260, 300, "This system will allow you to make a (real life) monetary donation to help support the server.  In return, we will give you donation points, which can be used to purchase various special items here.\n\nNote: Reward item pictures may differ from actual item.\n\nNote: $1 = " + DonationHandler.PointsPerDollar + " points", (bool)false, (bool)false);
			
			
			AddButton( 45, 266, 0x15E1, 0x15E5, 1, GumpButtonType.Reply, 0 ); //arrow pointing right
			AddLabel( 60,264, 0, "Donate now (will open your browser)");
		

			AddButton( 45, 286, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 ); //arrow pointing right
			AddLabel( 60,284, 0, "Spend donation points");
		
		
		}
		
		public void DisplayRewardPage()
		{
			int points = DonationHandler.GetPoints(m_Owner);
			
			const int itemsperpage=4;
			
			
			AddPage( m_Page );
			
			// title
			AddHtmlLocalized( 50, 65, 150, 20, 1072843, 0x1, false, false ); // Your Reward Points:
			AddLabel( 230, 65, 0x64, points.ToString() );				
			AddImageTiled( 35, 85, 270, 2, 0x23C5 );			
			AddHtmlLocalized( 35, 90, 270, 20, 1072844, 0x1, false, false ); // Please Choose a Reward:
			
			
			
			for(int i=0;i<itemsperpage;i++)
			{
				m_Index++;
								
				if(m_Index>=m_Items.Count)break;
			
			
				AddButton( 30, 110+(i*50),0x837, 0x838, 100 + m_Index, GumpButtonType.Reply, 0 );
				AddItem( 40, 100+(i*50) , m_Items[m_Index].ItemID,m_Items[m_Index].Hue );
				AddLabel( 120, 110+(i*50) , 0x64, m_Items[m_Index].Name );
				AddLabel( 120, 125+(i*50) , m_Items[m_Index].Price>points ? 42 : 61, "Cost: " + m_Items[m_Index].Price.ToString() + " Points" );
			
			}
					

			
			
					
			// buttons:

			
			if ( m_Page > 1 )
			{
				AddButton( 150, 335, 0x15E3, 0x15E7, (int) Buttons.Next, GumpButtonType.Page, m_Page - 1 );
				AddHtmlLocalized( 170, 335, 60, 20, 1074880, 0x1, false, false ); // Previous			
			}			
			
			m_Page += 1;
			
			if ( m_Index+1 < m_Items.Count )
			{
				AddButton( 300, 335, 0x15E1, 0x15E5, (int) Buttons.Next, GumpButtonType.Page, m_Page );
				AddHtmlLocalized( 240, 335, 60, 20, 1072854, 0x1, false, false ); // <div align=right>Next</div>
			}
		}
		
		
		public override void OnResponse( Server.Network.NetState state, RelayInfo info )
		{
			
			switch((Section)m_Section)
			{
				case Section.StartPage:
				{
					//open browser:
					if(info.ButtonID==1)
					{
						if(m_Owner.Account==null)m_Owner.SendMessage("Fatal error: Account is null!");
						else m_Owner.Send(new LaunchBrowser("http://donate.uovalor.com/index.php?uoaccount="+m_Owner.Account.Username));	
					}
					else if(info.ButtonID==2)
					{
						m_Owner.SendGump( new DonationGump(m_Owner,1) );
					}
				
				
				
				
				}break;
				case Section.Rewards:
				{
					//get reward:
					
					if(info.ButtonID>=100 && info.ButtonID<=100+m_Items.Count)
					{
						m_Owner.CloseGump( typeof(ConfirmRewardGump));
						m_Owner.SendGump( new ConfirmRewardGump(m_Items[info.ButtonID-100]) );
					}
				
				}break;
			
			}
			
		}
		
		
		
		
		
		
		
		
		
		
		
		public class ConfirmRewardGump : BaseConfirmGump
		{
			public override int TitleNumber{ get{ return 1074974; } } // Confirm Selection
			public override int LabelNumber{ get{ return 1074975; } } // Are you sure you wish to select this?
		
			DonationItem m_Item;
		
			public ConfirmRewardGump( DonationItem item ) : base()
			{
				m_Item = item;
				
				if ( m_Item != null )
					AddItem( 15, 75, m_Item.ItemID, m_Item.Hue );
					
					
				AddHtml( 15, 130, 300, 45, "<font color=\"#ffffff\">Please ensure you agree to the terms of the <a href=\"http://donate.uovalor.com/eula.php\">license agreement</a> before continuing.</font>", (bool)true, (bool)false);
					
				
			}
			
			public override void Confirm( Mobile from )
			{			
				m_Item.TryGiveItem(from);
			}
		}
	
	}
	
	
}