From f1a5aef581829259a812ab5539de5c00a97a3c1c Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Sun, 17 Aug 2025 20:52:46 -0500 Subject: [PATCH] Remove requirement but allow blank keybind --- MiraAPI.Example/Buttons/Freezer/FreezeButton.cs | 2 +- MiraAPI.Example/Buttons/MeetingButton.cs | 2 +- MiraAPI.Example/Buttons/NeutralKillerButton.cs | 2 +- MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs | 2 +- MiraAPI/Hud/CustomActionButton.cs | 10 +++++----- MiraAPI/PluginLoading/MiraPluginManager.cs | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MiraAPI.Example/Buttons/Freezer/FreezeButton.cs b/MiraAPI.Example/Buttons/Freezer/FreezeButton.cs index ddefcc2..1f10c6f 100644 --- a/MiraAPI.Example/Buttons/Freezer/FreezeButton.cs +++ b/MiraAPI.Example/Buttons/Freezer/FreezeButton.cs @@ -20,7 +20,7 @@ public class FreezeButton : CustomActionButton public override int MaxUses => (int)OptionGroupSingleton.Instance.FreezeUses; public override LoadableAsset Sprite => ExampleAssets.ExampleButton; - public override KeyboardKeyCode DefaultKeybind => KeyboardKeyCode.T; + public override KeyboardKeyCode? DefaultKeybind => KeyboardKeyCode.T; public override ModifierKey Modifier1 => ModifierKey.Control; protected override void OnClick() diff --git a/MiraAPI.Example/Buttons/MeetingButton.cs b/MiraAPI.Example/Buttons/MeetingButton.cs index 900d8a2..89e722b 100644 --- a/MiraAPI.Example/Buttons/MeetingButton.cs +++ b/MiraAPI.Example/Buttons/MeetingButton.cs @@ -16,7 +16,7 @@ public class MeetingButton : CustomActionButton public override int MaxUses => 3; public override LoadableAsset Sprite => ExampleAssets.ExampleButton; - public override KeyboardKeyCode DefaultKeybind => KeyboardKeyCode.P; + public override KeyboardKeyCode? DefaultKeybind => KeyboardKeyCode.P; public override ModifierKey Modifier1 => ModifierKey.Control; public override ModifierKey Modifier2 => ModifierKey.Shift; diff --git a/MiraAPI.Example/Buttons/NeutralKillerButton.cs b/MiraAPI.Example/Buttons/NeutralKillerButton.cs index 79fe06b..58d8bee 100644 --- a/MiraAPI.Example/Buttons/NeutralKillerButton.cs +++ b/MiraAPI.Example/Buttons/NeutralKillerButton.cs @@ -13,7 +13,7 @@ public class NeutralKillerButton : CustomActionButton public override string Name => "Win Game"; public override float Cooldown => 0f; public override LoadableAsset Sprite => ExampleAssets.ExampleButton; - public override KeyboardKeyCode DefaultKeybind => KeyboardKeyCode.K; + public override KeyboardKeyCode? DefaultKeybind => KeyboardKeyCode.K; protected override void OnClick() { CustomGameOver.Trigger([PlayerControl.LocalPlayer.Data]); diff --git a/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs b/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs index 55f773b..78beb0b 100644 --- a/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs +++ b/MiraAPI.Example/Buttons/Teleporter/TeleportButton.cs @@ -22,7 +22,7 @@ public class TeleportButton : CustomActionButton public override LoadableAsset Sprite => ExampleAssets.TeleportButton; public override Color TextOutlineColor => new Color32(221, 176, 152, 255); public static bool IsZoom { get; private set; } - public override KeyboardKeyCode DefaultKeybind => KeyboardKeyCode.M; + public override KeyboardKeyCode? DefaultKeybind => KeyboardKeyCode.M; public override bool Enabled(RoleBehaviour? role) { return role is TeleporterRole; diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 81ac5bd..4bd8c8e 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -54,23 +54,23 @@ public abstract class CustomActionButton public virtual int MaxUses => 0; /// - /// Gets or sets the current key binding for this button. + /// Gets the current key binding for this button. If null, no keybind will be added. /// - public virtual KeyboardKeyCode DefaultKeybind { get; } = KeyboardKeyCode.None; + public virtual KeyboardKeyCode? DefaultKeybind { get; } /// - /// The first optional modifier key (e.g., Control, Shift, Alt) that must be held with the main key to activate the button. + /// Gets the first optional modifier key (e.g., Control, Shift, Alt) that must be held with the main key to activate the button. /// public virtual ModifierKey Modifier1 => ModifierKey.None; /// - /// The second optional modifier key. + /// Gets the second optional modifier key. /// Set to if unused. /// public virtual ModifierKey Modifier2 => ModifierKey.None; /// - /// The third optional modifier key. + /// Gets the third optional modifier key. /// Set to if unused. /// public virtual ModifierKey Modifier3 => ModifierKey.None; diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 49adbda..759a0fd 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -138,13 +138,13 @@ public sealed class MiraPluginManager foreach (var button in CustomButtonManager.Buttons) { - if (button.DefaultKeybind is KeyboardKeyCode.None) + if (button.DefaultKeybind == null) { continue; } - KeybindManager.Register($"{button.Name}_Keybind", $"Keybind for {button.Name}", button.DefaultKeybind, button.ClickHandler, modifier1: button.Modifier1, modifier2: button.Modifier2, modifier3: button.Modifier3); + KeybindManager.Register($"{button.Name}_Keybind", $"Keybind for {button.Name}", (KeyboardKeyCode)button.DefaultKeybind, button.ClickHandler, modifier1: button.Modifier1, modifier2: button.Modifier2, modifier3: button.Modifier3); - Logger.Info($"Registered keybind for button '{button.GetType().Name}' with default key {button.DefaultKeybind}."); + Logger.Info($"Registered keybind for button '{button.GetType().Name}' with default key {(KeyboardKeyCode)button.DefaultKeybind}."); } }; }