diff --git a/CHANGELOG.md b/CHANGELOG.md index 521dcfb..d2e9631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,31 @@ All notable changes are documented here. Versions follow the Playnite extension ## [Unreleased] +## [0.8.1] - 2026-09-16 + +### Added + +- Shortcut icon selection for PBS-managed Desktop and Start menu shortcuts: Playnite Boot Screen, Playnite Fullscreen, or a persistent custom `.ico` file. +- A guided Quick Setup page that groups launch methods, boot-video selection, and Playnite reveal behavior with a compact readiness indicator. + +### Changed + +- Settings are organized into Quick Setup, Playback, Streaming, Advanced, and Diagnostics tabs. +- Fresh installations use the Playnite Boot Screen shortcut icon by default; upgrades from 0.8.0 keep the existing Playnite Fullscreen icon choice. +- Runtime updated to 1.0.13. + +### Fixed + +- Desktop-to-Fullscreen readiness now refreshes the active Windows display topology while Playnite is starting, fixing transitions such as Extended desktop to a single TV/display. +- Fullscreen readiness keeps `MainWindowHandle` as the primary path and falls back to visible top-level windows owned by the exact Playnite Fullscreen PID when the main handle is still transient. +- Foreground handoff reuses the window handle that actually satisfied readiness detection. +- A media-device/decoder failure now hides the failed video surface and continues with the Playnite-readiness fallback instead of leaving a frozen frame visible. + +### Compatibility + +- Existing settings, shortcuts, custom media, and streaming configuration are migrated automatically. +- Manual PBS monitor selection remains an explicit overlay-placement option; dynamic topology refresh affects Switch readiness only. + ## [0.8.0] - 2026-09-14 ### Added diff --git a/PlayniteBoot.sln b/PlayniteBoot.sln index 07c36ff..d2f3f38 100644 --- a/PlayniteBoot.sln +++ b/PlayniteBoot.sln @@ -1,21 +1,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 +# Visual Studio Version 18 +VisualStudioVersion = 18.10.12201.205 stable MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlayniteBoot", "PlayniteBoot\PlayniteBoot.csproj", "{29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29F3BCC1-12ED-423E-8C61-D0EB0218EEC3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ADC8B5E3-5897-422C-A2B2-3206A7D66225} + EndGlobalSection EndGlobal diff --git a/PlayniteBoot/Localization/en_US.xaml b/PlayniteBoot/Localization/en_US.xaml index f154314..e358648 100644 --- a/PlayniteBoot/Localization/en_US.xaml +++ b/PlayniteBoot/Localization/en_US.xaml @@ -126,8 +126,8 @@ Runtime is not ready yet. Use Repair runtime if automatic synchronization does not complete. Valid Needs repair - ● Installed - ○ Not installed + Installed + Not installed Status unavailable Shortcut “{0}” created or updated in {1}. Shortcut removed from {0}. @@ -161,6 +161,66 @@ The shortcut installer was not found. PowerShell could not be started to create the shortcut. The shortcut operation timed out. - Launch Playnite Fullscreen with a custom boot video and no console window. + Launch Playnite Fullscreen through Playnite Boot Screen with the configured boot video. Video files + + + Quick Setup + Playback + Advanced + Diagnostics + + Set up your custom Playnite startup in just a few steps. PBS shows a boot video while Playnite Fullscreen is opening. + Adjust where and how the boot video is displayed. These settings apply to every PBS launch method. + Advanced readiness and launch settings. The defaults are recommended for most setups. + Runtime maintenance, logging and diagnostic information. + + 1. Start Playnite with PBS + 2. Choose your boot video + 3. Choose when Playnite appears + PBS shortcuts + Desktop → Fullscreen + Display + Readiness detection + Playnite launch + External / manual launch + Launch method state + + Create a shortcut that starts PBS before Playnite Fullscreen. + Playnite's normal Fullscreen startup remains unchanged and does not show the boot screen. + Choose how to start PBS, select your video, and decide when Playnite should appear. + Choose when Playnite Boot Screen should be shown. + Choose the video shown while Playnite is starting. Accepted formats: {0}. + Ready + Playnite Boot Screen is ready to use. + Setup needed + Create a PBS shortcut or enable Desktop → Fullscreen. + Desktop PBS shortcut installed + Desktop PBS shortcut not installed + Start menu PBS shortcut installed + Start menu PBS shortcut not installed + Desktop to Fullscreen integration enabled + Desktop to Fullscreen integration disabled + Streaming preload support enabled + Streaming preload support disabled + + Shortcut icon + Custom .ico + Playnite Boot Screen + Playnite Fullscreen + Custom (.ico) + No .ico file selected. + Custom icon selected. + Icon files (*.ico)|*.ico + Choose .ico... + Custom shortcut icon copied to the PBS data folder. + + Other launchers can invoke PBS directly with this command. Launchers that start Playnite.FullscreenApp.exe themselves bypass PBS unless they explicitly integrate this command. + Shortcut state is detected from PBS-managed shortcuts. External launcher configuration is not inspected. + + The selected shortcut icon mode is not valid. + Choose a custom .ico file or select another shortcut icon. + Custom shortcut icons must use the .ico format. + The shortcut icon file does not exist: {0} + diff --git a/PlayniteBoot/Localization/it_IT.xaml b/PlayniteBoot/Localization/it_IT.xaml index 6f475c2..5f584db 100644 --- a/PlayniteBoot/Localization/it_IT.xaml +++ b/PlayniteBoot/Localization/it_IT.xaml @@ -126,8 +126,8 @@ Il runtime non è ancora pronto. Usa Ripara runtime se la sincronizzazione automatica non si completa. Valida Da riparare - ● Installato - ○ Non installato + Installato + Non installato Stato non disponibile Collegamento “{0}” creato o aggiornato in {1}. Collegamento rimosso da {0}. @@ -161,6 +161,66 @@ Installer dei collegamenti non trovato. Impossibile avviare PowerShell per creare il collegamento. Timeout durante l'operazione sul collegamento. - Avvia Playnite Fullscreen con un video personalizzato e senza finestra console. + Avvia Playnite Fullscreen tramite Playnite Boot Screen con il video di avvio configurato. File video + + + Configurazione rapida + Riproduzione + Avanzate + Diagnostica + + Configura il tuo avvio personalizzato di Playnite in pochi passaggi. PBS mostra un video di boot mentre Playnite Fullscreen si sta aprendo. + Regola dove e come viene mostrato il video di avvio. Queste impostazioni si applicano a tutti i metodi di avvio PBS. + Impostazioni avanzate per rilevamento e avvio. I valori predefiniti sono consigliati per la maggior parte delle configurazioni. + Manutenzione del runtime, log e informazioni diagnostiche. + + 1. Avvia Playnite con PBS + 2. Scegli il video di avvio + 3. Scegli quando mostrare Playnite + Collegamenti PBS + Desktop → Fullscreen + Schermo + Rilevamento disponibilità + Avvio Playnite + Avvio esterno / manuale + Stato metodi di avvio + + Crea un collegamento che avvia PBS prima di Playnite Fullscreen. + Il normale avvio di Playnite Fullscreen rimane invariato e non mostra la schermata di boot. + Scegli come avviare PBS, seleziona il tuo video e decidi quando mostrare Playnite. + Scegli quando deve essere mostrato Playnite Boot Screen. + Scegli il video mostrato durante l'avvio di Playnite. Formati accettati: {0}. + Pronto + Playnite Boot Screen è pronto per l'uso. + Configurazione necessaria + Crea un collegamento PBS o abilita Desktop → Fullscreen. + Collegamento PBS sul Desktop installato + Collegamento PBS sul Desktop non installato + Collegamento PBS nel menu Start installato + Collegamento PBS nel menu Start non installato + Integrazione Desktop a Fullscreen abilitata + Integrazione Desktop a Fullscreen disabilitata + Supporto preload streaming abilitato + Supporto preload streaming disabilitato + + Icona collegamento + File .ico + Playnite Boot Screen + Playnite Fullscreen + Personalizzata (.ico) + Nessun file .ico selezionato. + Icona personalizzata selezionata. + File icona (*.ico)|*.ico + Scegli .ico... + Icona personalizzata copiata nella cartella dati di PBS. + + Altri launcher possono richiamare PBS direttamente con questo comando. I launcher che avviano autonomamente Playnite.FullscreenApp.exe bypassano PBS, a meno che non integrino esplicitamente questo comando. + Lo stato dei collegamenti viene rilevato dai collegamenti gestiti da PBS. La configurazione dei launcher esterni non viene ispezionata. + + La modalità selezionata per l'icona del collegamento non è valida. + Scegli un file .ico personalizzato oppure seleziona un'altra icona per il collegamento. + Le icone personalizzate dei collegamenti devono usare il formato .ico. + Il file dell'icona del collegamento non esiste: {0} + diff --git a/PlayniteBoot/Models/PlayniteBootSettingsData.cs b/PlayniteBoot/Models/PlayniteBootSettingsData.cs index f485712..e83156f 100644 --- a/PlayniteBoot/Models/PlayniteBootSettingsData.cs +++ b/PlayniteBoot/Models/PlayniteBootSettingsData.cs @@ -3,6 +3,35 @@ namespace PlayniteBoot.Models { + public static class ShortcutIconModes + { + public const string Pbs = "pbs"; + public const string Playnite = "playnite"; + public const string Custom = "custom"; + + public static bool IsValid(string value) + { + return string.Equals(value, Pbs, StringComparison.OrdinalIgnoreCase) || + string.Equals(value, Playnite, StringComparison.OrdinalIgnoreCase) || + string.Equals(value, Custom, StringComparison.OrdinalIgnoreCase); + } + + public static string Normalize(string value) + { + if (string.Equals(value, Playnite, StringComparison.OrdinalIgnoreCase)) + { + return Playnite; + } + + if (string.Equals(value, Custom, StringComparison.OrdinalIgnoreCase)) + { + return Custom; + } + + return Pbs; + } + } + public static class VideoEndBehaviors { public const string Ready = "ready"; @@ -34,7 +63,7 @@ public static string Normalize(string value) public class PlayniteBootSettingsData : ObservableObject { - public const int CurrentSettingsVersion = 5; + public const int CurrentSettingsVersion = 6; private int settingsVersion; private string playniteExecutable = "auto"; @@ -64,6 +93,9 @@ public class PlayniteBootSettingsData : ObservableObject private bool enableDesktopFullscreenSwitch = true; private bool logEnabled = true; private string shortcutName = "Playnite Fullscreen"; + private string shortcutIconMode = ShortcutIconModes.Pbs; + private string customShortcutIconPath = string.Empty; + private string customShortcutIconFileName = string.Empty; private StreamingSettings streaming = new StreamingSettings(); public static PlayniteBootSettingsData CreateDefault() @@ -117,6 +149,9 @@ public double Volume public bool EnableDesktopFullscreenSwitch { get => enableDesktopFullscreenSwitch; set => SetValue(ref enableDesktopFullscreenSwitch, value); } public bool LogEnabled { get => logEnabled; set => SetValue(ref logEnabled, value); } public string ShortcutName { get => shortcutName; set => SetValue(ref shortcutName, value); } + public string ShortcutIconMode { get => shortcutIconMode; set => SetValue(ref shortcutIconMode, value); } + public string CustomShortcutIconPath { get => customShortcutIconPath; set => SetValue(ref customShortcutIconPath, value); } + public string CustomShortcutIconFileName { get => customShortcutIconFileName; set => SetValue(ref customShortcutIconFileName, value); } public StreamingSettings Streaming { get => streaming; set => SetValue(ref streaming, value); } } } diff --git a/PlayniteBoot/PlayniteBootPlugin.cs b/PlayniteBoot/PlayniteBootPlugin.cs index a8f6b37..6da717f 100644 --- a/PlayniteBoot/PlayniteBootPlugin.cs +++ b/PlayniteBoot/PlayniteBootPlugin.cs @@ -124,10 +124,12 @@ public string CreateShortcut(PlayniteBootSettingsData settings, ShortcutLocation var compatibilityResult = configWriter.Write(settings); LogVideoCompatibility(compatibilityResult); logger.Info($"{ProductName} runtime ready at {Paths.RuntimeDirectory}. Version {result.Version}."); + var iconPath = ResolveShortcutIconPath(settings); return shortcutService.Create( location, settings.ShortcutName, - "LOCPlayniteBootShortcutDescription".GetLocalized()); + "LOCPlayniteBootShortcutDescription".GetLocalized(), + iconPath); } } @@ -139,6 +141,36 @@ public bool RemoveShortcut(PlayniteBootSettingsData settings, ShortcutLocation l } } + private string ResolveShortcutIconPath(PlayniteBootSettingsData settings) + { + var mode = ShortcutIconModes.Normalize(settings?.ShortcutIconMode); + if (string.Equals(mode, ShortcutIconModes.Playnite, StringComparison.OrdinalIgnoreCase)) + { + // Null preserves the shortcut installer's historical behavior: it + // discovers Playnite.FullscreenApp.exe and uses its icon. + return null; + } + + var iconPath = string.Equals(mode, ShortcutIconModes.Custom, StringComparison.OrdinalIgnoreCase) + ? settings?.CustomShortcutIconPath + : Paths.DefaultShortcutIconPath; + + if (string.IsNullOrWhiteSpace(iconPath)) + { + throw new InvalidOperationException("LOCPlayniteBootValidationCustomShortcutIconMissing".GetLocalized()); + } + + iconPath = Path.GetFullPath(iconPath); + if (!File.Exists(iconPath)) + { + throw new FileNotFoundException( + string.Format("LOCPlayniteBootValidationShortcutIconFileMissing".GetLocalized(), iconPath), + iconPath); + } + + return iconPath; + } + private static void LogVideoCompatibility(VideoCompatibilityResult result) { if (result == null) diff --git a/PlayniteBoot/PlayniteBootSettings.cs b/PlayniteBoot/PlayniteBootSettings.cs index 80fb6d4..7361c4f 100644 --- a/PlayniteBoot/PlayniteBootSettings.cs +++ b/PlayniteBoot/PlayniteBootSettings.cs @@ -10,6 +10,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Security.Cryptography; using System.Text; using System.Windows; using System.Web.Script.Serialization; @@ -33,11 +34,16 @@ public PlayniteBootSettingsData Settings if (settings != null) { settings.PropertyChanged -= SettingsPropertyChanged; + if (settings.Streaming != null) + { + settings.Streaming.PropertyChanged -= StreamingSettingsPropertyChanged; + } } settings = value; EnsureDefaultsAndMigrate(); settings.PropertyChanged += SettingsPropertyChanged; + settings.Streaming.PropertyChanged += StreamingSettingsPropertyChanged; OnPropertyChanged(); OnPropertyChanged(nameof(DirectCommand)); @@ -50,6 +56,11 @@ public PlayniteBootSettingsData Settings OnPropertyChanged(nameof(VolumePercent)); OnPropertyChanged(nameof(SelectedVideoPath)); OnPropertyChanged(nameof(SelectedVideoPathDisplay)); + OnPropertyChanged(nameof(IsShortcutIconPbs)); + OnPropertyChanged(nameof(IsShortcutIconPlaynite)); + OnPropertyChanged(nameof(IsShortcutIconCustom)); + OnPropertyChanged(nameof(IsCustomShortcutIcon)); + OnPropertyChanged(nameof(CustomShortcutIconPathDisplay)); NotifyInstallationStatusChanged(); if (videoLibrary != null) @@ -88,6 +99,24 @@ public string SelectedVideoPath ? string.Empty : GetConfiguredVideoPath(); + public string ProductIconPath + { + get + { + try + { + var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var path = Path.Combine(directory ?? string.Empty, "icon.png"); + return File.Exists(path) ? path : string.Empty; + } + catch + { + return string.Empty; + } + } + } + + public string BootVideoDescription => F("LOCPlayniteBootSetupVideoDescription", VideoLibraryService.AcceptedFormatsDisplay); public string AcceptedVideoFormats => F("LOCPlayniteBootAcceptedFormats", VideoLibraryService.AcceptedFormatsDisplay); public string AcceptedVideoFormatsToolTip => L("LOCPlayniteBootTipAcceptedFormats"); @@ -155,6 +184,73 @@ public int VolumePercent : L("LOCPlayniteBootStatusConfigurationNeedsRepair"); public string DesktopShortcutStatus => GetShortcutStatus(ShortcutLocation.Desktop); public string StartMenuShortcutStatus => GetShortcutStatus(ShortcutLocation.StartMenu); + public bool IsDesktopShortcutInstalled => IsShortcutInstalled(ShortcutLocation.Desktop); + public bool IsStartMenuShortcutInstalled => IsShortcutInstalled(ShortcutLocation.StartMenu); + public bool IsDesktopFullscreenLaunchEnabled => Settings != null && Settings.EnableDesktopFullscreenSwitch; + public bool IsStreamingPreloadEnabled => Settings?.Streaming != null && Settings.Streaming.Enabled; + public bool IsQuickSetupReady => IsDesktopFullscreenLaunchEnabled || + IsDesktopShortcutInstalled || + IsStartMenuShortcutInstalled; + public bool IsShortcutIconPbs + { + get => Settings == null || string.Equals(Settings.ShortcutIconMode, ShortcutIconModes.Pbs, StringComparison.OrdinalIgnoreCase); + set + { + if (value) + { + SetShortcutIconMode(ShortcutIconModes.Pbs); + } + } + } + + public bool IsShortcutIconPlaynite + { + get => Settings != null && string.Equals(Settings.ShortcutIconMode, ShortcutIconModes.Playnite, StringComparison.OrdinalIgnoreCase); + set + { + if (value) + { + SetShortcutIconMode(ShortcutIconModes.Playnite); + } + } + } + + public bool IsShortcutIconCustom + { + get => Settings != null && string.Equals(Settings.ShortcutIconMode, ShortcutIconModes.Custom, StringComparison.OrdinalIgnoreCase); + set + { + if (value) + { + SetShortcutIconMode(ShortcutIconModes.Custom); + } + } + } + + public bool IsCustomShortcutIcon => IsShortcutIconCustom; + public string CustomShortcutIconPathDisplay => IsCustomShortcutIcon + ? (string.IsNullOrWhiteSpace(Settings.CustomShortcutIconPath) + ? L("LOCPlayniteBootShortcutCustomIconNone") + : (!string.IsNullOrWhiteSpace(Settings.CustomShortcutIconFileName) + ? Settings.CustomShortcutIconFileName + : L("LOCPlayniteBootShortcutCustomIconSelected"))) + : string.Empty; + public string DesktopLaunchMethodStatus => GetLaunchMethodStatus( + IsDesktopShortcutInstalled, + "LOCPlayniteBootSetupDesktopShortcutEnabled", + "LOCPlayniteBootSetupDesktopShortcutDisabled"); + public string StartMenuLaunchMethodStatus => GetLaunchMethodStatus( + IsStartMenuShortcutInstalled, + "LOCPlayniteBootSetupStartMenuShortcutEnabled", + "LOCPlayniteBootSetupStartMenuShortcutDisabled"); + public string DesktopFullscreenLaunchMethodStatus => GetLaunchMethodStatus( + IsDesktopFullscreenLaunchEnabled, + "LOCPlayniteBootSetupDesktopFullscreenEnabled", + "LOCPlayniteBootSetupDesktopFullscreenDisabled"); + public string StreamingPreloadStatus => GetLaunchMethodStatus( + IsStreamingPreloadEnabled, + "LOCPlayniteBootSetupStreamingPreloadEnabled", + "LOCPlayniteBootSetupStreamingPreloadDisabled"); public string ExtensionVersionDisplay { get @@ -182,6 +278,7 @@ public string ExtensionVersionDisplay public RelayCommand CreateStartMenuShortcutCommand { get; } public RelayCommand RemoveDesktopShortcutCommand { get; } public RelayCommand RemoveStartMenuShortcutCommand { get; } + public RelayCommand BrowseShortcutIconCommand { get; } public RelayCommand CopyDirectCommand { get; } public RelayCommand CopyPreloadCommand { get; } public RelayCommand CopyContinueCommand { get; } @@ -209,7 +306,6 @@ public PlayniteBootSettingsViewModel(PlayniteBootPlugin plugin) { new LocalizedOption("standalone", L("LOCPlayniteBootOptionFallbackStandalone")) }; - BrowseVideoCommand = new RelayCommand(BrowseVideo); RefreshVideoLibraryCommand = new RelayCommand(() => RefreshVideoLibrary(true)); OpenVideoFolderCommand = new RelayCommand(() => ExecuteAction(OpenVideoFolder)); @@ -220,6 +316,7 @@ public PlayniteBootSettingsViewModel(PlayniteBootPlugin plugin) CreateStartMenuShortcutCommand = new RelayCommand(() => ExecuteAction(() => CreateShortcut(ShortcutLocation.StartMenu))); RemoveDesktopShortcutCommand = new RelayCommand(() => ExecuteAction(() => RemoveShortcut(ShortcutLocation.Desktop))); RemoveStartMenuShortcutCommand = new RelayCommand(() => ExecuteAction(() => RemoveShortcut(ShortcutLocation.StartMenu))); + BrowseShortcutIconCommand = new RelayCommand(() => ExecuteAction(BrowseShortcutIcon)); CopyDirectCommand = new RelayCommand(() => CopyToClipboard(DirectCommand)); CopyPreloadCommand = new RelayCommand(() => CopyToClipboard(PreloadCommand)); CopyContinueCommand = new RelayCommand(() => CopyToClipboard(ContinueCommand)); @@ -248,6 +345,7 @@ public void EndEdit() { Settings.SettingsVersion = PlayniteBootSettingsData.CurrentSettingsVersion; Settings.ShortcutName = (Settings.ShortcutName ?? string.Empty).Trim(); + Settings.ShortcutIconMode = ShortcutIconModes.Normalize(Settings.ShortcutIconMode); if (IsManualMonitorSelection(Settings.Monitor)) { Settings.MonitorFallback = Settings.Monitor; @@ -310,6 +408,25 @@ public bool VerifySettings(out List errors) ValidateMinimum(errors, Settings.Streaming.PreloadAbandonTimeoutMilliseconds, 5000, L("LOCPlayniteBootLabelPreloadAbandonTimeout")); } + if (!ShortcutIconModes.IsValid(Settings.ShortcutIconMode)) + { + errors.Add(L("LOCPlayniteBootValidationShortcutIconMode")); + } + else if (string.Equals(Settings.ShortcutIconMode, ShortcutIconModes.Custom, StringComparison.OrdinalIgnoreCase)) + { + if (string.IsNullOrWhiteSpace(Settings.CustomShortcutIconPath)) + { + errors.Add(L("LOCPlayniteBootValidationCustomShortcutIconMissing")); + } + else if (!string.Equals(Path.GetExtension(Settings.CustomShortcutIconPath), ".ico", StringComparison.OrdinalIgnoreCase)) + { + errors.Add(L("LOCPlayniteBootValidationCustomShortcutIconFormat")); + } + else if (!File.Exists(Settings.CustomShortcutIconPath)) + { + errors.Add(F("LOCPlayniteBootValidationShortcutIconFileMissing", Settings.CustomShortcutIconPath)); + } + } ValidateShortcutName(errors, Settings.ShortcutName); return errors.Count == 0; @@ -356,8 +473,39 @@ private void SettingsPropertyChanged(object sender, PropertyChangedEventArgs eve if (eventArgs.PropertyName == nameof(PlayniteBootSettingsData.ShortcutName)) { - OnPropertyChanged(nameof(DesktopShortcutStatus)); - OnPropertyChanged(nameof(StartMenuShortcutStatus)); + NotifyLaunchMethodStatusChanged(); + return; + } + + if (eventArgs.PropertyName == nameof(PlayniteBootSettingsData.ShortcutIconMode)) + { + OnPropertyChanged(nameof(IsShortcutIconPbs)); + OnPropertyChanged(nameof(IsShortcutIconPlaynite)); + OnPropertyChanged(nameof(IsShortcutIconCustom)); + OnPropertyChanged(nameof(IsCustomShortcutIcon)); + OnPropertyChanged(nameof(CustomShortcutIconPathDisplay)); + return; + } + + if (eventArgs.PropertyName == nameof(PlayniteBootSettingsData.CustomShortcutIconPath) || + eventArgs.PropertyName == nameof(PlayniteBootSettingsData.CustomShortcutIconFileName)) + { + OnPropertyChanged(nameof(CustomShortcutIconPathDisplay)); + return; + } + + if (eventArgs.PropertyName == nameof(PlayniteBootSettingsData.EnableDesktopFullscreenSwitch)) + { + NotifyLaunchMethodStatusChanged(); + } + } + + private void StreamingSettingsPropertyChanged(object sender, PropertyChangedEventArgs eventArgs) + { + if (eventArgs.PropertyName == nameof(StreamingSettings.Enabled)) + { + OnPropertyChanged(nameof(IsStreamingPreloadEnabled)); + OnPropertyChanged(nameof(StreamingPreloadStatus)); } } @@ -377,6 +525,22 @@ private void SetVideoEndBehavior(string behavior) Settings.VideoEndBehavior = normalized; } + private void SetShortcutIconMode(string mode) + { + if (Settings == null) + { + return; + } + + var normalized = ShortcutIconModes.Normalize(mode); + if (string.Equals(Settings.ShortcutIconMode, normalized, StringComparison.OrdinalIgnoreCase)) + { + return; + } + + Settings.ShortcutIconMode = normalized; + } + private void EnsureDefaultsAndMigrate() { if (settings == null) @@ -446,6 +610,18 @@ private void EnsureDefaultsAndMigrate() settings.Streaming.PreloadAbandonTimeoutMilliseconds = 10000; } + if (settings.SettingsVersion < 6) + { + // Existing shortcuts historically used Playnite's Fullscreen icon. + // Preserve that appearance on upgrade. New installations default + // to the dedicated PBS icon. + settings.ShortcutIconMode = ShortcutIconModes.Playnite; + } + else + { + settings.ShortcutIconMode = ShortcutIconModes.Normalize(settings.ShortcutIconMode); + } + settings.SettingsVersion = PlayniteBootSettingsData.CurrentSettingsVersion; if (string.IsNullOrWhiteSpace(settings.VideoPath)) @@ -500,6 +676,11 @@ private void EnsureDefaultsAndMigrate() settings.ShortcutName = "Playnite Fullscreen"; } + if (settings.CustomShortcutIconPath == null) + { + settings.CustomShortcutIconPath = string.Empty; + } + if (string.IsNullOrWhiteSpace(settings.Streaming.FallbackMode)) { settings.Streaming.FallbackMode = "standalone"; @@ -603,6 +784,52 @@ private void OpenVideoFolder() ShellService.OpenFolder(plugin.Paths.MediaDirectory); } + private void BrowseShortcutIcon() + { + var selected = plugin.PlayniteApi.Dialogs.SelectFile(L("LOCPlayniteBootShortcutIconFileFilter")); + if (string.IsNullOrWhiteSpace(selected)) + { + return; + } + + if (!string.Equals(Path.GetExtension(selected), ".ico", StringComparison.OrdinalIgnoreCase)) + { + plugin.PlayniteApi.Dialogs.ShowErrorMessage( + L("LOCPlayniteBootValidationCustomShortcutIconFormat"), + PlayniteBootPlugin.ProductName); + return; + } + + var sourcePath = Path.GetFullPath(selected); + var targetPath = ImportShortcutIcon(sourcePath); + + Settings.CustomShortcutIconPath = targetPath; + Settings.CustomShortcutIconFileName = Path.GetFileName(sourcePath); + Settings.ShortcutIconMode = ShortcutIconModes.Custom; + RuntimeStatus = L("LOCPlayniteBootStatusCustomShortcutIconSelected"); + } + + private string ImportShortcutIcon(string sourcePath) + { + Directory.CreateDirectory(plugin.Paths.ShortcutIconsDirectory); + + byte[] hash; + using (var stream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.Read)) + using (var sha256 = SHA256.Create()) + { + hash = sha256.ComputeHash(stream); + } + + var hashName = string.Concat(hash.Take(12).Select(value => value.ToString("x2", CultureInfo.InvariantCulture))); + var targetPath = Path.Combine(plugin.Paths.ShortcutIconsDirectory, hashName + ".ico"); + if (!File.Exists(targetPath)) + { + File.Copy(sourcePath, targetPath, false); + } + + return targetPath; + } + private void RefreshVideoLibrary(bool updateStatus) { var selectedPath = GetConfiguredVideoPath(); @@ -858,6 +1085,7 @@ private string BuildDiagnostics() b.AppendLine("Video end behavior: " + VideoEndBehaviors.Normalize(Settings.VideoEndBehavior)); b.AppendLine("Streaming preload: " + (Settings.Streaming != null && Settings.Streaming.Enabled ? "enabled" : "disabled")); b.AppendLine("Desktop -> Fullscreen boot: " + (Settings.EnableDesktopFullscreenSwitch ? "enabled" : "disabled")); + b.AppendLine("Shortcut icon: " + ShortcutIconModes.Normalize(Settings.ShortcutIconMode)); b.AppendLine("Runtime installed: " + YesNo(File.Exists(plugin.Paths.ScriptPath) && File.Exists(plugin.Paths.ConfigPath))); b.AppendLine("Video exists: " + YesNo(videoExists)); b.AppendLine("Desktop shortcut: " + YesNo(plugin.ShortcutExists(Settings, ShortcutLocation.Desktop))); @@ -922,6 +1150,37 @@ private void NotifyInstallationStatusChanged() OnPropertyChanged(nameof(DesktopShortcutStatus)); OnPropertyChanged(nameof(StartMenuShortcutStatus)); OnPropertyChanged(nameof(ExtensionVersionDisplay)); + NotifyLaunchMethodStatusChanged(); + } + + private void NotifyLaunchMethodStatusChanged() + { + OnPropertyChanged(nameof(IsQuickSetupReady)); + OnPropertyChanged(nameof(IsDesktopShortcutInstalled)); + OnPropertyChanged(nameof(IsStartMenuShortcutInstalled)); + OnPropertyChanged(nameof(IsDesktopFullscreenLaunchEnabled)); + OnPropertyChanged(nameof(IsStreamingPreloadEnabled)); + OnPropertyChanged(nameof(DesktopLaunchMethodStatus)); + OnPropertyChanged(nameof(StartMenuLaunchMethodStatus)); + OnPropertyChanged(nameof(DesktopFullscreenLaunchMethodStatus)); + OnPropertyChanged(nameof(StreamingPreloadStatus)); + } + + private static string GetLaunchMethodStatus(bool enabled, string enabledKey, string disabledKey) + { + return L(enabled ? enabledKey : disabledKey); + } + + private bool IsShortcutInstalled(ShortcutLocation location) + { + try + { + return Settings != null && plugin.ShortcutExists(Settings, location); + } + catch + { + return false; + } } private bool IsRuntimeConfigurationValid() diff --git a/PlayniteBoot/PlayniteBootSettingsView.xaml b/PlayniteBoot/PlayniteBootSettingsView.xaml index ade39d1..e04ce2a 100644 --- a/PlayniteBoot/PlayniteBootSettingsView.xaml +++ b/PlayniteBoot/PlayniteBootSettingsView.xaml @@ -5,116 +5,301 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="760" d:DesignWidth="920"> + + + + - + - - - - + + - + + - - - - - - + + + + + + - - - - - - - - - - - - - - -