
//////////////////////////////////////////////////////////////////////
// PandoraUO.com
//////////////////////////////////////////////////////////////////////

using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
using Server.Items;

namespace Server.Gumps
{
    public class GoldControlGump : Gump
    {
        private Mobile caller;

        public static void Initialize()
        {
            CommandSystem.Register("GoldControl", AccessLevel.Developer, new CommandEventHandler(GoldControl_OnCommand));
        }

        [Usage("GoldControl")]
        [Description("Makes a call to your custom gump.")]
        public static void GoldControl_OnCommand(CommandEventArgs e)
        {
            if (e.Mobile.HasGump(typeof(GoldControlGump)))
                e.Mobile.CloseGump(typeof(GoldControlGump));

            e.Mobile.SendGump(new GoldControlGump(e.Mobile));
        }

        public GoldControlGump(Mobile from) : this()
        {
            caller = from;
        }

        public GoldControlGump() : base( 0, 0 )
        {
            Closable=false;
			Disposable=true;
			Dragable=true;
			Resizable=false;

			AddPage(0);
			AddBackground(0, 0, 192, 264, 9250);
			AddBackground(15, 15, 163, 45, 9260);
			AddImageTiled(30, 26, 130, 21, 1122);
			AddBackground(15, 60, 163, 190, 9260);
			AddLabel(31, 26, 999, @"PandoraUO Gold Control");
			AddLabel(33, 75, 999, @"Felucca");
			AddLabel(33, 155, 999, @"Tokuno");
			AddLabel(33, 135, 999, @"Malas");
			AddLabel(33, 115, 999, @"Ilshenar");
			AddLabel(33, 95, 999, @"Trammel");
			AddLabel(33, 175, 999, @"TerMur");

			AddImageTiled(92, 76, 63, 21, 2443);
			AddImageTiled(92, 175, 63, 21, 2443);
			AddImageTiled(92, 155, 63, 21, 2443);
			AddImageTiled(92, 135, 63, 21, 2443);
			AddImageTiled(92, 115, 63, 21, 2443);
			AddImageTiled(92, 95, 63, 21, 2443);

			AddTextEntry(100, 75, 47, 20,  999,  5, LootController.FeluccaGold.ToString());
			AddTextEntry(101, 175, 47, 20, 999,  6, LootController.TerMurGold.ToString());
			AddTextEntry(100, 154, 47, 20, 999,  7, LootController.TokunoGold.ToString());
			AddTextEntry(100, 137, 47, 20, 999,  8, LootController.MalasGold.ToString());
			AddTextEntry(100, 116, 47, 20, 999,  9, LootController.IlshenarGold.ToString());
			AddTextEntry(100, 98,  47, 20, 999, 10, LootController.TrammelGold.ToString());

			AddButton(97, 205, 242, 241, (int)Buttons.cancelbutton, GumpButtonType.Reply, 0);
			AddButton(30, 205, 248, 247, (int)Buttons.okaybutton, GumpButtonType.Reply, 0);
			
        }

        public enum Buttons
		{
			cancelbutton,
			okaybutton,
		}


        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch(info.ButtonID)
            {
                case (int)Buttons.cancelbutton:
				{
                    from.SendMessage("you decided not to make any gold control adjustments...");
					break;
				}
				case (int)Buttons.okaybutton:
				{
                    try
                    {
                        string temp;
                        TextRelay relay;
                        //felucca
                        relay = (TextRelay)info.GetTextEntry(5);
                        temp = (string)relay.Text.Trim();
                        LootController.FeluccaGold = Convert.ToDouble(temp);
                        //Trammel
                        relay = (TextRelay)info.GetTextEntry(10);
                        temp = (string)relay.Text.Trim();
                        LootController.TrammelGold = Convert.ToDouble(temp);
                        //Ilshenar
                        relay = (TextRelay)info.GetTextEntry(9);
                        temp = (string)relay.Text.Trim();
                        LootController.IlshenarGold = Convert.ToDouble(temp);
                        //Malas
                        relay = (TextRelay)info.GetTextEntry(8);
                        temp = (string)relay.Text.Trim();
                        LootController.MalasGold = Convert.ToDouble(temp);
                        //Tokuno
                        relay = (TextRelay)info.GetTextEntry(7);
                        temp = (string)relay.Text.Trim();
                        LootController.TokunoGold = Convert.ToDouble(temp);
                        //TerMur
                        relay = (TextRelay)info.GetTextEntry(6);
                        temp = (string)relay.Text.Trim();
                        LootController.TerMurGold = Convert.ToDouble(temp);
                        from.SendMessage("The gold control system has been updated, and awaiting server save to serialize...");
                    }
                    catch
                    {
                        from.SendMessage("You seem to have missed something, perhaps left a entry blank, or didnt use a decimal format 0.85 or 1.37?");
                    }
					break;
				}

            }
        }
    }
}