summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Müssig <patrick.muessig@gmx.de>2022-04-02 03:47:52 +0200
committerPatrick Müssig <patrick.muessig@gmx.de>2022-04-02 04:08:49 +0200
commit61d857c41fc2b90cd495c4923251cb1ed472e5ca (patch)
tree60961b6285b73b527d6b968603366d335c16b1d3 /src
parent6ad8ca932eb697a76dd9df43d6ae93c7ca4b2af5 (diff)
downloadSMAPI-61d857c41fc2b90cd495c4923251cb1ed472e5ca.tar.gz
SMAPI-61d857c41fc2b90cd495c4923251cb1ed472e5ca.tar.bz2
SMAPI-61d857c41fc2b90cd495c4923251cb1ed472e5ca.zip
Added support for `--developer-mode true|false`
Minimal changes required to enable/disable developer mode via command line argument. This commit does not include any error handling for invalid values how ever they will be ignored and not crash the game.
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/SCore.cs10
-rw-r--r--src/SMAPI/Program.cs19
2 files changed, 26 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index b4aa3595..801a7237 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -168,7 +168,8 @@ namespace StardewModdingAPI.Framework
/// <summary>Construct an instance.</summary>
/// <param name="modsPath">The path to search for mods.</param>
/// <param name="writeToConsole">Whether to output log messages to the console.</param>
- public SCore(string modsPath, bool writeToConsole)
+ /// <param name="developerModeValue">null if not modified else whether to use developer mode</param>
+ public SCore(string modsPath, bool writeToConsole, bool? developerModeValue)
{
SCore.Instance = this;
@@ -183,6 +184,13 @@ namespace StardewModdingAPI.Framework
// init basics
this.Settings = JsonConvert.DeserializeObject<SConfig>(File.ReadAllText(Constants.ApiConfigPath));
+
+ // temporary overwrite DeveloperMode Setting
+ if (developerModeValue.HasValue)
+ {
+ this.Settings.DeveloperMode = developerModeValue.Value;
+ }
+
if (File.Exists(Constants.ApiUserConfigPath))
JsonConvert.PopulateObject(File.ReadAllText(Constants.ApiUserConfigPath), this.Settings);
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index f2f65287..32bf0bdd 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -179,15 +179,30 @@ namespace StardewModdingAPI
bool writeToConsole = !args.Contains("--no-terminal") && Environment.GetEnvironmentVariable("SMAPI_NO_TERMINAL") == null;
// get mods path
+ bool? developerModeValue = null;
string modsPath;
{
string rawModsPath = null;
- // get from command line args
+ // get mods path from command line args
int pathIndex = Array.LastIndexOf(args, "--mods-path") + 1;
if (pathIndex >= 1 && args.Length >= pathIndex)
rawModsPath = args[pathIndex];
+ // get developer mode from command line args
+ int developerModeValueIndex = Array.LastIndexOf(args, "--developer-mode") + 1;
+ if (developerModeValueIndex >= 1 && args.Length >= developerModeValueIndex)
+ {
+ if (args[developerModeValueIndex].ToLower().Equals("true"))
+ {
+ developerModeValue = true;
+ }
+ else if (args[developerModeValueIndex].ToLower().Equals("false"))
+ {
+ developerModeValue = false;
+ }
+ }
+
// get from environment variables
if (string.IsNullOrWhiteSpace(rawModsPath))
rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH");
@@ -199,7 +214,7 @@ namespace StardewModdingAPI
}
// load SMAPI
- using SCore core = new SCore(modsPath, writeToConsole);
+ using SCore core = new SCore(modsPath, writeToConsole, developerModeValue);
core.RunInteractively();
}