forked from LavaGang/MelonLoader.Installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLine.cs
More file actions
104 lines (93 loc) · 3.37 KB
/
CommandLine.cs
File metadata and controls
104 lines (93 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace MelonLoader
{
internal static class CommandLine
{
internal static bool IsCMD = false;
internal static bool IsSilent = false;
internal static int CmdMode = 0;
internal static string ExePath = null;
internal static string ZipPath = null;
internal static string RequestedVersion = null;
internal static bool AutoDetectArch = true;
internal static bool Requested32Bit = false;
internal static string[] __args;
internal static bool Run(string[] args, ref int returnval)
{
__args = args;
if (args.Length <= 0)
return false;
if (string.IsNullOrEmpty(args[0]))
return false;
ExePath = string.Copy(args[0]);
if (args.Length == 1)
return false;
return true;
}
public static void Install()
{
if (!Program.ValidateUnityGamePath(ref ExePath))
{
// Output Error
return;
}
Program.GetCurrentInstallVersion(Path.GetDirectoryName(ExePath));
if (!string.IsNullOrEmpty(ZipPath))
{
InstallFromZip();
return;
}
if (Releases.All.Count <= 0)
{
// Output Error
return;
}
// Pull Latest Version
if (Program.CurrentInstalledVersion == null)
OperationHandler.CurrentOperation = OperationHandler.Operations.INSTALL;
else
{
Version selected_ver = new Version(Releases.Official[0]);
int compare_ver = selected_ver.CompareTo(Program.CurrentInstalledVersion);
if (compare_ver < 0)
OperationHandler.CurrentOperation = OperationHandler.Operations.DOWNGRADE;
else if (compare_ver > 0)
OperationHandler.CurrentOperation = OperationHandler.Operations.UPDATE;
else
OperationHandler.CurrentOperation = OperationHandler.Operations.REINSTALL;
}
OperationHandler.Automated_Install(Path.GetDirectoryName(ExePath), Releases.Official[0], Requested32Bit, (Releases.Official[0].StartsWith("v0.2") || Releases.Official[0].StartsWith("v0.1")));
}
public static void InstallFromZip()
{
if (!Program.ValidateZipPath(ZipPath))
{
// Output Error
return;
}
OperationHandler.ManualZip_Install(ZipPath, Path.GetDirectoryName(ExePath));
}
public static void Uninstall()
{
if (!Program.ValidateUnityGamePath(ref ExePath))
{
// Output Error
return;
}
string folderpath = Path.GetDirectoryName(ExePath);
Program.GetCurrentInstallVersion(folderpath);
if (Program.CurrentInstalledVersion == null)
{
// Output Error
return;
}
OperationHandler.CurrentOperation = OperationHandler.Operations.UNINSTALL;
OperationHandler.Uninstall(folderpath);
}
}
}