Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/PenguLoader/PenguLoader into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
nomi-san committed Aug 9, 2023
2 parents 928982b + a913a54 commit 9491d9d
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions loader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@ public static partial class Program
[STAThread]
static int Main(string[] args)
{
bool isUninstall = false;
var arg = args.Length > 0 ? args[0] : null;

if (args.Length > 0)
if (DataStore.IsDataStore(arg))
{
if (DataStore.IsDataStore(args[0]))
{
DataStore.DumpDataStore(args[0]);
return 0;
}
else if (args[0].Equals("--uninstall"))
{
isUninstall = true;
}
DataStore.DumpDataStore(arg);
return 0;
}

using (var mutex = new Mutex(true, "989d2110-46da-4c8d-84c1-c4a42e43c424", out var createdNew))
{
return isUninstall ? HandleUninstall(createdNew) : RunApplication(createdNew);
if (arg != null)
{
switch (arg)
{
case "--install":
return HandleInstall(createdNew, true);
case "--uninstall":
return HandleInstall(createdNew, false);
default:
break;
}
}

return RunApplication(createdNew);
}
}

Expand All @@ -58,16 +64,17 @@ static int RunApplication(bool createdNew)
return 0;
}

static int HandleUninstall(bool createdNew)
static int HandleInstall(bool createdNew, bool active)
{
if (!createdNew || Module.IsLoaded)
{
MessageBox.Show("Please close the running League Client and Loader menu before uninstalling it.",
var action = active ? "installing" : "uninstalling";
MessageBox.Show($"Please close the running League Client and Loader menu before {action} it.",
Name, MessageBoxButton.OK, MessageBoxImage.Information);
return -1;
}

Module.SetActive(false);
Module.SetActive(active);
return 0;
}

Expand Down

0 comments on commit 9491d9d

Please sign in to comment.