summaryrefslogtreecommitdiff
path: root/src/SMAPI/Metadata
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-04-11 21:15:16 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-04-11 21:15:16 -0400
commit9c1617c9ee51a0f6b93242fe8fc789336957460c (patch)
treefc1cf736ed0c7c6e8731abf87bfb8d1a17f8746d /src/SMAPI/Metadata
parentb9bc1a6d17cafa0a97b46ffecda432cfc2f23b51 (diff)
downloadSMAPI-9c1617c9ee51a0f6b93242fe8fc789336957460c.tar.gz
SMAPI-9c1617c9ee51a0f6b93242fe8fc789336957460c.tar.bz2
SMAPI-9c1617c9ee51a0f6b93242fe8fc789336957460c.zip
drop support for Stardew Valley 1.2 (#453)
Diffstat (limited to 'src/SMAPI/Metadata')
-rw-r--r--src/SMAPI/Metadata/CoreAssetPropagator.cs47
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs63
2 files changed, 2 insertions, 108 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index e54e0286..01ea24df 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -80,17 +80,8 @@ namespace StardewModdingAPI.Metadata
** Buildings
****/
case "buildings\\houses": // Farm
-#if STARDEW_VALLEY_1_3
reflection.GetField<Texture2D>(typeof(Farm), nameof(Farm.houseTextures)).SetValue(content.Load<Texture2D>(key));
return true;
-#else
- {
- Farm farm = Game1.getFarm();
- if (farm == null)
- return false;
- return farm.houseTextures = content.Load<Texture2D>(key);
- }
-#endif
/****
** Content\Characters\Farmer
@@ -101,20 +92,12 @@ namespace StardewModdingAPI.Metadata
case "characters\\farmer\\farmer_base": // Farmer
if (Game1.player == null || !Game1.player.isMale)
return false;
-#if STARDEW_VALLEY_1_3
return Game1.player.FarmerRenderer = new FarmerRenderer(key);
-#else
- return Game1.player.FarmerRenderer = new FarmerRenderer(content.Load<Texture2D>(key));
-#endif
case "characters\\farmer\\farmer_girl_base": // Farmer
if (Game1.player == null || Game1.player.isMale)
return false;
-#if STARDEW_VALLEY_1_3
return Game1.player.FarmerRenderer = new FarmerRenderer(key);
-#else
- return Game1.player.FarmerRenderer = new FarmerRenderer(content.Load<Texture2D>(key));
-#endif
case "characters\\farmer\\hairstyles": // Game1.loadContent
return FarmerRenderer.hairStylesTexture = content.Load<Texture2D>(key);
@@ -206,11 +189,6 @@ namespace StardewModdingAPI.Metadata
/****
** Content\Critters
****/
-#if !STARDEW_VALLEY_1_3
- case "tilesheets\\critters": // Criter.InitShared
- return Critter.critterTexture = content.Load<Texture2D>(key);
-#endif
-
case "tilesheets\\crops": // Game1.loadContent
return Game1.cropSpriteSheet = content.Load<Texture2D>(key);
@@ -265,11 +243,7 @@ namespace StardewModdingAPI.Metadata
Texture2D texture = content.Load<Texture2D>(key);
reflection.GetField<Texture2D>(titleMenu, "titleButtonsTexture").SetValue(texture);
foreach (TemporaryAnimatedSprite bird in reflection.GetField<List<TemporaryAnimatedSprite>>(titleMenu, "birds").GetValue())
-#if STARDEW_VALLEY_1_3
bird.texture = texture;
-#else
- bird.Texture = texture;
-#endif
return true;
}
return false;
@@ -284,12 +258,8 @@ namespace StardewModdingAPI.Metadata
return Game1.buffsIcons = content.Load<Texture2D>(key);
case "tilesheets\\bushes": // new Bush()
-#if STARDEW_VALLEY_1_3
reflection.GetField<Lazy<Texture2D>>(typeof(Bush), "texture").SetValue(new Lazy<Texture2D>(() => content.Load<Texture2D>(key)));
return true;
-#else
- return Bush.texture = content.Load<Texture2D>(key);
-#endif
case "tilesheets\\craftables": // Game1.loadContent
return Game1.bigCraftableSpriteSheet = content.Load<Texture2D>(key);
@@ -350,7 +320,7 @@ namespace StardewModdingAPI.Metadata
return this.ReloadNpcSprites(content, key, monster: true);
if (key.StartsWith(this.GetNormalisedPath("LooseSprites\\Fence"), StringComparison.InvariantCultureIgnoreCase))
- return this.ReloadFenceTextures(content, key);
+ return this.ReloadFenceTextures(key);
if (this.IsInFolder(key, "Portraits"))
return this.ReloadNpcPortraits(content, key);
@@ -435,21 +405,16 @@ namespace StardewModdingAPI.Metadata
{
Lazy<Texture2D> texture = new Lazy<Texture2D>(() => content.Load<Texture2D>(key));
foreach (Building building in buildings)
-#if STARDEW_VALLEY_1_3
building.texture = texture;
-#else
- building.texture = texture.Value;
-#endif
return true;
}
return false;
}
/// <summary>Reload the sprites for a fence type.</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>
- private bool ReloadFenceTextures(LocalizedContentManager content, string key)
+ private bool ReloadFenceTextures(string key)
{
// get fence type
if (!int.TryParse(this.GetSegments(key)[1].Substring("Fence".Length), out int fenceType))
@@ -528,11 +493,7 @@ namespace StardewModdingAPI.Metadata
{
Lazy<Texture2D> texture = new Lazy<Texture2D>(() => content.Load<Texture2D>(key));
foreach (Tree tree in trees)
-#if STARDEW_VALLEY_1_3
this.Reflection.GetField<Lazy<Texture2D>>(tree, "texture").SetValue(texture);
-#else
- this.Reflection.GetField<Texture2D>(tree, "texture").SetValue(texture.Value);
-#endif
return true;
}
@@ -547,11 +508,7 @@ namespace StardewModdingAPI.Metadata
/// <param name="texture">The texture to set.</param>
private void SetSpriteTexture(AnimatedSprite sprite, Texture2D texture)
{
-#if STARDEW_VALLEY_1_3
this.Reflection.GetField<Texture2D>(sprite, "spriteTexture").SetValue(texture);
-#else
- sprite.Texture = texture;
-#endif
}
/// <summary>Get an NPC name from the name of their file under <c>Content/Characters</c>.</summary>
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 4960a458..0b532a18 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -6,9 +6,6 @@ using StardewModdingAPI.Framework.ModLoading;
using StardewModdingAPI.Framework.ModLoading.Finders;
using StardewModdingAPI.Framework.ModLoading.Rewriters;
using StardewValley;
-#if STARDEW_VALLEY_1_3
-using SObject = StardewValley.Object;
-#endif
namespace StardewModdingAPI.Metadata
{
@@ -37,75 +34,15 @@ namespace StardewModdingAPI.Metadata
// rewrite for crossplatform compatibility
new MethodParentRewriter(typeof(SpriteBatch), typeof(SpriteBatchMethods), onlyIfPlatformChanged: true),
-#if !STARDEW_VALLEY_1_3
- // rewrite for Stardew Valley 1.2
- new FieldToPropertyRewriter(typeof(Game1), nameof(Game1.activeClickableMenu)),
- new FieldToPropertyRewriter(typeof(Game1), nameof(Game1.currentMinigame)),
- new FieldToPropertyRewriter(typeof(Game1), nameof(Game1.gameMode)),
- new FieldToPropertyRewriter(typeof(Game1), nameof(Game1.player)),
- new FieldReplaceRewriter(typeof(Game1), "borderFont", nameof(Game1.smallFont)),
- new FieldReplaceRewriter(typeof(Game1), "smoothFont", nameof(Game1.smallFont)),
-
- // rewrite for SMAPI 1.9
- new TypeReferenceRewriter("StardewModdingAPI.Inheritance.ItemStackChange", typeof(ItemStackChange)),
-#endif
-
// rewrite for SMAPI 2.0
new VirtualEntryCallRemover(),
// rewrite for Stardew Valley 1.3
-#if STARDEW_VALLEY_1_3
new StaticFieldToConstantRewriter<int>(typeof(Game1), "tileSize", Game1.tileSize),
-#endif
/****
** detect incompatible code
****/
- #if !STARDEW_VALLEY_1_3
- // detect changes in Stardew Valley 1.2
- new FieldFinder("StardewValley.Item", "set_Name", InstructionHandleResult.NotCompatible),
-
- // detect APIs removed in SMAPI 1.9
- new TypeFinder("StardewModdingAPI.Advanced.ConfigFile", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Advanced.IConfigFile", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Entities.SPlayer", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Extensions", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Inheritance.SGame", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Inheritance.SObject", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.LogWriter", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Manifest", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Version", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "DrawDebug", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "DrawTick", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "OnPostRenderHudEventNoCheck", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "OnPostRenderGuiEventNoCheck", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "OnPreRenderHudEventNoCheck", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GraphicsEvents", "OnPreRenderGuiEventNoCheck", InstructionHandleResult.NotCompatible),
-
- // detect APIs removed in SMAPI 2.0
- new TypeFinder("StardewModdingAPI.Command", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Config", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Log", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GameEvents", "Initialize", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GameEvents", "LoadContent", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.GameEvents", "GameLoaded", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.PlayerEvents", "LoadedGame", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.PlayerEvents", "FarmerChanged", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.TimeEvents", "DayOfMonthChanged", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.TimeEvents", "YearOfGameChanged", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.TimeEvents", "SeasonOfYearChanged", InstructionHandleResult.NotCompatible),
- new EventFinder("StardewModdingAPI.Events.TimeEvents", "OnNewDay", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Events.EventArgsCommand", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Events.EventArgsFarmerChanged", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Events.EventArgsLoadedGameChanged", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Events.EventArgsNewDay", InstructionHandleResult.NotCompatible),
- new TypeFinder("StardewModdingAPI.Events.EventArgsStringChanged", InstructionHandleResult.NotCompatible),
- new PropertyFinder("StardewModdingAPI.Mod", "PathOnDisk", InstructionHandleResult.NotCompatible),
- new PropertyFinder("StardewModdingAPI.Mod", "BaseConfigPath", InstructionHandleResult.NotCompatible),
- new PropertyFinder("StardewModdingAPI.Mod", "PerSaveConfigFolder", InstructionHandleResult.NotCompatible),
- new PropertyFinder("StardewModdingAPI.Mod", "PerSaveConfigPath", InstructionHandleResult.NotCompatible),
- #endif
-
// detect broken code
new ReferenceToMissingMemberFinder(this.ValidateReferencesToAssemblies),
new ReferenceToMemberWithUnexpectedTypeFinder(this.ValidateReferencesToAssemblies),