summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/StardewModdingAPI/Constants.cs11
-rw-r--r--src/StardewModdingAPI/Program.cs35
2 files changed, 21 insertions, 25 deletions
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 99bf834c..be44c664 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -65,6 +65,9 @@ namespace StardewModdingAPI
/// <summary>The file path to the log where the latest output should be saved.</summary>
internal static string LogPath => Path.Combine(Constants.LogDir, "SMAPI-latest.txt");
+ /// <summary>The full path to the folder containing mods.</summary>
+ internal static string ModPath { get; } = Path.Combine(Constants.ExecutionPath, "Mods");
+
/// <summary>Whether a player save has been loaded.</summary>
internal static bool IsSaveLoaded => Game1.hasLoadedGame && !string.IsNullOrEmpty(Game1.player.name);
@@ -74,6 +77,14 @@ namespace StardewModdingAPI
/// <summary>The game's current version as it should be displayed to players.</summary>
internal static ISemanticVersion GameDisplayVersion { get; } = Constants.GetGameDisplayVersion(Constants.GameVersion);
+ /// <summary>The target game platform.</summary>
+ internal static Platform TargetPlatform { get; } =
+#if SMAPI_FOR_WINDOWS
+ Platform.Windows;
+#else
+ Platform.Mono;
+#endif
+
/*********
** Protected methods
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 05d3e5e4..b7947df1 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -28,17 +28,6 @@ namespace StardewModdingAPI
/*********
** Properties
*********/
- /// <summary>The target game platform.</summary>
- private readonly Platform TargetPlatform =
-#if SMAPI_FOR_WINDOWS
- Platform.Windows;
-#else
- Platform.Mono;
-#endif
-
- /// <summary>The full path to the folder containing mods.</summary>
- private readonly string ModPath = Path.Combine(Constants.ExecutionPath, "Mods");
-
/// <summary>The log file to which to write messages.</summary>
private readonly LogFileManager LogFile = new LogFileManager(Constants.LogPath);
@@ -57,21 +46,17 @@ namespace StardewModdingAPI
/// <summary>Whether the game is currently running.</summary>
private bool IsGameRunning;
-
- /*********
- ** Accessors
- *********/
/// <summary>The underlying game instance.</summary>
- internal SGame GameInstance;
+ private SGame GameInstance;
/// <summary>Tracks the installed mods.</summary>
- internal readonly ModRegistry ModRegistry;
+ private readonly ModRegistry ModRegistry;
/// <summary>Manages deprecation warnings.</summary>
- internal readonly DeprecationManager DeprecationManager;
+ private readonly DeprecationManager DeprecationManager;
/// <summary>Manages console commands.</summary>
- internal readonly CommandManager CommandManager = new CommandManager();
+ private readonly CommandManager CommandManager = new CommandManager();
/*********
@@ -136,7 +121,7 @@ namespace StardewModdingAPI
this.Monitor.Log("Writing to the terminal is disabled because the --no-terminal argument was received. This usually means launching the terminal failed.", LogLevel.Warn);
// print file paths
- this.Monitor.Log($"Mods go here: {this.ModPath}");
+ this.Monitor.Log($"Mods go here: {Constants.ModPath}");
// hook into & launch the game
try
@@ -151,11 +136,11 @@ namespace StardewModdingAPI
// initialise folders
this.Monitor.Log("Loading SMAPI...");
- this.VerifyPath(this.ModPath);
+ this.VerifyPath(Constants.ModPath);
this.VerifyPath(Constants.LogDir);
// get executable path
- string executablePath = Path.Combine(Constants.ExecutionPath, this.TargetPlatform == Platform.Windows ? "Stardew Valley.exe" : "StardewValley.exe");
+ string executablePath = Path.Combine(Constants.ExecutionPath, Constants.TargetPlatform == Platform.Windows ? "Stardew Valley.exe" : "StardewValley.exe");
if (!File.Exists(executablePath))
{
this.Monitor.Log($"Couldn't find executable: {executablePath}", LogLevel.Error);
@@ -331,13 +316,13 @@ namespace StardewModdingAPI
JsonHelper jsonHelper = new JsonHelper();
// get assembly loader
- AssemblyLoader modAssemblyLoader = new AssemblyLoader(this.TargetPlatform, this.Monitor);
+ AssemblyLoader modAssemblyLoader = new AssemblyLoader(Constants.TargetPlatform, this.Monitor);
AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => modAssemblyLoader.ResolveAssembly(e.Name);
// load mod assemblies
int modsLoaded = 0;
List<Action> deprecationWarnings = new List<Action>(); // queue up deprecation warnings to show after mod list
- foreach (string directoryPath in Directory.GetDirectories(this.ModPath))
+ foreach (string directoryPath in Directory.GetDirectories(Constants.ModPath))
{
// passthrough empty directories
DirectoryInfo directory = new DirectoryInfo(directoryPath);
@@ -358,7 +343,7 @@ namespace StardewModdingAPI
this.Monitor.Log($"Ignored folder \"{directory.Name}\" which doesn't have a manifest.json.", LogLevel.Warn);
continue;
}
- string skippedPrefix = $"Skipped {manifestPath.Replace(this.ModPath, "").Trim('/', '\\')}";
+ string skippedPrefix = $"Skipped {manifestPath.Replace(Constants.ModPath, "").Trim('/', '\\')}";
// read manifest
Manifest manifest;