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.
This commit is contained in:
Kamron Batman 2024-08-09 19:07:32 -07:00 • committed by GitHub
parent 40d99f6d1c
commit 8282b00ca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
246 changed files with 1722 additions and 1383 deletions

View file

@ -212,7 +212,6 @@ public partial class DawnsMusicBox : Item, ISecurable
}
else
{
from.CloseGump<DawnsMusicBoxGump>();
from.SendGump(new DawnsMusicBoxGump(this));
}
}

View file

@ -1,4 +1,4 @@
using Server.Items;
using Server.Items;
using Server.Network;
namespace Server.Gumps;
@ -7,6 +7,8 @@ public class DawnsMusicBoxGump : Gump
{
private readonly DawnsMusicBox m_Box;
public override bool Singleton => true;
public DawnsMusicBoxGump(DawnsMusicBox box) : base(60, 36)
{
m_Box = box;

View file

@ -45,7 +45,6 @@ public partial class BrokenBedDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -63,6 +62,8 @@ public partial class BrokenBedDeed : BaseAddonDeed
{
private readonly BrokenBedDeed _deed;
public override bool Singleton => true;
public InternalGump(BrokenBedDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -40,7 +40,6 @@ public partial class BrokenVanityDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -58,6 +57,8 @@ public partial class BrokenVanityDeed : BaseAddonDeed
{
private readonly BrokenVanityDeed _deed;
public override bool Singleton => true;
public InternalGump(BrokenVanityDeed deed) : base(60, 63)
{
_deed = deed;

View file

@ -47,7 +47,6 @@ public partial class HearthOfHomeFireDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -65,6 +64,8 @@ public partial class HearthOfHomeFireDeed : BaseAddonDeed
{
private readonly HearthOfHomeFireDeed _deed;
public override bool Singleton => true;
public InternalGump(HearthOfHomeFireDeed deed) : base(150, 50)
{
_deed = deed;

View file

@ -35,7 +35,6 @@ public partial class TapestryOfSosaria : Item, ISecurable
{
if (from.InRange(GetWorldLocation(), 2))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump());
}
else
@ -51,6 +50,8 @@ public partial class TapestryOfSosaria : Item, ISecurable
private class InternalGump : Gump
{
public override bool Singleton => true;
public InternalGump() : base(50, 50)
{
AddImage(0, 0, 0x2C95);

View file

@ -92,7 +92,6 @@ public partial class CurtainsDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -110,6 +109,8 @@ public partial class CurtainsDeed : BaseAddonDeed
{
private readonly CurtainsDeed _deed;
public override bool Singleton => true;
public InternalGump(CurtainsDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -40,7 +40,6 @@ public partial class HangingAxesDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -58,6 +57,8 @@ public partial class HangingAxesDeed : BaseAddonDeed
{
private readonly HangingAxesDeed m_Deed;
public override bool Singleton => true;
public InternalGump(HangingAxesDeed deed) : base(60, 36)
{
m_Deed = deed;

View file

@ -40,7 +40,6 @@ public partial class HangingSwordsDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -58,6 +57,8 @@ public partial class HangingSwordsDeed : BaseAddonDeed
{
private readonly HangingSwordsDeed m_Deed;
public override bool Singleton => true;
public InternalGump(HangingSwordsDeed deed) : base(60, 36)
{
m_Deed = deed;

View file

@ -81,7 +81,6 @@ public partial class HouseLadderDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -99,6 +98,8 @@ public partial class HouseLadderDeed : BaseAddonDeed
{
private readonly HouseLadderDeed _deed;
public override bool Singleton => true;
public InternalGump(HouseLadderDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -42,7 +42,6 @@ public partial class StoneStatueDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -60,6 +59,8 @@ public partial class StoneStatueDeed : BaseAddonDeed
{
private readonly StoneStatueDeed _deed;
public override bool Singleton => true;
public InternalGump(StoneStatueDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -44,7 +44,6 @@ public partial class UnmadeBedDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -62,6 +61,8 @@ public partial class UnmadeBedDeed : BaseAddonDeed
{
private readonly UnmadeBedDeed _deed;
public override bool Singleton => true;
public InternalGump(UnmadeBedDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -41,7 +41,6 @@ public partial class VanityDeed : BaseAddonContainerDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -59,6 +58,8 @@ public partial class VanityDeed : BaseAddonContainerDeed
{
private readonly VanityDeed _deed;
public override bool Singleton => true;
public InternalGump(VanityDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -52,7 +52,6 @@ public partial class WoodenCoffinDeed : BaseAddonDeed
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -70,6 +69,8 @@ public partial class WoodenCoffinDeed : BaseAddonDeed
{
private readonly WoodenCoffinDeed _deed;
public override bool Singleton => true;
public InternalGump(WoodenCoffinDeed deed) : base(60, 36)
{
_deed = deed;

View file

@ -1,4 +1,4 @@
using ModernUO.Serialization;
using ModernUO.Serialization;
using Server.Gumps;
namespace Server.Items;
@ -19,8 +19,7 @@ public partial class HeritageToken : Item
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<HeritageTokenGump>();
from.SendGump(new HeritageTokenGump(this));
from.SendGump(new HeritageTokenGump(this), true);
}
else
{

View file

@ -33,7 +33,6 @@ public partial class PottedPlantDeed : Item
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -46,6 +45,8 @@ public partial class PottedPlantDeed : Item
{
private readonly PottedPlantDeed _deed;
public override bool Singleton => true;
public InternalGump(PottedPlantDeed deed) : base(100, 200)
{
_deed = deed;

View file

@ -65,7 +65,6 @@ public partial class SnowStatueDeed : Item
{
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(from, this));
}
else
@ -78,6 +77,8 @@ public partial class SnowStatueDeed : Item
{
private readonly SnowStatueDeed _deed;
public override bool Singleton => true;
public InternalGump(Mobile from, SnowStatueDeed deed) : base(100, 200)
{
_deed = deed;

View file

@ -96,7 +96,6 @@ public partial class WreathAddon : Item, IDyable, IAddon
{
if (from.InRange(GetWorldLocation(), 3))
{
from.CloseGump<WreathAddonGump>();
from.SendGump(new WreathAddonGump(from, this));
}
else
@ -111,6 +110,8 @@ public partial class WreathAddon : Item, IDyable, IAddon
private readonly WreathAddon _addon;
private readonly Mobile _from;
public override bool Singleton => true;
public WreathAddonGump(Mobile from, WreathAddon addon) : base(150, 50)
{
_from = from;

View file

@ -84,7 +84,6 @@ public partial class HouseRaffleDeed : Item
if (IsChildOf(from.Backpack))
{
from.CloseGump<WritOfLeaseGump>();
from.SendGump(new WritOfLeaseGump(this));
}
else
@ -95,6 +94,8 @@ public partial class HouseRaffleDeed : Item
private class WritOfLeaseGump : Gump
{
public override bool Singleton => true;
public WritOfLeaseGump(HouseRaffleDeed deed) : base(150, 50)
{
AddPage(0);

View file

@ -1,5 +1,6 @@
using ModernUO.Serialization;
using Server.Engines.VeteranRewards;
using Server.Gumps;
using Server.Multis;
namespace Server.Items;

View file

@ -226,19 +226,21 @@ public partial class SoulStone : Item, ISecurable
return;
}
from.CloseGump<SelectSkillGump>();
from.CloseGump<ConfirmSkillGump>();
from.CloseGump<ConfirmTransferGump>();
from.CloseGump<ConfirmRemovalGump>();
from.CloseGump<ErrorGump>();
var gumps = from.GetGumps();
gumps.Close<SelectSkillGump>();
gumps.Close<ConfirmSkillGump>();
gumps.Close<ConfirmTransferGump>();
gumps.Close<ConfirmRemovalGump>();
gumps.Close<ErrorGump>();
if (IsEmpty)
{
from.SendGump(new SelectSkillGump(this, from));
gumps.Send(new SelectSkillGump(this, from));
}
else
{
from.SendGump(new ConfirmTransferGump(this, from));
gumps.Send(new ConfirmTransferGump(this, from));
}
}

View file

@ -72,7 +72,6 @@ public abstract partial class SpecialScroll : Item
return;
}
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(from, this));
}
@ -81,6 +80,8 @@ public abstract partial class SpecialScroll : Item
private readonly Mobile _mobile;
private readonly SpecialScroll _scroll;
public override bool Singleton => true;
public InternalGump(Mobile mobile, SpecialScroll scroll) : base(25, 50)
{
_mobile = mobile;

View file

@ -61,7 +61,6 @@ public partial class AnkhOfSacrificeComponent : AddonComponent
}
else
{
m.CloseGump<AnkhResurrectGump>();
m.SendGump(new AnkhResurrectGump(m, ResurrectMessage.VirtueShrine));
}
}
@ -215,7 +214,6 @@ public partial class AnkhOfSacrificeDeed : BaseAddonDeed, IRewardItem, IRewardOp
if (IsChildOf(from.Backpack))
{
from.CloseGump<RewardOptionGump>();
from.SendGump(new RewardOptionGump(this));
}
else

View file

@ -77,7 +77,6 @@ public partial class Banner : Item, IAddon, IDyable, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1018318)); // Do you wish to re-deed this banner?
}
else
@ -133,7 +132,6 @@ public partial class BannerDeed : Item, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -154,6 +152,8 @@ public partial class BannerDeed : Item, IRewardItem
private readonly BannerDeed _banner;
public override bool Singleton => true;
public InternalGump(BannerDeed banner) : base(100, 200)
{
_banner = banner;
@ -274,7 +274,6 @@ public partial class BannerDeed : Item, IRewardItem
if (north && west)
{
from.CloseGump<FacingGump>();
from.SendGump(new FacingGump(_banner, _itemID, p3d, house));
}
else if (north || west)
@ -301,6 +300,8 @@ public partial class BannerDeed : Item, IRewardItem
private readonly int m_ItemID;
private readonly Point3D m_Location;
public override bool Singleton => true;
public FacingGump(BannerDeed banner, int itemID, Point3D location, BaseHouse house) : base(150, 50)
{
m_Banner = banner;

View file

@ -136,7 +136,6 @@ public partial class RewardBrazierDeed : Item, IRewardItem
return;
}
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
@ -154,6 +153,8 @@ public partial class RewardBrazierDeed : Item, IRewardItem
{
private readonly RewardBrazierDeed _brazier;
public override bool Singleton => true;
public InternalGump(RewardBrazierDeed brazier) : base(100, 200)
{
_brazier = brazier;

View file

@ -420,7 +420,6 @@ public partial class CannonDeed : BaseAddonDeed, IRewardItem, IRewardOption
if (IsChildOf(from.Backpack))
{
from.CloseGump<RewardOptionGump>();
from.SendGump(new RewardOptionGump(this));
}
else

View file

@ -61,7 +61,6 @@ public partial class DecorativeShield : Item, IAddon, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration?
}
else
@ -113,7 +112,6 @@ public partial class DecorativeShieldDeed : Item, IRewardItem
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -141,6 +139,8 @@ public partial class DecorativeShieldDeed : Item, IRewardItem
private readonly DecorativeShieldDeed _shield;
public override bool Singleton => true;
public InternalGump(DecorativeShieldDeed shield) : base(150, 50)
{
_shield = shield;
@ -267,7 +267,6 @@ public partial class DecorativeShieldDeed : Item, IRewardItem
if (north && west)
{
from.CloseGump<FacingGump>();
from.SendGump(new FacingGump(_shield, _itemID, p3d, house));
}
else if (north || west)
@ -294,6 +293,8 @@ public partial class DecorativeShieldDeed : Item, IRewardItem
private readonly Point3D _location;
private readonly DecorativeShieldDeed _shield;
public override bool Singleton => true;
public FacingGump(DecorativeShieldDeed shield, int itemID, Point3D location, BaseHouse house) : base(150, 50)
{
_shield = shield;

View file

@ -75,7 +75,6 @@ public partial class FlamingHead : StoneFaceTrapNoDamage, IAddon, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1018329)); // Do you wish to re-deed this skull?
}
else

View file

@ -65,7 +65,6 @@ public partial class HangingSkeleton : Item, IAddon, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration?
}
else
@ -129,7 +128,6 @@ public partial class HangingSkeletonDeed : Item, IRewardItem
return;
}
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
@ -147,6 +145,8 @@ public partial class HangingSkeletonDeed : Item, IRewardItem
{
private readonly HangingSkeletonDeed _deed;
public override bool Singleton => true;
public InternalGump(HangingSkeletonDeed skeleton) : base(100, 200)
{
_deed = skeleton;
@ -253,7 +253,6 @@ public partial class HangingSkeletonDeed : Item, IRewardItem
if (north && west)
{
from.CloseGump<FacingGump>();
from.SendGump(new FacingGump(_deed, _itemID, p3d, house));
}
else if (north || west)
@ -280,6 +279,8 @@ public partial class HangingSkeletonDeed : Item, IRewardItem
private readonly Point3D _location;
private readonly HangingSkeletonDeed _skeleton;
public override bool Singleton => true;
public FacingGump(HangingSkeletonDeed banner, int itemID, Point3D location, BaseHouse house) : base(150, 50)
{
_skeleton = banner;

View file

@ -368,7 +368,6 @@ public partial class MiningCartDeed : BaseAddonDeed, IRewardItem, IRewardOption
if (IsChildOf(from.Backpack))
{
from.CloseGump<RewardOptionGump>();
from.SendGump(new RewardOptionGump(this));
}
else

View file

@ -110,7 +110,6 @@ public partial class MinotaurStatueDeed : BaseAddonDeed, IRewardItem, IRewardOpt
if (IsChildOf(from.Backpack))
{
from.CloseGump<RewardOptionGump>();
from.SendGump(new RewardOptionGump(this));
}
else

View file

@ -50,7 +50,6 @@ public partial class PottedCactusDeed : Item, IRewardItem
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -73,6 +72,8 @@ public partial class PottedCactusDeed : Item, IRewardItem
{
private readonly PottedCactusDeed _deed;
public override bool Singleton => true;
public InternalGump(PottedCactusDeed cactus) : base(100, 200)
{
_deed = cactus;

View file

@ -76,7 +76,6 @@ public partial class StoneAnkh : BaseAddon, IRewardItem
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1049783)); // Do you wish to re-deed this decoration?
}
else
@ -122,7 +121,6 @@ public partial class StoneAnkhDeed : BaseAddonDeed, IRewardItem
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -150,6 +148,8 @@ public partial class StoneAnkhDeed : BaseAddonDeed, IRewardItem
{
private readonly StoneAnkhDeed _deed;
public override bool Singleton => true;
public InternalGump(StoneAnkhDeed deed) : base(150, 50)
{
_deed = deed;

View file

@ -203,7 +203,6 @@ public partial class TreeStumpDeed : BaseAddonDeed, IRewardItem, IRewardOption
if (IsChildOf(from.Backpack))
{
from.CloseGump<RewardOptionGump>();
from.SendGump(new RewardOptionGump(this));
}
else

View file

@ -304,7 +304,6 @@ public partial class WallBannerDeed : BaseAddonDeed, IRewardItem
if (IsChildOf(from.Backpack))
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
}
else
@ -324,6 +323,8 @@ public partial class WallBannerDeed : BaseAddonDeed, IRewardItem
{
private readonly WallBannerDeed _wallBanner;
public override bool Singleton => true;
public InternalGump(WallBannerDeed wallBanner) : base(150, 50)
{
_wallBanner = wallBanner;

View file

@ -174,7 +174,6 @@ public partial class WeaponEngravingTool : Item, IUsesRemaining, IRewardItem
if (targeted is BaseWeapon item)
{
from.CloseGump<InternalGump>();
from.SendGump(new InternalGump(_tool, item));
}
else
@ -189,6 +188,8 @@ public partial class WeaponEngravingTool : Item, IUsesRemaining, IRewardItem
private readonly BaseWeapon _target;
private readonly WeaponEngravingTool _tool;
public override bool Singleton => true;
public InternalGump(WeaponEngravingTool tool, BaseWeapon target) : base(0, 0)
{
_tool = tool;