From 2e8c7e06c5c46834b570b667cb7497fe4cc408ac Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 20 Dec 2020 22:34:59 -0500 Subject: update for split-screen mode This includes splitting GameRunner (the main game instance) from Game1 (now a per-screen game state), adding a PerScreen 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. --- src/SMAPI/Framework/ModHelpers/InputHelper.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/SMAPI/Framework/ModHelpers/InputHelper.cs') 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 *********/ - /// Manages the game's input state. - private readonly SInputState InputState; + /// Manages the game's input state for the current player instance. That may not be the main player in split-screen mode. + private readonly Func CurrentInputState; /********* @@ -17,41 +18,41 @@ namespace StardewModdingAPI.Framework.ModHelpers *********/ /// Construct an instance. /// The unique ID of the relevant mod. - /// Manages the game's input state. - public InputHelper(string modID, SInputState inputState) + /// Manages the game's input state for the current player instance. That may not be the main player in split-screen mode. + public InputHelper(string modID, Func currentInputState) : base(modID) { - this.InputState = inputState; + this.CurrentInputState = currentInputState; } /// public ICursorPosition GetCursorPosition() { - return this.InputState.CursorPosition; + return this.CurrentInputState().CursorPosition; } /// public bool IsDown(SButton button) { - return this.InputState.IsDown(button); + return this.CurrentInputState().IsDown(button); } /// public bool IsSuppressed(SButton button) { - return this.InputState.IsSuppressed(button); + return this.CurrentInputState().IsSuppressed(button); } /// public void Suppress(SButton button) { - this.InputState.OverrideButton(button, setDown: false); + this.CurrentInputState().OverrideButton(button, setDown: false); } /// public SButtonState GetState(SButton button) { - return this.InputState.GetState(button); + return this.CurrentInputState().GetState(button); } } } -- cgit