use platform-agnostic paths (#126)
This commit is contained in:
parent
2be6ad1574
commit
57da69c87c
|
@ -30,7 +30,7 @@ namespace StardewModdingAPI
|
|||
public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Console.WriteLine("An exception has been caught");
|
||||
File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + DateTime.UtcNow.Ticks + ".txt", e.ExceptionObject.ToString());
|
||||
File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{DateTime.UtcNow.Ticks}.txt"), e.ExceptionObject.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -40,7 +40,7 @@ namespace StardewModdingAPI
|
|||
public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
Console.WriteLine("A thread exception has been caught");
|
||||
File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.Exception.ToString());
|
||||
File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{Extensions.Random.Next(100000000, 999999999)}.txt"), e.Exception.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace StardewModdingAPI
|
|||
/// <summary>
|
||||
/// A basic path to store your mod's config at.
|
||||
/// </summary>
|
||||
public string BaseConfigPath => PathOnDisk + "\\config.json";
|
||||
public string BaseConfigPath => Path.Combine(this.PathOnDisk, "config.json");
|
||||
|
||||
/// <summary>
|
||||
/// A basic path to where per-save configs are stored
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace StardewModdingAPI
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
/// <summary>The full path to the Stardew Valley executable.</summary>
|
||||
private static readonly string GameExecutablePath = File.Exists(Path.Combine(Constants.ExecutionPath, "StardewValley.exe"))
|
||||
? Path.Combine(Constants.ExecutionPath, "StardewValley.exe") // Linux or Mac
|
||||
: Path.Combine(Constants.ExecutionPath, "Stardew Valley.exe"); // Windows
|
||||
|
||||
private static List<string> _modPaths;
|
||||
|
||||
public static SGame gamePtr;
|
||||
|
@ -103,9 +108,9 @@ namespace StardewModdingAPI
|
|||
//_modContentPaths.ForEach(path => VerifyPath(path));
|
||||
VerifyPath(Constants.LogDir);
|
||||
|
||||
if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe"))
|
||||
if (!File.Exists(GameExecutablePath))
|
||||
{
|
||||
throw new FileNotFoundException($"Could not found: {Constants.ExecutionPath}\\Stardew Valley.exe");
|
||||
throw new FileNotFoundException($"Could not found: {GameExecutablePath}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,7 @@ namespace StardewModdingAPI
|
|||
Log.AsyncY("Initializing SDV Assembly...");
|
||||
|
||||
// Load in the assembly - ignores security
|
||||
StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe");
|
||||
StardewAssembly = Assembly.UnsafeLoadFrom(GameExecutablePath);
|
||||
StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true);
|
||||
StardewGameInfo = StardewProgramType.GetField("gamePtr");
|
||||
|
||||
|
|
Loading…
Reference in New Issue