diff --git a/SRMLInstaller/Program.cs b/SRMLInstaller/Program.cs index 65a39e7..b828224 100644 --- a/SRMLInstaller/Program.cs +++ b/SRMLInstaller/Program.cs @@ -15,59 +15,62 @@ class Program public const String embeddedResourceProject = "SRMLInstaller."; static void Main(string[] args) { + bool vortexMode = args.Length > 0 && args[0].StartsWith("-v"); + bool vortexUninstall = vortexMode && args[0] == "-vu"; + try { string filename = ""; - if (args.Length == 0) - { + if (!vortexMode && args.Length == 0) filename = GameFinder.FindGame(); - - } else - { - filename = args[0]; - } + filename = (vortexMode ? args[1] : args[0]) + "/SlimeRancher_Data/Managed/Assembly-CSharp.dll"; string root = Path.GetDirectoryName(filename); - var srmlPath = Path.Combine(root, SRML); Console.WriteLine(); - - bool uninstalling = false; bool alreadypatched = false; bool didSrmlExist = File.Exists(srmlPath); + try_to_patch: if (File.Exists(srmlPath)) { var patcher = new Patcher(filename, GetOnLoad(srmlPath)); if (patcher.IsPatched()) { - - Console.Write($"Game is already patched! Would you like to uninstall? (selecting n will instead trigger an update) (y/n): "); alreadypatched = true; - poll_user: - var response = Console.ReadLine(); - if (response == "yes" || response == "y") + if (!vortexMode) { - uninstalling = true; - patcher.Uninstall(); + Console.Write($"Game is already patched! Would you like to uninstall? (selecting n will instead trigger an update) (y/n): "); + + poll_user: + var response = Console.ReadLine(); + if (response == "yes" || response == "y") + { + uninstalling = true; + patcher.Uninstall(); + } + else if (response == "n" || response == "no") + { + } + else + { + Console.Write("Please enter a valid option! (y/n): "); + goto poll_user; + } } - else if (response == "n" || response == "no") - { - } - else + if (vortexUninstall) { - Console.Write("Please enter a valid option! (y/n): "); - goto poll_user; + uninstalling = true; + patcher.Uninstall(); } } else { - Console.WriteLine("Patching..."); patcher.Patch(); Console.WriteLine("Patching Successful!"); @@ -138,22 +141,17 @@ void SendFilesOver(bool canLog = true) Console.WriteLine(); string type = alreadypatched ? "Update" : "Installation"; - string ending = alreadypatched? "" : $"(old assembly stored as { Path.GetFileNameWithoutExtension(filename)}_old.dll)"; if (!uninstalling) { - Console.WriteLine( $"{type} complete! "+ending); var modpath = Path.Combine(Directory.GetParent(root).Parent.FullName, "SRML", "Mods"); if (!Directory.Exists(modpath)) Directory.CreateDirectory(modpath); Console.WriteLine($"Mods can be installed at {modpath}"); - } else Console.WriteLine($"Uninstallation complete!"); - - } catch (UnauthorizedAccessException e) { @@ -164,10 +162,12 @@ void SendFilesOver(bool canLog = true) { Console.WriteLine(e); } + + if (vortexMode) return; + Console.Write("Press any key to continue..."); Console.ReadKey(); return; - } static MethodReference GetOnLoad(string path)