From 5083b65c8708b0c5c0a12871d2fdda830bb98f09 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 23 May 2022 14:33:01 -0400 Subject: fix readme headings for mod build package --- docs/technical/mod-package.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index c632af84..dd65a992 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -412,14 +412,14 @@ The NuGet package is generated automatically in `StardewModdingAPI.ModBuildConfi when you compile it. ## Release notes -## 4.0.1 +### 4.0.1 Released 14 April 2022. * Added detection for Xbox app game folders. * Fixed "_conflicts between different versions of Microsoft.Win32.Registry_" warnings in recent SMAPI versions. * Internal refactoring. -## 4.0.0 +### 4.0.0 Released 30 November 2021. * Updated for Stardew Valley 1.5.5 and SMAPI 3.13.0. (Older versions are no longer supported.) @@ -441,7 +441,7 @@ Released 30 November 2021. * If you need to bundle extra DLLs besides your mod DLL, see the [`BundleExtraAssemblies` documentation](#configure). -## 3.3.0 +### 3.3.0 Released 30 March 2021. * Added a build warning when the mod isn't compiled for `Any CPU`. @@ -450,7 +450,7 @@ Released 30 March 2021. * Added support for building mods against the 64-bit Linux version of the game on Windows. * The package now suppresses the misleading 'processor architecture mismatch' warnings. -## 3.2.2 +### 3.2.2 Released 23 September 2020. * Reworked and streamlined how the package is compiled. -- cgit From 064346594d2239b1dceb9ddbc78e147c555d63d7 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 24 May 2022 18:12:06 -0400 Subject: fix split-screen error when a mod provides a localized asset in one screen but not another --- docs/release-notes.md | 4 ++++ src/SMAPI/Framework/ContentCoordinator.cs | 24 +++++++++++++++++----- .../ContentManagers/BaseContentManager.cs | 12 ++++++----- 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index cd177f61..91ff0618 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,6 +1,10 @@ ← [README](README.md) # Release notes +## Upcoming release +* For players: + * Fixed error in split-screen mode when a mod provides a localized asset in one screen but not another. + ## 3.14.5 Released 22 May 2022 for Stardew Valley 1.5.6 or later. diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index fc61b44b..cfeb35c8 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -15,8 +15,8 @@ using StardewModdingAPI.Framework.Utilities; using StardewModdingAPI.Internal; using StardewModdingAPI.Metadata; using StardewModdingAPI.Toolkit.Serialization; -using StardewModdingAPI.Toolkit.Utilities; using StardewModdingAPI.Toolkit.Utilities.PathLookups; +using StardewModdingAPI.Utilities; using StardewValley; using StardewValley.GameData; using xTile; @@ -110,6 +110,10 @@ namespace StardewModdingAPI.Framework /// The absolute path to the . public string FullRootDirectory { get; } + /// A lookup which tracks whether each given asset name has a localized form. + /// This is a per-screen equivalent to the base game's field, since mods may provide different assets per-screen. + public PerScreen> LocalizedAssetNames { get; } = new(() => new()); + /********* ** Public methods @@ -245,6 +249,9 @@ namespace StardewModdingAPI.Framework { this.VanillaContentManager.Unload(); }); + + // forget localized flags (to match the logic in Game1.TranslateFields, which is called on language change) + this.LocalizedAssetNames.Value.Clear(); } /// Clean up when the player is returning to the title screen. @@ -275,6 +282,10 @@ namespace StardewModdingAPI.Framework // their changes, the assets won't be found in the cache so no changes will be propagated. if (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.en) this.InvalidateCache((contentManager, _, _) => contentManager is GameContentManager); + + // clear the localized assets lookup (to match the logic in Game1.CleanupReturningToTitle) + foreach ((_, Dictionary localizedAssets) in this.LocalizedAssetNames.GetActiveValues()) + localizedAssets.Clear(); } /// Parse a raw asset name. @@ -411,12 +422,15 @@ namespace StardewModdingAPI.Framework // A mod might provide a localized variant of a normally non-localized asset (like // `Maps/MovieTheater.fr-FR`). When the asset is invalidated, we need to recheck // whether the asset is localized in case it stops providing it. - foreach (IAssetName assetName in invalidatedAssets.Keys) { - LocalizedContentManager.localizedAssetNames.Remove(assetName.Name); + Dictionary localizedAssetNames = this.LocalizedAssetNames.Value; + foreach (IAssetName assetName in invalidatedAssets.Keys) + { + localizedAssetNames.Remove(assetName.Name); - if (LocalizedContentManager.localizedAssetNames.TryGetValue(assetName.BaseName, out string? targetForBaseKey) && targetForBaseKey == assetName.Name) - LocalizedContentManager.localizedAssetNames.Remove(assetName.BaseName); + if (localizedAssetNames.TryGetValue(assetName.BaseName, out string? targetForBaseKey) && targetForBaseKey == assetName.Name) + localizedAssetNames.Remove(assetName.BaseName); + } } // special case: maps may be loaded through a temporary content manager that's removed while the map is still in use. diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs index ddc02a8c..d7be0c37 100644 --- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs @@ -153,7 +153,9 @@ namespace StardewModdingAPI.Framework.ContentManagers return this.LoadExact(assetName, useCache: useCache); // check for localized asset - if (!LocalizedContentManager.localizedAssetNames.TryGetValue(assetName.Name, out _)) + // ReSharper disable once LocalVariableHidesMember -- this is deliberate + Dictionary localizedAssetNames = this.Coordinator.LocalizedAssetNames.Value; + if (!localizedAssetNames.TryGetValue(assetName.Name, out _)) { string localeCode = this.LanguageCodeString(language); IAssetName localizedName = new AssetName(baseName: assetName.BaseName, localeCode: localeCode, languageCode: language); @@ -161,7 +163,7 @@ namespace StardewModdingAPI.Framework.ContentManagers try { T data = this.LoadExact(localizedName, useCache: useCache); - LocalizedContentManager.localizedAssetNames[assetName.Name] = localizedName.Name; + localizedAssetNames[assetName.Name] = localizedName.Name; return data; } catch (ContentLoadException) @@ -170,18 +172,18 @@ namespace StardewModdingAPI.Framework.ContentManagers try { T data = this.LoadExact(localizedName, useCache: useCache); - LocalizedContentManager.localizedAssetNames[assetName.Name] = localizedName.Name; + localizedAssetNames[assetName.Name] = localizedName.Name; return data; } catch (ContentLoadException) { - LocalizedContentManager.localizedAssetNames[assetName.Name] = assetName.Name; + localizedAssetNames[assetName.Name] = assetName.Name; } } } // use cached key - string rawName = LocalizedContentManager.localizedAssetNames[assetName.Name]; + string rawName = localizedAssetNames[assetName.Name]; if (assetName.Name != rawName) assetName = this.Coordinator.ParseAssetName(rawName, allowLocales: this.TryLocalizeKeys); return this.LoadExact(assetName, useCache: useCache); -- cgit From e4cd7c8eb09fa50802ce4eb9dbe4683ce61f7a5d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 27 May 2022 18:08:30 -0400 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 5 ++++- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.ErrorHandler/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) (limited to 'docs') diff --git a/build/common.targets b/build/common.targets index 7b59e4ae..2e37e729 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,7 +1,7 @@ - 3.14.5 + 3.14.6 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 91ff0618..4770bd4f 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,9 +1,12 @@ ← [README](README.md) # Release notes -## Upcoming release +## 3.14.6 +Released 27 May 2022 for Stardew Valley 1.5.6 or later. + * For players: * Fixed error in split-screen mode when a mod provides a localized asset in one screen but not another. + * Minor optimizations. ## 3.14.5 Released 22 May 2022 for Stardew Valley 1.5.6 or later. diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 7b403a75..9d9a8061 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.14.5", + "Version": "3.14.6", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.14.5" + "MinimumApiVersion": "3.14.6" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index 2ac959bb..07c2512b 100644 --- a/src/SMAPI.Mods.ErrorHandler/manifest.json +++ b/src/SMAPI.Mods.ErrorHandler/manifest.json @@ -1,9 +1,9 @@ { "Name": "Error Handler", "Author": "SMAPI", - "Version": "3.14.5", + "Version": "3.14.6", "Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.", "UniqueID": "SMAPI.ErrorHandler", "EntryDll": "ErrorHandler.dll", - "MinimumApiVersion": "3.14.5" + "MinimumApiVersion": "3.14.6" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 707b6d8a..ec048dea 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.14.5", + "Version": "3.14.6", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.14.5" + "MinimumApiVersion": "3.14.6" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index b2916a8d..9212fc90 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -50,7 +50,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.14.5"; + internal static string RawApiVersion = "3.14.6"; } /// Contains SMAPI's constants and assumptions. -- cgit