add InputButton.ToSButton() extension

This commit is contained in:
Jesse Plamondon-Willard 2017-10-22 15:07:06 -04:00
parent f74321addc
commit 99c8dd7940
2 changed files with 16 additions and 2 deletions

View File

@ -4,8 +4,10 @@
* Fixed compatibility check crashing for players with Stardew Valley 1.08.
* For modders:
* The reflection API now works with public code to simplify mod integrations.
* Fixed `e.SuppressButton()` in input events not correctly suppressing keyboard buttons.
* Added support for public code in reflection API, to simplify mod integrations.
* Improved input events:
* Added `ToSButton()` extension for the game's `Game1.options` button type.
* Fixed `e.SuppressButton()` not correctly suppressing keyboard buttons.
* Fixed mods which implement `IAssetLoader` directly not being allowed to load files due to incorrect conflict detection.
* Fixed SMAPI blocking reflection access to vanilla members on overridden types.

View File

@ -615,6 +615,18 @@ namespace StardewModdingAPI
return (SButton)(SButtonExtensions.ControllerOffset + key);
}
/// <summary>Get the <see cref="SButton"/> equivalent for the given button.</summary>
/// <param name="input">The Stardew Valley button to convert.</param>
internal static SButton ToSButton(this InputButton input)
{
// derived from InputButton constructors
if (input.mouseLeft)
return SButton.MouseLeft;
if (input.mouseRight)
return SButton.MouseRight;
return input.key.ToSButton();
}
/// <summary>Get the <see cref="Keys"/> equivalent for the given button.</summary>
/// <param name="input">The button to convert.</param>
/// <param name="key">The keyboard equivalent.</param>