diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 691d868..dfc11ca 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -42,7 +42,7 @@ namespace Bloxstrap public static bool IsProductionBuild => IsActionBuild && BuildMetadata.CommitRef.StartsWith("tag", StringComparison.Ordinal); - public static bool IsStudioVisible => !String.IsNullOrEmpty(App.State.Prop.Studio.VersionGuid); + public static bool IsStudioVisible => !String.IsNullOrEmpty(App.RobloxState.Prop.Studio.VersionGuid); public static readonly MD5 MD5Provider = MD5.Create(); @@ -54,6 +54,8 @@ namespace Bloxstrap public static readonly JsonManager State = new(); + public static readonly JsonManager RobloxState = new(); + public static readonly FastFlagManager FastFlags = new(); public static readonly HttpClient HttpClient = new( @@ -336,6 +338,7 @@ namespace Bloxstrap Settings.Load(); State.Load(); + RobloxState.Load(); FastFlags.Load(); if (!Locale.SupportedLocales.ContainsKey(Settings.Prop.Locale)) diff --git a/Bloxstrap/AppData/RobloxPlayerData.cs b/Bloxstrap/AppData/RobloxPlayerData.cs index 3c4f728..bba6cc8 100644 --- a/Bloxstrap/AppData/RobloxPlayerData.cs +++ b/Bloxstrap/AppData/RobloxPlayerData.cs @@ -16,7 +16,7 @@ namespace Bloxstrap.AppData public override string ExecutableName => "RobloxPlayerBeta.exe"; - public override AppState State => App.State.Prop.Player; + public override AppState State => App.RobloxState.Prop.Player; public override IReadOnlyDictionary PackageDirectoryMap { get; set; } = new Dictionary() { diff --git a/Bloxstrap/AppData/RobloxStudioData.cs b/Bloxstrap/AppData/RobloxStudioData.cs index 2ada1c2..18c8e36 100644 --- a/Bloxstrap/AppData/RobloxStudioData.cs +++ b/Bloxstrap/AppData/RobloxStudioData.cs @@ -10,7 +10,7 @@ public override string ExecutableName => "RobloxStudioBeta.exe"; - public override AppState State => App.State.Prop.Studio; + public override AppState State => App.RobloxState.Prop.Studio; public override IReadOnlyDictionary PackageDirectoryMap { get; set; } = new Dictionary() { diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 6a8d6e1..0319397 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -61,7 +61,7 @@ namespace Bloxstrap private long _totalDownloadedBytes = 0; private bool _packageExtractionSuccess = true; - private bool _mustUpgrade => App.LaunchSettings.ForceFlag.Active || String.IsNullOrEmpty(AppData.State.VersionGuid) || !File.Exists(AppData.ExecutablePath); + private bool _mustUpgrade => App.LaunchSettings.ForceFlag.Active || App.State.Prop.ForceReinstall || String.IsNullOrEmpty(AppData.State.VersionGuid) || !File.Exists(AppData.ExecutablePath); private bool _noConnection = false; private AsyncMutex? _mutex; @@ -229,6 +229,7 @@ namespace Bloxstrap { App.Settings.Load(); App.State.Load(); + App.RobloxState.Load(); } if (!_noConnection) @@ -784,7 +785,7 @@ namespace Bloxstrap { string dirName = Path.GetFileName(dir); - if (dirName != App.State.Prop.Player.VersionGuid && dirName != App.State.Prop.Studio.VersionGuid) + if (dirName != App.RobloxState.Prop.Player.VersionGuid && dirName != App.RobloxState.Prop.Studio.VersionGuid) { Filesystem.AssertReadOnlyDirectory(dir); @@ -1020,8 +1021,8 @@ namespace Bloxstrap var allPackageHashes = new List(); - allPackageHashes.AddRange(App.State.Prop.Player.PackageHashes.Values); - allPackageHashes.AddRange(App.State.Prop.Studio.PackageHashes.Values); + allPackageHashes.AddRange(App.RobloxState.Prop.Player.PackageHashes.Values); + allPackageHashes.AddRange(App.RobloxState.Prop.Studio.PackageHashes.Values); if (!App.Settings.Prop.DebugDisableVersionPackageCleanup) { @@ -1050,7 +1051,7 @@ namespace Bloxstrap AppData.State.Size = distributionSize; - int totalSize = App.State.Prop.Player.Size + App.State.Prop.Studio.Size; + int totalSize = App.RobloxState.Prop.Player.Size + App.RobloxState.Prop.Studio.Size; using (var uninstallKey = Registry.CurrentUser.CreateSubKey(App.UninstallKey)) { @@ -1060,6 +1061,7 @@ namespace Bloxstrap App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB"); App.State.Save(); + App.RobloxState.Save(); _isInstalling = false; } @@ -1212,7 +1214,7 @@ namespace Bloxstrap var fileRestoreMap = new Dictionary>(); - foreach (string fileLocation in App.State.Prop.ModManifest) + foreach (string fileLocation in App.RobloxState.Prop.ModManifest) { if (modFolderFiles.Contains(fileLocation)) continue; @@ -1257,8 +1259,8 @@ namespace Bloxstrap } } - App.State.Prop.ModManifest = modFolderFiles; - App.State.Save(); + App.RobloxState.Prop.ModManifest = modFolderFiles; + App.RobloxState.Save(); App.Logger.WriteLine(LOG_IDENT, $"Finished checking file mods"); diff --git a/Bloxstrap/Installer.cs b/Bloxstrap/Installer.cs index 93f40c1..d57e985 100644 --- a/Bloxstrap/Installer.cs +++ b/Bloxstrap/Installer.cs @@ -197,7 +197,7 @@ namespace Bloxstrap var processes = new List(); - if (!String.IsNullOrEmpty(App.State.Prop.Player.VersionGuid)) + if (!String.IsNullOrEmpty(App.RobloxState.Prop.Player.VersionGuid)) processes.AddRange(Process.GetProcessesByName(App.RobloxPlayerAppName)); if (App.IsStudioVisible) @@ -587,16 +587,23 @@ namespace Bloxstrap } } - if (Utilities.CompareVersions(existingVer, "2.8.3") == VersionComparison.LessThan) + if (Utilities.CompareVersions(existingVer, "2.9.0") == VersionComparison.LessThan) { - // force reinstallation - App.State.Prop.Player.VersionGuid = ""; - App.State.Prop.Studio.VersionGuid = ""; + // move from App.State to App.RobloxState + if (App.State.Prop.GetDeprecatedPlayer() != null) + App.RobloxState.Prop.Player = App.State.Prop.GetDeprecatedPlayer()!; + + if (App.State.Prop.GetDeprecatedStudio() != null) + App.RobloxState.Prop.Studio = App.State.Prop.GetDeprecatedStudio()!; + + if (App.State.Prop.GetDeprecatedModManifest() != null) + App.RobloxState.Prop.ModManifest = App.State.Prop.GetDeprecatedModManifest()!; } App.Settings.Save(); App.FastFlags.Save(); App.State.Save(); + App.RobloxState.Save(); } if (currentVer is null) diff --git a/Bloxstrap/Models/Persistable/RobloxState.cs b/Bloxstrap/Models/Persistable/RobloxState.cs new file mode 100644 index 0000000..f4b3098 --- /dev/null +++ b/Bloxstrap/Models/Persistable/RobloxState.cs @@ -0,0 +1,11 @@ +namespace Bloxstrap.Models.Persistable +{ + public class RobloxState + { + public AppState Player { get; set; } = new(); + + public AppState Studio { get; set; } = new(); + + public List ModManifest { get; set; } = new(); + } +} diff --git a/Bloxstrap/Models/Persistable/State.cs b/Bloxstrap/Models/Persistable/State.cs index de05265..070f8e0 100644 --- a/Bloxstrap/Models/Persistable/State.cs +++ b/Bloxstrap/Models/Persistable/State.cs @@ -6,12 +6,28 @@ public bool PromptWebView2Install { get; set; } = true; - public AppState Player { get; set; } = new(); - - public AppState Studio { get; set; } = new(); + public bool ForceReinstall { get; set; } = false; public WindowState SettingsWindow { get; set; } = new(); - public List ModManifest { get; set; } = new(); + #region Deprecated properties + /// + /// Deprecated, use App.RobloxState.Player + /// + public AppState? Player { private get; set; } + public AppState? GetDeprecatedPlayer() => Player; + + /// + /// Deprecated, use App.RobloxState.Studio + /// + public AppState? Studio { private get; set; } + public AppState? GetDeprecatedStudio() => Studio; + + /// + /// Deprecated, use App.RobloxState.ModManifest + /// + public List? ModManifest { private get; set; } + public List? GetDeprecatedModManifest() => ModManifest; + #endregion } } diff --git a/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs index fdbc6db..69b2351 100644 --- a/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Settings/BehaviourViewModel.cs @@ -2,9 +2,6 @@ { public class BehaviourViewModel : NotifyPropertyChangedViewModel { - private string _oldPlayerVersionGuid = ""; - private string _oldStudioVersionGuid = ""; - public bool ConfirmLaunches { get => App.Settings.Prop.ConfirmLaunches; @@ -21,22 +18,8 @@ { // wouldnt it be better to check old version guids? // what about fresh installs? - get => String.IsNullOrEmpty(App.State.Prop.Player.VersionGuid) && String.IsNullOrEmpty(App.State.Prop.Studio.VersionGuid); - set - { - if (value) - { - _oldPlayerVersionGuid = App.State.Prop.Player.VersionGuid; - _oldStudioVersionGuid = App.State.Prop.Studio.VersionGuid; - App.State.Prop.Player.VersionGuid = ""; - App.State.Prop.Studio.VersionGuid = ""; - } - else - { - App.State.Prop.Player.VersionGuid = _oldPlayerVersionGuid; - App.State.Prop.Studio.VersionGuid = _oldStudioVersionGuid; - } - } + get => App.State.Prop.ForceReinstall || (String.IsNullOrEmpty(App.RobloxState.Prop.Player.VersionGuid) && String.IsNullOrEmpty(App.RobloxState.Prop.Studio.VersionGuid)); + set => App.State.Prop.ForceReinstall = value; } } }