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

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

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

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

        [Usage("IntensityControl")]
        [Description("Makes a call to your custom gump.")]
        public static void IntensityControl_OnCommand(CommandEventArgs e)
        {
            if (e.Mobile.HasGump(typeof(IntensityControlGump)))
                e.Mobile.CloseGump(typeof(IntensityControlGump));
            e.Mobile.SendGump(new IntensityControlGump(e.Mobile));
        }

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

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

			AddPage(0);
			AddBackground(0, 0, 257, 299, 9250);
			AddBackground(15, 15, 226, 45, 9260);
			AddImageTiled(30, 26, 196, 21, 1122);
			AddBackground(15, 60, 226, 226, 9260);
			AddLabel(35, 25, 999, @"Item Intensity Control System");
			AddLabel(33, 115, 999, @"Felucca");
			AddLabel(33, 195, 999, @"Tokuno");
			AddLabel(33, 175, 999, @"Malas");
			AddLabel(33, 155, 999, @"Ilshenar");
			AddLabel(33, 135, 999, @"Trammel");
			AddLabel(33, 215, 999, @"TerMur");
			AddImageTiled(92, 116, 63, 21, 2443);
			AddImageTiled(92, 215, 63, 21, 2443);
			AddImageTiled(92, 195, 63, 21, 2443);
			AddImageTiled(92, 175, 63, 21, 2443);
			AddImageTiled(92, 155, 63, 21, 2443);
			AddImageTiled(92, 135, 63, 21, 2443);
            AddTextEntry(100, 115, 47, 20, 999, 5, LootController.FeluccaMinIntensity.ToString());
            AddTextEntry(100, 215, 47, 20, 999, 6, LootController.TerMurMinIntensity.ToString());
            AddTextEntry(100, 194, 47, 20, 999, 7, LootController.TokunoMinIntensity.ToString());
            AddTextEntry(100, 177, 47, 20, 999, 8, LootController.MalasMinIntensity.ToString());
            AddTextEntry(100, 156, 47, 20, 999, 9, LootController.IlshenarMinIntensity.ToString());
            AddTextEntry(100, 138, 47, 20, 999, 10, LootController.TrammelMinIntensity.ToString());
			AddButton(159, 245, 242, 241, (int)Buttons.cancelbutton, GumpButtonType.Reply, 0);
			AddButton(91, 245, 248, 247, (int)Buttons.okaybutton, GumpButtonType.Reply, 0);
			AddLabel(109, 90, 999, @"Min");
			AddImageTiled(159, 116, 63, 21, 2443);
			AddImageTiled(159, 215, 63, 21, 2443);
			AddImageTiled(159, 195, 63, 21, 2443);
			AddImageTiled(159, 175, 63, 21, 2443);
			AddImageTiled(159, 155, 63, 21, 2443);
			AddImageTiled(159, 135, 63, 21, 2443);
            AddTextEntry(167, 115, 47, 20, 999, 11, LootController.FeluccaMaxIntensity.ToString());
            AddTextEntry(168, 215, 47, 20, 999, 12, LootController.TerMurMaxIntensity.ToString());
            AddTextEntry(167, 194, 47, 20, 999, 13, LootController.TokunoMaxIntensity.ToString());
            AddTextEntry(167, 177, 47, 20, 999, 14, LootController.MalasMaxIntensity.ToString());
            AddTextEntry(167, 156, 47, 20, 999, 15, LootController.IlshenarMaxIntensity.ToString());
            AddTextEntry(167, 138, 47, 20, 999, 16, LootController.TrammelMaxIntensity.ToString());
			AddLabel(176, 89, 999, @"Max");
        }

        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.FeluccaMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(11);
                             temp = (string)relay.Text.Trim();
                             LootController.FeluccaMaxIntensity = Convert.ToInt32(temp);
                             //Trammel
                             relay = (TextRelay)info.GetTextEntry(10);
                             temp = (string)relay.Text.Trim();
                             LootController.TrammelMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(16);
                             temp = (string)relay.Text.Trim();
                             LootController.TrammelMaxIntensity = Convert.ToInt32(temp);
                             //Ilshenar
                             relay = (TextRelay)info.GetTextEntry(9);
                             temp = (string)relay.Text.Trim();
                             LootController.IlshenarMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(15);
                             temp = (string)relay.Text.Trim();
                             LootController.IlshenarMaxIntensity = Convert.ToInt32(temp);
                             //Malas
                             relay = (TextRelay)info.GetTextEntry(8);
                             temp = (string)relay.Text.Trim();
                             LootController.MalasMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(14);
                             temp = (string)relay.Text.Trim();
                             LootController.MalasMaxIntensity = Convert.ToInt32(temp);
                             //Tokuno
                             relay = (TextRelay)info.GetTextEntry(7);
                             temp = (string)relay.Text.Trim();
                             LootController.TokunoMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(13);
                             temp = (string)relay.Text.Trim();
                             LootController.TokunoMaxIntensity = Convert.ToInt32(temp);
                             //TerMur
                             relay = (TextRelay)info.GetTextEntry(6);
                             temp = (string)relay.Text.Trim();
                             LootController.TerMurMinIntensity = Convert.ToInt32(temp);
                             relay = (TextRelay)info.GetTextEntry(12);
                             temp = (string)relay.Text.Trim();
                             LootController.TerMurMaxIntensity = Convert.ToInt32(temp);
                             from.SendMessage("The item intensity 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?");
                         }
                         break;
                     }
             }
        }
    }
}