fix SMAPI's display device not hooked correctly in split-screen mode

This commit is contained in:
Jesse Plamondon-Willard 2021-09-27 17:06:15 -04:00
parent 31e31538f1
commit ab8599583e
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
4 changed files with 20 additions and 13 deletions

View File

@ -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.

View File

@ -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();
}
/// <summary>Raised after the game finishes loading its initial content.</summary>
private void OnGameContentLoaded()
/// <summary>Raised after an instance finishes loading its initial content.</summary>
private void OnInstanceContentLoaded()
{
// override map display device
Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);

View File

@ -54,6 +54,9 @@ namespace StardewModdingAPI.Framework
/// <summary>Raised when the instance is updating its state (roughly 60 times per second).</summary>
private readonly Action<SGame, GameTime, Action> OnUpdating;
/// <summary>Raised after the instance finishes loading its initial content.</summary>
private readonly Action OnContentLoaded;
/*********
** Accessors
@ -106,7 +109,8 @@ namespace StardewModdingAPI.Framework
/// <param name="multiplayer">The core multiplayer logic.</param>
/// <param name="exitGameImmediately">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.</param>
/// <param name="onUpdating">Raised when the instance is updating its state (roughly 60 times per second).</param>
public SGame(PlayerIndex playerIndex, int instanceIndex, Monitor monitor, Reflector reflection, EventManager eventManager, SInputState input, SModHooks modHooks, SMultiplayer multiplayer, Action<string> exitGameImmediately, Action<SGame, GameTime, Action> onUpdating)
/// <param name="onContentLoaded">Raised after the game finishes loading its initial content.</param>
public SGame(PlayerIndex playerIndex, int instanceIndex, Monitor monitor, Reflector reflection, EventManager eventManager, SInputState input, SModHooks modHooks, SMultiplayer multiplayer, Action<string> exitGameImmediately, Action<SGame, GameTime, 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;
}
/// <summary>Get the current input state for a button.</summary>
@ -138,6 +143,13 @@ namespace StardewModdingAPI.Framework
return input.GetState(button);
}
/// <inheritdoc />
protected override void LoadContent()
{
base.LoadContent();
this.OnContentLoaded();
}
/*********
** Protected methods

View File

@ -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);
}
/// <inheritdoc />
@ -129,14 +129,6 @@ namespace StardewModdingAPI.Framework
/*********
** Protected methods
*********/
/// <summary>Load content when the game is launched.</summary>
protected override void LoadContent()
{
base.LoadContent();
this.OnGameContentLoaded();
}
/// <summary>Perform cleanup logic when the game exits.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="args">The event args.</param>