Skip to content

Commit

Permalink
Allow Install of latest downloaded file
Browse files Browse the repository at this point in the history
Code Simplifications
  • Loading branch information
HimDek committed Nov 5, 2021
1 parent 3c2ce6b commit 2bf9cbe
Showing 1 changed file with 82 additions and 103 deletions.
185 changes: 82 additions & 103 deletions Form_yuzuEarlyAccessLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,33 @@ private void checkBox_Delyuzu_CheckedChanged(object sender, EventArgs e)
private void pictureBox_Refresh_Click(object sender, EventArgs e)
{
log.WriteLine("\nRefreshing");
groupBox_Progress.Visible = false;
groupBox_Firmware.Visible = false;

progressBar1.Value = 0;
label_Progress.Text = progressBar1.Value.ToString() + "%";

button_Launch.Visible = false;
button_Download.Visible = false;
label_Message.Visible = false;
button_Firmware.Visible = true;
button_Cancel.Visible = true;

button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Regular);
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Regular);

button_Launch.Size = new Size(350, 60);
button_Download.Size = new Size(350, 60);
button_Download.Location = new Point(368, 225);

groupBox_Progress.Visible = false;
groupBox_Firmware.Visible = false;

label_Info.Text = "";
label_Speed.Visible = true;
label_Info.Visible = false;
label_Info.ForeColor = Fore;
label_Info.Font = new Font(label_Info.Font.Name, label_Info.Font.Size, FontStyle.Regular);
label_Firmware.Font = new Font(label_Firmware.Font.Name, label_Firmware.Font.Size, FontStyle.Regular);

pictureBox_Refresh.Visible = false;
backgroundWorker_Check.RunWorkerAsync();
}
Expand Down Expand Up @@ -303,16 +324,8 @@ private void Button_About_Click(object sender, EventArgs e)

private void Timer_Refresh_Tick(object sender, EventArgs e)
{
log.WriteLine("\nRefreshing");
timer_Refresh.Enabled = false;
groupBox_Progress.Visible = false;
groupBox_Firmware.Visible = false;
button_Launch.Visible = false;
button_Download.Visible = false;
label_Message.Visible = false;
label_Info.Visible = false;
pictureBox_Refresh.Visible = false;
backgroundWorker_Check.RunWorkerAsync();
pictureBox_Refresh_Click(sender, e);
}

private void BackgroundWorker_SystemInfo_DoWork(object sender, DoWorkEventArgs e)
Expand Down Expand Up @@ -621,6 +634,14 @@ private void BackgroundWorker_Check_DoWork(object sender, DoWorkEventArgs e)
{
firm = "0.0.0";
}
if (latest == "")
{
latest = "0";
}
if (lfirm == "")
{
lfirm = "0.0.0";
}

String latestfileVer = installed;
String latestfirfileVer = firm;
Expand All @@ -645,7 +666,7 @@ private void BackgroundWorker_Check_DoWork(object sender, DoWorkEventArgs e)
{
latest = latestfileVer;
}

if (Internet)
{
if (DeleteyuzuArchive)
Expand Down Expand Up @@ -700,6 +721,14 @@ private void BackgroundWorker_Check_DoWork(object sender, DoWorkEventArgs e)
{
firm = "";
}
if (latest == "0")
{
latest = "";
}
if (lfirm == "0.0.0")
{
lfirm = "";
}

file = "Windows-Yuzu-EA-" + latest + ".7z";
firfile = "Switch-Firmware-" + lfirm + ".zip";
Expand All @@ -721,7 +750,7 @@ private void BackgroundWorker_Check_DoWork(object sender, DoWorkEventArgs e)
log.WriteLine(" Not found file \"" + path + "\\Switch-Firmware-" + lfirm + ".zip\"");
}

if (version != launcherlatest)
if (Internet && version != launcherlatest)
{
Downloading = true;
backgroundWorker_Check.ReportProgress(7);
Expand Down Expand Up @@ -778,34 +807,15 @@ private void BackgroundWorker_Check_ProgressChanged(object sender, ProgressChang
private void BackgroundWorker_Check_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
log.WriteLine("Updating UI");
progressBar1.Value = 0;
label_Progress.Text = progressBar1.Value.ToString() + "%";
label_Message.Visible = false;
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Regular);
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Regular);
label_Info.ForeColor = Color.Black;
label_Info.Font = new Font(label_Info.Font.Name, label_Info.Font.Size, FontStyle.Regular);
label_Info.Text = "";
label_Firmware.Font = new Font(label_Firmware.Font.Name, label_Firmware.Font.Size, FontStyle.Regular);
button_Launch.Size = new Size(350, 60);
button_Download.Size = new Size(350, 60);
button_Download.Location = new Point(368, 225);
button_Cancel.Visible = true;
button_Firmware.Visible = true;
label_Speed.Visible = true;

if (installed == "pre")
if (installed != "")
{
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Bold);
button_Launch.Text = "Launch yuzu Early Access";
}
else
{
if (installed != "")
button_Launch.Text = "Launch yuzu Early Access " + installed;
if (installed == "pre")
{
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Bold);
button_Launch.Text = "Launch yuzu Early Access " + installed;
button_Launch.Text = "Launch yuzu Early Access";
}
}

Expand All @@ -815,20 +825,16 @@ private void BackgroundWorker_Check_RunWorkerCompleted(object sender, RunWorkerC
{
if (System.IO.File.Exists(file))
{
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Text = "Install yuzu Early Access " + latest;
}
else
{
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Text = "Download yuzu Early Access " + latest;
}
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Download.Size = new Size(706, 60);
button_Download.Location = new Point(12, 225);
button_Launch.Visible = false;
button_Download.Visible = true;
}
else
{
Expand All @@ -837,59 +843,55 @@ private void BackgroundWorker_Check_RunWorkerCompleted(object sender, RunWorkerC
if (System.IO.File.Exists(file))
{
button_Download.Text = "ReInstall yuzu Early Access " + latest;
button_Download.Visible = true;
}
else
{
button_Download.Text = "ReDownload yuzu Early Access " + latest;
button_Download.Visible = true;
}
}
else
{
if (System.IO.File.Exists(file))
{
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Text = "Update to yuzu Early Access " + latest;
button_Download.Visible = true;
}
else
{
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Text = "Download yuzu Early Access " + latest;
button_Download.Visible = true;
}
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
}

button_Launch.Visible = true;
}

button_Download.Visible = true;

if (firm == "")
{
if (!System.IO.File.Exists(firfile))
{
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
button_Firmware.Text = "Download Firmware " + lfirm;
}
if (System.IO.File.Exists(firfile))
{
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
button_Firmware.Text = "Install Firmware " + lfirm;
}
else
{
button_Firmware.Text = "Download Firmware " + lfirm;
}
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
}
else
{
if (lfirm == firm)
{
if (!System.IO.File.Exists(firfile))
{
button_Firmware.Text = "ReDownload Firmware " + lfirm;
}
if (System.IO.File.Exists(firfile))
{
button_Firmware.Text = "ReInstall Firmware " + lfirm;
}
else
{
button_Firmware.Text = "ReDownload Firmware " + lfirm;
}
}
else
{
Expand All @@ -911,7 +913,6 @@ private void BackgroundWorker_Check_RunWorkerCompleted(object sender, RunWorkerC
button_Download.Text = "Install yuzu Early Access " + latest;
button_Download.Size = new Size(706, 60);
button_Download.Location = new Point(12, 225);
button_Launch.Visible = false;
button_Download.Visible = true;
}
else
Expand All @@ -922,87 +923,65 @@ private void BackgroundWorker_Check_RunWorkerCompleted(object sender, RunWorkerC
}
label_Info.Font = new Font(label_Info.Font.Name, label_Info.Font.Size, FontStyle.Bold);
label_Info.ForeColor = Color.Red;
label_Info.Text = "Error retrieving Updates! Check Your Internet and Refresh";
label_Info.Text = "Error retrieving Updates! Check Your Internet and Refresh.";
label_Info.Visible = true;
}
else
{
if (latest == installed)
{
button_Download.Text = "ReInstall yuzu Early Access " + latest;
button_Download.Visible = true;
}
else
{
button_Download.Font = new Font(button_Download.Font.Name, button_Download.Font.Size, FontStyle.Bold);
button_Launch.Font = new Font(button_Launch.Font.Name, button_Launch.Font.Size, FontStyle.Regular);
button_Download.Text = "Install yuzu Early Access " + latest;
button_Download.Visible = true;
}
if (!System.IO.File.Exists(file))
{
button_Launch.Size = new Size(706, 60);
button_Launch.Visible = true;
button_Download.Visible = false;
}

if (System.IO.File.Exists(file))
{
button_Launch.Visible = true;
button_Download.Visible = true;
}
else
{
button_Launch.Size = new Size(706, 60);
}

if (!System.IO.File.Exists("prod.keys") && !System.IO.File.Exists(UserProfile + "\\AppData\\Roaming\\yuzu\\keys\\prod.keys"))
{
label_Info.Font = new Font(label_Info.Font.Name, label_Info.Font.Size, FontStyle.Bold);
label_Info.ForeColor = Color.Red;
label_Info.Text = "Could not find prod.keys! Check Your Internet and Refresh.";
label_Info.Visible = true;
}
else
{
label_Info.Font = new Font(label_Info.Font.Name, label_Info.Font.Size, FontStyle.Bold);
label_Info.Text = "prod.keys may be old! Check Your Internet and Refresh.";
label_Info.Visible = true;
}

button_Launch.Visible = true;
label_Info.Visible = true;
}
if (firm == "")

if (System.IO.File.Exists(firfile))
{
if (System.IO.File.Exists(firfile))
if (lfirm == firm)
{
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
button_Firmware.Text = "Install Firmware " + lfirm;
button_Firmware.Text = "ReInstall Firmware " + lfirm;
}
if (!System.IO.File.Exists(firfile))
else
{
button_Firmware.Visible = false;
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
button_Firmware.Text = "Install Firmware " + lfirm;
}
}
else
{
if (lfirm == firm)
{
if (System.IO.File.Exists(firfile))
{
button_Firmware.Text = "ReInstall Firmware " + lfirm;
}
if (!System.IO.File.Exists(firfile))
{
button_Firmware.Visible = false;
}
}
else
{
if (System.IO.File.Exists(firfile))
{
button_Firmware.Font = new Font(button_Firmware.Font.Name, button_Firmware.Font.Size, FontStyle.Bold);
button_Firmware.Text = "Install Firmware " + lfirm;
}
if (!System.IO.File.Exists(firfile))
{
button_Firmware.Visible = false;
}
}
button_Firmware.Visible = false;
}
}

if (firm != "")
{
label_Firmware.Text = "Installed Version: " + firm;
Expand Down

0 comments on commit 2bf9cbe

Please sign in to comment.