mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
use newer event stuff + fix attribute
This commit is contained in:
6 files changed
+20
-23
No files matched your search
@@ -14,6 +14,7 @@ using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
[RegisterEventContainer]
|
||||
public static class ExampleEventHandlers
|
||||
{
|
||||
public static void Initialize()
|
||||
|
||||
@@ -26,6 +26,9 @@ public partial class ExamplePlugin : BasePlugin, IMiraPlugin
|
||||
public string OptionsTitleText { get; } = "Mira API\nExample Mod";
|
||||
public string CustomOptionMenuNameTwo { get; } = "Example Options";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ForceRegisterEvents => false;
|
||||
|
||||
public ConfigFile GetConfigFile()
|
||||
{
|
||||
return Config;
|
||||
|
||||
@@ -5,5 +5,5 @@ namespace MiraAPI.Events;
|
||||
/// <summary>
|
||||
/// Register a container of <see cref="MiraEvent"/>s.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RegisterEventContainerAttribute : Attribute;
|
||||
@@ -8,7 +8,6 @@ using MiraAPI.Patches;
|
||||
using MiraAPI.Patches.Roles;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.VanillaEvents;
|
||||
using Reactor;
|
||||
using Reactor.Localization;
|
||||
using Reactor.Networking;
|
||||
@@ -44,6 +43,9 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
/// <inheritdoc />
|
||||
public bool DebugMode => IsDevBuild;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ForceRegisterEvents => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current device is running Starlight (on mobile).
|
||||
/// </summary>
|
||||
@@ -96,8 +98,6 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
"Dictates the unit of distance used in numeric option displays representing a distance.");
|
||||
Harmony.PatchAll();
|
||||
RoleOptionsCollectionPatch.PatchRoleMethods(Harmony);
|
||||
UiResetEvents.Initialize();
|
||||
JudgeEvents.Initialize();
|
||||
|
||||
ReactorCredits.Register("Mira API", Version, IsDevBuild, ReactorCredits.AlwaysShow);
|
||||
|
||||
|
||||
@@ -4,15 +4,11 @@ using MiraAPI.Roles;
|
||||
|
||||
namespace MiraAPI.VanillaEvents;
|
||||
|
||||
[RegisterEventContainer]
|
||||
internal static class JudgeEvents
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
// This is required because MiraAPI isn't an IMiraPlugin (besides in the gamemodes branch)
|
||||
MiraEventManager.RegisterEventHandler<ProcessVotesEvent>(ProcessVotesEventHandler, -1000);
|
||||
}
|
||||
|
||||
private static void ProcessVotesEventHandler(ProcessVotesEvent @event)
|
||||
[RegisterEvent(-1000)]
|
||||
public static void ProcessVotesEventHandler(ProcessVotesEvent @event)
|
||||
{
|
||||
if (!MeetingHud.Instance.TryGetWinningOverrule(
|
||||
out var judgeOverrule,
|
||||
|
||||
@@ -5,17 +5,11 @@ using MiraAPI.LocalSettings;
|
||||
|
||||
namespace MiraAPI.VanillaEvents;
|
||||
|
||||
[RegisterEventContainer]
|
||||
internal static class UiResetEvents
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
MiraEventManager.RegisterEventHandler<UiButtonResetEvent>(ResetButtonParents);
|
||||
MiraEventManager.RegisterEventHandler<UiButtonPostResetEvent>(PlaceWikiButton, -900);
|
||||
MiraEventManager.RegisterEventHandler<UiButtonPostResetEvent>(PlaceSubmergedButton, -800);
|
||||
MiraEventManager.RegisterEventHandler<UiButtonPostResetEvent>(PlaceModifierUi, -700);
|
||||
}
|
||||
|
||||
private static void ResetButtonParents(UiButtonResetEvent _)
|
||||
[RegisterEvent]
|
||||
public static void ResetButtonParents(UiButtonResetEvent _)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
@@ -36,7 +30,8 @@ internal static class UiResetEvents
|
||||
}
|
||||
}
|
||||
|
||||
private static void PlaceWikiButton(UiButtonPostResetEvent @event)
|
||||
[RegisterEvent(-900)]
|
||||
public static void PlaceWikiButton(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var wikiButton = MiraHudHelper.VanillaMatchInfoButton;
|
||||
if (!wikiButton)
|
||||
@@ -50,7 +45,8 @@ internal static class UiResetEvents
|
||||
wikiButton.transform.SetParent(opts.WikiOnBottomRow.Value ? secondRow.transform : firstRow.transform);
|
||||
}
|
||||
|
||||
private static void PlaceSubmergedButton(UiButtonPostResetEvent @event)
|
||||
[RegisterEvent(-800)]
|
||||
public static void PlaceSubmergedButton(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var subButton = MiraHudHelper.SubmergedFloorButton;
|
||||
if (!subButton)
|
||||
@@ -62,7 +58,8 @@ internal static class UiResetEvents
|
||||
subButton.transform.SetParent(secondRow.transform);
|
||||
}
|
||||
|
||||
private static void PlaceModifierUi(UiButtonPostResetEvent @event)
|
||||
[RegisterEvent(-700)]
|
||||
public static void PlaceModifierUi(UiButtonPostResetEvent @event)
|
||||
{
|
||||
var modDisplay = MiraHudHelper.ModifierDisplayOnRight ? MiraHudHelper.ModifierDisplayObject : null!;
|
||||
if (!modDisplay)
|
||||
|
||||
Reference in new issue
Block a user