summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Metadata
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-23 20:22:33 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-23 20:22:33 -0400
commite8648e217a3c0e45bf78e903623e6f250f92e88d (patch)
treeb9ce6c62df96ec15c46e1743c6d209ac15195cb2 /src/StardewModdingAPI/Metadata
parenteeee6b185d5438e5d44ed0da7c23cf19813b29ea (diff)
downloadSMAPI-e8648e217a3c0e45bf78e903623e6f250f92e88d.tar.gz
SMAPI-e8648e217a3c0e45bf78e903623e6f250f92e88d.tar.bz2
SMAPI-e8648e217a3c0e45bf78e903623e6f250f92e88d.zip
add support for reloading wallpaper and building textures (#335)
Diffstat (limited to 'src/StardewModdingAPI/Metadata')
-rw-r--r--src/StardewModdingAPI/Metadata/CoreAssets.cs33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Metadata/CoreAssets.cs b/src/StardewModdingAPI/Metadata/CoreAssets.cs
index 256a911a..c350b0da 100644
--- a/src/StardewModdingAPI/Metadata/CoreAssets.cs
+++ b/src/StardewModdingAPI/Metadata/CoreAssets.cs
@@ -5,6 +5,8 @@ using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework;
using StardewValley;
using StardewValley.BellsAndWhistles;
+using StardewValley.Buildings;
+using StardewValley.Locations;
using StardewValley.Objects;
using StardewValley.Projectiles;
@@ -83,7 +85,10 @@ namespace StardewModdingAPI.Metadata
{
if (Game1.player != null && !Game1.player.isMale)
Game1.player.FarmerRenderer = new FarmerRenderer(content.Load<Texture2D>(key));
- }
+ },
+
+ // from Wallpaper constructor
+ ["Maps\\walls_and_floors"] = (content, key) => Wallpaper.wallpaperTexture = content.Load<Texture2D>(key)
}
.ToDictionary(p => getNormalisedPath(p.Key), p => p.Value);
}
@@ -101,7 +106,33 @@ namespace StardewModdingAPI.Metadata
return true;
}
+ // building textures
+ if (key.StartsWith(this.GetNormalisedPath("Buildings\\")))
+ {
+ Building[] buildings = this.GetAllBuildings().Where(p => key == this.GetNormalisedPath($"Buildings\\{p.buildingType}")).ToArray();
+ if (buildings.Any())
+ {
+ Texture2D texture = content.Load<Texture2D>(key);
+ foreach (Building building in buildings)
+ building.texture = texture;
+ return true;
+ }
+ return false;
+ }
+
return false;
}
+
+
+ /*********
+ ** Private methods
+ *********/
+ /// <summary>Get all player-constructed buildings in the world.</summary>
+ private IEnumerable<Building> GetAllBuildings()
+ {
+ return Game1.locations
+ .OfType<BuildableGameLocation>()
+ .SelectMany(p => p.buildings);
+ }
}
}