|
30 | 30 | using StardewModdingAPI.Framework.ModLoading; |
31 | 31 | using StardewModdingAPI.Framework.Networking; |
32 | 32 | using StardewModdingAPI.Framework.Reflection; |
| 33 | +using StardewModdingAPI.Framework.Rendering; |
33 | 34 | using StardewModdingAPI.Framework.Serialization; |
34 | 35 | using StardewModdingAPI.Framework.StateTracking.Snapshots; |
35 | 36 | using StardewModdingAPI.Framework.Utilities; |
|
46 | 47 | using StardewValley.Mods; |
47 | 48 | using StardewValley.Objects; |
48 | 49 | using StardewValley.SDKs; |
| 50 | +using xTile.Display; |
49 | 51 | using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode; |
50 | 52 | using MiniMonoModHotfix = MonoMod.Utils.MiniMonoModHotfix; |
51 | 53 | using PathUtilities = StardewModdingAPI.Toolkit.Utilities.PathUtilities; |
@@ -130,6 +132,9 @@ internal class SCore : IDisposable |
130 | 132 | /// <summary>Whether the game has initialized for any custom languages from <c>Data/AdditionalLanguages</c>.</summary> |
131 | 133 | private bool AreCustomLanguagesInitialized; |
132 | 134 |
|
| 135 | + /// <summary>Whether the player just returned to the title screen.</summary> |
| 136 | + public bool JustReturnedToTitle { get; set; } |
| 137 | + |
133 | 138 | /// <summary>The last language set by the game.</summary> |
134 | 139 | private (string Locale, LanguageCode Code) LastLanguage { get; set; } = ("", LanguageCode.en); |
135 | 140 |
|
@@ -487,6 +492,10 @@ private void OnGameInitialized() |
487 | 492 | /// <summary>Raised after an instance finishes loading its initial content.</summary> |
488 | 493 | private void OnInstanceContentLoaded() |
489 | 494 | { |
| 495 | + // override map display device |
| 496 | + if (Constants.GameVersion.IsOlderThan("1.6.15")) |
| 497 | + Game1.mapDisplayDevice = this.GetMapDisplayDevice_OBSOLETE(); |
| 498 | + |
490 | 499 | // log GPU info |
491 | 500 | #if SMAPI_FOR_WINDOWS |
492 | 501 | this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}"); |
@@ -603,6 +612,17 @@ private void OnPlayerInstanceUpdating(SGame instance, GameTime gameTime, Action |
603 | 612 |
|
604 | 613 | try |
605 | 614 | { |
| 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 | + |
606 | 626 | /********* |
607 | 627 | ** Execute commands |
608 | 628 | *********/ |
@@ -1160,6 +1180,7 @@ internal void OnLoadStageChanged(LoadStage newStage) |
1160 | 1180 | break; |
1161 | 1181 |
|
1162 | 1182 | case LoadStage.None: |
| 1183 | + this.JustReturnedToTitle = true; |
1163 | 1184 | this.UpdateWindowTitles(); |
1164 | 1185 | break; |
1165 | 1186 |
|
@@ -2349,6 +2370,13 @@ private IFileLookup GetFileLookup(string rootDirectory) |
2349 | 2370 | : MinimalFileLookup.GetCachedFor(rootDirectory); |
2350 | 2371 | } |
2351 | 2372 |
|
| 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 | + |
2352 | 2380 | /// <summary>Get the absolute path to the next available log file.</summary> |
2353 | 2381 | private string GetLogPath() |
2354 | 2382 | { |
|
0 commit comments