From ab8599583e549bda59bc3e0783bd5e1657ef7b1b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 27 Sep 2021 17:06:15 -0400 Subject: fix SMAPI's display device not hooked correctly in split-screen mode --- docs/release-notes.md | 3 +++ src/SMAPI/Framework/SCore.cs | 6 +++--- src/SMAPI/Framework/SGame.cs | 14 +++++++++++++- src/SMAPI/Framework/SGameRunner.cs | 10 +--------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 25698ffa..c03b6005 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -5,6 +5,9 @@ * For players: * Fixed mod edits to the farmhouse shifting the player down one tile in some cases. +* For mod authors: + * Fixed map tile rotations/flips not working for farmhands in split-screen mode. + ## 3.12.7 Released 18 September 2021 for Stardew Valley 1.5.4. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 86b69239..6dffb1de 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -247,7 +247,7 @@ namespace StardewModdingAPI.Framework multiplayer: this.Multiplayer, exitGameImmediately: this.ExitGameImmediately, - onGameContentLoaded: this.OnGameContentLoaded, + onGameContentLoaded: this.OnInstanceContentLoaded, onGameUpdating: this.OnGameUpdating, onPlayerInstanceUpdating: this.OnPlayerInstanceUpdating, onGameExiting: this.OnGameExiting @@ -429,8 +429,8 @@ namespace StardewModdingAPI.Framework ).Start(); } - /// Raised after the game finishes loading its initial content. - private void OnGameContentLoaded() + /// Raised after an instance finishes loading its initial content. + private void OnInstanceContentLoaded() { // override map display device Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice); diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index 55ab8377..4e134455 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -54,6 +54,9 @@ namespace StardewModdingAPI.Framework /// Raised when the instance is updating its state (roughly 60 times per second). private readonly Action OnUpdating; + /// Raised after the instance finishes loading its initial content. + private readonly Action OnContentLoaded; + /********* ** Accessors @@ -106,7 +109,8 @@ namespace StardewModdingAPI.Framework /// The core multiplayer logic. /// Immediately exit the game without saving. This should only be invoked when an irrecoverable fatal error happens that risks save corruption or game-breaking bugs. /// Raised when the instance is updating its state (roughly 60 times per second). - public SGame(PlayerIndex playerIndex, int instanceIndex, Monitor monitor, Reflector reflection, EventManager eventManager, SInputState input, SModHooks modHooks, SMultiplayer multiplayer, Action exitGameImmediately, Action onUpdating) + /// Raised after the game finishes loading its initial content. + public SGame(PlayerIndex playerIndex, int instanceIndex, Monitor monitor, Reflector reflection, EventManager eventManager, SInputState input, SModHooks modHooks, SMultiplayer multiplayer, Action exitGameImmediately, Action onUpdating, Action onContentLoaded) : base(playerIndex, instanceIndex) { // init XNA @@ -124,6 +128,7 @@ namespace StardewModdingAPI.Framework this.Reflection = reflection; this.ExitGameImmediately = exitGameImmediately; this.OnUpdating = onUpdating; + this.OnContentLoaded = onContentLoaded; } /// Get the current input state for a button. @@ -138,6 +143,13 @@ namespace StardewModdingAPI.Framework return input.GetState(button); } + /// + protected override void LoadContent() + { + base.LoadContent(); + + this.OnContentLoaded(); + } /********* ** Protected methods diff --git a/src/SMAPI/Framework/SGameRunner.cs b/src/SMAPI/Framework/SGameRunner.cs index 45e7369c..b816bb7c 100644 --- a/src/SMAPI/Framework/SGameRunner.cs +++ b/src/SMAPI/Framework/SGameRunner.cs @@ -94,7 +94,7 @@ namespace StardewModdingAPI.Framework public override Game1 CreateGameInstance(PlayerIndex playerIndex = PlayerIndex.One, int instanceIndex = 0) { SInputState inputState = new SInputState(); - return new SGame(playerIndex, instanceIndex, this.Monitor, this.Reflection, this.Events, inputState, this.ModHooks, this.Multiplayer, this.ExitGameImmediately, this.OnPlayerInstanceUpdating); + return new SGame(playerIndex, instanceIndex, this.Monitor, this.Reflection, this.Events, inputState, this.ModHooks, this.Multiplayer, this.ExitGameImmediately, this.OnPlayerInstanceUpdating, this.OnGameContentLoaded); } /// @@ -129,14 +129,6 @@ namespace StardewModdingAPI.Framework /********* ** Protected methods *********/ - /// Load content when the game is launched. - protected override void LoadContent() - { - base.LoadContent(); - - this.OnGameContentLoaded(); - } - /// Perform cleanup logic when the game exits. /// The event sender. /// The event args. -- cgit