Skip to content

Commit

Permalink
vortex install/uninstall mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionmeow committed Aug 6, 2022
1 parent cc4ff6b commit aa8702b
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions SRMLInstaller/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down

0 comments on commit aa8702b

Please sign in to comment.