diff --git a/Projects/UOContent/Gumps/SciterTestGump.cs b/Projects/UOContent/Gumps/SciterTestGump.cs index ce6b87a43..4147c24c8 100644 --- a/Projects/UOContent/Gumps/SciterTestGump.cs +++ b/Projects/UOContent/Gumps/SciterTestGump.cs @@ -1,4 +1,5 @@ using Server.Gumps; +using Server.Items; using Server.Network; using System; using System.IO; @@ -8,20 +9,48 @@ namespace Server.Gumps { public class SciterTestGump : Gump { + public class Item + { + public string Name { get; set; } + public int Count { get; set; } + } public class Shop { - public string[] ShopItems { get; set; } = new string[] { "item1", "item2" }; + public Item[] ShopItems { get; set; } = new Item[] + { + new Item(){Name="Arrow",Count = 10 }, + new Item(){Name="Bolt",Count = 10 }, + new Item(){Name="Gold",Count = 20000 }, + }; } - + public Shop _shop = new Shop(); public SciterTestGump(Mobile user) : base( 0, 0 ) { UseWebRender = true; - AddBody(Body()); + AddBody(body()); } + + public void TryToAddItem(Mobile m, int index) + { + if (_shop.ShopItems.Length < index) + return; + + var itemName = _shop.ShopItems[index].Name; + var itemCount = Convert.ToInt32(_shop.ShopItems[index].Count); + + var type = AssemblyHandler.FindTypeByName(itemName); + + var item = Activator.CreateInstance(type, args: new object[] { itemCount }); + if (item is Server.Item _item) + { + m.AddToBackpack(_item); + } + + } public override void OnResponse(NetState sender, RelayInfo info) { var from = sender.Mobile; @@ -30,263 +59,229 @@ namespace Server.Gumps case 0: // close sender.RemoveGump(this); break; - case 1: // hide - from.Hidden = true; + case 1: + SendData(from, "1", _shop); break; - case 2: // unhide - from.Hidden = false; + case 2: + TryToAddItem(from, Convert.ToInt32(info.TextEntries[0].Text)); break; - case 3: // sendDataToCLeint - SendData(from, "ShowSend", new Shop()); - break; - case 4: // showData - var builder = new StringBuilder(); - for (int i = 0; i < info.TextEntries.Length; i++) - { - var test = info.TextEntries[i].Text; - builder.Append("argument "); - builder.Append(i.ToString()); - builder.Append(" = "); - builder.Append(test); - builder.Append(" "); - } - from.SendAsciiMessage(builder.ToString()); - - break; default: break; - - } + } - public string Body() + public string body() { - return "\r\n" + - "
\r\n" + - "