From 27856ebea25791d2d82a42a670327f6dd5c4ac23 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 9 Oct 2022 18:03:05 -0400 Subject: drop UseRawImageLoading option Raw image loading is now always enabled, except in PyTK compatibility mode. --- .../Framework/ContentManagers/ModContentManager.cs | 42 ++++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'src/SMAPI/Framework/ContentManagers') diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index ddb6f6f5..badbd766 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -30,9 +30,6 @@ namespace StardewModdingAPI.Framework.ContentManagers /********* ** Fields *********/ - /// Whether to use raw image data when possible, instead of initializing an XNA Texture2D instance through the GPU. - private readonly bool UseRawImageLoading; - /// Encapsulates SMAPI's JSON file parsing. private readonly JsonHelper JsonHelper; @@ -74,15 +71,13 @@ namespace StardewModdingAPI.Framework.ContentManagers /// Encapsulates SMAPI's JSON file parsing. /// A callback to invoke when the content manager is being disposed. /// A lookup for files within the . - /// Whether to use raw image data when possible, instead of initializing an XNA Texture2D instance through the GPU. - public ModContentManager(string name, IContentManager gameContentManager, IServiceProvider serviceProvider, string modName, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action onDisposing, IFileLookup fileLookup, bool useRawImageLoading) + public ModContentManager(string name, IContentManager gameContentManager, IServiceProvider serviceProvider, string modName, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action onDisposing, IFileLookup fileLookup) : base(name, serviceProvider, rootDirectory, currentCulture, coordinator, monitor, reflection, onDisposing, isNamespaced: true) { this.GameContentManager = gameContentManager; this.FileLookup = fileLookup; this.JsonHelper = jsonHelper; this.ModName = modName; - this.UseRawImageLoading = useRawImageLoading; this.TryLocalizeKeys = false; } @@ -205,34 +200,25 @@ namespace StardewModdingAPI.Framework.ContentManagers { this.AssertValidType(assetName, file, typeof(Texture2D), typeof(IRawTextureData)); bool returnRawData = typeof(T).IsAssignableTo(typeof(IRawTextureData)); - bool loadRawData = - returnRawData - || ( - this.UseRawImageLoading + #if SMAPI_DEPRECATED - && !this.ShouldDisableIntermediateRawDataLoad(assetName, file) + if (!returnRawData && this.ShouldDisableIntermediateRawDataLoad(assetName, file)) + { + using FileStream stream = File.OpenRead(file.FullName); + Texture2D texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, stream).SetName(assetName); + this.PremultiplyTransparency(texture); + return (T)(object)texture; + } #endif - ); - // load - if (loadRawData) - { - IRawTextureData raw = this.LoadRawImageData(file, returnRawData); + IRawTextureData raw = this.LoadRawImageData(file, returnRawData); - if (returnRawData) - return (T)raw; - else - { - Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice, raw.Width, raw.Height).SetName(assetName); - texture.SetData(raw.Data); - return (T)(object)texture; - } - } + if (returnRawData) + return (T)raw; else { - using FileStream stream = File.OpenRead(file.FullName); - Texture2D texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, stream).SetName(assetName); - this.PremultiplyTransparency(texture); + Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice, raw.Width, raw.Height).SetName(assetName); + texture.SetData(raw.Data); return (T)(object)texture; } } -- cgit