summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Constants.cs11
-rw-r--r--src/SMAPI/Program.cs68
-rw-r--r--src/SMAPI/StardewModdingAPI.metadata.json12
3 files changed, 69 insertions, 22 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index d96c5839..532112ff 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -82,8 +82,11 @@ namespace StardewModdingAPI
/// <summary>The file path for the SMAPI metadata file.</summary>
internal static string ApiMetadataPath => Path.Combine(Constants.ExecutionPath, $"{typeof(Program).Assembly.GetName().Name}.metadata.json");
- /// <summary>The file path to the log where the latest output should be saved.</summary>
- internal static string DefaultLogPath => Path.Combine(Constants.LogDir, "SMAPI-latest.txt");
+ /// <summary>The filename prefix for SMAPI log files.</summary>
+ internal static string LogNamePrefix { get; } = "SMAPI-latest";
+
+ /// <summary>The filename extension for SMAPI log files.</summary>
+ internal static string LogNameExtension { get; } = "txt";
/// <summary>A copy of the log leading up to the previous fatal crash, if any.</summary>
internal static string FatalCrashLog => Path.Combine(Constants.LogDir, "SMAPI-crash.txt");
@@ -113,8 +116,8 @@ namespace StardewModdingAPI
/// <summary>Initialise the static values.</summary>
static Constants()
{
- Constants.ApiVersionForToolkit = new Toolkit.SemanticVersion("2.6-beta.15");
- Constants.MinimumGameVersion = new GameVersion("1.3.13");
+ Constants.ApiVersionForToolkit = new Toolkit.SemanticVersion("2.6-beta.16");
+ Constants.MinimumGameVersion = new GameVersion("1.3.17");
Constants.ApiVersion = new SemanticVersion(Constants.ApiVersionForToolkit);
}
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 83ce6f99..4ede45d5 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -118,30 +118,19 @@ namespace StardewModdingAPI
// get flags from arguments
bool writeToConsole = !args.Contains("--no-terminal");
- // get log path from arguments
- string logPath = null;
- {
- int pathIndex = Array.LastIndexOf(args, "--log-path") + 1;
- if (pathIndex >= 1 && args.Length >= pathIndex)
- {
- logPath = args[pathIndex];
- if (!Path.IsPathRooted(logPath))
- logPath = Path.Combine(Constants.LogDir, logPath);
- }
- }
- if (string.IsNullOrWhiteSpace(logPath))
- logPath = Constants.DefaultLogPath;
-
// load SMAPI
- using (Program program = new Program(writeToConsole, logPath))
+ using (Program program = new Program(writeToConsole))
program.RunInteractively();
}
/// <summary>Construct an instance.</summary>
/// <param name="writeToConsole">Whether to output log messages to the console.</param>
- /// <param name="logPath">The full file path to which to write log messages.</param>
- public Program(bool writeToConsole, string logPath)
+ public Program(bool writeToConsole)
{
+ // init log file
+ this.PurgeLogFiles();
+ string logPath = this.GetLogPath();
+
// init basics
this.Settings = JsonConvert.DeserializeObject<SConfig>(File.ReadAllText(Constants.ApiConfigPath));
this.LogFile = new LogFileManager(logPath);
@@ -1257,5 +1246,50 @@ namespace StardewModdingAPI
if (this.Settings.VerboseLogging)
this.Monitor.Log(message, LogLevel.Trace);
}
+
+ /// <summary>Get the absolute path to the next available log file.</summary>
+ private string GetLogPath()
+ {
+ // default path
+ {
+ FileInfo defaultFile = new FileInfo(Path.Combine(Constants.LogDir, $"{Constants.LogNamePrefix}.{Constants.LogNameExtension}"));
+ if (!defaultFile.Exists)
+ return defaultFile.FullName;
+ }
+
+ // get first disambiguated path
+ for (int i = 2; i < int.MaxValue; i++)
+ {
+ FileInfo file = new FileInfo(Path.Combine(Constants.LogDir, $"{Constants.LogNamePrefix}.player-{i}.{Constants.LogNameExtension}"));
+ if (!file.Exists)
+ return file.FullName;
+ }
+
+ // should never happen
+ throw new InvalidOperationException("Could not find an available log path.");
+ }
+
+ /// <summary>Delete all log files created by SMAPI.</summary>
+ private void PurgeLogFiles()
+ {
+ DirectoryInfo logsDir = new DirectoryInfo(Constants.LogDir);
+ if (!logsDir.Exists)
+ return;
+
+ foreach (FileInfo logFile in logsDir.EnumerateFiles("*.txt"))
+ {
+ if (logFile.Name.StartsWith(Constants.LogNamePrefix, StringComparison.InvariantCultureIgnoreCase))
+ {
+ try
+ {
+ FileUtilities.ForceDelete(logFile);
+ }
+ catch (IOException)
+ {
+ // ignore file if it's in use
+ }
+ }
+ }
+ }
}
}
diff --git a/src/SMAPI/StardewModdingAPI.metadata.json b/src/SMAPI/StardewModdingAPI.metadata.json
index 47c45b24..adf5fdd1 100644
--- a/src/SMAPI/StardewModdingAPI.metadata.json
+++ b/src/SMAPI/StardewModdingAPI.metadata.json
@@ -64,7 +64,7 @@
"~1.1 | Status": "AssumeBroken"
},
- "AdjustArtisanPrices": {
+ "Adjust Artisan Prices": {
"ID": "ThatNorthernMonkey.AdjustArtisanPrices",
"FormerIDs": "1e36d4ca-c7ef-4dfb-9927-d27a6c3c8bdc", // changed in 0.0.2-pathoschild-update
"MapRemoteVersions": { "0.01": "0.0.1" },
@@ -130,6 +130,11 @@
"~1.0.8 | Status": "AssumeBroken" // broke in SMAPI 2.0
},
+ "Arcade Pong": {
+ "ID": "Platonymous.ArcadePong",
+ "~1.0.2 | Status": "AssumeBroken" // broke in SMAPI 2.6-beta.16 due to reflection into SMAPI internals
+ },
+
"Ashley Mod": {
"FormerIDs": "{EntryDll: 'AshleyMod.dll'}",
"~1.0.1 | Status": "AssumeBroken" // broke in SMAPI 2.0
@@ -1474,6 +1479,11 @@
"Default | UpdateKey": "Nexus:1102" // added in 1.3.1
},
+ "Split Screen": {
+ "ID": "Ilyaki.SplitScreen",
+ "~3.0.1 | Status": "AssumeBroken" // broke in SMAPI 2.6-beta.16 due to reflection into SMAPI internals
+ },
+
"Sprinkler Range": {
"ID": "cat.sprinklerrange",
"Default | UpdateKey": "Nexus:1179"