summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-22 15:07:06 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-22 15:07:06 -0400
commit99c8dd79406f5099194d72e26085a49939705259 (patch)
tree407a11718df1f7e51e0d794c1f33cc0aa3883f00
parentf74321addc79a5616cc0f43e4f5f4b8154fac827 (diff)
downloadSMAPI-99c8dd79406f5099194d72e26085a49939705259.tar.gz
SMAPI-99c8dd79406f5099194d72e26085a49939705259.tar.bz2
SMAPI-99c8dd79406f5099194d72e26085a49939705259.zip
add InputButton.ToSButton() extension
-rw-r--r--docs/release-notes.md6
-rw-r--r--src/SMAPI/SButton.cs12
2 files changed, 16 insertions, 2 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 199e32c5..65536915 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -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.
diff --git a/src/SMAPI/SButton.cs b/src/SMAPI/SButton.cs
index 0ec799db..bd6635c7 100644
--- a/src/SMAPI/SButton.cs
+++ b/src/SMAPI/SButton.cs
@@ -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>