diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-20 22:34:59 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-12-20 22:34:59 -0500 |
commit | 2e8c7e06c5c46834b570b667cb7497fe4cc408ac (patch) | |
tree | af2cb14a02d85fb2b435ceb38a81c9a97146bf87 /src/SMAPI/Framework/ModHelpers/InputHelper.cs | |
parent | 50a146d1c9a228391c4201685a5e0df9daa529e9 (diff) | |
download | SMAPI-2e8c7e06c5c46834b570b667cb7497fe4cc408ac.tar.gz SMAPI-2e8c7e06c5c46834b570b667cb7497fe4cc408ac.tar.bz2 SMAPI-2e8c7e06c5c46834b570b667cb7497fe4cc408ac.zip |
update for split-screen mode
This includes splitting GameRunner (the main game instance) from Game1 (now a per-screen game state), adding a PerScreen<T> utility to simplify per-screen values, adding separate per-screen input handling and events, adding new Context fields for split-screen, and logging the screen ID in split-screen mode to distinguish log entries.
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/InputHelper.cs')
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/InputHelper.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs index 09ce3c65..e1317544 100644 --- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs @@ -1,3 +1,4 @@ +using System; using StardewModdingAPI.Framework.Input; namespace StardewModdingAPI.Framework.ModHelpers @@ -8,8 +9,8 @@ namespace StardewModdingAPI.Framework.ModHelpers /********* ** Accessors *********/ - /// <summary>Manages the game's input state.</summary> - private readonly SInputState InputState; + /// <summary>Manages the game's input state for the current player instance. That may not be the main player in split-screen mode.</summary> + private readonly Func<SInputState> CurrentInputState; /********* @@ -17,41 +18,41 @@ namespace StardewModdingAPI.Framework.ModHelpers *********/ /// <summary>Construct an instance.</summary> /// <param name="modID">The unique ID of the relevant mod.</param> - /// <param name="inputState">Manages the game's input state.</param> - public InputHelper(string modID, SInputState inputState) + /// <param name="currentInputState">Manages the game's input state for the current player instance. That may not be the main player in split-screen mode.</param> + public InputHelper(string modID, Func<SInputState> currentInputState) : base(modID) { - this.InputState = inputState; + this.CurrentInputState = currentInputState; } /// <inheritdoc /> public ICursorPosition GetCursorPosition() { - return this.InputState.CursorPosition; + return this.CurrentInputState().CursorPosition; } /// <inheritdoc /> public bool IsDown(SButton button) { - return this.InputState.IsDown(button); + return this.CurrentInputState().IsDown(button); } /// <inheritdoc /> public bool IsSuppressed(SButton button) { - return this.InputState.IsSuppressed(button); + return this.CurrentInputState().IsSuppressed(button); } /// <inheritdoc /> public void Suppress(SButton button) { - this.InputState.OverrideButton(button, setDown: false); + this.CurrentInputState().OverrideButton(button, setDown: false); } /// <inheritdoc /> public SButtonState GetState(SButton button) { - return this.InputState.GetState(button); + return this.CurrentInputState().GetState(button); } } } |