diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-09 22:56:42 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-02-09 22:56:42 -0500 |
commit | 388ef0a01205387c5ae56f0cdbe8a86a1febc3de (patch) | |
tree | c9b6c4d9a3af7639354f29148c6366e9fb222eec /src | |
parent | a13003de8b8601ac693d7af960fab67d285dbd0e (diff) | |
download | SMAPI-388ef0a01205387c5ae56f0cdbe8a86a1febc3de.tar.gz SMAPI-388ef0a01205387c5ae56f0cdbe8a86a1febc3de.tar.bz2 SMAPI-388ef0a01205387c5ae56f0cdbe8a86a1febc3de.zip |
reorganise rewriters (#231)
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI.AssemblyRewriters/Rewriters/Crossplatform/SpriteBatch_MethodRewriter.cs (renamed from src/StardewModdingAPI.AssemblyRewriters/Rewriters/SpriteBatchRewriter.cs) | 9 | ||||
-rw-r--r-- | src/StardewModdingAPI.AssemblyRewriters/Rewriters/SDV1_2/Game1_ActiveClickableMenu_FieldRewriter.cs (renamed from src/StardewModdingAPI.AssemblyRewriters/Rewriters/ActiveClickableMenuRewriter.cs) | 6 | ||||
-rw-r--r-- | src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj | 4 | ||||
-rw-r--r-- | src/StardewModdingAPI/Constants.cs | 10 |
4 files changed, 18 insertions, 11 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/Rewriters/SpriteBatchRewriter.cs b/src/StardewModdingAPI.AssemblyRewriters/Rewriters/Crossplatform/SpriteBatch_MethodRewriter.cs index 109a6a6e..252fe6d0 100644 --- a/src/StardewModdingAPI.AssemblyRewriters/Rewriters/SpriteBatchRewriter.cs +++ b/src/StardewModdingAPI.AssemblyRewriters/Rewriters/Crossplatform/SpriteBatch_MethodRewriter.cs @@ -5,11 +5,12 @@ using Mono.Cecil; using Mono.Cecil.Cil; using StardewModdingAPI.AssemblyRewriters.Framework; -namespace StardewModdingAPI.AssemblyRewriters.Rewriters +namespace StardewModdingAPI.AssemblyRewriters.Rewriters.Crossplatform { /// <summary>Rewrites references to <see cref="SpriteBatch"/> to fix inconsistent method signatures between MonoGame and XNA.</summary> /// <remarks>MonoGame has one <c>SpriteBatch.Begin</c> method with optional arguments, but XNA has multiple method overloads. Incompatible method references are rewritten to use <see cref="WrapperMethods"/>, which redirects all method signatures to the proper compiled MonoGame/XNA method.</remarks> - public class SpriteBatchRewriter : BaseMethodRewriter + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "This class is not meant to be used directly, and is deliberately named to make it easier to know what it changes at a glance.")] + public class SpriteBatch_MethodRewriter : BaseMethodRewriter { /********* ** Protected methods @@ -22,7 +23,7 @@ namespace StardewModdingAPI.AssemblyRewriters.Rewriters { return platformChanged && methodRef.DeclaringType.FullName == typeof(SpriteBatch).FullName - && this.HasMatchingSignature(typeof(SpriteBatchRewriter.WrapperMethods), methodRef); + && this.HasMatchingSignature(typeof(SpriteBatch_MethodRewriter.WrapperMethods), methodRef); } /// <summary>Rewrite a method for compatibility.</summary> @@ -33,7 +34,7 @@ namespace StardewModdingAPI.AssemblyRewriters.Rewriters /// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param> protected override void Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, MethodReference methodRef, PlatformAssemblyMap assemblyMap) { - methodRef.DeclaringType = module.Import(typeof(SpriteBatchRewriter.WrapperMethods)); + methodRef.DeclaringType = module.Import(typeof(SpriteBatch_MethodRewriter.WrapperMethods)); } diff --git a/src/StardewModdingAPI.AssemblyRewriters/Rewriters/ActiveClickableMenuRewriter.cs b/src/StardewModdingAPI.AssemblyRewriters/Rewriters/SDV1_2/Game1_ActiveClickableMenu_FieldRewriter.cs index b8aef019..36634b28 100644 --- a/src/StardewModdingAPI.AssemblyRewriters/Rewriters/ActiveClickableMenuRewriter.cs +++ b/src/StardewModdingAPI.AssemblyRewriters/Rewriters/SDV1_2/Game1_ActiveClickableMenu_FieldRewriter.cs @@ -1,13 +1,15 @@ +using System.Diagnostics.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using StardewModdingAPI.AssemblyRewriters.Framework; using StardewValley; -namespace StardewModdingAPI.AssemblyRewriters.Rewriters +namespace StardewModdingAPI.AssemblyRewriters.Rewriters.SDV1_2 { /// <summary>Rewrites field references to <see cref="Game1.activeClickableMenu"/>.</summary> /// <remarks>Stardew Valley changed the <see cref="Game1.activeClickableMenu"/> field to a property, which broke many mods that reference it.</remarks> - public class ActiveClickableMenuRewriter : BaseFieldRewriter + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "This class is not meant to be used directly, and is deliberately named to make it easier to know what it changes at a glance.")] + public class Game1_ActiveClickableMenu_FieldRewriter : BaseFieldRewriter { /********* ** Protected methods diff --git a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj index 4433131b..a58dc176 100644 --- a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj +++ b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj @@ -77,8 +77,8 @@ <Compile Include="Framework\BaseFieldRewriter.cs" /> <Compile Include="Framework\BaseMethodRewriter.cs" /> <Compile Include="Framework\RewriteHelper.cs" /> - <Compile Include="Rewriters\ActiveClickableMenuRewriter.cs" /> - <Compile Include="Rewriters\SpriteBatchRewriter.cs" /> + <Compile Include="Rewriters\SDV1_2\Game1_ActiveClickableMenu_FieldRewriter.cs" /> + <Compile Include="Rewriters\Crossplatform\SpriteBatch_MethodRewriter.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs index 57704def..cee33560 100644 --- a/src/StardewModdingAPI/Constants.cs +++ b/src/StardewModdingAPI/Constants.cs @@ -4,7 +4,8 @@ using System.IO; using System.Linq; using System.Reflection; using StardewModdingAPI.AssemblyRewriters; -using StardewModdingAPI.AssemblyRewriters.Rewriters; +using StardewModdingAPI.AssemblyRewriters.Rewriters.Crossplatform; +using StardewModdingAPI.AssemblyRewriters.Rewriters.SDV1_2; using StardewValley; namespace StardewModdingAPI @@ -125,8 +126,11 @@ namespace StardewModdingAPI { return new IInstructionRewriter[] { - new SpriteBatchRewriter(), - new ActiveClickableMenuRewriter() + // crossplatform + new SpriteBatch_MethodRewriter(), + + // Stardew Valley 1.2 + new Game1_ActiveClickableMenu_FieldRewriter() }; } |