mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Remove requirement but allow blank keybind
This commit is contained in:
1 parent
ce15e93e59
commit
f1a5aef581
6 files changed
+12
-12
No files matched your search
@@ -20,7 +20,7 @@ public class FreezeButton : CustomActionButton<PlayerControl>
|
||||
public override int MaxUses => (int)OptionGroupSingleton<FreezerRoleSettings>.Instance.FreezeUses;
|
||||
|
||||
public override LoadableAsset<Sprite> 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()
|
||||
|
||||
@@ -16,7 +16,7 @@ public class MeetingButton : CustomActionButton
|
||||
public override int MaxUses => 3;
|
||||
|
||||
public override LoadableAsset<Sprite> 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;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class NeutralKillerButton : CustomActionButton
|
||||
public override string Name => "Win Game";
|
||||
public override float Cooldown => 0f;
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override KeyboardKeyCode DefaultKeybind => KeyboardKeyCode.K;
|
||||
public override KeyboardKeyCode? DefaultKeybind => KeyboardKeyCode.K;
|
||||
protected override void OnClick()
|
||||
{
|
||||
CustomGameOver.Trigger<NeutralKillerGameOver>([PlayerControl.LocalPlayer.Data]);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TeleportButton : CustomActionButton
|
||||
public override LoadableAsset<Sprite> 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;
|
||||
|
||||
@@ -54,23 +54,23 @@ public abstract class CustomActionButton
|
||||
public virtual int MaxUses => 0;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public virtual KeyboardKeyCode DefaultKeybind { get; } = KeyboardKeyCode.None;
|
||||
public virtual KeyboardKeyCode? DefaultKeybind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public virtual ModifierKey Modifier1 => ModifierKey.None;
|
||||
|
||||
/// <summary>
|
||||
/// The second optional modifier key.
|
||||
/// Gets the second optional modifier key.
|
||||
/// Set to <see cref="ModifierKey.None"/> if unused.
|
||||
/// </summary>
|
||||
public virtual ModifierKey Modifier2 => ModifierKey.None;
|
||||
|
||||
/// <summary>
|
||||
/// The third optional modifier key.
|
||||
/// Gets the third optional modifier key.
|
||||
/// Set to <see cref="ModifierKey.None"/> if unused.
|
||||
/// </summary>
|
||||
public virtual ModifierKey Modifier3 => ModifierKey.None;
|
||||
|
||||
@@ -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<MiraApiPlugin>.Info($"Registered keybind for button '{button.GetType().Name}' with default key {button.DefaultKeybind}.");
|
||||
Logger<MiraApiPlugin>.Info($"Registered keybind for button '{button.GetType().Name}' with default key {(KeyboardKeyCode)button.DefaultKeybind}.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user