Use enum value for determining launch mode

might change how this looks, such as getting rid of StudioAuth as its own thing
This commit is contained in:
pizzaboxer 2023-10-10 23:00:34 +01:00
parent a92ea7ba3d
commit e0f261067e
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 40 additions and 30 deletions

View File

@ -197,8 +197,7 @@ namespace Bloxstrap
#endif #endif
string commandLine = ""; string commandLine = "";
bool isStudioLaunch = false; LaunchMode launchMode = LaunchMode.Player;
bool isStudioAuth = false;
if (IsMenuLaunch) if (IsMenuLaunch)
{ {
@ -240,19 +239,21 @@ namespace Bloxstrap
else if (LaunchArgs[0].StartsWith("roblox-studio:")) else if (LaunchArgs[0].StartsWith("roblox-studio:"))
{ {
commandLine = ProtocolHandler.ParseUri(LaunchArgs[0]); commandLine = ProtocolHandler.ParseUri(LaunchArgs[0]);
if (!commandLine.Contains("-startEvent")) if (!commandLine.Contains("-startEvent"))
commandLine += " -startEvent www.roblox.com/robloxQTStudioStartedEvent"; commandLine += " -startEvent www.roblox.com/robloxQTStudioStartedEvent";
isStudioLaunch = true;
launchMode = LaunchMode.Studio;
} }
else if (LaunchArgs[0].StartsWith("roblox-studio-auth:")) else if (LaunchArgs[0].StartsWith("roblox-studio-auth:"))
{ {
commandLine = HttpUtility.UrlDecode(LaunchArgs[0]); commandLine = HttpUtility.UrlDecode(LaunchArgs[0]);
isStudioLaunch = true; launchMode = LaunchMode.StudioAuth;
isStudioAuth = true;
} }
else if (LaunchArgs[0] == "-ide") else if (LaunchArgs[0] == "-ide")
{ {
isStudioLaunch = true; launchMode = LaunchMode.Studio;
if (LaunchArgs.Length >= 2) if (LaunchArgs.Length >= 2)
commandLine = $"-task EditFile -localPlaceFile \"{LaunchArgs[1]}\""; commandLine = $"-task EditFile -localPlaceFile \"{LaunchArgs[1]}\"";
} }
@ -273,7 +274,7 @@ namespace Bloxstrap
// start bootstrapper and show the bootstrapper modal if we're not running silently // start bootstrapper and show the bootstrapper modal if we're not running silently
Logger.WriteLine(LOG_IDENT, "Initializing bootstrapper"); Logger.WriteLine(LOG_IDENT, "Initializing bootstrapper");
Bootstrapper bootstrapper = new(commandLine, isStudioLaunch, isStudioAuth); Bootstrapper bootstrapper = new(commandLine, launchMode);
IBootstrapperDialog? dialog = null; IBootstrapperDialog? dialog = null;
if (!IsQuiet) if (!IsQuiet)
@ -290,7 +291,7 @@ namespace Bloxstrap
Mutex? singletonMutex = null; Mutex? singletonMutex = null;
if (Settings.Prop.MultiInstanceLaunching && !isStudioLaunch) if (Settings.Prop.MultiInstanceLaunching && launchMode == LaunchMode.Player)
{ {
Logger.WriteLine(LOG_IDENT, "Creating singleton mutex"); Logger.WriteLine(LOG_IDENT, "Creating singleton mutex");

View File

@ -23,27 +23,26 @@ namespace Bloxstrap
private bool FreshInstall => String.IsNullOrEmpty(_versionGuid); private bool FreshInstall => String.IsNullOrEmpty(_versionGuid);
private string _playerFileName => _studioLaunch ? "RobloxStudioBeta.exe" : "RobloxPlayerBeta.exe"; private string _playerFileName => _launchMode == LaunchMode.Player ? "RobloxPlayerBeta.exe" : "RobloxStudioBeta.exe";
// TODO: change name // TODO: change name
private string _playerLocation => Path.Combine(_versionFolder, _playerFileName); private string _playerLocation => Path.Combine(_versionFolder, _playerFileName);
private string _launchCommandLine; private string _launchCommandLine;
private bool _studioLaunch; private LaunchMode _launchMode;
private bool _studioAuth;
private string _versionGuid private string _versionGuid
{ {
get get
{ {
return _studioLaunch ? App.State.Prop.StudioVersionGuid : App.State.Prop.PlayerVersionGuid; return _launchMode == LaunchMode.Player ? App.State.Prop.PlayerVersionGuid : App.State.Prop.StudioVersionGuid;
} }
set set
{ {
if (_studioLaunch) if (_launchMode == LaunchMode.Player)
App.State.Prop.StudioVersionGuid = value;
else
App.State.Prop.PlayerVersionGuid = value; App.State.Prop.PlayerVersionGuid = value;
else
App.State.Prop.StudioVersionGuid = value;
} }
} }
@ -51,15 +50,15 @@ namespace Bloxstrap
{ {
get get
{ {
return _studioLaunch ? App.State.Prop.StudioSize : App.State.Prop.PlayerSize; return _launchMode == LaunchMode.Player ? App.State.Prop.PlayerSize : App.State.Prop.StudioSize;
} }
set set
{ {
if (_studioLaunch) if (_launchMode == LaunchMode.Player)
App.State.Prop.StudioSize = value;
else
App.State.Prop.PlayerSize = value; App.State.Prop.PlayerSize = value;
else
App.State.Prop.StudioSize = value;
} }
} }
@ -76,17 +75,17 @@ namespace Bloxstrap
private IReadOnlyDictionary<string, string> _packageDirectories; private IReadOnlyDictionary<string, string> _packageDirectories;
public IBootstrapperDialog? Dialog = null; public IBootstrapperDialog? Dialog = null;
public bool IsStudioLaunch => _studioLaunch;
public bool IsStudioLaunch => _launchMode != LaunchMode.Player;
#endregion #endregion
#region Core #region Core
public Bootstrapper(string launchCommandLine, bool studioLaunch, bool studioAuth) public Bootstrapper(string launchCommandLine, LaunchMode launchMode)
{ {
_launchCommandLine = launchCommandLine; _launchCommandLine = launchCommandLine;
_studioLaunch = studioLaunch; _launchMode = launchMode;
_studioAuth = studioAuth;
_packageDirectories = _studioLaunch ? PackageMap.Studio : PackageMap.Player; _packageDirectories = _launchMode == LaunchMode.Player ? PackageMap.Player : PackageMap.Studio;
} }
private void SetStatus(string message) private void SetStatus(string message)
@ -94,7 +93,8 @@ namespace Bloxstrap
App.Logger.WriteLine("Bootstrapper::SetStatus", message); App.Logger.WriteLine("Bootstrapper::SetStatus", message);
string productName = "Roblox"; string productName = "Roblox";
if (_studioLaunch)
if (_launchMode != LaunchMode.Player)
productName += " Studio"; productName += " Studio";
message = message.Replace("{product}", productName); message = message.Replace("{product}", productName);
@ -242,7 +242,7 @@ namespace Bloxstrap
ClientVersion clientVersion; ClientVersion clientVersion;
string binaryType = _studioLaunch ? "WindowsStudio64" : "WindowsPlayer"; string binaryType = _launchMode == LaunchMode.Player ? "WindowsPlayer" : "WindowsStudio64";
try try
{ {
@ -314,7 +314,7 @@ namespace Bloxstrap
return; return;
} }
if (!_studioAuth) if (_launchMode != LaunchMode.StudioAuth)
{ {
_launchCommandLine = _launchCommandLine.Replace("LAUNCHTIMEPLACEHOLDER", DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString()); _launchCommandLine = _launchCommandLine.Replace("LAUNCHTIMEPLACEHOLDER", DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString());
@ -336,7 +336,7 @@ namespace Bloxstrap
WorkingDirectory = _versionFolder WorkingDirectory = _versionFolder
}; };
if (_studioAuth) if (_launchMode == LaunchMode.StudioAuth)
{ {
Process.Start(startInfo); Process.Start(startInfo);
Dialog?.CloseBootstrapper(); Dialog?.CloseBootstrapper();
@ -356,7 +356,7 @@ namespace Bloxstrap
App.Logger.WriteLine(LOG_IDENT, $"Started Roblox (PID {gameClientPid})"); App.Logger.WriteLine(LOG_IDENT, $"Started Roblox (PID {gameClientPid})");
string eventName = _studioLaunch ? "www.roblox.com/robloxQTStudioStartedEvent" : "www.roblox.com/robloxStartedEvent"; string eventName = _launchMode == LaunchMode.Player ? "www.roblox.com/robloxStartedEvent" : "www.roblox.com/robloxQTStudioStartedEvent";
using (SystemEvent startEvent = new(eventName)) using (SystemEvent startEvent = new(eventName))
{ {
bool startEventFired = await startEvent.WaitForEvent(); bool startEventFired = await startEvent.WaitForEvent();
@ -367,7 +367,7 @@ namespace Bloxstrap
return; return;
} }
if (App.Settings.Prop.EnableActivityTracking && !_studioLaunch) if (App.Settings.Prop.EnableActivityTracking && _launchMode == LaunchMode.Player)
App.NotifyIcon?.SetProcessId(gameClientPid); App.NotifyIcon?.SetProcessId(gameClientPid);
if (App.Settings.Prop.EnableActivityTracking) if (App.Settings.Prop.EnableActivityTracking)

View File

@ -0,0 +1,9 @@
namespace Bloxstrap.Enums
{
public enum LaunchMode
{
Player,
Studio,
StudioAuth
}
}