fix: Updates BOB/BOD gumps to the new API (#2250)
### Summary * Moves BOBGump to DynamicGump. * BOBGump no longer creates a whole new gump context object on every send. * Moves BODBuyGump to StaticGump.
This commit is contained in:
parent
340acafcb3
commit
641a3eb1f8
2 changed files with 750 additions and 769 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -3,135 +3,142 @@ using Server.Items;
|
||||||
using Server.Mobiles;
|
using Server.Mobiles;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
||||||
namespace Server.Engines.BulkOrders
|
namespace Server.Engines.BulkOrders;
|
||||||
|
|
||||||
|
public class BODBuyGump : StaticGump<BODBuyGump>
|
||||||
{
|
{
|
||||||
public class BODBuyGump : Gump
|
private BOBGump _gump;
|
||||||
|
private readonly IBOBEntry _entry;
|
||||||
|
private readonly int _price;
|
||||||
|
|
||||||
|
public BODBuyGump(BOBGump gump, IBOBEntry entry, int price) : base(100, 200)
|
||||||
{
|
{
|
||||||
private readonly BulkOrderBook m_Book;
|
_gump = gump;
|
||||||
private readonly IBOBEntry m_Entry;
|
_entry = entry;
|
||||||
private readonly PlayerMobile m_From;
|
_price = price;
|
||||||
private readonly int m_Page;
|
}
|
||||||
private readonly int m_Price;
|
|
||||||
|
|
||||||
public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200)
|
protected override void BuildLayout(ref StaticGumpBuilder builder)
|
||||||
|
{
|
||||||
|
builder.AddPage();
|
||||||
|
|
||||||
|
builder.AddBackground(100, 10, 300, 150, 5054);
|
||||||
|
|
||||||
|
builder.AddHtmlLocalized(125, 20, 250, 24, 1019070); // You have agreed to purchase:
|
||||||
|
builder.AddHtmlLocalized(125, 45, 250, 24, 1045151); // a bulk order deed
|
||||||
|
|
||||||
|
builder.AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of:
|
||||||
|
builder.AddLabelPlaceholder(125, 95, 0, "price");
|
||||||
|
|
||||||
|
builder.AddButton(250, 130, 4005, 4007, 1);
|
||||||
|
builder.AddHtmlLocalized(282, 130, 100, 24, 1011012); // CANCEL
|
||||||
|
|
||||||
|
builder.AddButton(120, 130, 4005, 4007, 2);
|
||||||
|
builder.AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void BuildStrings(ref GumpStringsBuilder builder)
|
||||||
|
{
|
||||||
|
builder.SetStringSlot("price", $"{_price:N0}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||||
|
{
|
||||||
|
if (sender.Mobile is not PlayerMobile pm)
|
||||||
{
|
{
|
||||||
m_From = from;
|
return;
|
||||||
m_Book = book;
|
|
||||||
m_Entry = entry;
|
|
||||||
m_Price = price;
|
|
||||||
m_Page = page;
|
|
||||||
|
|
||||||
AddPage(0);
|
|
||||||
|
|
||||||
AddBackground(100, 10, 300, 150, 5054);
|
|
||||||
|
|
||||||
AddHtmlLocalized(125, 20, 250, 24, 1019070); // You have agreed to purchase:
|
|
||||||
AddHtmlLocalized(125, 45, 250, 24, 1045151); // a bulk order deed
|
|
||||||
|
|
||||||
AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of:
|
|
||||||
AddLabel(125, 95, 0, price.ToString());
|
|
||||||
|
|
||||||
AddButton(250, 130, 4005, 4007, 1);
|
|
||||||
AddHtmlLocalized(282, 130, 100, 24, 1011012); // CANCEL
|
|
||||||
|
|
||||||
AddButton(120, 130, 4005, 4007, 2);
|
|
||||||
AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
if (info.ButtonID != 2)
|
||||||
{
|
{
|
||||||
if (info.ButtonID != 2)
|
pm.SendLocalizedMessage(503207); // Cancelled purchase.
|
||||||
{
|
return;
|
||||||
m_From.SendLocalizedMessage(503207); // Cancelled purchase.
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Book.RootParent is not PlayerVendor pv)
|
var book = _gump.Book;
|
||||||
{
|
|
||||||
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_Book.Entries.Contains(m_Entry))
|
if (book.RootParent is not PlayerVendor pv)
|
||||||
{
|
{
|
||||||
pv.SayTo(m_From, 1062382); // The deed selected is not available.
|
pm.SendLocalizedMessage(1062382); // The deed selected is not available.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var price = 0;
|
if (!book.Entries.Contains(_entry))
|
||||||
|
{
|
||||||
|
pv.SayTo(pm, 1062382); // The deed selected is not available.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pv.GetVendorItem(m_Book)?.IsForSale == false)
|
var price = 0;
|
||||||
{
|
|
||||||
price = m_Entry.Price;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (price != m_Price)
|
if (pv.GetVendorItem(book)?.IsForSale == false)
|
||||||
{
|
{
|
||||||
pv.SayTo(
|
price = _entry.Price;
|
||||||
m_From,
|
}
|
||||||
"The price has been been changed. If you like, you may offer to purchase the item again."
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (price == 0)
|
if (price != _price)
|
||||||
{
|
{
|
||||||
pv.SayTo(m_From, 1062382); // The deed selected is not available.
|
pv.SayTo(
|
||||||
return;
|
pm,
|
||||||
}
|
"The price has been been changed. If you like, you may offer to purchase the item again."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var item = m_Entry.Reconstruct();
|
if (price == 0)
|
||||||
|
{
|
||||||
|
pv.SayTo(pm, 1062382); // The deed selected is not available.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pv.Say(m_From.Name);
|
var item = _entry.Reconstruct();
|
||||||
|
|
||||||
var pack = m_From.Backpack;
|
pv.Say(pm.Name);
|
||||||
|
|
||||||
if (pack?.CheckHold(
|
var pack = pm.Backpack;
|
||||||
m_From,
|
|
||||||
|
if (pack?.CheckHold(
|
||||||
|
pm,
|
||||||
item,
|
item,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
0,
|
0,
|
||||||
item.PileWeight + item.TotalWeight
|
item.PileWeight + item.TotalWeight
|
||||||
) != true)
|
) != true)
|
||||||
|
{
|
||||||
|
pv.SayTo(pm, 503204); // You do not have room in your backpack for this
|
||||||
|
pm.SendGump(_gump);
|
||||||
|
item.Delete();
|
||||||
|
}
|
||||||
|
else if (pack.ConsumeTotal(typeof(Gold), price) || Banker.Withdraw(pm, price))
|
||||||
|
{
|
||||||
|
book.RemoveEntry(_entry);
|
||||||
|
pv.HoldGold += price;
|
||||||
|
pm.AddToBackpack(item);
|
||||||
|
|
||||||
|
// The bulk order deed has been placed in your backpack.
|
||||||
|
pm.SendLocalizedMessage(1045152);
|
||||||
|
|
||||||
|
if (book.Entries.Count / 5 < book.ItemCount)
|
||||||
{
|
{
|
||||||
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
|
book.ItemCount--;
|
||||||
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
|
book.InvalidateItems();
|
||||||
item.Delete();
|
}
|
||||||
|
|
||||||
|
if (book.Entries.Count > 0)
|
||||||
|
{
|
||||||
|
_gump.ResetList();
|
||||||
|
pm.SendGump(_gump);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pack.ConsumeTotal(typeof(Gold), price) || Banker.Withdraw(m_From, price))
|
pm.SendLocalizedMessage(1062381); // The book is empty.
|
||||||
{
|
|
||||||
m_Book.RemoveEntry(m_Entry);
|
|
||||||
m_Book.InvalidateProperties();
|
|
||||||
pv.HoldGold += price;
|
|
||||||
m_From.AddToBackpack(item);
|
|
||||||
|
|
||||||
// The bulk order deed has been placed in your backpack.
|
|
||||||
m_From.SendLocalizedMessage(1045152);
|
|
||||||
|
|
||||||
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
|
|
||||||
{
|
|
||||||
m_Book.ItemCount--;
|
|
||||||
m_Book.InvalidateItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Book.Entries.Count > 0)
|
|
||||||
{
|
|
||||||
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_From.SendLocalizedMessage(1062381); // The book is empty.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pv.SayTo(m_From, 503205); // You cannot afford this item.
|
|
||||||
item.Delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pv.SayTo(pm, 503205); // You cannot afford this item.
|
||||||
|
item.Delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue