summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Constants.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Constants.cs')
-rw-r--r--src/StardewModdingAPI/Constants.cs66
1 files changed, 62 insertions, 4 deletions
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 05e410ab..3feb0830 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -1,7 +1,10 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using StardewModdingAPI.AssemblyRewriters;
+using StardewModdingAPI.AssemblyRewriters.Rewriters;
using StardewValley;
namespace StardewModdingAPI
@@ -23,13 +26,13 @@ namespace StardewModdingAPI
** Accessors
*********/
/// <summary>SMAPI's current semantic version.</summary>
- public static readonly Version Version = new Version(1, 2, 0, null);
+ public static readonly Version Version = new Version(1, 3, 0, null);
/// <summary>The minimum supported version of Stardew Valley.</summary>
public const string MinimumGameVersion = "1.1";
/// <summary>The GitHub repository to check for updates.</summary>
- public const string GitHubRepository = "ClxS/SMAPI";
+ public const string GitHubRepository = "Pathoschild/SMAPI";
/// <summary>The directory path containing Stardew Valley's app data.</summary>
public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
@@ -63,8 +66,63 @@ namespace StardewModdingAPI
/*********
- ** Private field
+ ** Protected methods
*********/
+ /// <summary>Get metadata for mapping assemblies to the current platform.</summary>
+ /// <param name="targetPlatform">The target game platform.</param>
+ internal static PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
+ {
+ // get assembly changes needed for platform
+ string[] removeAssemblyReferences;
+ Assembly[] targetAssemblies;
+ switch (targetPlatform)
+ {
+ case Platform.Mono:
+ removeAssemblyReferences = new[]
+ {
+ "Stardew Valley",
+ "Microsoft.Xna.Framework",
+ "Microsoft.Xna.Framework.Game",
+ "Microsoft.Xna.Framework.Graphics"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly
+ };
+ break;
+
+ case Platform.Windows:
+ removeAssemblyReferences = new[]
+ {
+ "StardewValley",
+ "MonoGame.Framework"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly,
+ typeof(Microsoft.Xna.Framework.Game).Assembly,
+ typeof(Microsoft.Xna.Framework.Graphics.SpriteBatch).Assembly
+ };
+ break;
+
+ default:
+ throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
+ }
+
+ return new PlatformAssemblyMap(targetPlatform, removeAssemblyReferences, targetAssemblies);
+ }
+
+ /// <summary>Get method rewriters which fix incompatible method calls in mod assemblies.</summary>
+ internal static IEnumerable<IMethodRewriter> GetMethodRewriters()
+ {
+ return new[]
+ {
+ new SpriteBatchRewriter()
+ };
+ }
+
/// <summary>Get the name of a save directory for the current player.</summary>
private static string GetSaveFolderName()
{
@@ -72,4 +130,4 @@ namespace StardewModdingAPI
return $"{prefix}_{Game1.uniqueIDForThisGame}";
}
}
-} \ No newline at end of file
+}