From 57e6454fd7153a7f6995ea11522481a7dea609ce Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 24 May 2023 14:56:47 +0100 Subject: [PATCH] Add program size estimation conditions are kinda messy but its fine --- Bloxstrap/Bootstrapper.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 06dfbc2..ab22d14 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -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;