From 9fb6d67417ee3f2db0754b135786e052ae308683 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 18 Jan 2021 18:52:31 -0500 Subject: add asset propagation for Strings\StringsFromCSFiles --- docs/release-notes.md | 11 +++++++---- src/SMAPI/Metadata/CoreAssetPropagator.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index bb379898..9a63de7c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,11 +12,14 @@ * Improved game path detection in the installer. The installer now prefers the path registered by Steam or GOG Galaxy, and can also now detect the default install path for manual GOG installs. * For modders: - * Expanded `PerScreen` API: you can now get/set the value for any screen, get all active values, or clear all values. - * Expanded player info received from multiplayer API/events with new `IsSplitScreen` and `ScreenID` fields. + * Improved multiplayer APIs: + * `PerScreen` now lets you get/set the value for any screen, get all active values, or clear all values. + * Peer data for the multiplayer API/events now includes `IsSplitScreen` and `ScreenID` fields. + * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. + * Improved asset propagation: + * Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names). + * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading but bypasses a Visual Studio debugger crash. * Game errors shown in the chatbox are now logged. - * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This may prevent older mods from loading, but bypasses a Visual Studio crash when debugging. - * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. * For the Error Handler mod: * Added in SMAPI 3.9. This has vanilla error-handling that was previously added by SMAPI directly. That simplifies the core SMAPI logic, and lets players or modders disable it if needed. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 72130e05..24b578ad 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -408,6 +408,12 @@ namespace StardewModdingAPI.Metadata case "minigames\\titlebuttons": // TitleMenu return this.ReloadTitleButtons(content, key); + /**** + ** Content\Strings + ****/ + case "strings\\stringsfromcsfiles": + return this.ReloadStringsFromCsFiles(content); + /**** ** Content\TileSheets ****/ @@ -1028,6 +1034,27 @@ namespace StardewModdingAPI.Metadata return true; } + /// Reload cached translations from the Strings\StringsFromCSFiles asset. + /// The content manager through which to reload the asset. + /// Returns whether any data was reloaded. + /// Derived from the . + private bool ReloadStringsFromCsFiles(LocalizedContentManager content) + { + Game1.samBandName = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2156"); + Game1.elliottBookName = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2157"); + + string[] dayNames = this.Reflection.GetField(typeof(Game1), "_shortDayDisplayName").GetValue(); + dayNames[0] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3042"); + dayNames[1] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3043"); + dayNames[2] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3044"); + dayNames[3] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3045"); + dayNames[4] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3046"); + dayNames[5] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3047"); + dayNames[6] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3048"); + + return true; + } + /**** ** Helpers ****/ -- cgit