add studio protocols

This commit is contained in:
bluepilledgreat 2023-10-04 11:07:32 +01:00
parent a70ed1aead
commit 2c1c2a374f
2 changed files with 33 additions and 5 deletions

View File

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

View File

@ -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");