Skip to content

Commit 3cb37d9

Browse files
committed
add temporary backwards compatibility with Stardew Valley 1.6.14
That will allow releasing SMAPI 4.10.0 ahead of the Stardew Valley 1.6.15 update.
1 parent 492a650 commit 3cb37d9

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/SMAPI/Framework/SCore.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
using StardewModdingAPI.Framework.ModLoading;
3131
using StardewModdingAPI.Framework.Networking;
3232
using StardewModdingAPI.Framework.Reflection;
33+
using StardewModdingAPI.Framework.Rendering;
3334
using StardewModdingAPI.Framework.Serialization;
3435
using StardewModdingAPI.Framework.StateTracking.Snapshots;
3536
using StardewModdingAPI.Framework.Utilities;
@@ -46,6 +47,7 @@
4647
using StardewValley.Mods;
4748
using StardewValley.Objects;
4849
using StardewValley.SDKs;
50+
using xTile.Display;
4951
using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode;
5052
using MiniMonoModHotfix = MonoMod.Utils.MiniMonoModHotfix;
5153
using PathUtilities = StardewModdingAPI.Toolkit.Utilities.PathUtilities;
@@ -130,6 +132,9 @@ internal class SCore : IDisposable
130132
/// <summary>Whether the game has initialized for any custom languages from <c>Data/AdditionalLanguages</c>.</summary>
131133
private bool AreCustomLanguagesInitialized;
132134

135+
/// <summary>Whether the player just returned to the title screen.</summary>
136+
public bool JustReturnedToTitle { get; set; }
137+
133138
/// <summary>The last language set by the game.</summary>
134139
private (string Locale, LanguageCode Code) LastLanguage { get; set; } = ("", LanguageCode.en);
135140

@@ -487,6 +492,10 @@ private void OnGameInitialized()
487492
/// <summary>Raised after an instance finishes loading its initial content.</summary>
488493
private void OnInstanceContentLoaded()
489494
{
495+
// override map display device
496+
if (Constants.GameVersion.IsOlderThan("1.6.15"))
497+
Game1.mapDisplayDevice = this.GetMapDisplayDevice_OBSOLETE();
498+
490499
// log GPU info
491500
#if SMAPI_FOR_WINDOWS
492501
this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}");
@@ -603,6 +612,17 @@ private void OnPlayerInstanceUpdating(SGame instance, GameTime gameTime, Action
603612

604613
try
605614
{
615+
/*********
616+
** Reapply overrides
617+
*********/
618+
if (this.JustReturnedToTitle)
619+
{
620+
if (Game1.mapDisplayDevice is not SDisplayDevice && Constants.GameVersion.IsOlderThan("1.6.15"))
621+
Game1.mapDisplayDevice = this.GetMapDisplayDevice_OBSOLETE();
622+
623+
this.JustReturnedToTitle = false;
624+
}
625+
606626
/*********
607627
** Execute commands
608628
*********/
@@ -1160,6 +1180,7 @@ internal void OnLoadStageChanged(LoadStage newStage)
11601180
break;
11611181

11621182
case LoadStage.None:
1183+
this.JustReturnedToTitle = true;
11631184
this.UpdateWindowTitles();
11641185
break;
11651186

@@ -2349,6 +2370,13 @@ private IFileLookup GetFileLookup(string rootDirectory)
23492370
: MinimalFileLookup.GetCachedFor(rootDirectory);
23502371
}
23512372

2373+
/// <summary>Get the map display device which applies SMAPI features like tile rotation to loaded maps.</summary>
2374+
/// <remarks>This only exists for backwards compatibility with Stardew Valley 1.6.14, and will be removed in the next SMAPI update. See <see cref="SGame.CreateDisplayDevice"/> instead.</remarks>
2375+
private IDisplayDevice GetMapDisplayDevice_OBSOLETE()
2376+
{
2377+
return new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
2378+
}
2379+
23522380
/// <summary>Get the absolute path to the next available log file.</summary>
23532381
private string GetLogPath()
23542382
{

src/SMAPI/Framework/SGame.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ protected internal override LocalizedContentManager CreateContentManager(IServic
179179
}
180180

181181
/// <inheritdoc />
182+
[SuppressMessage("ReSharper", "ParameterHidesMember")]
182183
protected internal override IDisplayDevice CreateDisplayDevice(ContentManager content, GraphicsDevice graphicsDevice)
183184
{
184185
return new SDisplayDevice(content, graphicsDevice);

0 commit comments

Comments
 (0)