Check if player executable exists (#128)

This commit is contained in:
pizzaboxer 2023-04-12 11:06:27 +02:00
parent 65c85b612a
commit d7dc198a8b
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 20 additions and 31 deletions

View File

@ -68,6 +68,7 @@ namespace Bloxstrap
private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid);
private static string DesktopShortcutLocation => Path.Combine(Directories.Desktop, "Play Roblox.lnk");
private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
private string? _launchCommandLine;
@ -144,8 +145,9 @@ namespace Bloxstrap
CheckInstallMigration();
// if roblox needs updating but is running and we have multiple instances open, ignore update for now
if (App.IsFirstRun || _versionGuid != App.State.Prop.VersionGuid && !Utilities.CheckIfRobloxRunning())
// only update roblox if we're running for the first time, or if
// roblox isn't running and our version guid is out of date, or the player exe doesn't exist
if (App.IsFirstRun || !Utilities.CheckIfRobloxRunning() && (_versionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation)))
await InstallLatestVersion();
// last time the version folder was set, it was set to the latest version guid
@ -153,10 +155,10 @@ namespace Bloxstrap
_versionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid);
if (App.IsFirstRun)
{
App.ShouldSaveConfigs = true;
IntegrationMigrator.Execute();
App.FastFlags.Save();
}
if (App.Settings.Prop.UseReShade)
SetStatus("Configuring/Downloading ReShade...");
@ -170,8 +172,6 @@ namespace Bloxstrap
CheckInstall();
IntegrationMigrator.Execute();
// at this point we've finished updating our configs
App.Settings.Save();
App.State.Save();
@ -336,7 +336,7 @@ namespace Bloxstrap
// whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes
bool shouldWait = false;
Process gameClient = Process.Start(Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"), _launchCommandLine);
Process gameClient = Process.Start(_playerLocation, _launchCommandLine);
List<Process> autocloseProcesses = new();
GameActivityWatcher? activityWatcher = null;
DiscordRichPresence? richPresence = null;
@ -708,23 +708,20 @@ namespace Bloxstrap
string oldVersionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid);
if (_versionGuid != App.State.Prop.VersionGuid && Directory.Exists(oldVersionFolder))
{
// and also to delete our old version folder
if (_versionGuid != App.State.Prop.VersionGuid && Directory.Exists(oldVersionFolder))
Directory.Delete(oldVersionFolder, true);
}
// move old compatibility flags for the old location
using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"))
{
string oldGameClientLocation = Path.Combine(oldVersionFolder, "RobloxPlayerBeta.exe");
string newGameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
string? appFlags = (string?)appFlagsKey.GetValue(oldGameClientLocation);
if (appFlags is not null)
{
App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {newGameClientLocation}...");
appFlagsKey.SetValue(newGameClientLocation, appFlags);
App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {_playerLocation}...");
appFlagsKey.SetValue(_playerLocation, appFlags);
appFlagsKey.DeleteValue(oldGameClientLocation);
}
}
@ -747,23 +744,22 @@ namespace Bloxstrap
using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"))
{
const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE";
string gameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe");
string? appFlags = (string?)appFlagsKey.GetValue(gameClientLocation);
string? appFlags = (string?)appFlagsKey.GetValue(_playerLocation);
if (App.Settings.Prop.DisableFullscreenOptimizations)
{
if (appFlags is null)
appFlagsKey.SetValue(gameClientLocation, $"~{flag}");
appFlagsKey.SetValue(_playerLocation, $"~{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))
{
// if there's more than one space, there's more flags set we need to preserve
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
appFlagsKey.DeleteValue(gameClientLocation);
appFlagsKey.DeleteValue(_playerLocation);
}
}

View File

@ -69,29 +69,24 @@ namespace Bloxstrap.Helpers
{
base.Load();
// set to 99999 by default if it doesnt immediately exist
// set to 9999 by default if it doesnt already exist
if (GetValue("DFIntTaskSchedulerTargetFps") is null)
{
SetValue("DFIntTaskSchedulerTargetFps", 9999);
if (!App.IsFirstRun)
Save();
}
}
public override void Save()
{
App.Logger.WriteLine($"[FastFlagManager::Save] Attempting to save JSON to {FileLocation}...");
// reload for any changes made while the menu was open
Load();
if (Changes.Count == 0)
{
App.Logger.WriteLine($"[FastFlagManager::Save] No changes to apply, aborting.");
return;
}
// reload for any changes made while the menu was open
Load();
foreach (var change in Changes)
{
if (change.Value is null)

View File

@ -6,8 +6,6 @@ namespace Bloxstrap.Helpers
{
public static void Execute()
{
App.FastFlags.Load();
// v2.2.0 - remove rbxfpsunlocker
string rbxfpsunlocker = Path.Combine(Directories.Integrations, "rbxfpsunlocker");