diff --git a/KeySuppressor/IGMCMOptionsAPI.cs b/KeySuppressor/IGMCMOptionsAPI.cs new file mode 100644 index 0000000..255ef73 --- /dev/null +++ b/KeySuppressor/IGMCMOptionsAPI.cs @@ -0,0 +1,177 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewModdingAPI.Utilities; +using StardewValley; + +namespace GenericModConfigMenu +{ + /// The API which lets other mods add a config UI through Generic Mod Config Menu. + public interface IGenericModConfigMenuApi + { + /********* + ** Methods + *********/ + /**** + ** Must be called first + ****/ + /// Register a mod whose config can be edited through the UI. + /// The mod's manifest. + /// Reset the mod's config to its default values. + /// Save the mod's current config to the config.json file. + /// Whether the options can only be edited from the title screen. + /// Each mod can only be registered once, unless it's deleted via before calling this again. + void Register(IManifest mod, Action reset, Action save, bool titleScreenOnly = false); + + + /**** + ** Basic options + ****/ + /// Add a section title at the current position in the form. + /// The mod's manifest. + /// The title text shown in the form. + /// The tooltip text shown when the cursor hovers on the title, or null to disable the tooltip. + void AddSectionTitle(IManifest mod, Func text, Func tooltip = null); + + /// Add a paragraph of text at the current position in the form. + /// The mod's manifest. + /// The paragraph text to display. + void AddParagraph(IManifest mod, Func text); + + /// Add an image at the current position in the form. + /// The mod's manifest. + /// The image texture to display. + /// The pixel area within the texture to display, or null to show the entire image. + /// The zoom factor to apply to the image. + void AddImage(IManifest mod, Func texture, Rectangle? texturePixelArea = null, int scale = Game1.pixelZoom); + + /// Add a boolean option at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddBoolOption(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, string fieldId = null); + + /// Add an integer option at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The minimum allowed value, or null to allow any. + /// The maximum allowed value, or null to allow any. + /// The interval of values that can be selected. + /// Get the display text to show for a value, or null to show the number as-is. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddNumberOption(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, int? min = null, int? max = null, int? interval = null, Func formatValue = null, string fieldId = null); + + /// Add a float option at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The minimum allowed value, or null to allow any. + /// The maximum allowed value, or null to allow any. + /// The interval of values that can be selected. + /// Get the display text to show for a value, or null to show the number as-is. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddNumberOption(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, float? min = null, float? max = null, float? interval = null, Func formatValue = null, string fieldId = null); + + /// Add a string option at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The values that can be selected, or null to allow any. + /// Get the display text to show for a value from , or null to show the values as-is. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddTextOption(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, string[] allowedValues = null, Func formatAllowedValue = null, string fieldId = null); + + /// Add a key binding at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddKeybind(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, string fieldId = null); + + /// Add a key binding list at the current position in the form. + /// The mod's manifest. + /// Get the current value from the mod config. + /// Set a new value in the mod config. + /// The label text to show in the form. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + void AddKeybindList(IManifest mod, Func getValue, Action setValue, Func name, Func tooltip = null, string fieldId = null); + + + /**** + ** Multi-page management + ****/ + /// Start a new page in the mod's config UI, or switch to that page if it already exists. All options registered after this will be part of that page. + /// The mod's manifest. + /// The unique page ID. + /// The page title shown in its UI, or null to show the value. + /// You must also call to make the page accessible. This is only needed to set up a multi-page config UI. If you don't call this method, all options will be part of the mod's main config UI instead. + void AddPage(IManifest mod, string pageId, Func pageTitle = null); + + /// Add a link to a page added via at the current position in the form. + /// The mod's manifest. + /// The unique ID of the page to open when the link is clicked. + /// The link text shown in the form. + /// The tooltip text shown when the cursor hovers on the link, or null to disable the tooltip. + void AddPageLink(IManifest mod, string pageId, Func text, Func tooltip = null); + + + /**** + ** Advanced + ****/ + /// Add an option at the current position in the form using custom rendering logic. + /// The mod's manifest. + /// The label text to show in the form. + /// Draw the option in the config UI. This is called with the sprite batch being rendered and the pixel position at which to start drawing. + /// The tooltip text shown when the cursor hovers on the field, or null to disable the tooltip. + /// A callback raised just before the menu containing this option is opened. + /// A callback raised before the form's current values are saved to the config (i.e. before the save callback passed to ). + /// A callback raised after the form's current values are saved to the config (i.e. after the save callback passed to ). + /// A callback raised before the form is reset to its default values (i.e. before the reset callback passed to ). + /// A callback raised after the form is reset to its default values (i.e. after the reset callback passed to ). + /// A callback raised just before the menu containing this option is closed. + /// The pixel height to allocate for the option in the form, or null for a standard input-sized option. This is called and cached each time the form is opened. + /// The unique field ID for use with , or null to auto-generate a randomized ID. + /// The custom logic represented by the callback parameters is responsible for managing its own state if needed. For example, you can store state in a static field or use closures to use a state variable. + void AddComplexOption(IManifest mod, Func name, Action draw, Func tooltip = null, Action beforeMenuOpened = null, Action beforeSave = null, Action afterSave = null, Action beforeReset = null, Action afterReset = null, Action beforeMenuClosed = null, Func height = null, string fieldId = null); + + /// Set whether the options registered after this point can only be edited from the title screen. + /// The mod's manifest. + /// Whether the options can only be edited from the title screen. + /// This lets you have different values per-field. Most mods should just set it once in . + void SetTitleScreenOnlyForNextOptions(IManifest mod, bool titleScreenOnly); + + /// Register a method to notify when any option registered by this mod is edited through the config UI. + /// The mod's manifest. + /// The method to call with the option's unique field ID and new value. + /// Options use a randomized ID by default; you'll likely want to specify the fieldId argument when adding options if you use this. + void OnFieldChanged(IManifest mod, Action onChange); + + /// Open the config UI for a specific mod. + /// The mod's manifest. + void OpenModMenu(IManifest mod); + + /// Get the currently-displayed mod config menu, if any. + /// The manifest of the mod whose config menu is being shown, or null if not applicable. + /// The page ID being shown for the current config menu, or null if not applicable. This may be null even if a mod config menu is shown (e.g. because the mod doesn't have pages). + /// Returns whether a mod config menu is being shown. + bool TryGetCurrentMenu(out IManifest mod, out string page); + + /// Remove a mod from the config UI and delete all its options and pages. + /// The mod's manifest. + void Unregister(IManifest mod); + } +} \ No newline at end of file diff --git a/KeySuppressor/KeySuppressor.csproj b/KeySuppressor/KeySuppressor.csproj index f8f9c6f..9e24eb2 100644 --- a/KeySuppressor/KeySuppressor.csproj +++ b/KeySuppressor/KeySuppressor.csproj @@ -1,84 +1,9 @@ - - - + - $(MSBuildProjectName) - + net48 + 8.0 - - Debug - AnyCPU - {B6DD0C36-999B-44FD-9316-C0AA6D5A6E7A} - Library - Properties - KeySuppressor - KeySuppressor - v4.5.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 3 - Program - C:\Program Files %28x86%29\Steam\steamapps\common\Stardew Valley\StardewModdingAPI.exe - C:\Program Files %28x86%29\Steam\steamapps\common\Stardew Valley - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - Program - C:\Program Files %28x86%29\Steam\steamapps\common\Stardew Valley\StardewModdingAPI.exe - C:\Program Files %28x86%29\Steam\steamapps\common\Stardew Valley - - - true - bin\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - true - - - - - - - - - - - - - - - - - - - - + - \ No newline at end of file diff --git a/KeySuppressor/ModConfig.cs b/KeySuppressor/ModConfig.cs index e122118..d19b055 100644 --- a/KeySuppressor/ModConfig.cs +++ b/KeySuppressor/ModConfig.cs @@ -1,10 +1,5 @@ using StardewModdingAPI; -using StardewModdingAPI.Utilities; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace KeySuppressor { @@ -23,32 +18,34 @@ public enum SuppressMode private static Dictionary GetDefaultSuppressedKeys() { - var defaultSuppressedKeys = new Dictionary(); - defaultSuppressedKeys.Add(SButton.DPadDown, SuppressMode.Suppress); - defaultSuppressedKeys.Add(SButton.DPadLeft, SuppressMode.Suppress); - defaultSuppressedKeys.Add(SButton.DPadRight, SuppressMode.Suppress); - defaultSuppressedKeys.Add(SButton.DPadUp, SuppressMode.Suppress); - defaultSuppressedKeys.Add(SButton.LeftShift, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightStick, SuppressMode.Suppress); - defaultSuppressedKeys.Add(SButton.ControllerA, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.ControllerB, SuppressMode.SuppressOnlyWhenPlayerFree); - defaultSuppressedKeys.Add(SButton.ControllerX, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.ControllerY, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.ControllerBack, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.ControllerStart, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.BigButton, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftShoulder, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightShoulder, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftTrigger, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightTrigger, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftThumbstickDown, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftThumbstickLeft, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftThumbstickRight, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.LeftThumbstickUp, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightThumbstickDown, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightThumbstickLeft, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightThumbstickRight, SuppressMode.DoNotSuppress); - defaultSuppressedKeys.Add(SButton.RightThumbstickUp, SuppressMode.DoNotSuppress); + var defaultSuppressedKeys = new Dictionary + { + { SButton.DPadUp, SuppressMode.DoNotSuppress }, + { SButton.DPadDown, SuppressMode.DoNotSuppress }, + { SButton.DPadLeft, SuppressMode.DoNotSuppress }, + { SButton.DPadRight, SuppressMode.DoNotSuppress }, + { SButton.ControllerA, SuppressMode.DoNotSuppress }, + { SButton.ControllerB, SuppressMode.SuppressOnlyWhenPlayerFree }, + { SButton.ControllerX, SuppressMode.DoNotSuppress }, + { SButton.ControllerY, SuppressMode.DoNotSuppress }, + { SButton.LeftStick, SuppressMode.DoNotSuppress }, + { SButton.LeftThumbstickUp, SuppressMode.DoNotSuppress }, + { SButton.LeftThumbstickDown, SuppressMode.DoNotSuppress }, + { SButton.LeftThumbstickLeft, SuppressMode.DoNotSuppress }, + { SButton.LeftThumbstickRight, SuppressMode.DoNotSuppress }, + { SButton.RightStick, SuppressMode.Suppress }, + { SButton.RightThumbstickUp, SuppressMode.DoNotSuppress }, + { SButton.RightThumbstickDown, SuppressMode.DoNotSuppress }, + { SButton.RightThumbstickLeft, SuppressMode.DoNotSuppress }, + { SButton.RightThumbstickRight, SuppressMode.DoNotSuppress }, + { SButton.LeftShoulder, SuppressMode.DoNotSuppress }, + { SButton.LeftTrigger, SuppressMode.DoNotSuppress }, + { SButton.RightShoulder, SuppressMode.DoNotSuppress }, + { SButton.RightTrigger, SuppressMode.DoNotSuppress }, + { SButton.ControllerBack, SuppressMode.DoNotSuppress }, + { SButton.ControllerStart, SuppressMode.DoNotSuppress }, + { SButton.BigButton, SuppressMode.DoNotSuppress } + }; return defaultSuppressedKeys; } } diff --git a/KeySuppressor/ModEntry.cs b/KeySuppressor/ModEntry.cs index 858a1ce..925acf8 100644 --- a/KeySuppressor/ModEntry.cs +++ b/KeySuppressor/ModEntry.cs @@ -2,11 +2,6 @@ using StardewModdingAPI.Events; using StardewModdingAPI.Utilities; using StardewValley; -using StardewValley.Menus; -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml; namespace KeySuppressor { @@ -15,7 +10,7 @@ public class ModEntry : Mod #region Properties public static IMonitor MonitorObject { get; private set; } - private ModConfig Config; + private ModConfig config; #endregion @@ -24,19 +19,284 @@ public class ModEntry : Mod public override void Entry(IModHelper helper) { MonitorObject = Monitor; - Config = this.Helper.ReadConfig(); + config = this.Helper.ReadConfig(); helper.Events.Input.ButtonsChanged += SuppressKeys; + helper.Events.GameLoop.GameLaunched += OnLaunch; } + private void OnLaunch(object sender, GameLaunchedEventArgs e) + { + //GMCM support + var configMenu = this.Helper.ModRegistry.GetApi("spacechase0.GenericModConfigMenu"); + if (configMenu == null) return; + + configMenu.Register( + mod: this.ModManifest, + reset: () => this.config = new ModConfig(), + save: () => this.Helper.WriteConfig(this.config) + ); + + string toString(ModConfig.SuppressMode mode) + { + return mode switch + { + ModConfig.SuppressMode.DoNotSuppress => "DoNotSuppress", + ModConfig.SuppressMode.Suppress => "Suppress", + ModConfig.SuppressMode.SuppressOnlyInMenu => "SuppressOnlyInMenu", + ModConfig.SuppressMode.SuppressOnlyWhenPlayerFree => "SuppressWhenPlayerFree", + ModConfig.SuppressMode.SuppressOnlyWhenPlayerCanMove => "SuppressOnlyWhenPlayerCanMove", + _ => null, + }; + } + + ModConfig.SuppressMode toMode(string mode) + { + return mode switch + { + "DoNotSuppress" => ModConfig.SuppressMode.DoNotSuppress, + "Suppress" => ModConfig.SuppressMode.Suppress, + "SuppressOnlyInMenu" => ModConfig.SuppressMode.SuppressOnlyInMenu, + "SuppressWhenPlayerFree" => ModConfig.SuppressMode.SuppressOnlyWhenPlayerFree, + "SuppressOnlyWhenPlayerCanMove" => ModConfig.SuppressMode.SuppressOnlyWhenPlayerCanMove, + _ => throw new System.Exception("Invalid mode!") + }; + } + + configMenu.AddSectionTitle( + mod: this.ModManifest, + text: () => "DPad Buttons" + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "DPad Up", + getValue: () => toString(config.SuppressedKeys[SButton.DPadUp]), + setValue: value => this.config.SuppressedKeys[SButton.DPadUp] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "DPad Down", + getValue: () => toString(config.SuppressedKeys[SButton.DPadDown]), + setValue: value => this.config.SuppressedKeys[SButton.DPadDown] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "DPad Left", + getValue: () => toString(config.SuppressedKeys[SButton.DPadLeft]), + setValue: value => this.config.SuppressedKeys[SButton.DPadLeft] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "DPad Right", + getValue: () => toString(config.SuppressedKeys[SButton.DPadRight]), + setValue: value => this.config.SuppressedKeys[SButton.DPadRight] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddSectionTitle( + mod: this.ModManifest, + text: () => "Face Buttons" + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "A", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerA]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerA] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "B", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerB]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerB] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "X", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerX]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerX] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Y", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerY]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerY] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddSectionTitle( + mod: this.ModManifest, + text: () => "Analog Thumbsticks" + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Thumbstick Button", + getValue: () => toString(config.SuppressedKeys[SButton.LeftStick]), + setValue: value => this.config.SuppressedKeys[SButton.LeftStick] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Thumbstick Up", + getValue: () => toString(config.SuppressedKeys[SButton.LeftThumbstickUp]), + setValue: value => this.config.SuppressedKeys[SButton.LeftThumbstickUp] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Thumbstick Down", + getValue: () => toString(config.SuppressedKeys[SButton.LeftThumbstickDown]), + setValue: value => this.config.SuppressedKeys[SButton.LeftThumbstickDown] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Thumbstick Left", + getValue: () => toString(config.SuppressedKeys[SButton.LeftThumbstickLeft]), + setValue: value => this.config.SuppressedKeys[SButton.LeftThumbstickLeft] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Thumbstick Right", + getValue: () => toString(config.SuppressedKeys[SButton.LeftThumbstickRight]), + setValue: value => this.config.SuppressedKeys[SButton.LeftThumbstickRight] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Stick Button", + getValue: () => toString(config.SuppressedKeys[SButton.RightStick]), + setValue: value => this.config.SuppressedKeys[SButton.RightStick] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Thumbstick Up", + getValue: () => toString(config.SuppressedKeys[SButton.RightThumbstickUp]), + setValue: value => this.config.SuppressedKeys[SButton.RightThumbstickUp] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Thumbstick Down", + getValue: () => toString(config.SuppressedKeys[SButton.RightThumbstickDown]), + setValue: value => this.config.SuppressedKeys[SButton.RightThumbstickDown] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Thumbstick Left", + getValue: () => toString(config.SuppressedKeys[SButton.RightThumbstickLeft]), + setValue: value => this.config.SuppressedKeys[SButton.RightThumbstickLeft] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Thumbstick Right", + getValue: () => toString(config.SuppressedKeys[SButton.RightThumbstickRight]), + setValue: value => this.config.SuppressedKeys[SButton.RightThumbstickRight] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddSectionTitle( + mod: this.ModManifest, + text: () => "Trigger/Shoulder Buttons" + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Trigger", + getValue: () => toString(config.SuppressedKeys[SButton.LeftTrigger]), + setValue: value => this.config.SuppressedKeys[SButton.LeftTrigger] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Left Shoulder", + getValue: () => toString(config.SuppressedKeys[SButton.LeftShoulder]), + setValue: value => this.config.SuppressedKeys[SButton.LeftShoulder] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Trigger", + getValue: () => toString(config.SuppressedKeys[SButton.RightTrigger]), + setValue: value => this.config.SuppressedKeys[SButton.RightTrigger] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Right Shoulder", + getValue: () => toString(config.SuppressedKeys[SButton.RightShoulder]), + setValue: value => this.config.SuppressedKeys[SButton.RightShoulder] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddSectionTitle( + mod: this.ModManifest, + text: () => "Menu Buttons" + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Start", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerStart]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerStart] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Back", + getValue: () => toString(config.SuppressedKeys[SButton.ControllerBack]), + setValue: value => this.config.SuppressedKeys[SButton.ControllerBack] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + + configMenu.AddTextOption( + mod: this.ModManifest, + name: () => "Big Button", + getValue: () => toString(config.SuppressedKeys[SButton.BigButton]), + setValue: value => this.config.SuppressedKeys[SButton.BigButton] = toMode(value), + allowedValues: new string[] { "DoNotSuppress", "Suppress", "SuppressOnlyInMenu", "SuppressWhenPlayerFree", "SuppressOnlyWhenPlayerCanMove" } + ); + } + // Set very low (even lower than low) event priority so that this event is handled after all other mods have handled that event. That way the keys are only suppressed for the base game functionality. #endregion [EventPriority(EventPriority.Low - 10000)] private void SuppressKeys(object sender, ButtonsChangedEventArgs e) { - if (Config != null) + if (config != null) { - foreach (var keyValue in Config.SuppressedKeys) + foreach (var keyValue in config.SuppressedKeys) { switch (keyValue.Value) { @@ -47,9 +307,8 @@ private void SuppressKeys(object sender, ButtonsChangedEventArgs e) this.Helper.Input.SuppressActiveKeybinds(KeybindList.ForSingle(keyValue.Key)); break; } - } } } } -} +} \ No newline at end of file