mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
wip
This commit is contained in:
1 parent
9d130a53de
commit
af3d99eafe
5 files changed
+48
-2
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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(' ', '_');
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user