From b23df9b2ad2e5e52dae91dcc8f257a40541c90ac Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Sat, 28 Oct 2023 13:56:54 -0500 Subject: [PATCH] Support Playnite URI for connecting to server e.g. playnite://lancommander/connect/http%3A%2F%2Flocalhost%3A1337 --- .../LANCommanderLibraryPlugin.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs b/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs index f3a52dd..7974a3f 100644 --- a/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs +++ b/LANCommander.Playnite.Extension/LANCommanderLibraryPlugin.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; +using System.Web; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -73,6 +74,16 @@ namespace LANCommander.PlaynitePlugin if (Guid.TryParse(args.Arguments[1], out gameId)) PlayniteApi.StartGame(gameId); break; + + case "connect": + if (args.Arguments.Length == 1) + { + ShowAuthenticationWindow(); + break; + } + + ShowAuthenticationWindow(HttpUtility.UrlDecode(args.Arguments[1])); + break; } }); @@ -394,7 +405,7 @@ namespace LANCommander.PlaynitePlugin Logger.Trace("Name change was cancelled"); } - public Window ShowAuthenticationWindow() + public Window ShowAuthenticationWindow(string serverAddress = null) { Window window = null; Application.Current.Dispatcher.Invoke((Action)delegate @@ -410,7 +421,7 @@ namespace LANCommander.PlaynitePlugin window.Content = new Views.Authentication(this); window.DataContext = new ViewModels.Authentication() { - ServerAddress = Settings?.ServerAddress + ServerAddress = serverAddress ?? Settings?.ServerAddress }; window.Owner = PlayniteApi.Dialogs.GetCurrentAppWindow();