migrate to new display device hook in Stardew Valley 1.6.15

This commit is contained in:
Jesse Plamondon-Willard
2024-12-18 18:51:48 -05:00
parent 78cae722e5
commit 492a650776
2 changed files with 10 additions and 30 deletions
-27
View File
@@ -30,7 +30,6 @@ using StardewModdingAPI.Framework.ModHelpers;
using StardewModdingAPI.Framework.ModLoading;
using StardewModdingAPI.Framework.Networking;
using StardewModdingAPI.Framework.Reflection;
using StardewModdingAPI.Framework.Rendering;
using StardewModdingAPI.Framework.Serialization;
using StardewModdingAPI.Framework.StateTracking.Snapshots;
using StardewModdingAPI.Framework.Utilities;
@@ -47,7 +46,6 @@ using StardewValley.Menus;
using StardewValley.Mods;
using StardewValley.Objects;
using StardewValley.SDKs;
using xTile.Display;
using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode;
using MiniMonoModHotfix = MonoMod.Utils.MiniMonoModHotfix;
using PathUtilities = StardewModdingAPI.Toolkit.Utilities.PathUtilities;
@@ -132,9 +130,6 @@ internal class SCore : IDisposable
/// <summary>Whether the game has initialized for any custom languages from <c>Data/AdditionalLanguages</c>.</summary>
private bool AreCustomLanguagesInitialized;
/// <summary>Whether the player just returned to the title screen.</summary>
public bool JustReturnedToTitle { get; set; }
/// <summary>The last language set by the game.</summary>
private (string Locale, LanguageCode Code) LastLanguage { get; set; } = ("", LanguageCode.en);
@@ -492,9 +487,6 @@ internal class SCore : IDisposable
/// <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);
// log GPU info
#if SMAPI_FOR_WINDOWS
this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}");
@@ -611,17 +603,6 @@ internal class SCore : IDisposable
try
{
/*********
** Reapply overrides
*********/
if (this.JustReturnedToTitle)
{
if (Game1.mapDisplayDevice is not SDisplayDevice)
Game1.mapDisplayDevice = this.GetMapDisplayDevice();
this.JustReturnedToTitle = false;
}
/*********
** Execute commands
*********/
@@ -1179,7 +1160,6 @@ internal class SCore : IDisposable
break;
case LoadStage.None:
this.JustReturnedToTitle = true;
this.UpdateWindowTitles();
break;
@@ -2369,13 +2349,6 @@ internal class SCore : IDisposable
: MinimalFileLookup.GetCachedFor(rootDirectory);
}
/// <summary>Get the map display device which applies SMAPI features like tile rotation to loaded maps.</summary>
/// <remarks>This is separate to let mods like PyTK wrap it with their own functionality.</remarks>
private IDisplayDevice GetMapDisplayDevice()
{
return new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
}
/// <summary>Get the absolute path to the next available log file.</summary>
private string GetLogPath()
{
+10 -3
View File
@@ -2,11 +2,13 @@ using System;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Enums;
using StardewModdingAPI.Events;
using StardewModdingAPI.Framework.Input;
using StardewModdingAPI.Framework.Reflection;
using StardewModdingAPI.Framework.Rendering;
using StardewModdingAPI.Framework.StateTracking.Snapshots;
using StardewModdingAPI.Framework.Utilities;
using StardewModdingAPI.Internal;
@@ -15,6 +17,7 @@ using StardewValley;
using StardewValley.Logging;
using StardewValley.Menus;
using StardewValley.Minigames;
using xTile.Display;
namespace StardewModdingAPI.Framework;
@@ -166,9 +169,7 @@ internal class SGame : Game1
/*********
** Protected methods
*********/
/// <summary>Construct a content manager to read game content files.</summary>
/// <param name="serviceProvider">The service provider to use to locate services.</param>
/// <param name="rootDirectory">The root directory to search for content.</param>
/// <inheritdoc />
protected internal override LocalizedContentManager CreateContentManager(IServiceProvider serviceProvider, string rootDirectory)
{
if (SGame.CreateContentManagerImpl == null)
@@ -177,6 +178,12 @@ internal class SGame : Game1
return SGame.CreateContentManagerImpl(serviceProvider, rootDirectory);
}
/// <inheritdoc />
protected internal override IDisplayDevice CreateDisplayDevice(ContentManager content, GraphicsDevice graphicsDevice)
{
return new SDisplayDevice(content, graphicsDevice);
}
/// <summary>Initialize the instance when the game starts.</summary>
protected override void Initialize()
{