This commit is contained in:
xChipseq committed 2025-09-07 21:25:15 +02:00
1 parent 9d130a53de
commit af3d99eafe
5 files changed
+48 -2

No files matched your search

+12
View File
@@ -17,6 +17,8 @@ public static class KeybindManager
/// </summary>
public static List<MiraKeybind> Keybinds { get; } = new();
internal static List<VanillaKeybind> VanillaKeybinds { get; } = new();
internal static void RewiredInit()
{
try
@@ -91,4 +93,14 @@ public static class KeybindManager
return all.ToArray();
}
internal static void RegisterVanillaKeybind(AbilityButton button, InputAction inputAction)
{
var keybind = new VanillaKeybind(button, inputAction);
VanillaKeybinds.Add(keybind);
typeof(VanillaKeybindSingleton<>)
.MakeGenericType(button.GetType())
.GetField("_instance")!
.SetValue(null, keybind);
}
}
+2 -2
View File
@@ -8,7 +8,7 @@ namespace MiraAPI.Keybinds;
/// <summary>
/// Represents a registered keybind.
/// </summary>
public class MiraKeybind
public class MiraKeybind()
{
/// <summary>
/// Gets name of the keybind
@@ -64,7 +64,7 @@ public class MiraKeybind
string name,
KeyboardKeyCode? defaultKeycode,
ModifierKey[]? modifierKeys = null,
bool exclusive = true)
bool exclusive = true) : this()
{
Name = name;
Id = name.ToLower(CultureInfo.InvariantCulture).Replace(' ', '_');
+18
View File
@@ -0,0 +1,18 @@
using Rewired;
using TMPro;
using UnityEngine;
namespace MiraAPI.Keybinds;
public class VanillaKeybind
{
public AbilityButton Ability { get; }
public InputAction RewiredInputAction { get; }
public KeyboardKeyCode CurrentKey => KeybindUtils.GetKeycodeByActionId(RewiredInputAction.id);
public VanillaKeybind(AbilityButton ability, InputAction inputAction)
{
Ability = ability;
RewiredInputAction = inputAction;
}
}
@@ -0,0 +1,15 @@
using System.Linq;
namespace MiraAPI.Keybinds;
public static class VanillaKeybindSingleton<T> where T : AbilityButton
{
internal static VanillaKeybind _instance;
/// <summary>
/// Gets the instance of the option group.
/// </summary>
#pragma warning disable CA1000
public static VanillaKeybind Instance => _instance;
#pragma warning restore CA1000
}
+1
View File
@@ -124,6 +124,7 @@ public static class HudManagerPatches
}
var icon = Helpers.CreateKeybindIcon(buttonObj, key, keybindIconPos);
vanillaKeybindIcons.Add(icon.transform.GetChild(0).GetComponent<TextMeshPro>(), actionId);
KeybindManager.RegisterVanillaKeybind();
}
}