diff --git a/Projects/UOContent/Engines/Help/HelpEvents.cs b/Projects/UOContent/Engines/Help/HelpEvents.cs new file mode 100644 index 000000000..e1738ebfd --- /dev/null +++ b/Projects/UOContent/Engines/Help/HelpEvents.cs @@ -0,0 +1,27 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Server.Engines.Help; + +public static class HelpEvents +{ + public static event Action PageEnqueued; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void InvokePageEnqueued(PageEntry e) => PageEnqueued?.Invoke(e); + + public static event Action PageRemoved; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void InvokePageRemoved(PageEntry e) => PageRemoved?.Invoke(e); + + public static event Action PageHandlerChanged; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void InvokePageHandlerChanged(Mobile old, Mobile value, PageEntry e) => PageHandlerChanged?.Invoke(old, value, e); + + public static event Action PageWaiting; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void InvokePageWaiting(PageEntry e) => PageWaiting?.Invoke(e); + + public static event Action StuckMenu; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void InvokeStuckMenu(Mobile m) => StuckMenu?.Invoke(m); +} diff --git a/Projects/UOContent/Engines/Help/PageQueue.cs b/Projects/UOContent/Engines/Help/PageQueue.cs index eac51bf81..ea0c418cd 100644 --- a/Projects/UOContent/Engines/Help/PageQueue.cs +++ b/Projects/UOContent/Engines/Help/PageQueue.cs @@ -103,6 +103,8 @@ namespace Server.Engines.Help { m_Entry.Handler = null; } + + HelpEvents.InvokePageWaiting(m_Entry); } else { @@ -171,6 +173,13 @@ namespace Server.Engines.Help { m_KeyedByHandler[value] = entry; } + + if (old == null || value == null) + { + return; + } + + HelpEvents.InvokePageHandlerChanged(old, value, entry); } [Usage("Pages"), Description("Opens the page queue menu.")] @@ -212,6 +221,8 @@ namespace Server.Engines.Help { m_KeyedByHandler.Remove(e.Handler); } + + HelpEvents.InvokePageRemoved(e); } public static PageEntry GetEntry(Mobile sender) @@ -258,6 +269,8 @@ namespace Server.Engines.Help { Email.SendQueueEmail(entry, GetPageTypeName(entry.Type)); } + + HelpEvents.InvokePageEnqueued(entry); } } } diff --git a/Projects/UOContent/Engines/Help/StuckMenu.cs b/Projects/UOContent/Engines/Help/StuckMenu.cs index f6cab4d90..4fc57aed2 100644 --- a/Projects/UOContent/Engines/Help/StuckMenu.cs +++ b/Projects/UOContent/Engines/Help/StuckMenu.cs @@ -1,4 +1,5 @@ using System; +using Server.Engines.Help; using Server.Factions; using Server.Gumps; using Server.Mobiles; @@ -194,16 +195,16 @@ namespace Server.Menus.Questions m_Mobile.SendLocalizedMessage(1010588); // You choose not to go to any city. } } - else - { - var index = info.ButtonID - 1; - var entries = IsInSecondAgeArea(m_Mobile) ? m_T2AEntries : m_Entries; - if (index >= 0 && index < entries.Length) - { - Teleport(entries[index]); - } + var index = info.ButtonID - 1; + var entries = IsInSecondAgeArea(m_Mobile) ? m_T2AEntries : m_Entries; + + if (index >= 0 && index < entries.Length) + { + Teleport(entries[index]); } + + HelpEvents.InvokeStuckMenu(m_Mobile); } private void Teleport(StuckMenuEntry entry)