From 2c1c2a374f68d595cec5f938df3910c17321c9dc Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:07:32 +0100 Subject: [PATCH] add studio protocols --- Bloxstrap/Bootstrapper.cs | 25 ++++++++++++++++++++++--- Bloxstrap/ProtocolHandler.cs | 13 +++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 16c68eb..ed0823e 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -502,6 +502,8 @@ namespace Bloxstrap ProtocolHandler.Register("roblox", "Roblox", Paths.Application); ProtocolHandler.Register("roblox-player", "Roblox", Paths.Application); + ProtocolHandler.Register("roblox-studio", "Roblox", Paths.Application, "-studio"); + ProtocolHandler.Register("roblox-studio-auth", "Roblox", Paths.Application, "-studio"); if (Environment.ProcessPath is not null && Environment.ProcessPath != Paths.Application) { @@ -678,13 +680,13 @@ namespace Bloxstrap bool robloxStillInstalled = true; // check if stock bootstrapper is still installed - RegistryKey? bootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-player"); + using RegistryKey? bootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-player"); if (bootstrapperKey is null) { + robloxStillInstalled = false; + ProtocolHandler.Unregister("roblox"); ProtocolHandler.Unregister("roblox-player"); - - robloxStillInstalled = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-studio") is not null; } else { @@ -696,6 +698,23 @@ namespace Bloxstrap ProtocolHandler.Register("roblox-player", "Roblox", bootstrapperLocation); } + using RegistryKey? studioBootstrapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\roblox-studio"); + if (studioBootstrapperKey is null) + { + robloxStillInstalled = false; + + ProtocolHandler.Unregister("roblox-studio"); + ProtocolHandler.Unregister("roblox-studio-auth"); + } + else + { + robloxStillInstalled = true; + + string studioLocation = (string?)studioBootstrapperKey.GetValue("InstallLocation") + "RobloxStudioBeta.exe"; // points to studio exe instead of bootstrapper + ProtocolHandler.Register("roblox-studio", "Roblox", studioLocation); + ProtocolHandler.Register("roblox-studio-auth", "Roblox", studioLocation); + } + // if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder // in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0) // if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up diff --git a/Bloxstrap/ProtocolHandler.cs b/Bloxstrap/ProtocolHandler.cs index 44ff873..4b63546 100644 --- a/Bloxstrap/ProtocolHandler.cs +++ b/Bloxstrap/ProtocolHandler.cs @@ -105,9 +105,18 @@ namespace Bloxstrap App.State.Save(); } - public static void Register(string key, string name, string handler) + private static string ConstructHandlerArgs(string handler, string? extraArgs = null) { - string handlerArgs = $"\"{handler}\" %1"; + string handlerArgs = $"\"{handler}\""; + if (!string.IsNullOrEmpty(extraArgs)) + handlerArgs += $" {extraArgs}"; + handlerArgs += " %1"; + return handlerArgs; + } + + public static void Register(string key, string name, string handler, string? extraArgs = null) + { + string handlerArgs = ConstructHandlerArgs(handler, extraArgs); RegistryKey uriKey = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{key}"); RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon"); RegistryKey uriCommandKey = uriKey.CreateSubKey(@"shell\open\command");