feat: Adds delegate events for Help system (#2054)
This commit is contained in:
parent
cc61c1d6d2
commit
1da5a49baf
3 changed files with 49 additions and 8 deletions
27
Projects/UOContent/Engines/Help/HelpEvents.cs
Normal file
27
Projects/UOContent/Engines/Help/HelpEvents.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server.Engines.Help;
|
||||
|
||||
public static class HelpEvents
|
||||
{
|
||||
public static event Action<PageEntry> PageEnqueued;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InvokePageEnqueued(PageEntry e) => PageEnqueued?.Invoke(e);
|
||||
|
||||
public static event Action<PageEntry> PageRemoved;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InvokePageRemoved(PageEntry e) => PageRemoved?.Invoke(e);
|
||||
|
||||
public static event Action<Mobile, Mobile, PageEntry> PageHandlerChanged;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InvokePageHandlerChanged(Mobile old, Mobile value, PageEntry e) => PageHandlerChanged?.Invoke(old, value, e);
|
||||
|
||||
public static event Action<PageEntry> PageWaiting;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InvokePageWaiting(PageEntry e) => PageWaiting?.Invoke(e);
|
||||
|
||||
public static event Action<Mobile> StuckMenu;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InvokeStuckMenu(Mobile m) => StuckMenu?.Invoke(m);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue