ModernUO/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs
Kamron Batman 8282b00ca2
feat: Moves gumps out of the core (#1916)
> [!Important]
> **Developer Note**
> This code change will **completely move gumps out of the core**


### Summary

- Adds `GetGumps()` convenience which exposes methods to Find/Close/Send multiple gumps. This helper is a performance improvement by eliminating the Dictionary<Player, List> lookup for gumps.
2024-08-09 19:07:32 -07:00

79 lines
2.1 KiB
C#

using Server.Items;
using Server.Multis;
using Server.Network;
namespace Server.Gumps
{
public class RewardDemolitionGump : Gump
{
private readonly IAddon m_Addon;
public override bool Singleton => true;
public RewardDemolitionGump(IAddon addon, int question) : base(150, 50)
{
m_Addon = addon;
Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
AddBackground(0, 0, 220, 170, 0x13BE);
AddBackground(10, 10, 200, 150, 0xBB8);
AddHtmlLocalized(20, 30, 180, 60, question); // Do you wish to re-deed this decoration?
AddHtmlLocalized(55, 100, 150, 25, 1011011); // CONTINUE
AddButton(20, 100, 0xFA5, 0xFA7, (int)Buttons.Confirm);
AddHtmlLocalized(55, 125, 150, 25, 1011012); // CANCEL
AddButton(20, 125, 0xFA5, 0xFA7, (int)Buttons.Cancel);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (m_Addon is not Item item || item.Deleted)
{
return;
}
if (info.ButtonID != (int)Buttons.Confirm)
{
return;
}
var m = sender.Mobile;
var house = BaseHouse.FindHouseAt(m);
if (house?.IsOwner(m) != true)
{
// You can only re-deed this decoration if you are the house owner or originally placed the decoration.
m.SendLocalizedMessage(1049784);
return;
}
if (m.InRange(item.Location, 2))
{
var deed = m_Addon.Deed;
if (deed != null)
{
m.AddToBackpack(deed);
house.Addons.Remove(item);
item.Delete();
}
}
else
{
m.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
}
}
private enum Buttons
{
Cancel,
Confirm
}
}
}