Support Playnite URI for connecting to server

e.g. playnite://lancommander/connect/http%3A%2F%2Flocalhost%3A1337
media
Pat Hartl 2023-10-28 13:56:54 -05:00
parent ff9ec5a17b
commit b23df9b2ad
1 changed files with 13 additions and 2 deletions

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Web;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@ -73,6 +74,16 @@ namespace LANCommander.PlaynitePlugin
if (Guid.TryParse(args.Arguments[1], out gameId)) if (Guid.TryParse(args.Arguments[1], out gameId))
PlayniteApi.StartGame(gameId); PlayniteApi.StartGame(gameId);
break; 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"); Logger.Trace("Name change was cancelled");
} }
public Window ShowAuthenticationWindow() public Window ShowAuthenticationWindow(string serverAddress = null)
{ {
Window window = null; Window window = null;
Application.Current.Dispatcher.Invoke((Action)delegate Application.Current.Dispatcher.Invoke((Action)delegate
@ -410,7 +421,7 @@ namespace LANCommander.PlaynitePlugin
window.Content = new Views.Authentication(this); window.Content = new Views.Authentication(this);
window.DataContext = new ViewModels.Authentication() window.DataContext = new ViewModels.Authentication()
{ {
ServerAddress = Settings?.ServerAddress ServerAddress = serverAddress ?? Settings?.ServerAddress
}; };
window.Owner = PlayniteApi.Dialogs.GetCurrentAppWindow(); window.Owner = PlayniteApi.Dialogs.GetCurrentAppWindow();