Add program size estimation

conditions are kinda messy but its fine
This commit is contained in:
pizzaboxer 2023-05-24 14:56:47 +01:00
parent 54b65f8728
commit 57e6454fd7
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -188,7 +188,10 @@ namespace Bloxstrap
await ApplyModifications();
if (App.IsFirstRun || FreshInstall)
{
Register();
RegisterProgramSize();
}
CheckInstall();
@ -425,6 +428,20 @@ namespace Bloxstrap
App.Logger.WriteLine("[Bootstrapper::StartRoblox] Registered application");
}
public void RegisterProgramSize()
{
App.Logger.WriteLine("[Bootstrapper::RegisterProgramSize] Registering approximate program size...");
using RegistryKey uninstallKey = Registry.CurrentUser.CreateSubKey($"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{App.ProjectName}");
// sum compressed and uncompressed package sizes and convert to kilobytes
int totalSize = (_versionPackageManifest.Sum(x => x.Size) + _versionPackageManifest.Sum(x => x.PackedSize)) / 1000;
uninstallKey.SetValue("EstimatedSize", totalSize);
App.Logger.WriteLine($"[Bootstrapper::RegisterProgramSize] Registered as {totalSize} KB");
}
private void CheckInstallMigration()
{
// check if we've changed our install location since the last time we started
@ -785,6 +802,10 @@ namespace Bloxstrap
App.State.Prop.VersionGuid = _latestVersionGuid;
// don't register program size until the program is registered
if (!App.IsFirstRun && !FreshInstall)
RegisterProgramSize();
if (Dialog is not null)
Dialog.CancelEnabled = false;