summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Constants.cs2
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs44
-rw-r--r--src/SMAPI/Framework/Logging/LogManager.cs4
-rw-r--r--src/SMAPI/Framework/SCore.cs13
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs4
5 files changed, 43 insertions, 24 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index d0c693bf..fbc00d1d 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -54,7 +54,7 @@ namespace StardewModdingAPI
internal static int? LogScreenId { get; set; }
/// <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>
diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
index 63cd1759..38bcf153 100644
--- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using System.Linq;
using System.Reflection;
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>
private T RawLoad<T>(string assetName, LanguageCode language, bool useCache)
{
- // use cached key
- 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)
+ try
{
- string translatedKey = $"{assetName}.{this.GetLocale(language)}";
- try
- {
- T obj = base.RawLoad<T>(translatedKey, useCache);
- this.LocalizedAssetNames[assetName] = translatedKey;
- return obj;
- }
- catch (ContentLoadException)
+ // use cached key
+ 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)
{
- this.LocalizedAssetNames[assetName] = assetName;
+ 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);
+ // 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>
diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs
index 6fe44d98..f2876146 100644
--- a/src/SMAPI/Framework/Logging/LogManager.cs
+++ b/src/SMAPI/Framework/Logging/LogManager.cs
@@ -406,6 +406,10 @@ namespace StardewModdingAPI.Framework.Logging
}
}
+ // simplify exception messages
+ if (level == LogLevel.Error)
+ message = ExceptionHelper.SimplifyExtensionMessage(message);
+
// forward to monitor
gameMonitor.Log(message, level);
}
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 5913430e..86b69239 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -289,7 +289,7 @@ namespace StardewModdingAPI.Framework
this.UpdateWindowTitles();
// start game
- this.Monitor.Log("Starting game...", LogLevel.Debug);
+ this.Monitor.Log("Waiting for game to launch...", LogLevel.Debug);
try
{
this.IsGameRunning = true;
@@ -377,7 +377,7 @@ namespace StardewModdingAPI.Framework
// load mods
{
- this.Monitor.Log("Loading mod metadata...");
+ this.Monitor.Log("Loading mod metadata...", LogLevel.Debug);
ModResolver resolver = new ModResolver();
// log loose files
@@ -1487,7 +1487,7 @@ namespace StardewModdingAPI.Framework
/// <param name="modDatabase">Handles access to SMAPI's internal mod metadata list.</param>
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
IList<IModMetadata> skippedMods = new List<IModMetadata>();
@@ -1523,6 +1523,7 @@ namespace StardewModdingAPI.Framework
this.ReloadTranslations(loaded);
// initialize loaded non-content-pack mods
+ this.Monitor.Log("Launching mods...", LogLevel.Debug);
foreach (IModMetadata metadata in loadedMods)
{
// add interceptors
@@ -1572,6 +1573,8 @@ namespace StardewModdingAPI.Framework
// unlock mod integrations
this.ModRegistry.AreAllModsInitialized = true;
+
+ this.Monitor.Log("Mods loaded and ready!", LogLevel.Debug);
}
/// <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());
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;
}
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index 708673c3..35ae26b3 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -414,6 +414,10 @@ namespace StardewModdingAPI.Metadata
SpriteText.coloredTexture = content.Load<Texture2D>(key);
return true;
+ case "loosesprites\\giftbox": // Game1.LoadContent
+ Game1.giftboxTexture = content.Load<Texture2D>(key);
+ return true;
+
case "loosesprites\\nightbg": // Game1.LoadContent
Game1.nightbg = content.Load<Texture2D>(key);
return true;