From 07d6dff0a91191bf5581d5d210ff3356ee4d5ed4 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidoS@users.noreply.github.com> Date: Thu, 22 Aug 2024 21:09:48 -0500 Subject: [PATCH] Stickers: fixed desktop bind selection --- .../BTKUI/BtkUiAddon_CAT_StickersMod.cs | 8 +- Stickers/Main.cs | 2 +- Stickers/ModSettings.cs | 92 ++++++++++++++++++- 3 files changed, 95 insertions(+), 7 deletions(-) diff --git a/Stickers/Integrations/BTKUI/BtkUiAddon_CAT_StickersMod.cs b/Stickers/Integrations/BTKUI/BtkUiAddon_CAT_StickersMod.cs index 3a3226d..3681fd1 100644 --- a/Stickers/Integrations/BTKUI/BtkUiAddon_CAT_StickersMod.cs +++ b/Stickers/Integrations/BTKUI/BtkUiAddon_CAT_StickersMod.cs @@ -23,14 +23,14 @@ public static partial class BtkUiAddon private static readonly MultiSelection _desktopKeybindSelection = new( "Desktop Keybind", - Enum.GetNames(typeof(KeyCode)), - (int)ModSettings.Entry_PlaceBinding.Value + Enum.GetNames(typeof(ModSettings.KeyBind)), + Array.IndexOf(Enum.GetValues(typeof(ModSettings.KeyBind)), ModSettings.Entry_PlaceBinding.Value) ) { OnOptionUpdated = i => { - if (Enum.GetValues(typeof(KeyCode)) is string[] options) // inefficient but works - ModSettings.Entry_PlaceBinding.Value = (KeyCode)Enum.Parse(typeof(KeyCode), options[i]); + string[] options = Enum.GetNames(typeof(ModSettings.KeyBind)); + ModSettings.Entry_PlaceBinding.Value = (ModSettings.KeyBind)Enum.Parse(typeof(ModSettings.KeyBind), options[i]); } }; diff --git a/Stickers/Main.cs b/Stickers/Main.cs index dfc4941..bb4be55 100644 --- a/Stickers/Main.cs +++ b/Stickers/Main.cs @@ -33,7 +33,7 @@ public class StickerMod : MelonMod if (!ModSettings.Entry_UsePlaceBinding.Value) return; - if (!Input.GetKeyDown(ModSettings.Entry_PlaceBinding.Value)) + if (!Input.GetKeyDown((KeyCode)ModSettings.Entry_PlaceBinding.Value)) return; StickerSystem.Instance.PlaceStickerFromTransform(PlayerSetup.Instance.activeCam.transform); diff --git a/Stickers/ModSettings.cs b/Stickers/ModSettings.cs index 04c29bb..4ed80fe 100644 --- a/Stickers/ModSettings.cs +++ b/Stickers/ModSettings.cs @@ -44,9 +44,97 @@ public static class ModSettings internal static readonly MelonPreferences_Entry Entry_UsePlaceBinding = Category.CreateEntry("use_binding", true, "Use Place Binding", "Use the place binding to place stickers."); - internal static readonly MelonPreferences_Entry Entry_PlaceBinding = - Category.CreateEntry("place_binding", KeyCode.G, "Sticker Bind", "The key binding to place stickers."); + internal static readonly MelonPreferences_Entry Entry_PlaceBinding = + Category.CreateEntry("place_binding", KeyBind.G, "Sticker Bind", "The key binding to place stickers."); + + internal enum KeyBind + { + // Alphabetic keys + A = KeyCode.A, // 0x00000061 + B = KeyCode.B, // 0x00000062 + C = KeyCode.C, // 0x00000063 + D = KeyCode.D, // 0x00000064 + E = KeyCode.E, // 0x00000065 + F = KeyCode.F, // 0x00000066 + G = KeyCode.G, // 0x00000067 + H = KeyCode.H, // 0x00000068 + I = KeyCode.I, // 0x00000069 + J = KeyCode.J, // 0x0000006A + K = KeyCode.K, // 0x0000006B + L = KeyCode.L, // 0x0000006C + M = KeyCode.M, // 0x0000006D + N = KeyCode.N, // 0x0000006E + O = KeyCode.O, // 0x0000006F + P = KeyCode.P, // 0x00000070 + Q = KeyCode.Q, // 0x00000071 + R = KeyCode.R, // 0x00000072 + S = KeyCode.S, // 0x00000073 + T = KeyCode.T, // 0x00000074 + U = KeyCode.U, // 0x00000075 + V = KeyCode.V, // 0x00000076 + W = KeyCode.W, // 0x00000077 + X = KeyCode.X, // 0x00000078 + Y = KeyCode.Y, // 0x00000079 + Z = KeyCode.Z, // 0x0000007A + + // Mouse Buttons + Mouse0 = KeyCode.Mouse0, // 0x00000143 + Mouse1 = KeyCode.Mouse1, // 0x00000144 + Mouse2 = KeyCode.Mouse2, // 0x00000145 + Mouse3 = KeyCode.Mouse3, // 0x00000146 + Mouse4 = KeyCode.Mouse4, // 0x00000147 + Mouse5 = KeyCode.Mouse5, // 0x00000148 + Mouse6 = KeyCode.Mouse6, // 0x00000149 + // Special Characters + // Backspace = KeyCode.Backspace, // 0x00000008 + // Tab = KeyCode.Tab, // 0x00000009 + // Clear = KeyCode.Clear, // 0x0000000C + // Return = KeyCode.Return, // 0x0000000D + // Pause = KeyCode.Pause, // 0x00000013 + // Escape = KeyCode.Escape, // 0x0000001B + // Space = KeyCode.Space, // 0x00000020 + // Exclaim = KeyCode.Exclaim, // 0x00000021 + // DoubleQuote = KeyCode.DoubleQuote, // 0x00000022 + // Hash = KeyCode.Hash, // 0x00000023 + // Dollar = KeyCode.Dollar, // 0x00000024 + // Percent = KeyCode.Percent, // 0x00000025 + // Ampersand = KeyCode.Ampersand, // 0x00000026 + // Quote = KeyCode.Quote, // 0x00000027 + // LeftParen = KeyCode.LeftParen, // 0x00000028 + // RightParen = KeyCode.RightParen, // 0x00000029 + // Asterisk = KeyCode.Asterisk, // 0x0000002A + // Plus = KeyCode.Plus, // 0x0000002B + // Comma = KeyCode.Comma, // 0x0000002C + // Minus = KeyCode.Minus, // 0x0000002D + // Period = KeyCode.Period, // 0x0000002E + // Slash = KeyCode.Slash, // 0x0000002F + // Alpha0 = KeyCode.Alpha0, // 0x00000030 + // Alpha1 = KeyCode.Alpha1, // 0x00000031 + // Alpha2 = KeyCode.Alpha2, // 0x00000032 + // Alpha3 = KeyCode.Alpha3, // 0x00000033 + // Alpha4 = KeyCode.Alpha4, // 0x00000034 + // Alpha5 = KeyCode.Alpha5, // 0x00000035 + // Alpha6 = KeyCode.Alpha6, // 0x00000036 + // Alpha7 = KeyCode.Alpha7, // 0x00000037 + // Alpha8 = KeyCode.Alpha8, // 0x00000038 + // Alpha9 = KeyCode.Alpha9, // 0x00000039 + // Colon = KeyCode.Colon, // 0x0000003A + // Semicolon = KeyCode.Semicolon, // 0x0000003B + // Less = KeyCode.Less, // 0x0000003C + // Equals = KeyCode.Equals, // 0x0000003D + // Greater = KeyCode.Greater, // 0x0000003E + // Question = KeyCode.Question, // 0x0000003F + // At = KeyCode.At, // 0x00000040 + // LeftBracket = KeyCode.LeftBracket, // 0x0000005B + // Backslash = KeyCode.Backslash, // 0x0000005C + // RightBracket = KeyCode.RightBracket, // 0x0000005D + // Caret = KeyCode.Caret, // 0x0000005E + // Underscore = KeyCode.Underscore, // 0x0000005F + // BackQuote = KeyCode.BackQuote, // 0x00000060 + // Delete = KeyCode.Delete // 0x0000007F + } + internal static readonly MelonPreferences_Entry Hidden_SelectedStickerName = Category.CreateEntry("hidden_selected_sticker", string.Empty, is_hidden: true, display_name: "Selected Sticker", description: "The currently selected sticker name.");