From 65c7c9b733bf6c6122ea591bba789a914dbd404d Mon Sep 17 00:00:00 2001 From: James Finlay Date: Sun, 6 Mar 2016 12:19:59 -0800 Subject: Basic refactor of Main - Moved sections of Main out into: ConfigureUI, ConfigurePaths, ConfigureInjector, ConfigureSDV, GameRunInvoker --- StardewModdingAPI/Program.cs | 207 +++++++++++++++++++++++++------------------ 1 file changed, 120 insertions(+), 87 deletions(-) (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 28073135..900c4889 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -18,10 +18,11 @@ namespace StardewModdingAPI { public class Program { + private static List _modPaths; + private static List _modContentPaths; + public static string ExecutionPath { get; private set; } - public static string DataPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")); - public static List ModPaths = new List(); - public static List ModContentPaths = new List(); + public static string DataPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")); public static string LogPath = Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "ErrorLogs"); public static Texture2D DebugPixel { get; private set; } @@ -37,86 +38,99 @@ namespace StardewModdingAPI public static Thread gameThread; public static Thread consoleInputThread; - public const string Version = "0.36 Alpha"; + private const string _version = "0.36 Alpha"; + private static string _consoleTitle = string.Format("Stardew Modding API Console - Version {0}", _version); public static bool StardewInjectorLoaded { get; private set; } public static Mod StardewInjectorMod { get; private set; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// + /// Main method holding the API execution + /// + /// private static void Main(string[] args) - { - Console.Title = "Stardew Modding API Console"; + { + try + { + ConfigureUI(); + ConfigurePaths(); + ConfigureInjector(); + ConfigureSDV(); + + GameRunInvoker(); + } + catch (Exception e) + { + // Catch and display all exceptions. + Log.Error("Critical error: " + e); + } + + Log.Comment("The API will now terminate. Press any key to continue..."); + Console.ReadKey(); + } - Console.Title += " - Version " + Version; + /// + /// Set up the console properties + /// + private static void ConfigureUI() + { + Console.Title = _consoleTitle; + #if DEBUG Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR NEEDS TO REUPLOAD THIS VERSION"; -#endif +#endif + } + + /// + /// Setup the required paths and logging + /// + private static void ConfigurePaths() + { + Log.Info("Validating api paths..."); + + _modPaths = new List(); + _modContentPaths = new List(); //TODO: Have an app.config and put the paths inside it so users can define locations to load mods from ExecutionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - ModPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods")); - ModPaths.Add(Path.Combine(ExecutionPath, "Mods")); - ModPaths.Add(Path.Combine(Path.Combine(ExecutionPath, "Mods"), "Content")); - ModContentPaths.Add(Path.Combine(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"), "Content")); + _modPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods")); + _modPaths.Add(Path.Combine(ExecutionPath, "Mods")); + _modPaths.Add(Path.Combine(Path.Combine(ExecutionPath, "Mods"), "Content")); + _modContentPaths.Add(Path.Combine(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"), "Content")); //Checks that all defined modpaths exist as directories - foreach (string ModPath in ModPaths) - { - try - { - if (File.Exists(ModPath)) - File.Delete(ModPath); - if (!Directory.Exists(ModPath)) - Directory.CreateDirectory(ModPath); - } - catch (Exception ex) - { - Log.Error("Could not create a missing ModPath: " + ModPath + "\n\n" + ex); - } - } - //Same for content - foreach (string ModContentPath in ModContentPaths) - { - try - { - if (!Directory.Exists(ModContentPath)) - Directory.CreateDirectory(ModContentPath); - } - catch (Exception ex) - { - Log.Error("Could not create a missing ModContentPath: " + ModContentPath + "\n\n" + ex); - } - } - //And then make sure we have an errorlog dir - try - { - if (!Directory.Exists(LogPath)) - Directory.CreateDirectory(LogPath); - } - catch (Exception ex) - { - Log.Error("Could not create the missing ErrorLogs path: " + LogPath + "\n\n" + ex); - } + _modPaths.ForEach(path => VerifyPath(path)); + _modContentPaths.ForEach(path => VerifyPath(path)); + VerifyPath(LogPath); - Log.Info("Initializing SDV Assembly..."); - if (!File.Exists(ExecutionPath + "\\Stardew Valley.exe")) - { - //If the api isn't next to SDV.exe then terminate. Though it'll crash before we even get here w/o sdv.exe. Perplexing. - Log.Error("Could not find: " + ExecutionPath + "\\Stardew Valley.exe"); - Log.Error("The API will now terminate."); - Console.ReadKey(); - Environment.Exit(-4); + Log.Initialize(LogPath); + + Log.Verbose(LogPath); + + if (!File.Exists(ExecutionPath + "\\Stardew Valley.exe")) + { + throw new FileNotFoundException(string.Format("Could not found: {0}\\Stardew Valley.exe", ExecutionPath)); } - - //Load in that assembly. Also, ignore security :D - StardewAssembly = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew Valley.exe"); - - //This will load the injector before anything else if it sees it - //It doesn't matter though - //I'll leave it as a feature in case anyone in the community wants to tinker with it - //All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method - foreach (string ModPath in ModPaths) + } + + /// + /// Load the injector. + /// + /// + /// This will load the injector before anything else if it sees it + /// It doesn't matter though + /// I'll leave it as a feature in case anyone in the community wants to tinker with it + /// All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method + /// + private static void ConfigureInjector() + { + //This will load the injector before anything else if it sees it + //It doesn't matter though + //I'll leave it as a feature in case anyone in the community wants to tinker with it + //All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method + foreach (string ModPath in _modPaths) { foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll")) { @@ -145,7 +159,18 @@ namespace StardewModdingAPI Log.Error("Failed to load mod '{0}'. Exception details:\n" + ex, s); } } - } + } + } + + /// + /// Load Stardev Valley and control features + /// + private static void ConfigureSDV() + { + Log.Info("Initializing SDV Assembly..."); + + // Load in that assembly. Also, ignore security :D + StardewAssembly = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew Valley.exe"); StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr"); @@ -189,7 +214,7 @@ namespace StardewModdingAPI //Change the game's version Log.Info("Injecting New SDV Version..."); - Game1.version += "-Z_MODDED | SMAPI " + Version; + Game1.version += "-Z_MODDED | SMAPI " + _version; //Create the thread for the game to run in. gameThread = new Thread(RunGame); @@ -234,13 +259,19 @@ namespace StardewModdingAPI gamePtr.IsMouseVisible = false; gamePtr.Window.Title = "Stardew Valley - Version " + Game1.version; StardewForm.Resize += Events.GraphicsEvents.InvokeResize; - }); + }); + } + /// + /// Wrap the 'RunGame' method for console output + /// + private static void GameRunInvoker() + { //Game's in memory now, send the event Log.Verbose("Game Loaded"); Events.GameEvents.InvokeGameLoaded(); - Log.Comment(ConsoleColor.Cyan, "Type 'help' for help, or 'help ' for a command's usage"); + Log.Comment("Type 'help' for help, or 'help ' for a command's usage"); //Begin listening to input consoleInputThread.Start(); @@ -258,25 +289,27 @@ namespace StardewModdingAPI Log.Verbose("Game Execution Finished"); Log.Verbose("Shutting Down..."); Thread.Sleep(100); - /* - int time = 0; - int step = 100; - int target = 1000; - while (true) - { - time += step; - Thread.Sleep(step); - - Console.Write("."); - - if (time >= target) - break; - } - */ Environment.Exit(0); } - + /// + /// Create the given directory path if it does not exist + /// + /// Desired directory path + private static void VerifyPath(string path) + { + try + { + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + } + catch (Exception ex) + { + Log.Error("Could not create a path: " + path + "\n\n" + ex); + } + } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -340,7 +373,7 @@ namespace StardewModdingAPI { Log.Verbose("LOADING MODS"); int loadedMods = 0; - foreach (string ModPath in ModPaths) + foreach (string ModPath in _modPaths) { foreach (String s in Directory.GetFiles(ModPath, "*.dll")) { -- cgit From 04abcec53c132e6871782d7d6b860a9679113275 Mon Sep 17 00:00:00 2001 From: James Finlay Date: Sun, 6 Mar 2016 12:51:22 -0800 Subject: Quick fixes --- StardewModdingAPI/Program.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 9767c1b4..af845440 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -77,7 +77,6 @@ namespace StardewModdingAPI { Console.Title = _consoleTitle; - Console.Title += " - Version " + Version.VersionString; #if DEBUG Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR NEEDS TO REUPLOAD THIS VERSION"; #endif @@ -107,13 +106,11 @@ namespace StardewModdingAPI StardewModdingAPI.Log.Initialize(LogPath); - StardewModdingAPI.Log.Verbose(LogPath); - if (!File.Exists(ExecutionPath + "\\Stardew Valley.exe")) { throw new FileNotFoundException(string.Format("Could not found: {0}\\Stardew Valley.exe", ExecutionPath)); - } } + } /// /// Load the injector. @@ -271,7 +268,7 @@ namespace StardewModdingAPI StardewModdingAPI.Log.Verbose("Game Loaded"); Events.GameEvents.InvokeGameLoaded(); - StardewModdingAPI.Log.Comment(ConsoleColor.Cyan, "Type 'help' for help, or 'help ' for a command's usage"); + StardewModdingAPI.Log.Comment("Type 'help' for help, or 'help ' for a command's usage"); //Begin listening to input consoleInputThread.Start(); -- cgit From 93112cbb3245409554878b835812048954314d2b Mon Sep 17 00:00:00 2001 From: James Finlay Date: Sun, 6 Mar 2016 13:58:40 -0800 Subject: Additional cleanup - Moved Version & static strings to 'Constants' class - Cleaned out unused code that is not being used --- StardewModdingAPI/Constants.cs | 44 ++++++++++++ StardewModdingAPI/Program.cs | 104 ++++++----------------------- StardewModdingAPI/StardewModdingAPI.csproj | 2 +- StardewModdingAPI/Version.cs | 23 ------- 4 files changed, 66 insertions(+), 107 deletions(-) create mode 100644 StardewModdingAPI/Constants.cs delete mode 100644 StardewModdingAPI/Version.cs (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs new file mode 100644 index 00000000..fb35feb9 --- /dev/null +++ b/StardewModdingAPI/Constants.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using System.Reflection; + +namespace StardewModdingAPI +{ + /// + /// Static class containing readonly values. + /// + public static class Constants + { + /// + /// Stardew Valley's local app data location. + /// %LocalAppData%//StardewValley + /// + public static string DataPath => Path.Combine(Environment.SpecialFolder.ApplicationData.ToString(), "StardewValley"); + + /// + /// Execution path to execute the code. + /// + public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + /// + /// Title for the API console + /// + public static string ConsoleTitle => string.Format("Stardew Modding API Console - Version {0}", VersionString); + + /// + /// Path for log files to be output to. + /// %LocalAppData%//StardewValley//ErrorLogs + /// + public static string LogPath => Path.Combine(Environment.SpecialFolder.ApplicationData.ToString(), "StardewValley", "ErrorLogs"); + + public const int MajorVersion = 0; + + public const int MinorVersion = 37; + + public const int PatchVersion = 1; + + public const string Build = "Alpha"; + + public static string VersionString => string.Format("{0}.{1}.{2} {3}", MajorVersion, MinorVersion, PatchVersion, Build); + } +} diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index af845440..f1ccd936 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -21,12 +21,6 @@ namespace StardewModdingAPI private static List _modPaths; private static List _modContentPaths; - private static string _consoleTitle = string.Format("Stardew Modding API Console - Version {0}", Version.VersionString); - - public static string ExecutionPath { get; private set; } - public static string DataPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")); - public static string LogPath = Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "ErrorLogs"); - public static Texture2D DebugPixel { get; private set; } public static SGame gamePtr; @@ -75,7 +69,7 @@ namespace StardewModdingAPI /// private static void ConfigureUI() { - Console.Title = _consoleTitle; + Console.Title = Constants.ConsoleTitle; #if DEBUG Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR NEEDS TO REUPLOAD THIS VERSION"; @@ -93,22 +87,21 @@ namespace StardewModdingAPI _modContentPaths = new List(); //TODO: Have an app.config and put the paths inside it so users can define locations to load mods from - ExecutionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - _modPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods")); - _modPaths.Add(Path.Combine(ExecutionPath, "Mods")); - _modPaths.Add(Path.Combine(Path.Combine(ExecutionPath, "Mods"), "Content")); - _modContentPaths.Add(Path.Combine(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"), "Content")); + _modPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods")); + _modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods")); + _modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content")); + _modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content")); //Checks that all defined modpaths exist as directories _modPaths.ForEach(path => VerifyPath(path)); _modContentPaths.ForEach(path => VerifyPath(path)); - VerifyPath(LogPath); + VerifyPath(Constants.LogPath); - StardewModdingAPI.Log.Initialize(LogPath); + StardewModdingAPI.Log.Initialize(Constants.LogPath); - if (!File.Exists(ExecutionPath + "\\Stardew Valley.exe")) + if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe")) { - throw new FileNotFoundException(string.Format("Could not found: {0}\\Stardew Valley.exe", ExecutionPath)); + throw new FileNotFoundException(string.Format("Could not found: {0}\\Stardew Valley.exe", Constants.ExecutionPath)); } } @@ -122,11 +115,7 @@ namespace StardewModdingAPI /// All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method /// private static void ConfigureInjector() - { - //This will load the injector before anything else if it sees it - //It doesn't matter though - //I'll leave it as a feature in case anyone in the community wants to tinker with it - //All you need is a DLL that inherits from mod and is called StardewInjector.dll with an Entry() method + { foreach (string ModPath in _modPaths) { foreach (String s in Directory.GetFiles(ModPath, "StardewInjector.dll")) @@ -166,65 +155,22 @@ namespace StardewModdingAPI { StardewModdingAPI.Log.Info("Initializing SDV Assembly..."); - // Load in that assembly. Also, ignore security :D - StardewAssembly = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew Valley.exe"); - + // Load in the assembly - ignores security + StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe"); StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true); StardewGameInfo = StardewProgramType.GetField("gamePtr"); - #region deprecated - /* - * Lol no. I tried though. - if (File.Exists(ExecutionPath + "\\Stardew_Injector.exe")) - { - //Stardew_Injector Mode - StardewInjectorLoaded = true; - Program.Log.LogInfo("STARDEW_INJECTOR DETECTED, LAUNCHING USING INJECTOR CALLS"); - Assembly inj = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Stardew_Injector.exe"); - Type prog = inj.GetType("Stardew_Injector.Program", true); - FieldInfo hooker = prog.GetField("hooker", BindingFlags.NonPublic | BindingFlags.Static); - - //hook.GetMethod("Initialize").Invoke(hooker.GetValue(null), null); - //customize the initialize method for SGame instead of Game - Assembly cecil = Assembly.UnsafeLoadFrom(ExecutionPath + "\\Mono.Cecil.dll"); - Type assDef = cecil.GetType("Mono.Cecil.AssemblyDefinition"); - var aDefs = assDef.GetMethods(BindingFlags.Public | BindingFlags.Static); - var aDef = aDefs.First(x => x.ToString().Contains("ReadAssembly(System.String)")); - var theAssDef = aDef.Invoke(null, new object[] { Assembly.GetExecutingAssembly().Location }); - var modDef = assDef.GetProperty("MainModule", BindingFlags.Public | BindingFlags.Instance); - var theModDef = modDef.GetValue(theAssDef); - Console.WriteLine("MODDEF: " + theModDef); - Type hook = inj.GetType("Stardew_Injector.Stardew_Hooker", true); - hook.GetField("m_vAsmDefinition", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(hooker.GetValue(null), theAssDef); - hook.GetField("m_vModDefinition", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(hooker.GetValue(null), theModDef); - - //hook.GetMethod("Initialize").Invoke(hooker.GetValue(null), null); - hook.GetMethod("ApplyHooks").Invoke(hooker.GetValue(null), null); - //hook.GetMethod("Finalize").Invoke(hooker.GetValue(null), null); - //hook.GetMethod("Run").Invoke(hooker.GetValue(null), null); - - Console.ReadKey(); - //Now go back and load Stardew through SMAPI - } - */ - #endregion - - //Change the game's version - StardewModdingAPI.Log.Info("Injecting New SDV Version..."); - Game1.version += "-Z_MODDED | SMAPI " + Version.VersionString; + // Change the game's version + StardewModdingAPI.Log.Verbose("Injecting New SDV Version..."); + Game1.version += string.Format("-Z_MODDED | SMAPI {0}", Constants.VersionString); - //Create the thread for the game to run in. + // Create the thread for the game to run in. gameThread = new Thread(RunGame); StardewModdingAPI.Log.Info("Starting SDV..."); - gameThread.Start(); - - //I forget. - SGame.GetStaticFields(); + gameThread.Start(); - while (!ready) - { - //Wait for the game to load up - } + // Wait for the game to load up + while (!ready) ; //SDV is running StardewModdingAPI.Log.Comment("SDV Loaded Into Memory"); @@ -233,23 +179,15 @@ namespace StardewModdingAPI StardewModdingAPI.Log.Verbose("Initializing Console Input Thread..."); consoleInputThread = new Thread(ConsoleInputThread); - //The only command in the API (at least it should be, for now)\ - + // The only command in the API (at least it should be, for now) Command.RegisterCommand("help", "Lists all commands | 'help ' returns command description").CommandFired += help_CommandFired; //Command.RegisterCommand("crash", "crashes sdv").CommandFired += delegate { Game1.player.draw(null); }; //Subscribe to events Events.ControlEvents.KeyPressed += Events_KeyPressed; Events.GameEvents.LoadContent += Events_LoadContent; - //Events.MenuChanged += Events_MenuChanged; //Idk right now - -#if DEBUG - //Experimental - //Events.LocationsChanged += Events_LocationsChanged; - //Events.CurrentLocationChanged += Events_CurrentLocationChanged; -#endif + //Events.MenuChanged += Events_MenuChanged; //Idk right now - //Do tweaks using winforms invoke because I'm lazy StardewModdingAPI.Log.Verbose("Applying Final SDV Tweaks..."); StardewInvoke(() => { diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 8d9dc4ba..6d70b1c5 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -98,6 +98,7 @@ + @@ -121,7 +122,6 @@ - diff --git a/StardewModdingAPI/Version.cs b/StardewModdingAPI/Version.cs deleted file mode 100644 index baccd53b..00000000 --- a/StardewModdingAPI/Version.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardewModdingAPI -{ - public static class Version - { - public const int MajorVersion = 0; - public const int MinorVersion = 37; - public const int PatchVersion = 1; - public const string Build = "Alpha"; - - public static string VersionString { - get - { - return string.Format("{0}.{1}.{2} {3}", MajorVersion, MinorVersion, PatchVersion, Build); - } - } - } -} -- cgit From bfd8d047666737443c8cf99bd4764d7bf03ee91b Mon Sep 17 00:00:00 2001 From: James Finlay Date: Sun, 6 Mar 2016 14:04:22 -0800 Subject: Reverting GetFolderPath change --- StardewModdingAPI/Constants.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs index fb35feb9..f8b913f7 100644 --- a/StardewModdingAPI/Constants.cs +++ b/StardewModdingAPI/Constants.cs @@ -13,7 +13,7 @@ namespace StardewModdingAPI /// Stardew Valley's local app data location. /// %LocalAppData%//StardewValley /// - public static string DataPath => Path.Combine(Environment.SpecialFolder.ApplicationData.ToString(), "StardewValley"); + public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); /// /// Execution path to execute the code. @@ -29,7 +29,7 @@ namespace StardewModdingAPI /// Path for log files to be output to. /// %LocalAppData%//StardewValley//ErrorLogs /// - public static string LogPath => Path.Combine(Environment.SpecialFolder.ApplicationData.ToString(), "StardewValley", "ErrorLogs"); + public static string LogPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); public const int MajorVersion = 0; -- cgit