summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Metadata')
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs45
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs5
2 files changed, 31 insertions, 19 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index 5c77bf66..71199d59 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -34,9 +34,6 @@ namespace StardewModdingAPI.Metadata
/// <summary>Simplifies access to private game code.</summary>
private readonly Reflector Reflection;
- /// <summary>Encapsulates monitoring and logging.</summary>
- private readonly IMonitor Monitor;
-
/// <summary>Optimized bucket categories for batch reloading assets.</summary>
private enum AssetBucket
{
@@ -57,12 +54,10 @@ namespace StardewModdingAPI.Metadata
/// <summary>Initialize the core asset data.</summary>
/// <param name="assertAndNormalizeAssetName">Normalizes an asset key to match the cache key and assert that it's valid.</param>
/// <param name="reflection">Simplifies access to private code.</param>
- /// <param name="monitor">Encapsulates monitoring and logging.</param>
- public CoreAssetPropagator(Func<string, string> assertAndNormalizeAssetName, Reflector reflection, IMonitor monitor)
+ public CoreAssetPropagator(Func<string, string> assertAndNormalizeAssetName, Reflector reflection)
{
this.AssertAndNormalizeAssetName = assertAndNormalizeAssetName;
this.Reflection = reflection;
- this.Monitor = monitor;
}
/// <summary>Reload one of the game's core assets (if applicable).</summary>
@@ -457,17 +452,7 @@ namespace StardewModdingAPI.Metadata
return false;
case "minigames\\titlebuttons": // TitleMenu
- {
- if (Game1.activeClickableMenu is TitleMenu titleMenu)
- {
- Texture2D texture = content.Load<Texture2D>(key);
- titleMenu.titleButtonsTexture = texture;
- foreach (TemporaryAnimatedSprite bird in titleMenu.birds)
- bird.texture = texture;
- return true;
- }
- }
- return false;
+ return this.ReloadTitleButtons(content, key);
/****
** Content\TileSheets
@@ -574,6 +559,32 @@ namespace StardewModdingAPI.Metadata
/****
** Reload texture methods
****/
+ /// <summary>Reload buttons on the title screen.</summary>
+ /// <param name="content">The content manager through which to reload the asset.</param>
+ /// <param name="key">The asset key to reload.</param>
+ /// <returns>Returns whether any textures were reloaded.</returns>
+ /// <remarks>Derived from the <see cref="TitleMenu"/> constructor and <see cref="TitleMenu.setUpIcons"/>.</remarks>
+ private bool ReloadTitleButtons(LocalizedContentManager content, string key)
+ {
+ if (Game1.activeClickableMenu is TitleMenu titleMenu)
+ {
+ Texture2D texture = content.Load<Texture2D>(key);
+
+ titleMenu.titleButtonsTexture = texture;
+ titleMenu.backButton.texture = texture;
+ titleMenu.aboutButton.texture = texture;
+ titleMenu.languageButton.texture = texture;
+ foreach (ClickableTextureComponent button in titleMenu.buttons)
+ button.texture = titleMenu.titleButtonsTexture;
+ foreach (TemporaryAnimatedSprite bird in titleMenu.birds)
+ bird.texture = texture;
+
+ return true;
+ }
+
+ return false;
+ }
+
/// <summary>Reload the sprites for matching pets or horses.</summary>
/// <typeparam name="TAnimal">The animal type.</typeparam>
/// <param name="content">The content manager through which to reload the asset.</param>
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 79d7a7a8..09a199f9 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -35,8 +35,9 @@ namespace StardewModdingAPI.Metadata
if (platformChanged)
yield return new MethodParentRewriter(typeof(SpriteBatch), typeof(SpriteBatchFacade));
- // rewrite for Stardew Valley 1.3
- yield return new StaticFieldToConstantRewriter<int>(typeof(Game1), "tileSize", Game1.tileSize);
+ // heuristic rewrites
+ yield return new HeuristicFieldRewriter(this.ValidateReferencesToAssemblies);
+ yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies);
#if HARMONY_2
// rewrite for SMAPI 3.6 (Harmony 1.x => 2.0 update)