diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index ac48c4a..78fa114 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -1,11 +1,14 @@ using System; using System.Globalization; +using System.Linq; using MiraAPI.Events; using MiraAPI.Events.Mira; +using MiraAPI.Keybinds; using MiraAPI.Patches; using MiraAPI.Utilities; using MiraAPI.Utilities.Assets; using Rewired; +using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; @@ -120,6 +123,11 @@ public abstract class CustomActionButton /// public ActionButton? Button { get; set; } + /// + /// Gets the gameObject used for the keybind icon. + /// + public GameObject KeybindIcon { get; set; } + /// /// The method used to create the button. /// @@ -191,6 +199,13 @@ public abstract class CustomActionButton } } })); + + KeybindIcon = Object.Instantiate(Button.usesRemainingSprite.gameObject, Button.transform); + KeybindIcon.GetComponent().sprite = MiraAssets.KeybindButton.LoadAsset(); + KeybindIcon.transform.GetChild(0).GetComponent().text = + KeybindManager.GetEntries().First(x => x.Id == $"{Name}_Keybind").Key.ToString(); + KeybindIcon.name = "KeybindIcon"; + KeybindIcon.transform.localPosition = new(0.341f, 0.374f, -0.1f); } /// @@ -558,4 +573,4 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB Target = null; SetOutline(false); } -} +} \ No newline at end of file diff --git a/MiraAPI/Resources/KeybindButton.png b/MiraAPI/Resources/KeybindButton.png new file mode 100644 index 0000000..e537b3b Binary files /dev/null and b/MiraAPI/Resources/KeybindButton.png differ diff --git a/MiraAPI/Utilities/Assets/MiraAssets.cs b/MiraAPI/Utilities/Assets/MiraAssets.cs index 1bd130a..148c65a 100644 --- a/MiraAPI/Utilities/Assets/MiraAssets.cs +++ b/MiraAPI/Utilities/Assets/MiraAssets.cs @@ -94,4 +94,9 @@ public static class MiraAssets /// Gets the white CategoryHeader used in the Settings Menu. /// public static LoadableResourceAsset CategoryHeader { get; } = new("MiraAPI.Resources.CategoryHeader.png"); + + /// + /// Gets the sprite used for the Keybind icons. + /// + public static LoadableResourceAsset KeybindButton { get; } = new("MiraAPI.Resources.KeybindButton.png"); }