Skip to content

Commit

Permalink
Code cleanup and minor fixes
Browse files Browse the repository at this point in the history
 - Fixed channel arg not being set when launching game client
 - Fixed preferences tooltip hiding too early
 - Fixed last deploy info not showing for the right channel
 - Last deploy info now shows deploy timestamp according to system timezone
  • Loading branch information
pizzaboxer committed Aug 27, 2022
1 parent ff2bd47 commit 8316c9e
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 146 deletions.
4 changes: 2 additions & 2 deletions Bloxstrap/Bloxstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<Platforms>AnyCPU;x86</Platforms>
<ApplicationIcon>Bloxstrap.ico</ApplicationIcon>
<Version>1.4.0</Version>
<FileVersion>1.4.0.0</FileVersion>
<Version>1.4.1</Version>
<FileVersion>1.4.1.0</FileVersion>
<UseWPF>True</UseWPF>
</PropertyGroup>

Expand Down
54 changes: 18 additions & 36 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,40 +83,14 @@ public partial class Bootstrapper
#endregion

#region Core
public Bootstrapper()
public Bootstrapper(string? launchCommandLine = null)
{
LaunchCommandLine = launchCommandLine;
FreshInstall = String.IsNullOrEmpty(Program.Settings.VersionGuid);
Client.Timeout = TimeSpan.FromMinutes(10);
}

public void Initialize(string? launchCommandLine = null)
{
LaunchCommandLine = launchCommandLine;

switch (Program.Settings.BootstrapperStyle)
{
case BootstrapperStyle.VistaDialog:
Application.Run(new VistaDialog(this));
break;

case BootstrapperStyle.LegacyDialog2009:
Application.Run(new LegacyDialog2009(this));
break;

case BootstrapperStyle.LegacyDialog2011:
Application.Run(new LegacyDialog2011(this));
break;

case BootstrapperStyle.ProgressDialog:
Application.Run(new ProgressDialog(this));
break;

case BootstrapperStyle.ProgressDialogDark:
Application.Run(new ProgressDialogDark(this));
break;
}
}

// this is called from BootstrapperStyleForm.SetupDialog()
public async Task Run()
{
if (LaunchCommandLine == "-uninstall")
Expand Down Expand Up @@ -183,7 +157,12 @@ private async Task StartRoblox()
Dialog.Message = "Starting Roblox...";

// launch time isn't really required for all launches, but it's usually just safest to do this
LaunchCommandLine += " --launchtime=" + DateTimeOffset.Now.ToUnixTimeSeconds() + " -startEvent " + startEventName;
LaunchCommandLine += " --launchtime=" + DateTimeOffset.Now.ToUnixTimeSeconds();

if (Program.Settings.Channel.ToLower() != DeployManager.DefaultChannel.ToLower())
LaunchCommandLine += " -channel " + Program.Settings.Channel.ToLower();

LaunchCommandLine += " -startEvent " + startEventName;

using (SystemEvent startEvent = new(startEventName))
{
Expand Down Expand Up @@ -400,8 +379,10 @@ private async Task InstallLatestVersion()

Dialog.CancelEnabled = true;

// i believe the original bootstrapper bases the progress bar off zip
// extraction progress, but here i'm doing package download progress
// i believe the bootstrapper bases the progress bar off
// bytes downloaded / bytes total according to rbxPkgManifest?
// i'm too lazy for that, so here it's just based off how many packages
// have finished downloading

Dialog.ProgressStyle = ProgressBarStyle.Continuous;

Expand All @@ -411,7 +392,7 @@ private async Task InstallLatestVersion()

foreach (Package package in VersionPackageManifest)
{
// no await, download all the packages at once
// download all the packages at once
DownloadPackage(package);
}

Expand All @@ -430,6 +411,8 @@ private async Task InstallLatestVersion()

Debug.WriteLine("Finished downloading");

Dialog.Message = "Configuring Roblox...";

Directory.CreateDirectory(Directories.Versions);

foreach (Package package in VersionPackageManifest)
Expand All @@ -440,8 +423,6 @@ private async Task InstallLatestVersion()

Debug.WriteLine("Finished extracting packages");

Dialog.Message = "Configuring Roblox...";

string appSettingsLocation = Path.Combine(VersionFolder, "AppSettings.xml");
await File.WriteAllTextAsync(appSettingsLocation, AppSettings);

Expand Down Expand Up @@ -529,7 +510,8 @@ private void ApplyModifications()
File.Copy(fileModFolder, fileVersionFolder, true);
}

// now we check for files that have been deleted from the mod folder
// now check for files that have been deleted from the mod folder
// according to the manifest
foreach (string fileLocation in manifestFiles)
{
if (modFolderFiles.Contains(fileLocation))
Expand Down
13 changes: 6 additions & 7 deletions Bloxstrap/Dialogs/BootstrapperStyles/BootstrapperStyleForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bloxstrap.Helpers;
using Bloxstrap.Helpers.RSMM;
using Bloxstrap.Enums;

namespace Bloxstrap.Dialogs.BootstrapperStyles
{
Expand All @@ -18,7 +17,7 @@ public string Message
set
{
if (this.InvokeRequired)
this.Invoke(new Action(() => { _message = value; }));
this.Invoke(() => _message = value);
else
_message = value;
}
Expand All @@ -30,7 +29,7 @@ public ProgressBarStyle ProgressStyle
set
{
if (this.InvokeRequired)
this.Invoke(new Action(() => { _progressStyle = value; }));
this.Invoke(() => _progressStyle = value);
else
_progressStyle = value;
}
Expand All @@ -42,7 +41,7 @@ public int ProgressValue
set
{
if (this.InvokeRequired)
this.Invoke(new Action(() => { _progressValue = value; }));
this.Invoke(() => _progressValue = value);
else
_progressValue = value;
}
Expand All @@ -54,7 +53,7 @@ public bool CancelEnabled
set
{
if (this.InvokeRequired)
this.Invoke(new Action(() => { _cancelEnabled = value; }));
this.Invoke(() => _cancelEnabled = value);
else
_cancelEnabled = value;
}
Expand All @@ -63,7 +62,7 @@ public bool CancelEnabled
public void SetupDialog()
{
this.Text = Program.ProjectName;
this.Icon = IconManager.GetIconResource();
this.Icon = Program.Settings.BootstrapperIcon.GetIcon();

if (Bootstrapper is null)
{
Expand Down
4 changes: 2 additions & 2 deletions Bloxstrap/Dialogs/BootstrapperStyles/LegacyDialog2011.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Bloxstrap.Helpers;
using Bloxstrap.Enums;

namespace Bloxstrap.Dialogs.BootstrapperStyles
{
Expand Down Expand Up @@ -37,7 +37,7 @@ public LegacyDialog2011(Bootstrapper? bootstrapper = null)
Bootstrapper = bootstrapper;

// have to convert icon -> bitmap since winforms scaling is poop
this.IconBox.Image = IconManager.GetIconResource().ToBitmap();
this.IconBox.Image = Program.Settings.BootstrapperIcon.GetIcon().ToBitmap();

SetupDialog();
}
Expand Down
4 changes: 2 additions & 2 deletions Bloxstrap/Dialogs/BootstrapperStyles/ProgressDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Bloxstrap.Helpers;
using Bloxstrap.Enums;

namespace Bloxstrap.Dialogs.BootstrapperStyles
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public ProgressDialog(Bootstrapper? bootstrapper = null)

Bootstrapper = bootstrapper;

this.IconBox.BackgroundImage = IconManager.GetBitmapResource();
this.IconBox.BackgroundImage = Program.Settings.BootstrapperIcon.GetBitmap();

SetupDialog();
}
Expand Down
4 changes: 2 additions & 2 deletions Bloxstrap/Dialogs/BootstrapperStyles/ProgressDialogDark.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Bloxstrap.Helpers;
using Bloxstrap.Enums;

namespace Bloxstrap.Dialogs.BootstrapperStyles
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public ProgressDialogDark(Bootstrapper? bootstrapper = null)

Bootstrapper = bootstrapper;

this.IconBox.BackgroundImage = IconManager.GetBitmapResource();
this.IconBox.BackgroundImage = Program.Settings.BootstrapperIcon.GetBitmap();

SetupDialog();
}
Expand Down
5 changes: 2 additions & 3 deletions Bloxstrap/Dialogs/BootstrapperStyles/VistaDialog.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bloxstrap.Helpers;
using Bloxstrap.Helpers.RSMM;
using Bloxstrap.Enums;

namespace Bloxstrap.Dialogs.BootstrapperStyles
{
Expand Down Expand Up @@ -66,7 +65,7 @@ public VistaDialog(Bootstrapper? bootstrapper = null)

Dialog = new TaskDialogPage()
{
Icon = new TaskDialogIcon(IconManager.GetIconResource()),
Icon = new TaskDialogIcon(Program.Settings.BootstrapperIcon.GetIcon()),
Caption = Program.ProjectName,

Buttons = { TaskDialogButton.Cancel },
Expand Down
4 changes: 4 additions & 0 deletions Bloxstrap/Dialogs/Preferences.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 9 additions & 33 deletions Bloxstrap/Dialogs/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.Win32;

using Bloxstrap.Dialogs.BootstrapperStyles;
using Bloxstrap.Enums;
using Bloxstrap.Helpers;
using Bloxstrap.Helpers.Integrations;
Expand Down Expand Up @@ -58,10 +57,12 @@ private async Task GetChannelInfo(string channel)

VersionDeploy info = await DeployManager.GetLastDeploy(channel);

if (info.FileVersion is null || info.Date is null)
if (info.FileVersion is null || info.Timestamp is null)
return;

ChannelInfo = $"Last deploy:\nv{info.FileVersion} @ {info.Date}";
string strTimestamp = info.Timestamp.Value.ToString("MM/dd/yyyy hh:mm:ss tt", Program.CultureFormat);

ChannelInfo = $"Last deploy:\nv{info.FileVersion} @ {strTimestamp}";
}

public Preferences()
Expand Down Expand Up @@ -200,30 +201,7 @@ private void SaveButton_Click(object sender, EventArgs e)
private void PreviewButton_Click(object sender, EventArgs e)
{
this.Visible = false;

switch (Program.Settings.BootstrapperStyle)
{
case BootstrapperStyle.VistaDialog:
new VistaDialog().ShowDialog();
break;

case BootstrapperStyle.LegacyDialog2009:
new LegacyDialog2009().ShowDialog();
break;

case BootstrapperStyle.LegacyDialog2011:
new LegacyDialog2011().ShowDialog();
break;

case BootstrapperStyle.ProgressDialog:
new ProgressDialog().ShowDialog();
break;

case BootstrapperStyle.ProgressDialogDark:
new ProgressDialogDark().ShowDialog();
break;
}

Program.Settings.BootstrapperStyle.Show();
this.Visible = true;
}

Expand All @@ -246,7 +224,7 @@ private void IconSelection_SelectedIndexChanged(object sender, EventArgs e)
{
BootstrapperIcon icon = SelectableIcons[this.IconSelection.Text];

this.IconPreview.BackgroundImage = IconManager.GetBitmapResource(icon);
this.IconPreview.BackgroundImage = icon.GetBitmap();

if (!this.Visible)
return;
Expand Down Expand Up @@ -304,12 +282,10 @@ private void ButtonOpenModFolder_Click(object sender, EventArgs e)

private void SelectChannel_SelectedValueChanged(object sender, EventArgs e)
{
if (this.Visible)
Program.Settings.Channel = this.SelectChannel.Text;

Task.Run(() => GetChannelInfo(Program.Settings.Channel));

if (!this.Visible)
return;

Program.Settings.Channel = this.SelectChannel.Text;
}

private void ToggleCheckForUpdates_CheckedChanged(object sender, EventArgs e)
Expand Down
65 changes: 65 additions & 0 deletions Bloxstrap/Enums/BootstrapperIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,69 @@ public enum BootstrapperIcon
Icon2019,
Icon2022
}

public static class BootstrapperIconEx
{
public static Icon GetIcon(this BootstrapperIcon icon)
{
switch (icon)
{
case BootstrapperIcon.Icon2009:
return Properties.Resources.Icon2009_ico;

case BootstrapperIcon.Icon2011:
return Properties.Resources.Icon2011_ico;

case BootstrapperIcon.IconEarly2015:
return Properties.Resources.IconEarly2015_ico;

case BootstrapperIcon.IconLate2015:
return Properties.Resources.IconLate2015_ico;

case BootstrapperIcon.Icon2017:
return Properties.Resources.Icon2017_ico;

case BootstrapperIcon.Icon2019:
return Properties.Resources.Icon2019_ico;

case BootstrapperIcon.Icon2022:
return Properties.Resources.Icon2022_ico;

case BootstrapperIcon.IconBloxstrap:
default:
return Properties.Resources.IconBloxstrap_ico;
}
}

public static Bitmap GetBitmap(this BootstrapperIcon icon)
{
switch (icon)
{
case BootstrapperIcon.Icon2009:
return Properties.Resources.Icon2009_png;

case BootstrapperIcon.Icon2011:
return Properties.Resources.Icon2011_png;

case BootstrapperIcon.IconEarly2015:
return Properties.Resources.IconEarly2015_png;

case BootstrapperIcon.IconLate2015:
return Properties.Resources.IconLate2015_png;

case BootstrapperIcon.Icon2017:
return Properties.Resources.Icon2017_png;

case BootstrapperIcon.Icon2019:
return Properties.Resources.Icon2019_png;

case BootstrapperIcon.Icon2022:
return Properties.Resources.Icon2022_png;

case BootstrapperIcon.IconBloxstrap:
default:
return Properties.Resources.IconBloxstrap_png;
}
}
}
}
Loading

0 comments on commit 8316c9e

Please sign in to comment.