Check if player executable exists (#128)

This commit is contained in:
pizzaboxer 2023-04-12 11:06:27 +02:00
parent c650c29016
commit ef9a28c8ec
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -71,14 +71,15 @@ namespace Bloxstrap
private readonly CancellationTokenSource _cancelTokenSource = new(); private readonly CancellationTokenSource _cancelTokenSource = new();
private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid); private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid);
private static string DesktopShortcutLocation => Path.Combine(Directories.Desktop, "Play Roblox.lnk");
private static bool ShouldInstallWebView2 = false; private static bool ShouldInstallWebView2 = false;
private static string DesktopShortcutLocation => Path.Combine(Directories.Desktop, "Play Roblox.lnk");
private string? _launchCommandLine; private string? _launchCommandLine;
private string _latestVersionGuid = null!; private string _latestVersionGuid = null!;
private PackageManifest _versionPackageManifest = null!; private PackageManifest _versionPackageManifest = null!;
private string _versionFolder = null!; private string _versionFolder = null!;
private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
private bool _isInstalling = false; private bool _isInstalling = false;
private double _progressIncrement; private double _progressIncrement;
@ -161,8 +162,9 @@ namespace Bloxstrap
CheckInstallMigration(); CheckInstallMigration();
// if roblox needs updating but is running and we have multiple instances open, ignore update for now // only update roblox if we're running for the first time, or if
if (App.IsFirstRun || _latestVersionGuid != App.State.Prop.VersionGuid && !Utilities.CheckIfRobloxRunning()) // roblox isn't running and our version guid is out of date, or the player exe doesn't exist
if (App.IsFirstRun || !Utilities.CheckIfRobloxRunning() && (_latestVersionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation)))
await InstallLatestVersion(); await InstallLatestVersion();
// last time the version folder was set, it was set to the latest version guid // last time the version folder was set, it was set to the latest version guid
@ -356,7 +358,7 @@ namespace Bloxstrap
// whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes // whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes
bool shouldWait = false; bool shouldWait = false;
Process gameClient = Process.Start(Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"), _launchCommandLine); Process gameClient = Process.Start(_playerLocation, _launchCommandLine);
List<Process> autocloseProcesses = new(); List<Process> autocloseProcesses = new();
GameActivityWatcher? activityWatcher = null; GameActivityWatcher? activityWatcher = null;
DiscordRichPresence? richPresence = null; DiscordRichPresence? richPresence = null;
@ -762,13 +764,12 @@ namespace Bloxstrap
using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"))
{ {
string oldGameClientLocation = Path.Combine(oldVersionFolder, "RobloxPlayerBeta.exe"); string oldGameClientLocation = Path.Combine(oldVersionFolder, "RobloxPlayerBeta.exe");
string newGameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
string? appFlags = (string?)appFlagsKey.GetValue(oldGameClientLocation); string? appFlags = (string?)appFlagsKey.GetValue(oldGameClientLocation);
if (appFlags is not null) if (appFlags is not null)
{ {
App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {newGameClientLocation}..."); App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {_playerLocation}...");
appFlagsKey.SetValue(newGameClientLocation, appFlags); appFlagsKey.SetValue(_playerLocation, appFlags);
appFlagsKey.DeleteValue(oldGameClientLocation); appFlagsKey.DeleteValue(oldGameClientLocation);
} }
} }
@ -827,23 +828,22 @@ namespace Bloxstrap
using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"))
{ {
const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE"; const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE";
string gameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"); string? appFlags = (string?)appFlagsKey.GetValue(_playerLocation);
string? appFlags = (string?)appFlagsKey.GetValue(gameClientLocation);
if (App.Settings.Prop.DisableFullscreenOptimizations) if (App.Settings.Prop.DisableFullscreenOptimizations)
{ {
if (appFlags is null) if (appFlags is null)
appFlagsKey.SetValue(gameClientLocation, $"~{flag}"); appFlagsKey.SetValue(_playerLocation, $"~{flag}");
else if (!appFlags.Contains(flag)) else if (!appFlags.Contains(flag))
appFlagsKey.SetValue(gameClientLocation, appFlags + flag); appFlagsKey.SetValue(_playerLocation, appFlags + flag);
} }
else if (appFlags is not null && appFlags.Contains(flag)) else if (appFlags is not null && appFlags.Contains(flag))
{ {
// if there's more than one space, there's more flags set we need to preserve // if there's more than one space, there's more flags set we need to preserve
if (appFlags.Split(' ').Length > 2) if (appFlags.Split(' ').Length > 2)
appFlagsKey.SetValue(gameClientLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length)); appFlagsKey.SetValue(_playerLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length));
else else
appFlagsKey.DeleteValue(gameClientLocation); appFlagsKey.DeleteValue(_playerLocation);
} }
} }