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:
parent
40d99f6d1c
commit
8282b00ca2
246 changed files with 1722 additions and 1383 deletions
|
|
@ -58,6 +58,8 @@ public sealed class HelpGump : DynamicGump
|
|||
{
|
||||
private readonly Mobile _from;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public HelpGump(Mobile from) : base(0, 0) => _from = from;
|
||||
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
|
|
@ -206,12 +208,6 @@ public sealed class HelpGump : DynamicGump
|
|||
builder.AddHtmlLocalized(180, y + 150, 335, 40, 1001015); // NO - I meant to ask for help with another matter.
|
||||
}
|
||||
|
||||
public override void SendTo(NetState ns)
|
||||
{
|
||||
_from.CloseGump<HelpGump>();
|
||||
base.SendTo(ns);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static void AddOption(
|
||||
ref DynamicGumpBuilder builder, int y, int buttonId, int localizedName, GumpButtonType type = GumpButtonType.Reply,
|
||||
|
|
@ -237,12 +233,9 @@ public sealed class HelpGump : DynamicGump
|
|||
|
||||
public static void HelpRequest(Mobile m)
|
||||
{
|
||||
foreach (var gump in m.NetState.Gumps)
|
||||
if (m.HasGump<HelpGump>())
|
||||
{
|
||||
if (gump is HelpGump)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PageQueue.CheckAllowedToPage(m))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ public sealed class PagePromptGump : StaticGump<PagePromptGump>
|
|||
private readonly Mobile _from;
|
||||
private readonly PageType _type;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public PagePromptGump(Mobile from, PageType type) : base(0, 0)
|
||||
{
|
||||
_from = from;
|
||||
|
|
@ -31,12 +33,6 @@ public sealed class PagePromptGump : StaticGump<PagePromptGump>
|
|||
builder. AddButton(405, 355, 2073, 2072, 0); // Cancel
|
||||
}
|
||||
|
||||
public override void SendTo(NetState ns)
|
||||
{
|
||||
_from.CloseGump<PagePromptGump>();
|
||||
base.SendTo(ns);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 0)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
|
|
|||
|
|
@ -118,9 +118,7 @@ namespace Server.Engines.Help
|
|||
{
|
||||
if (PageQueue.List.IndexOf(m_List[info.ButtonID - 1]) >= 0)
|
||||
{
|
||||
var g = new PageEntryGump(state.Mobile, m_List[info.ButtonID - 1]);
|
||||
|
||||
g.SendTo(state);
|
||||
state.SendGump(new PageEntryGump(state.Mobile, m_List[info.ButtonID - 1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -224,13 +222,13 @@ namespace Server.Engines.Help
|
|||
private readonly Mobile m_From;
|
||||
private readonly PredefinedResponse m_Response;
|
||||
|
||||
public override bool Singleton => true;
|
||||
|
||||
public PredefGump(Mobile from, PredefinedResponse response) : base(30, 30)
|
||||
{
|
||||
m_From = from;
|
||||
m_Response = response;
|
||||
|
||||
from.CloseGump<PredefGump>();
|
||||
|
||||
var canEdit = from.AccessLevel >= AccessLevel.GameMaster;
|
||||
|
||||
AddPage(0);
|
||||
|
|
@ -593,9 +591,7 @@ namespace Server.Engines.Help
|
|||
|
||||
public void Resend(NetState state)
|
||||
{
|
||||
var g = new PageEntryGump(m_Mobile, m_Entry);
|
||||
|
||||
g.SendTo(state);
|
||||
state.SendGump(new PageEntryGump(m_Mobile, m_Entry));
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState state, in RelayInfo info)
|
||||
|
|
@ -613,9 +609,7 @@ namespace Server.Engines.Help
|
|||
{
|
||||
if (m_Entry.Handler != state.Mobile)
|
||||
{
|
||||
var g = new PageQueueGump();
|
||||
|
||||
g.SendTo(state);
|
||||
state.SendGump(new PageQueueGump());
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -722,10 +716,7 @@ namespace Server.Engines.Help
|
|||
PageQueue.Remove(m_Entry);
|
||||
|
||||
state.Mobile.SendMessage("You delete the page.");
|
||||
|
||||
var g = new PageQueueGump();
|
||||
|
||||
g.SendTo(state);
|
||||
state.SendGump(new PageQueueGump());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -764,10 +755,7 @@ namespace Server.Engines.Help
|
|||
m_Entry.Handler = null;
|
||||
|
||||
state.Mobile.SendMessage("You mark the page as handled, and remove it from the queue.");
|
||||
|
||||
var g = new PageQueueGump();
|
||||
|
||||
g.SendTo(state);
|
||||
state.SendGump(new PageQueueGump());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue