add method to suppress active keybindings (#744)
This commit is contained in:
parent
f251f0d06c
commit
e40483aab1
|
@ -12,9 +12,11 @@
|
|||
* Improved game path detection in the installer. The installer now prefers the path registered by Steam or GOG Galaxy, and can also now detect the default install path for manual GOG installs.
|
||||
|
||||
* For modders:
|
||||
* Added new input APIs:
|
||||
* Added [API for multi-key bindings](https://stardewcommunitywiki.com/Modding:Modder_Guide/APIs/Input#KeybindList).
|
||||
* Added a new [`Input.ButtonsChanged` event](https://stardewcommunitywiki.com/Modding:Modder_Guide/APIs/Events#Input.ButtonsChanged).
|
||||
* Added a `buttonState.IsDown()` extension.
|
||||
* Added a `helper.Input.SuppressActiveKeybindings` method which suppresses the active buttons in a keybind list.
|
||||
* Improved multiplayer APIs:
|
||||
* `PerScreen<T>` now lets you get/set the value for any screen, get all active values, or clear all values.
|
||||
* Peer data for the multiplayer API/events now includes `IsSplitScreen` and `ScreenID` fields.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using StardewModdingAPI.Framework.Input;
|
||||
using StardewModdingAPI.Utilities;
|
||||
|
||||
namespace StardewModdingAPI.Framework.ModHelpers
|
||||
{
|
||||
|
@ -49,6 +50,19 @@ namespace StardewModdingAPI.Framework.ModHelpers
|
|||
this.CurrentInputState().OverrideButton(button, setDown: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SuppressActiveKeybinds(KeybindList keybindList)
|
||||
{
|
||||
foreach (Keybind keybind in keybindList.Keybinds)
|
||||
{
|
||||
if (!keybind.GetState().IsDown())
|
||||
continue;
|
||||
|
||||
foreach (SButton button in keybind.Buttons)
|
||||
this.Suppress(button);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public SButtonState GetState(SButton button)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using StardewModdingAPI.Utilities;
|
||||
|
||||
namespace StardewModdingAPI
|
||||
{
|
||||
/// <summary>Provides an API for checking and changing input state.</summary>
|
||||
|
@ -18,6 +20,10 @@ namespace StardewModdingAPI
|
|||
/// <param name="button">The button to suppress.</param>
|
||||
void Suppress(SButton button);
|
||||
|
||||
/// <summary>Suppress the keybinds which are currently down.</summary>
|
||||
/// <param name="keybindList">The keybind list whose active keybinds to suppress.</param>
|
||||
void SuppressActiveKeybinds(KeybindList keybindList);
|
||||
|
||||
/// <summary>Get the state of a button.</summary>
|
||||
/// <param name="button">The button to check.</param>
|
||||
SButtonState GetState(SButton button);
|
||||
|
|
Loading…
Reference in New Issue