//////////////////////////////////////////////////////////////////////
// Automatically generated by Bradley's GumpStudio and roadmaster's
// exporter.dll, Special thanks goes to Daegon whose work the exporter
// was based off of, and Shadow wolf for his Template Idea.
//////////////////////////////////////////////////////////////////////
//#define RunUo2_0
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class CustomCharGump : Gump
{
public class SheetInfos
{
public int ButtonID = 0;
public int ChoosenCity { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
private Mobile caller;
private SheetInfos sheetInfos;
private int currentSelected;
private GumpButton[] professionButtons;
public static void Initialize()
{
CommandSystem.Register("CustomCharGump", AccessLevel.Administrator, new CommandEventHandler(_OnCommand));
}
[Usage("CustomCharGump")]
[Description("Makes a call to your custom gump.")]
public static void _OnCommand(CommandEventArgs e)
{
var caller = e.Mobile;
if (caller.HasGump(typeof(CustomCharGump)))
caller.CloseGump(typeof(CustomCharGump));
caller.SendGump(new CustomCharGump(caller));
}
public CustomCharGump(Mobile from) : this()
{
caller = from;
InitializeButtons();
AddButtonEntries();
LoadGumpElements();
}
public CustomCharGump(Mobile from, SheetInfos infos) : this()
{
sheetInfos = infos;
caller = from;
if(infos.ButtonID > 0)
{
SetButtonActive(infos.ButtonID);
}
else
{
InitializeButtons();
AddButtonEntries();
}
LoadGumpElements();
}
public CustomCharGump() : base(0, 0)
{
this.Closable = false;
this.Disposable = false;
this.Dragable = true;
this.Resizable = false;
AddPage(0);
AddBackground(148, 30, 422, 545, 9300);
AddLabel(179, 63, 0, @"First Name");
AddLabel(321, 507, 37, @"");
AddButton(321, 540, 247, 248, 0, GumpButtonType.Reply, 0);
AddLabel(183, 396, 0, @"Hunter");
AddLabel(280, 396, 0, @"Carpenter");
AddLabel(393, 396, 0, @"Noble");
AddLabel(478, 396, 0, @"Mercenary");
AddLabel(185, 499, 0, @"Sailor");
AddLabel(292, 499, 0, @"Knight");
AddLabel(379, 499, 0, @"Blacksmith");
AddLabel(472, 499, 0, @"Broken Lord");
AddHtml(565, 43, 201, 524, @"
<b>Olar</b>
vai Cagar", (bool)true, (bool)true);
AddLabel(302, 278, 0, @"Choose Profession");
InitializeButtons();
}
private void LoadGumpElements()
{
AddBackground(172, 92, 162, 25, 9350);
AddTextEntry(175, 94, 157, 23, 0, 0, sheetInfos != null ? sheetInfos.FirstName : @"", 10);
AddLabel(389, 63, 0, @"Last Name");
AddBackground(382, 92, 162, 25, 9350);
AddTextEntry(385, 94, 157, 23, 0, 2, sheetInfos != null ? sheetInfos.LastName : @"", 10);
AddRadio(181, 187, 209, 208, sheetInfos != null ? sheetInfos.ChoosenCity == 1 ? true : false : true, 1);
AddLabel(302, 150, 0, @"Choose Kingdom");
AddLabel(204, 187, 0, @"Britannia");
AddRadio(181, 216, 209, 208, sheetInfos != null ? sheetInfos.ChoosenCity == 2 ? true : false : false, 2);
AddLabel(204, 216, 0, @"Trinsic");
AddRadio(181, 245, 209, 208, sheetInfos != null ? sheetInfos.ChoosenCity == 3 ? true : false : false, 3);
AddLabel(204, 245, 0, @"Skara Brae");
}
public override void OnResponse(NetState sender, RelayInfo info)
{
var sheet = new SheetInfos();
Mobile from = sender.Mobile;
TextRelay entry0 = info.GetTextEntry(0);
sheet.FirstName = (entry0 == null ? "" : entry0.Text.Trim());
TextRelay entry2 = info.GetTextEntry(2);
sheet.LastName = (entry2 == null ? "" : entry2.Text.Trim());
if(info.ButtonID != 0)
{
for(int i = 0; i < info.Switches.Length; i++)
{
if(info.IsSwitched(info.Switches[i]))
{
sheet.ChoosenCity = info.Switches[i];
}
}
sheet.ButtonID = info.ButtonID;
//SetButtonActive(info.ButtonID);
caller.SendGump(new CustomCharGump(caller,sheet));
}
}
private void InitializeButtons()
{
professionButtons = new GumpButton[8];
professionButtons[0] = new GumpButton(176, 329, 5575, 5576, 1, GumpButtonType.Reply, 0);
professionButtons[1] = new GumpButton(283, 329, 5559, 5560, 2, GumpButtonType.Reply, 0);
professionButtons[2] = new GumpButton(382, 329, 5571, 5572, 3, GumpButtonType.Reply, 0);
professionButtons[3] = new GumpButton(481, 329, 5577, 5578, 4, GumpButtonType.Reply, 0);
professionButtons[4] = new GumpButton(176, 431, 5565, 5566, 5, GumpButtonType.Reply, 0);
professionButtons[5] = new GumpButton(283, 431, 5587, 5588, 6, GumpButtonType.Reply, 0);
professionButtons[6] = new GumpButton(382, 431, 5555, 5556, 7, GumpButtonType.Reply, 0);
professionButtons[7] = new GumpButton(481, 431, 5573, 5574, 8, GumpButtonType.Reply, 0);
}
private void SetButtonActive(int buttonID)
{
switch(buttonID)
{
case 1:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[0] = new GumpButton(176, 329, 5576, 5576, 1, GumpButtonType.Page, 0);
AddButtonEntries();
break;
}
case 2:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[1] = new GumpButton(283, 329, 5560, 5560, 2, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 3:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[2] = new GumpButton(382, 329, 5572, 5572, 3, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 4:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[3] = new GumpButton(481, 329, 5578, 5578, 4, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 5:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[4] = new GumpButton(176, 431, 5566, 5566, 5, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 6:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[5] = new GumpButton(283, 431, 5588, 5588, 6, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 7:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[6] = new GumpButton(382, 431, 5556, 5556, 7, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
case 8:
{
RemoveButtonEntries();
InitializeButtons();
professionButtons[7] = new GumpButton(481, 431, 5574, 5574, 8, GumpButtonType.Reply, 0);
AddButtonEntries();
break;
}
}
}
private void RemoveButtonEntries()
{
for (int i = 0; i < professionButtons.Length; i++)
{
this.Entries.Remove(professionButtons[i]);
}
}
private void AddButtonEntries()
{
for (int i = 0; i < professionButtons.Length; i++)
{
this.Add(professionButtons[i]);
}
}
}
}