add RobloxState

This commit is contained in:
bluepilledgreat 2025-03-12 18:55:20 +00:00
parent 3f666333ee
commit bff40a40a7
8 changed files with 61 additions and 39 deletions

View File

@ -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> State = new();
public static readonly JsonManager<RobloxState> 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))

View File

@ -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<string, string> PackageDirectoryMap { get; set; } = new Dictionary<string, string>()
{

View File

@ -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<string, string> PackageDirectoryMap { get; set; } = new Dictionary<string, string>()
{

View File

@ -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<string>();
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<string, List<string>>();
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");

View File

@ -197,7 +197,7 @@ namespace Bloxstrap
var processes = new List<Process>();
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)

View File

@ -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<string> ModManifest { get; set; } = new();
}
}

View File

@ -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<string> ModManifest { get; set; } = new();
#region Deprecated properties
/// <summary>
/// Deprecated, use App.RobloxState.Player
/// </summary>
public AppState? Player { private get; set; }
public AppState? GetDeprecatedPlayer() => Player;
/// <summary>
/// Deprecated, use App.RobloxState.Studio
/// </summary>
public AppState? Studio { private get; set; }
public AppState? GetDeprecatedStudio() => Studio;
/// <summary>
/// Deprecated, use App.RobloxState.ModManifest
/// </summary>
public List<string>? ModManifest { private get; set; }
public List<string>? GetDeprecatedModManifest() => ModManifest;
#endregion
}
}

View File

@ -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;
}
}
}