Skip to content

Commit

Permalink
Launch Mod Manager after installation
Browse files Browse the repository at this point in the history
  • Loading branch information
OSA413 committed Sep 30, 2023
1 parent 9336802 commit 3e6ec87
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
35 changes: 21 additions & 14 deletions Sonic4_ModLoader/OneClickModInstaller/Forms/UltimateWinForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ private void bModInstall_Click(object sender, EventArgs e)
bModInstall.Enabled = false;
mod.Status = ModInstallationStatus.Beginning;

while (DoNextStep()) {}
ContinueInstallation();
}
}

public void ContinueAFterDownload(object o, AsyncCompletedEventArgs e)
{
mod.Status = ModInstallationStatus.Downloaded;
while (DoNextStep()) {}
if (Downloader.Total != -1 && Downloader.Recieved != Downloader.Total)
mod.Status = ModInstallationStatus.ServerError;
else
mod.Status = ModInstallationStatus.Downloaded;
ContinueInstallation();
}

public bool Download()
Expand All @@ -90,6 +93,11 @@ public bool Download()
return false;
}

public void ContinueInstallation()
{
while (DoNextStep()) { }
}

public bool DoNextStep()
{
UpdateUI.Status(mod.Status.ToString());
Expand All @@ -101,20 +109,19 @@ public bool DoNextStep()

public bool _DoNextStep() => mod.Status switch
{
ModInstallationStatus.Beginning => mod.Prepare(),
ModInstallationStatus.Downloading => Download(),
ModInstallationStatus.Downloaded => mod.ExtractMod(),
ModInstallationStatus.Extracted => mod.FindRoots(),
ModInstallationStatus.Scanned => mod.InstallFromModRoots(),
ModInstallationStatus.ServerError => false,
ModInstallationStatus.Extracting => false,
ModInstallationStatus.Scanning => false,
ModInstallationStatus.Installing => false,
ModInstallationStatus.Installed => false,
ModInstallationStatus.ModIsComplicated => false,
_ => false,
ModInstallationStatus.Installed => ExitLaunchManager(),
_ => mod.DoNextStep(),
};

public bool ExitLaunchManager()
{
if (cbExitLaunchManager.Checked)
if (Launcher.LaunchModManager())
Application.Exit();
return false;
}

void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
string unit;
Expand Down
3 changes: 0 additions & 3 deletions Sonic4_ModLoader/OneClickModInstaller/Forms/UpdateUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ public static void ModInstallation()
form.bModPath.Enabled = !form.mod.FromArgs;
form.bModInstall.Enabled = true;
break;
case ModInstallationStatus.ModIsComplicated:
form.bModPath.Enabled = !form.mod.FromArgs;
break;
case ModInstallationStatus.Installed:
if (!form.mod.FromArgs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ public enum ModInstallationStatus
Downloading,
ServerError,
Downloaded,
Extracting,
Extracted,
Scanning,
Scanned,
Installing,
Installed,
ModIsComplicated
}

public class ModInstallationInstance
Expand Down Expand Up @@ -81,11 +77,7 @@ public void ContinueInstallation()
ModInstallationStatus.Extracted => FindRoots(),
ModInstallationStatus.Scanned => InstallFromModRoots(),
ModInstallationStatus.ServerError => false,
ModInstallationStatus.Extracting => false,
ModInstallationStatus.Scanning => false,
ModInstallationStatus.Installing => false,
ModInstallationStatus.Installed => false,
ModInstallationStatus.ModIsComplicated => false,
_ => false,
};

Expand Down

0 comments on commit 3e6ec87

Please sign in to comment.