From 140dde19fd21add33f940bf17a98a71ed9696cb5 Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Tue, 19 Jan 2021 12:23:01 -0500 Subject: [PATCH 1/2] Add description for OneClick registry keys Adds a description to protocol handler registry keys when setting up OneClick install. --- ModAssistant/App.xaml.cs | 4 ++-- ModAssistant/Classes/OneClickInstaller.cs | 8 ++++++-- ModAssistant/Pages/Options.xaml.cs | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ModAssistant/App.xaml.cs b/ModAssistant/App.xaml.cs index e8a7ae7..098ecf9 100644 --- a/ModAssistant/App.xaml.cs +++ b/ModAssistant/App.xaml.cs @@ -168,12 +168,12 @@ namespace ModAssistant } else { - OneClickInstaller.Register(args[1], true); + OneClickInstaller.Register(args[1], true, args[2]); } Update = false; GUI = false; - args = Shift(args, 2); + args = Shift(args, args.Length); break; case "--unregister": diff --git a/ModAssistant/Classes/OneClickInstaller.cs b/ModAssistant/Classes/OneClickInstaller.cs index 631705a..6ab19d2 100644 --- a/ModAssistant/Classes/OneClickInstaller.cs +++ b/ModAssistant/Classes/OneClickInstaller.cs @@ -58,7 +58,7 @@ namespace ModAssistant await API.Playlists.DownloadAll(uri); } - public static void Register(string Protocol, bool Background = false) + public static void Register(string Protocol, bool Background = false, string Description = null) { if (IsRegistered(Protocol) == true) return; @@ -75,6 +75,10 @@ namespace ModAssistant if (ProtocolKey.GetValue("OneClick-Provider", "").ToString() != "ModAssistant") { + if (Description != null) + { + ProtocolKey.SetValue("", Description, RegistryValueKind.String); + } ProtocolKey.SetValue("URL Protocol", "", RegistryValueKind.String); ProtocolKey.SetValue("OneClick-Provider", "ModAssistant", RegistryValueKind.String); CommandKey.SetValue("", $"\"{Utils.ExePath}\" \"--install\" \"%1\""); @@ -84,7 +88,7 @@ namespace ModAssistant } else { - Utils.StartAsAdmin($"\"--register\" \"{Protocol}\""); + Utils.StartAsAdmin($"\"--register\" \"{Protocol}\" \"{Description}\""); } } catch (Exception e) diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index b2215cd..dfe605c 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -137,7 +137,7 @@ namespace ModAssistant.Pages public void ModelSaberProtocolHandler_Checked(object sender, RoutedEventArgs e) { - OneClickInstaller.Register("modelsaber"); + OneClickInstaller.Register("modelsaber", Description: "URL:ModelSaber OneClick Install"); } public void ModelSaberProtocolHandler_Unchecked(object sender, RoutedEventArgs e) @@ -147,7 +147,7 @@ namespace ModAssistant.Pages public void BeatSaverProtocolHandler_Checked(object sender, RoutedEventArgs e) { - OneClickInstaller.Register("beatsaver"); + OneClickInstaller.Register("beatsaver", Description: "URL:BeatSaver OneClick Install"); } public void BeatSaverProtocolHandler_Unchecked(object sender, RoutedEventArgs e) @@ -156,7 +156,7 @@ namespace ModAssistant.Pages } public void PlaylistsProtocolHandler_Checked(object sender, RoutedEventArgs e) { - OneClickInstaller.Register("bsplaylist"); + OneClickInstaller.Register("bsplaylist", Description: "URL:BeatSaver Playlist OneClick Install"); } public void PlaylistsProtocolHandler_Unchecked(object sender, RoutedEventArgs e) From 177820b954a58652c2bd8ed30e8682f6ca5b7686 Mon Sep 17 00:00:00 2001 From: Stevoisiak Date: Tue, 19 Jan 2021 19:55:59 -0500 Subject: [PATCH 2/2] Shift arguments by 3 Addresses https://github.com/Assistant/ModAssistant/pull/293#discussion_r560598751 --- ModAssistant/App.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ModAssistant/App.xaml.cs b/ModAssistant/App.xaml.cs index 098ecf9..ac397d0 100644 --- a/ModAssistant/App.xaml.cs +++ b/ModAssistant/App.xaml.cs @@ -162,7 +162,7 @@ namespace ModAssistant break; case "--register": - if (args.Length < 2 || string.IsNullOrEmpty(args[1])) + if (args.Length < 3 || string.IsNullOrEmpty(args[1])) { Utils.SendNotify(string.Format((string)Current.FindResource("App:InvalidArgument"), "--register")); } @@ -173,7 +173,7 @@ namespace ModAssistant Update = false; GUI = false; - args = Shift(args, args.Length); + args = Shift(args, 3); break; case "--unregister":