diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index a5c73a9..c7174e5 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -510,6 +510,10 @@ namespace Bloxstrap ProtocolHandler.Register("roblox-studio", "Roblox", Paths.Application); ProtocolHandler.Register("roblox-studio-auth", "Roblox", Paths.Application); + ProtocolHandler.RegisterRobloxPlace(Paths.Application); + ProtocolHandler.RegisterExtension(".rbxl"); + ProtocolHandler.RegisterExtension(".rbxlx"); + if (Environment.ProcessPath is not null && Environment.ProcessPath != Paths.Application) { // in case the user is reinstalling @@ -711,12 +715,18 @@ namespace Bloxstrap ProtocolHandler.Unregister("roblox-studio"); ProtocolHandler.Unregister("roblox-studio-auth"); + + ProtocolHandler.Unregister("Roblox.Place"); + ProtocolHandler.Unregister(".rbxl"); + ProtocolHandler.Unregister(".rbxlx"); } else { 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); + + ProtocolHandler.RegisterRobloxPlace(studioLocation); } // if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder diff --git a/Bloxstrap/ProtocolHandler.cs b/Bloxstrap/ProtocolHandler.cs index 2fe49f2..3b9695a 100644 --- a/Bloxstrap/ProtocolHandler.cs +++ b/Bloxstrap/ProtocolHandler.cs @@ -7,6 +7,8 @@ namespace Bloxstrap { static class ProtocolHandler { + private const string RobloxPlaceKey = "Roblox.Place"; + // map uri keys to command line args private static readonly IReadOnlyDictionary UriKeyArgMap = new Dictionary() { @@ -135,6 +137,39 @@ namespace Bloxstrap uriCommandKey.Close(); } + public static void RegisterRobloxPlace(string handler) + { + const string keyValue = "Roblox Place"; + string handlerArgs = $"\"{handler}\" -ide \"%1\""; + string iconValue = $"{handler},0"; + + using RegistryKey uriKey = Registry.CurrentUser.CreateSubKey(@"Software\Classes\" + RobloxPlaceKey); + using RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon"); + using RegistryKey uriOpenKey = uriKey.CreateSubKey(@"shell\Open"); + using RegistryKey uriCommandKey = uriOpenKey.CreateSubKey(@"command"); + + if (uriKey.GetValue("") as string != keyValue) + uriKey.SetValue("", keyValue); + + if (uriCommandKey.GetValue("") as string != handlerArgs) + uriCommandKey.SetValue("", handlerArgs); + + if (uriOpenKey.GetValue("") as string != "Open") + uriOpenKey.SetValue("", "Open"); + + if (uriIconKey.GetValue("") as string != iconValue) + uriIconKey.SetValue("", iconValue); + } + + public static void RegisterExtension(string key) + { + using RegistryKey uriKey = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{key}"); + uriKey.CreateSubKey(RobloxPlaceKey + @"\ShellNew"); + + if (uriKey.GetValue("") as string != RobloxPlaceKey) + uriKey.SetValue("", RobloxPlaceKey); + } + public static void Unregister(string key) { try