Stickers: fixed desktop bind selection

This commit is contained in:
NotAKidoS 2024-08-22 21:09:48 -05:00
parent de414d3077
commit 07d6dff0a9
3 changed files with 95 additions and 7 deletions

View file

@ -23,14 +23,14 @@ public static partial class BtkUiAddon
private static readonly MultiSelection _desktopKeybindSelection = private static readonly MultiSelection _desktopKeybindSelection =
new( new(
"Desktop Keybind", "Desktop Keybind",
Enum.GetNames(typeof(KeyCode)), Enum.GetNames(typeof(ModSettings.KeyBind)),
(int)ModSettings.Entry_PlaceBinding.Value Array.IndexOf(Enum.GetValues(typeof(ModSettings.KeyBind)), ModSettings.Entry_PlaceBinding.Value)
) )
{ {
OnOptionUpdated = i => OnOptionUpdated = i =>
{ {
if (Enum.GetValues(typeof(KeyCode)) is string[] options) // inefficient but works string[] options = Enum.GetNames(typeof(ModSettings.KeyBind));
ModSettings.Entry_PlaceBinding.Value = (KeyCode)Enum.Parse(typeof(KeyCode), options[i]); ModSettings.Entry_PlaceBinding.Value = (ModSettings.KeyBind)Enum.Parse(typeof(ModSettings.KeyBind), options[i]);
} }
}; };

View file

@ -33,7 +33,7 @@ public class StickerMod : MelonMod
if (!ModSettings.Entry_UsePlaceBinding.Value) if (!ModSettings.Entry_UsePlaceBinding.Value)
return; return;
if (!Input.GetKeyDown(ModSettings.Entry_PlaceBinding.Value)) if (!Input.GetKeyDown((KeyCode)ModSettings.Entry_PlaceBinding.Value))
return; return;
StickerSystem.Instance.PlaceStickerFromTransform(PlayerSetup.Instance.activeCam.transform); StickerSystem.Instance.PlaceStickerFromTransform(PlayerSetup.Instance.activeCam.transform);

View file

@ -44,9 +44,97 @@ public static class ModSettings
internal static readonly MelonPreferences_Entry<bool> Entry_UsePlaceBinding = internal static readonly MelonPreferences_Entry<bool> Entry_UsePlaceBinding =
Category.CreateEntry("use_binding", true, "Use Place Binding", "Use the place binding to place stickers."); Category.CreateEntry("use_binding", true, "Use Place Binding", "Use the place binding to place stickers.");
internal static readonly MelonPreferences_Entry<KeyCode> Entry_PlaceBinding = internal static readonly MelonPreferences_Entry<KeyBind> Entry_PlaceBinding =
Category.CreateEntry("place_binding", KeyCode.G, "Sticker Bind", "The key binding to place stickers."); 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<string> Hidden_SelectedStickerName = internal static readonly MelonPreferences_Entry<string> Hidden_SelectedStickerName =
Category.CreateEntry("hidden_selected_sticker", string.Empty, is_hidden: true, display_name: "Selected Sticker", description: "The currently selected sticker name."); Category.CreateEntry("hidden_selected_sticker", string.Empty, is_hidden: true, display_name: "Selected Sticker", description: "The currently selected sticker name.");