deprecate PyTK compatibility mode

This commit is contained in:
Jesse Plamondon-Willard 2022-08-29 18:17:53 -04:00
parent 2bb8e8353b
commit 47a68fbb7b
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
4 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,9 @@ using System;
using System.Reflection; using System.Reflection;
using StardewModdingAPI.Events; using StardewModdingAPI.Events;
using StardewModdingAPI.Internal.Patching; using StardewModdingAPI.Internal.Patching;
#if SMAPI_DEPRECATED
using StardewModdingAPI.Mods.ErrorHandler.ModPatches; using StardewModdingAPI.Mods.ErrorHandler.ModPatches;
#endif
using StardewModdingAPI.Mods.ErrorHandler.Patches; using StardewModdingAPI.Mods.ErrorHandler.Patches;
using StardewValley; using StardewValley;
@ -39,10 +41,12 @@ namespace StardewModdingAPI.Mods.ErrorHandler
new ObjectPatcher(), new ObjectPatcher(),
new SaveGamePatcher(this.Monitor, this.OnSaveContentRemoved), new SaveGamePatcher(this.Monitor, this.OnSaveContentRemoved),
new SpriteBatchPatcher(), new SpriteBatchPatcher(),
new UtilityPatcher(), new UtilityPatcher()
#if SMAPI_DEPRECATED
// mod patches // mod patches
new PyTkPatcher(helper.ModRegistry) , new PyTkPatcher(helper.ModRegistry)
#endif
); );
// hook events // hook events

View File

@ -1,3 +1,4 @@
#if SMAPI_DEPRECATED
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
@ -77,3 +78,4 @@ namespace StardewModdingAPI.Mods.ErrorHandler.ModPatches
} }
} }
} }
#endif

View File

@ -50,8 +50,10 @@ namespace StardewModdingAPI.Framework.ContentManagers
/********* /*********
** Accessors ** Accessors
*********/ *********/
#if SMAPI_DEPRECATED
/// <summary>Whether to enable legacy compatibility mode for PyTK scale-up textures.</summary> /// <summary>Whether to enable legacy compatibility mode for PyTK scale-up textures.</summary>
internal static bool EnablePyTkLegacyMode; internal static bool EnablePyTkLegacyMode;
#endif
/********* /*********
@ -202,6 +204,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
bool expectsRawData = typeof(T).IsAssignableTo(typeof(IRawTextureData)); bool expectsRawData = typeof(T).IsAssignableTo(typeof(IRawTextureData));
bool asRawData = expectsRawData || this.UseRawImageLoading; bool asRawData = expectsRawData || this.UseRawImageLoading;
#if SMAPI_DEPRECATED
// disable raw data if PyTK will rescale the image (until it supports raw data) // disable raw data if PyTK will rescale the image (until it supports raw data)
if (asRawData && !expectsRawData) if (asRawData && !expectsRawData)
{ {
@ -212,9 +215,10 @@ namespace StardewModdingAPI.Framework.ContentManagers
// current file has a '.pytk.json' rescale file though, since PyTK may still // current file has a '.pytk.json' rescale file though, since PyTK may still
// rescale it if the original asset or another edit gets rescaled. // rescale it if the original asset or another edit gets rescaled.
asRawData = false; asRawData = false;
this.Monitor.LogOnce("Enabled compatibility mode for PyTK 1.23.* or earlier. This won't cause any issues, but may impact performance.", LogLevel.Warn); this.Monitor.LogOnce("Enabled compatibility mode for PyTK 1.23.* or earlier. This won't cause any issues, but may impact performance. This will no longer be supported in the upcoming SMAPI 4.0.0.", LogLevel.Warn);
} }
} }
#endif
// load // load
if (asRawData) if (asRawData)

View File

@ -1672,6 +1672,7 @@ namespace StardewModdingAPI.Framework
// initialize translations // initialize translations
this.ReloadTranslations(loaded); this.ReloadTranslations(loaded);
#if SMAPI_DEPRECATED
// set temporary PyTK compatibility mode // set temporary PyTK compatibility mode
// This is part of a three-part fix for PyTK 1.23.* and earlier. When removing this, // This is part of a three-part fix for PyTK 1.23.* and earlier. When removing this,
// search 'Platonymous.Toolkit' to find the other part in SMAPI and Content Patcher. // search 'Platonymous.Toolkit' to find the other part in SMAPI and Content Patcher.
@ -1679,6 +1680,7 @@ namespace StardewModdingAPI.Framework
IModInfo? pyTk = this.ModRegistry.Get("Platonymous.Toolkit"); IModInfo? pyTk = this.ModRegistry.Get("Platonymous.Toolkit");
ModContentManager.EnablePyTkLegacyMode = pyTk is not null && pyTk.Manifest.Version.IsOlderThan("1.24.0"); ModContentManager.EnablePyTkLegacyMode = pyTk is not null && pyTk.Manifest.Version.IsOlderThan("1.24.0");
} }
#endif
// initialize loaded non-content-pack mods // initialize loaded non-content-pack mods
this.Monitor.Log("Launching mods...", LogLevel.Debug); this.Monitor.Log("Launching mods...", LogLevel.Debug);