Merge branch 'develop' into stable

This commit is contained in:
Jesse Plamondon-Willard 2021-09-18 13:08:38 -04:00
commit ebe41180c4
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
15 changed files with 142 additions and 67 deletions

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<!--set general build properties --> <!--set general build properties -->
<Version>3.12.6</Version> <Version>3.12.7</Version>
<Product>SMAPI</Product> <Product>SMAPI</Product>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths> <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>

View File

@ -1,8 +1,25 @@
← [README](README.md) ← [README](README.md)
# Release notes # Release notes
## 3.12.7
Released 18 September 2021 for Stardew Valley 1.5.4.
* For players:
* Added more progress updates in the log during startup.
* Simplified asset load error message.
* Simplified exception logs.
* Fixed crash loading mods with corrupted translation files.
* For mod authors:
* Added asset propagation for `LooseSprites\Giftbox`.
* Improved SMAPI's crossplatform read/writing of `Color`, `Point`, `Rectangle`, and `Vector2` in JSON to support nullable fields too.
* For the web UI:
* The mod compatibility list now shows the beta status by default (if any).
* Fixed JSON validator line numbers sometimes incorrect.
## 3.12.6 ## 3.12.6
Released 03 September 2021 for Stardew Valley 1.5.4 or later. Released 03 September 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Added friendly error when using SMAPI 3.2._x_ with Stardew Valley 1.5.5 or later. * Added friendly error when using SMAPI 3.2._x_ with Stardew Valley 1.5.5 or later.
@ -26,18 +43,18 @@ to format asset names, you should switch to `PathUtilities.NormalizeAssetName` n
continue working in the next game update. continue working in the next game update.
## 3.12.5 ## 3.12.5
Released 26 August 2021 for Stardew Valley 1.5.4 or later. Released 26 August 2021 for Stardew Valley 1.5.4.
* Fixed some mods in unofficial 64-bit mode no longer loading after SMAPI 3.12.3. * Fixed some mods in unofficial 64-bit mode no longer loading after SMAPI 3.12.3.
## 3.12.4 ## 3.12.4
Released 25 August 2021 for Stardew Valley 1.5.4 or later. Released 25 August 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Fixed error loading some mods in SMAPI 3.12.3. * Fixed error loading some mods in SMAPI 3.12.3.
## 3.12.3 ## 3.12.3
Released 25 August 2021 for Stardew Valley 1.5.4 or later. Released 25 August 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Added friendly error in 64-bit mode when a mod is 32-bit only. * Added friendly error in 64-bit mode when a mod is 32-bit only.
@ -56,7 +73,7 @@ Released 25 August 2021 for Stardew Valley 1.5.4 or later.
* Fixed update checks shown for prerelease mod versions if you have a working non-prerelease version. * Fixed update checks shown for prerelease mod versions if you have a working non-prerelease version.
## 3.12.2 ## 3.12.2
Released 05 August 2021 for Stardew Valley 1.5.4 or later. Released 05 August 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Fixed error creating a new save or joining a multiplayer world in 3.12.1. * Fixed error creating a new save or joining a multiplayer world in 3.12.1.
@ -67,7 +84,7 @@ Released 05 August 2021 for Stardew Valley 1.5.4 or later.
* Fixed `NullReferenceException` in SMAPI's error-handling when trying to handle an invalid `ReflectionTypeLoadException`. * Fixed `NullReferenceException` in SMAPI's error-handling when trying to handle an invalid `ReflectionTypeLoadException`.
## 3.12.1 ## 3.12.1
Released 03 August 2021 for Stardew Valley 1.5.4 or later. Released 03 August 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* The software conflict message is now shown as a warning to simplify troubleshooting. * The software conflict message is now shown as a warning to simplify troubleshooting.
@ -78,7 +95,7 @@ Released 03 August 2021 for Stardew Valley 1.5.4 or later.
* Fixed `Constants.Save*` fields incorrect if the save's folder name and ID don't match. * Fixed `Constants.Save*` fields incorrect if the save's folder name and ID don't match.
## 3.12.0 ## 3.12.0
Released 01 August 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/54388616). Released 01 August 2021 for Stardew Valley 1.5.4. See [release highlights](https://www.patreon.com/posts/54388616).
* For players: * For players:
* Added save recovery when content mods leave null objects in the save (in _Error Handler_). * Added save recovery when content mods leave null objects in the save (in _Error Handler_).
@ -96,7 +113,7 @@ Released 01 August 2021 for Stardew Valley 1.5.4 or later. See [release highligh
* Fixed reloading a map not correctly reapplying interior doors. * Fixed reloading a map not correctly reapplying interior doors.
## 3.11.0 ## 3.11.0
Released 09 July 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/53514295). Released 09 July 2021 for Stardew Valley 1.5.4. See [release highlights](https://www.patreon.com/posts/53514295).
* For players: * For players:
* Updated for Stardew Valley 1.4.5 multiplayer hotfix on Linux/macOS. * Updated for Stardew Valley 1.4.5 multiplayer hotfix on Linux/macOS.
@ -120,13 +137,13 @@ Released 09 July 2021 for Stardew Valley 1.5.4 or later. See [release highlights
* Fixed JSON schema for `i18n` files requiring the wrong value for the `$schema` field. * Fixed JSON schema for `i18n` files requiring the wrong value for the `$schema` field.
## 3.10.1 ## 3.10.1
Released 03 May 2021 for Stardew Valley 1.5.4 or later. Released 03 May 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Fixed installer leaving an unneeded `StardewModdingAPI-x64.exe` file in 32-bit game folders. * Fixed installer leaving an unneeded `StardewModdingAPI-x64.exe` file in 32-bit game folders.
## 3.10 ## 3.10
Released 03 May 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/50764911). Released 03 May 2021 for Stardew Valley 1.5.4. See [release highlights](https://www.patreon.com/posts/50764911).
* For players: * For players:
* Added full support for the [unofficial 64-bit Stardew Valley patch](https://stardewvalleywiki.com/Modding:Migrate_to_64-bit_on_Windows), which removes memory limits. The installer detects which version of SMAPI you need, and SMAPI shows update alerts for Stardew64Installer if applicable. * Added full support for the [unofficial 64-bit Stardew Valley patch](https://stardewvalleywiki.com/Modding:Migrate_to_64-bit_on_Windows), which removes memory limits. The installer detects which version of SMAPI you need, and SMAPI shows update alerts for Stardew64Installer if applicable.
@ -151,7 +168,7 @@ Released 03 May 2021 for Stardew Valley 1.5.4 or later. See [release highlights]
* Fixed update subkeys not working in file descriptions for Nexus mods marked as adult content. * Fixed update subkeys not working in file descriptions for Nexus mods marked as adult content.
## 3.9.5 ## 3.9.5
Released 21 March 2021 for Stardew Valley 1.5.4 or later. Released 21 March 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Added console command to reset community center bundles _(in Console Commands)_. * Added console command to reset community center bundles _(in Console Commands)_.
@ -172,13 +189,13 @@ Released 21 March 2021 for Stardew Valley 1.5.4 or later.
_Note: mods don't need to handle the difference in most cases, but some players may use MonoGame on Windows in upcoming versions. Mods which check `Constants.TargetPlatform` should review usages as needed._ _Note: mods don't need to handle the difference in most cases, but some players may use MonoGame on Windows in upcoming versions. Mods which check `Constants.TargetPlatform` should review usages as needed._
## 3.9.4 ## 3.9.4
Released 07 March 2021 for Stardew Valley 1.5.4 or later. Released 07 March 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Fixed installer error if the `Mods` folder doesn't exist in 3.9.3. * Fixed installer error if the `Mods` folder doesn't exist in 3.9.3.
## 3.9.3 ## 3.9.3
Released 07 March 2021 for Stardew Valley 1.5.4 or later. Released 07 March 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Added descriptive error if possible when a `PathTooLongException` crashes SMAPI or the installer. * Added descriptive error if possible when a `PathTooLongException` crashes SMAPI or the installer.
@ -194,7 +211,7 @@ Released 07 March 2021 for Stardew Valley 1.5.4 or later.
* Updated the JSON validator/schema for Content Patcher 1.21. * Updated the JSON validator/schema for Content Patcher 1.21.
## 3.9.2 ## 3.9.2
Released 21 February 2021 for Stardew Valley 1.5.4 or later. Released 21 February 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Added more aggressive memory optimization to reduce `OutOfMemoryException` errors with some mods. * Added more aggressive memory optimization to reduce `OutOfMemoryException` errors with some mods.
@ -217,14 +234,14 @@ Released 21 February 2021 for Stardew Valley 1.5.4 or later.
* Fixed SMAPI toolkit defaulting the mod type incorrectly if a mod's `manifest.json` has neither `EntryDll` nor `ContentPackFor`. This only affects external tools, since SMAPI itself validates those fields separately. * Fixed SMAPI toolkit defaulting the mod type incorrectly if a mod's `manifest.json` has neither `EntryDll` nor `ContentPackFor`. This only affects external tools, since SMAPI itself validates those fields separately.
## 3.9.1 ## 3.9.1
Released 25 January 2021 for Stardew Valley 1.5.4 or later. Released 25 January 2021 for Stardew Valley 1.5.4.
* For players: * For players:
* Fixed _tile contains an invalid TileSheet reference_ crash after mods change certain maps. * Fixed _tile contains an invalid TileSheet reference_ crash after mods change certain maps.
* Fixed _patched game code_ issue shown for the bundled Error Handler mod. * Fixed _patched game code_ issue shown for the bundled Error Handler mod.
## 3.9 ## 3.9
Released 22 January 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/46553874). Released 22 January 2021 for Stardew Valley 1.5.4. See [release highlights](https://www.patreon.com/posts/46553874).
* For players: * For players:
* Updated for Stardew Valley 1.5.4. * Updated for Stardew Valley 1.5.4.

View File

@ -1,10 +1,11 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Text.RegularExpressions;
namespace StardewModdingAPI.Internal namespace StardewModdingAPI.Internal
{ {
/// <summary>Provides extension methods for handling exceptions.</summary> /// <summary>Provides extension methods for handling exceptions.</summary>
internal static class ExceptionExtensions internal static class ExceptionHelper
{ {
/********* /*********
** Public methods ** Public methods
@ -15,20 +16,26 @@ namespace StardewModdingAPI.Internal
{ {
try try
{ {
string message;
switch (exception) switch (exception)
{ {
case TypeLoadException ex: case TypeLoadException ex:
return $"Failed loading type '{ex.TypeName}': {exception}"; message = $"Failed loading type '{ex.TypeName}': {exception}";
break;
case ReflectionTypeLoadException ex: case ReflectionTypeLoadException ex:
string summary = ex.ToString(); string summary = ex.ToString();
foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0]) foreach (Exception childEx in ex.LoaderExceptions ?? new Exception[0])
summary += $"\n\n{childEx?.GetLogSummary()}"; summary += $"\n\n{childEx?.GetLogSummary()}";
return summary; message = summary;
break;
default: default:
return exception?.ToString() ?? $"<null exception>\n{Environment.StackTrace}"; message = exception?.ToString() ?? $"<null exception>\n{Environment.StackTrace}";
break;
} }
return ExceptionHelper.SimplifyExtensionMessage(message);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -44,5 +51,26 @@ namespace StardewModdingAPI.Internal
exception = exception.InnerException; exception = exception.InnerException;
return exception; return exception;
} }
/// <summary>Simplify common patterns in exception log messages that don't convey useful info.</summary>
/// <param name="message">The log message to simplify.</param>
public static string SimplifyExtensionMessage(string message)
{
// remove namespace for core exception types
message = Regex.Replace(
message,
@"(?:StardewModdingAPI\.Framework\.Exceptions|Microsoft\.Xna\.Framework|System|System\.IO)\.([a-zA-Z]+Exception):",
"$1:"
);
// remove unneeded root build paths for SMAPI and Stardew Valley
message = message
.Replace(@"C:\source\_Stardew\SMAPI\src\", "")
.Replace(@"C:\GitlabRunner\builds\Gq5qA5P4\0\ConcernedApe\", "");
// remove placeholder info in Linux/macOS stack traces
return message
.Replace(@"<filename unknown>:0", "");
}
} }
} }

View File

@ -14,6 +14,6 @@
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\ConsoleLogLevel.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\ConsoleLogLevel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\IConsoleWriter.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\IConsoleWriter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\MonitorColorScheme.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ConsoleWriting\MonitorColorScheme.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExceptionExtensions.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ExceptionHelper.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,9 @@
{ {
"Name": "Console Commands", "Name": "Console Commands",
"Author": "SMAPI", "Author": "SMAPI",
"Version": "3.12.6", "Version": "3.12.7",
"Description": "Adds SMAPI console commands that let you manipulate the game.", "Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands", "UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll", "EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.12.6" "MinimumApiVersion": "3.12.7"
} }

View File

@ -1,9 +1,9 @@
{ {
"Name": "Error Handler", "Name": "Error Handler",
"Author": "SMAPI", "Author": "SMAPI",
"Version": "3.12.6", "Version": "3.12.7",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.", "Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler", "UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll", "EntryDll": "ErrorHandler.dll",
"MinimumApiVersion": "3.12.6" "MinimumApiVersion": "3.12.7"
} }

View File

@ -1,9 +1,9 @@
{ {
"Name": "Save Backup", "Name": "Save Backup",
"Author": "SMAPI", "Author": "SMAPI",
"Version": "3.12.6", "Version": "3.12.7",
"Description": "Automatically backs up all your saves once per day into its folder.", "Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup", "UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll", "EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.12.6" "MinimumApiVersion": "3.12.7"
} }

View File

@ -22,7 +22,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters
/// <param name="objectType">The object type.</param> /// <param name="objectType">The object type.</param>
public override bool CanConvert(Type objectType) public override bool CanConvert(Type objectType)
{ {
return objectType == typeof(T); return objectType == typeof(T) || Nullable.GetUnderlyingType(objectType) == typeof(T);
} }
/// <summary>Writes the JSON representation of the object.</summary> /// <summary>Writes the JSON representation of the object.</summary>
@ -44,10 +44,15 @@ namespace StardewModdingAPI.Toolkit.Serialization.Converters
string path = reader.Path; string path = reader.Path;
switch (reader.TokenType) switch (reader.TokenType)
{ {
case JsonToken.Null when Nullable.GetUnderlyingType(objectType) != null:
return null;
case JsonToken.StartObject: case JsonToken.StartObject:
return this.ReadObject(JObject.Load(reader), path); return this.ReadObject(JObject.Load(reader), path);
case JsonToken.String: case JsonToken.String:
return this.ReadString(JToken.Load(reader).Value<string>(), path); return this.ReadString(JToken.Load(reader).Value<string>(), path);
default: default:
throw new SParseException($"Can't parse {typeof(T).Name} from {reader.TokenType} node (path: {reader.Path})."); throw new SParseException($"Can't parse {typeof(T).Name} from {reader.TokenType} node (path: {reader.Path}).");
} }

View File

@ -90,21 +90,27 @@ namespace StardewModdingAPI.Web.Controllers
// parse JSON // parse JSON
JToken parsed; JToken parsed;
try
{ {
parsed = JToken.Parse(file.Content, new JsonLoadSettings // load raw JSON
var settings = new JsonLoadSettings
{ {
DuplicatePropertyNameHandling = DuplicatePropertyNameHandling.Error, DuplicatePropertyNameHandling = DuplicatePropertyNameHandling.Error,
CommentHandling = CommentHandling.Load CommentHandling = CommentHandling.Load
}); };
} try
catch (JsonReaderException ex) {
{ parsed = JToken.Parse(file.Content, settings);
return this.View("Index", result.AddErrors(new JsonValidatorErrorModel(ex.LineNumber, ex.Path, ex.Message, ErrorType.None))); }
} catch (JsonReaderException ex)
{
return this.View("Index", result.AddErrors(new JsonValidatorErrorModel(ex.LineNumber, ex.Path, ex.Message, ErrorType.None)));
}
// format JSON // format JSON
result.SetContent(parsed.ToString(Formatting.Indented), expiry: file.Expiry, uploadWarning: file.Warning); string formatted = parsed.ToString(Formatting.Indented);
result.SetContent(formatted, expiry: file.Expiry, uploadWarning: file.Warning);
parsed = JToken.Parse(formatted); // update line number references
}
// skip if no schema selected // skip if no schema selected
if (schemaName == "none") if (schemaName == "none")

View File

@ -45,7 +45,7 @@ else
@if (hasBeta) @if (hasBeta)
{ {
<p id="beta-blurb" v-show="showAdvanced"><strong>Note:</strong> "@betaLabel" lines are for an unreleased version of SMAPI, not the stable version most players have. If a mod doesn't have that line, the info applies to both versions of SMAPI.</p> <p id="beta-blurb"><strong>Note:</strong> "@betaLabel" lines are for the beta version of Stardew Valley, not the stable version most players have. If a mod doesn't have that line, the info applies to both versions.</p>
} }
</div> </div>
@ -99,7 +99,7 @@ else
</td> </td>
<td> <td>
<div v-html="mod.Compatibility.Summary"></div> <div v-html="mod.Compatibility.Summary"></div>
<div v-if="mod.BetaCompatibility" v-show="showAdvanced"> <div v-if="mod.BetaCompatibility">
<strong v-if="mod.BetaCompatibility">@betaLabel:</strong> <strong v-if="mod.BetaCompatibility">@betaLabel:</strong>
<span v-html="mod.BetaCompatibility.Summary"></span> <span v-html="mod.BetaCompatibility.Summary"></span>
</div> </div>

View File

@ -54,7 +54,7 @@ namespace StardewModdingAPI
internal static int? LogScreenId { get; set; } internal static int? LogScreenId { get; set; }
/// <summary>SMAPI's current raw semantic version.</summary> /// <summary>SMAPI's current raw semantic version.</summary>
internal static string RawApiVersion = "3.12.6"; internal static string RawApiVersion = "3.12.7";
} }
/// <summary>Contains SMAPI's constants and assumptions.</summary> /// <summary>Contains SMAPI's constants and assumptions.</summary>

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
@ -205,28 +206,35 @@ namespace StardewModdingAPI.Framework.ContentManagers
/// <remarks>Derived from <see cref="LocalizedContentManager.Load{T}(string, LocalizedContentManager.LanguageCode)"/>.</remarks> /// <remarks>Derived from <see cref="LocalizedContentManager.Load{T}(string, LocalizedContentManager.LanguageCode)"/>.</remarks>
private T RawLoad<T>(string assetName, LanguageCode language, bool useCache) private T RawLoad<T>(string assetName, LanguageCode language, bool useCache)
{ {
// use cached key try
if (language == this.Language && this.LocalizedAssetNames.TryGetValue(assetName, out string cachedKey))
return base.RawLoad<T>(cachedKey, useCache);
// try translated key
if (language != LocalizedContentManager.LanguageCode.en)
{ {
string translatedKey = $"{assetName}.{this.GetLocale(language)}"; // use cached key
try if (language == this.Language && this.LocalizedAssetNames.TryGetValue(assetName, out string cachedKey))
{ return base.RawLoad<T>(cachedKey, useCache);
T obj = base.RawLoad<T>(translatedKey, useCache);
this.LocalizedAssetNames[assetName] = translatedKey;
return obj;
}
catch (ContentLoadException)
{
this.LocalizedAssetNames[assetName] = assetName;
}
}
// try base asset // try translated key
return base.RawLoad<T>(assetName, useCache); if (language != LocalizedContentManager.LanguageCode.en)
{
string translatedKey = $"{assetName}.{this.GetLocale(language)}";
try
{
T obj = base.RawLoad<T>(translatedKey, useCache);
this.LocalizedAssetNames[assetName] = translatedKey;
return obj;
}
catch (ContentLoadException)
{
this.LocalizedAssetNames[assetName] = assetName;
}
}
// try base asset
return base.RawLoad<T>(assetName, useCache);
}
catch (ContentLoadException ex) when (ex.InnerException is FileNotFoundException innerEx && innerEx.InnerException == null)
{
throw new SContentLoadException($"Error loading \"{assetName}\": it isn't in the Content folder and no mod provided it.");
}
} }
/// <summary>Parse an asset key that contains an explicit language into its asset name and language, if applicable.</summary> /// <summary>Parse an asset key that contains an explicit language into its asset name and language, if applicable.</summary>

View File

@ -406,6 +406,10 @@ namespace StardewModdingAPI.Framework.Logging
} }
} }
// simplify exception messages
if (level == LogLevel.Error)
message = ExceptionHelper.SimplifyExtensionMessage(message);
// forward to monitor // forward to monitor
gameMonitor.Log(message, level); gameMonitor.Log(message, level);
} }

View File

@ -289,7 +289,7 @@ namespace StardewModdingAPI.Framework
this.UpdateWindowTitles(); this.UpdateWindowTitles();
// start game // start game
this.Monitor.Log("Starting game...", LogLevel.Debug); this.Monitor.Log("Waiting for game to launch...", LogLevel.Debug);
try try
{ {
this.IsGameRunning = true; this.IsGameRunning = true;
@ -377,7 +377,7 @@ namespace StardewModdingAPI.Framework
// load mods // load mods
{ {
this.Monitor.Log("Loading mod metadata..."); this.Monitor.Log("Loading mod metadata...", LogLevel.Debug);
ModResolver resolver = new ModResolver(); ModResolver resolver = new ModResolver();
// log loose files // log loose files
@ -1487,7 +1487,7 @@ namespace StardewModdingAPI.Framework
/// <param name="modDatabase">Handles access to SMAPI's internal mod metadata list.</param> /// <param name="modDatabase">Handles access to SMAPI's internal mod metadata list.</param>
private void LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, ContentCoordinator contentCore, ModDatabase modDatabase) private void LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, ContentCoordinator contentCore, ModDatabase modDatabase)
{ {
this.Monitor.Log("Loading mods..."); this.Monitor.Log("Loading mods...", LogLevel.Debug);
// load mods // load mods
IList<IModMetadata> skippedMods = new List<IModMetadata>(); IList<IModMetadata> skippedMods = new List<IModMetadata>();
@ -1523,6 +1523,7 @@ namespace StardewModdingAPI.Framework
this.ReloadTranslations(loaded); this.ReloadTranslations(loaded);
// initialize loaded non-content-pack mods // initialize loaded non-content-pack mods
this.Monitor.Log("Launching mods...", LogLevel.Debug);
foreach (IModMetadata metadata in loadedMods) foreach (IModMetadata metadata in loadedMods)
{ {
// add interceptors // add interceptors
@ -1572,6 +1573,8 @@ namespace StardewModdingAPI.Framework
// unlock mod integrations // unlock mod integrations
this.ModRegistry.AreAllModsInitialized = true; this.ModRegistry.AreAllModsInitialized = true;
this.Monitor.Log("Mods loaded and ready!", LogLevel.Debug);
} }
/// <summary>Raised after a mod adds or removes asset interceptors.</summary> /// <summary>Raised after a mod adds or removes asset interceptors.</summary>
@ -1891,9 +1894,9 @@ namespace StardewModdingAPI.Framework
string locale = Path.GetFileNameWithoutExtension(file.Name.ToLower().Trim()); string locale = Path.GetFileNameWithoutExtension(file.Name.ToLower().Trim());
try try
{ {
if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary<string, string> data)) if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary<string, string> data) || data == null)
{ {
errors.Add($"{file.Name} file couldn't be read"); // should never happen, since we're iterating files that exist errors.Add($"{file.Name} file couldn't be read"); // mainly happens when the file is corrupted or empty
continue; continue;
} }

View File

@ -414,6 +414,10 @@ namespace StardewModdingAPI.Metadata
SpriteText.coloredTexture = content.Load<Texture2D>(key); SpriteText.coloredTexture = content.Load<Texture2D>(key);
return true; return true;
case "loosesprites\\giftbox": // Game1.LoadContent
Game1.giftboxTexture = content.Load<Texture2D>(key);
return true;
case "loosesprites\\nightbg": // Game1.LoadContent case "loosesprites\\nightbg": // Game1.LoadContent
Game1.nightbg = content.Load<Texture2D>(key); Game1.nightbg = content.Load<Texture2D>(key);
return true; return true;