Skip to content

Commit

Permalink
This completes the installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
OSA413 committed Sep 21, 2023
1 parent 1385aeb commit 486b56b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Sonic4_ModLoader/OneClickModInstaller/Forms/UltimateWinForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ private void UnInstallAndUpdateStatus(Action<GAME?> d, GAME? game = null)

private void bModInstall_Click(object sender, EventArgs e)
{
//TODO: change
if (mod.Status == ModInstallationStatus.Beginning
|| mod.Cancelled == true
|| mod.Status == ModInstallationStatus.Installed
Expand All @@ -71,7 +70,14 @@ private void bModInstall_Click(object sender, EventArgs e)
tbModURL.ReadOnly = true;
bModPath.Enabled =
bModInstall.Enabled = false;
//StartInstallation();
mod.Status = ModInstallationStatus.Beginning;

UpdateUI.Status(mod.Status.ToString());
while (mod.DoNextStep())
{
mod.ContinueInstallation();
UpdateUI.Status(mod.Status.ToString());
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions Sonic4_ModLoader/OneClickModInstaller/Forms/UpdateUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Common.MyIO;
using Common.URL;
using Common.Launcher;
using System.Drawing;

namespace OneClickModInstaller
{
Expand Down Expand Up @@ -39,6 +40,12 @@ public static void ModInfo() {
form.lDownloadID.Text = null;
}

public static void Status(string text)
{
form.statusBar.Text = text;
Console.WriteLine(text);
}

public static void GlobalGameStatus()
{
var statuses = hiWrapper.GetAllInstallationStatus();
Expand Down
22 changes: 15 additions & 7 deletions Sonic4_ModLoader/OneClickModInstaller/ModInstallationInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public void ContinueInstallation()
ModInstallationStatus.Downloaded => ExtractMod(),
ModInstallationStatus.Extracted => FindRoots(),
ModInstallationStatus.Scanned => InstallFromModRoots(),
ModInstallationStatus.ServerError => throw new NotImplementedException(),
ModInstallationStatus.Extracting => throw new NotImplementedException(),
ModInstallationStatus.Scanning => throw new NotImplementedException(),
ModInstallationStatus.Installing => throw new NotImplementedException(),
ModInstallationStatus.Installed => throw new NotImplementedException(),
ModInstallationStatus.ModIsComplicated => throw new NotImplementedException(),
ModInstallationStatus.ServerError => false,
ModInstallationStatus.Extracting => false,
ModInstallationStatus.Scanning => false,
ModInstallationStatus.Installing => false,
ModInstallationStatus.Installed => false,
ModInstallationStatus.ModIsComplicated => false,
_ => false,
};

Expand All @@ -96,9 +96,15 @@ public bool Prepare()

Status = ModInstallationStatus.Downloading;
if (info.FromArchive)
{
ModArchivePath = Link;
Status = ModInstallationStatus.Downloaded;
}
else if (info.FromDir)
{
ModDirectory = Link;
Status = ModInstallationStatus.Extracted;
}
return true;
}

Expand All @@ -109,7 +115,7 @@ public bool Download()

public bool ExtractMod()
{
ModDirectory = Path.GetFileNameWithoutExtension(ModArchivePath) + "_extracted";
ModDirectory = ModArchivePath + "_extracted";

if (Directory.Exists(ModDirectory))
MyDirectory.DeleteRecursively(ModDirectory);
Expand All @@ -118,6 +124,8 @@ public bool ExtractMod()
ModArchive.Extract(ModArchivePath, Settings.Paths["7-Zip"]);
else
ModArchive.Extract(ModArchivePath);

Status = ModInstallationStatus.Extracted;
return true;
}

Expand Down

0 comments on commit 486b56b

Please sign in to comment.