Skip to content

Commit 492a650

Browse files
committed
migrate to new display device hook in Stardew Valley 1.6.15
1 parent 78cae72 commit 492a650

2 files changed

Lines changed: 10 additions & 30 deletions

File tree

src/SMAPI/Framework/SCore.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
using StardewModdingAPI.Framework.ModLoading;
3131
using StardewModdingAPI.Framework.Networking;
3232
using StardewModdingAPI.Framework.Reflection;
33-
using StardewModdingAPI.Framework.Rendering;
3433
using StardewModdingAPI.Framework.Serialization;
3534
using StardewModdingAPI.Framework.StateTracking.Snapshots;
3635
using StardewModdingAPI.Framework.Utilities;
@@ -47,7 +46,6 @@
4746
using StardewValley.Mods;
4847
using StardewValley.Objects;
4948
using StardewValley.SDKs;
50-
using xTile.Display;
5149
using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode;
5250
using MiniMonoModHotfix = MonoMod.Utils.MiniMonoModHotfix;
5351
using PathUtilities = StardewModdingAPI.Toolkit.Utilities.PathUtilities;
@@ -132,9 +130,6 @@ internal class SCore : IDisposable
132130
/// <summary>Whether the game has initialized for any custom languages from <c>Data/AdditionalLanguages</c>.</summary>
133131
private bool AreCustomLanguagesInitialized;
134132

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

@@ -492,9 +487,6 @@ private void OnGameInitialized()
492487
/// <summary>Raised after an instance finishes loading its initial content.</summary>
493488
private void OnInstanceContentLoaded()
494489
{
495-
// override map display device
496-
Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
497-
498490
// log GPU info
499491
#if SMAPI_FOR_WINDOWS
500492
this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}");
@@ -611,17 +603,6 @@ private void OnPlayerInstanceUpdating(SGame instance, GameTime gameTime, Action
611603

612604
try
613605
{
614-
/*********
615-
** Reapply overrides
616-
*********/
617-
if (this.JustReturnedToTitle)
618-
{
619-
if (Game1.mapDisplayDevice is not SDisplayDevice)
620-
Game1.mapDisplayDevice = this.GetMapDisplayDevice();
621-
622-
this.JustReturnedToTitle = false;
623-
}
624-
625606
/*********
626607
** Execute commands
627608
*********/
@@ -1179,7 +1160,6 @@ internal void OnLoadStageChanged(LoadStage newStage)
11791160
break;
11801161

11811162
case LoadStage.None:
1182-
this.JustReturnedToTitle = true;
11831163
this.UpdateWindowTitles();
11841164
break;
11851165

@@ -2369,13 +2349,6 @@ private IFileLookup GetFileLookup(string rootDirectory)
23692349
: MinimalFileLookup.GetCachedFor(rootDirectory);
23702350
}
23712351

2372-
/// <summary>Get the map display device which applies SMAPI features like tile rotation to loaded maps.</summary>
2373-
/// <remarks>This is separate to let mods like PyTK wrap it with their own functionality.</remarks>
2374-
private IDisplayDevice GetMapDisplayDevice()
2375-
{
2376-
return new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
2377-
}
2378-
23792352
/// <summary>Get the absolute path to the next available log file.</summary>
23802353
private string GetLogPath()
23812354
{

src/SMAPI/Framework/SGame.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
using System.Collections.ObjectModel;
33
using System.Diagnostics.CodeAnalysis;
44
using Microsoft.Xna.Framework;
5+
using Microsoft.Xna.Framework.Content;
56
using Microsoft.Xna.Framework.Graphics;
67
using StardewModdingAPI.Enums;
78
using StardewModdingAPI.Events;
89
using StardewModdingAPI.Framework.Input;
910
using StardewModdingAPI.Framework.Reflection;
11+
using StardewModdingAPI.Framework.Rendering;
1012
using StardewModdingAPI.Framework.StateTracking.Snapshots;
1113
using StardewModdingAPI.Framework.Utilities;
1214
using StardewModdingAPI.Internal;
@@ -15,6 +17,7 @@
1517
using StardewValley.Logging;
1618
using StardewValley.Menus;
1719
using StardewValley.Minigames;
20+
using xTile.Display;
1821

1922
namespace StardewModdingAPI.Framework;
2023

@@ -166,9 +169,7 @@ public override bool ShouldDrawOnBuffer()
166169
/*********
167170
** Protected methods
168171
*********/
169-
/// <summary>Construct a content manager to read game content files.</summary>
170-
/// <param name="serviceProvider">The service provider to use to locate services.</param>
171-
/// <param name="rootDirectory">The root directory to search for content.</param>
172+
/// <inheritdoc />
172173
protected internal override LocalizedContentManager CreateContentManager(IServiceProvider serviceProvider, string rootDirectory)
173174
{
174175
if (SGame.CreateContentManagerImpl == null)
@@ -177,6 +178,12 @@ protected internal override LocalizedContentManager CreateContentManager(IServic
177178
return SGame.CreateContentManagerImpl(serviceProvider, rootDirectory);
178179
}
179180

181+
/// <inheritdoc />
182+
protected internal override IDisplayDevice CreateDisplayDevice(ContentManager content, GraphicsDevice graphicsDevice)
183+
{
184+
return new SDisplayDevice(content, graphicsDevice);
185+
}
186+
180187
/// <summary>Initialize the instance when the game starts.</summary>
181188
protected override void Initialize()
182189
{

0 commit comments

Comments
 (0)