diff --git a/CHANGELOG.md b/CHANGELOG.md index bea75ab..88228fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ Every release must also be added to [manifests/installer_manifest.yaml](manifests/installer_manifest.yaml), which is what Playnite reads to offer updates. +## 1.4.0 – 2026-11-24 + +- Changed: The sidebar icon now matches the theme's other icons, including their hover and selected shades. The + colored icon, and fixed white and black versions, can be chosen in the settings. +- Added: Settings for the aspect ratio and stretch mode of collection posters and of game covers on a collection's + page, with presets for common cover shapes such as Steam, GOG Galaxy and DVD boxes. +- Added: Option to include hidden games in a dynamic collection. They're still left out by default. + ## 1.3.0 – 2026-11-06 - Added: Collapse a collection page's header to just its title, game count and dynamic badge. diff --git a/docs/developer-guide.md b/docs/developer-guide.md index 12b9685..3da9ce4 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -117,7 +117,23 @@ Version history: **1** was the initial format (extension 1.0.0); **2** added `Ga `GameCollectionsSettings` is saved by Playnite to `config.json`. Add a property using `SetValue`, and bind to `Settings.` in `GameCollectionsSettingsView.xaml`. Mark state that shouldn't be saved with `[DontSerialize]`. Themes can read these properties through `{PluginSettings Plugin=GameCollections, Path=}`. -`SettingsChanged` fires after the settings dialog is saved or cancelled. +`SettingsChanged` fires after the settings dialog is saved or cancelled. The plugin uses it to swap the sidebar +icon and to call `CollectionsRootViewModel.OnDisplaySettingsChanged`, which passes poster and cover changes on to +the open pages. + +- **Aspect ratios** are stored as two numbers each (`CollectionPosterAspectWidth/Height`, + `GameCoverAspectWidth/Height`). Views read the computed `CollectionPosterRatio` and `GameCoverRatio` (height per + unit of width), which fall back to 2:3 for invalid values and are clamped to between 1:4 and 4:1. + `VerifySettings` rejects values that aren't greater than 0. The **Presets** menus come from + `GameCollectionsSettingsViewModel.Presets` and are built in the settings view's code-behind; picking one sets both + numbers. +- **Stretch modes** are WPF `Stretch` values, applied by `PosterImage.Stretch` to its image brush. +- **Sidebar icons**: `icon-white.png` and `icon-black.png` sit next to `icon.png` and are copied to the output by + the `icon*.png` item in the project file. They were made from `icon.png` with the folder solid and the cards + behind it in fainter tones, so regenerate them if the icon changes. +- **Match theme** (`SidebarIconStyle.Theme`) uses `ThemedSidebarIcon` instead of a path: a rectangle filled with the + inherited `Foreground` and masked by `icon-black.png`'s opacity, sized by the inherited font size. Themes change the + sidebar button's `Foreground` on hover and selection, so it follows those shades the way font glyph icons do. ## Manual order diff --git a/docs/user-guide.md b/docs/user-guide.md index 0682d3e..e53239f 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -25,6 +25,31 @@ Click **Collections** in the sidebar. The page keeps its state (open collection, Deleting a collection never deletes or changes any games. +## Appearance settings + +In the extension's settings (*Add-ons → Extension settings → Generic → Game Collections*): + +- **Sidebar → Icon**: **Match theme** (default) draws the icon in the same colours as the theme's other sidebar + icons, including their hover and selected shades. You can also choose the **Colored** icon, or a fixed **White** + or **Black** version. It changes as soon as you save. +- **Collection posters**: the shape of posters on the Collections page and in a collection's header, as an + **aspect ratio** (width : height, default 2 : 3), and the **stretch mode**. +- **Game covers on a collection's page**: the same for the game cards. The card size slider sets their width, and + the ratio sets their height. + +| Stretch mode | What the image does | +|---|---| +| None | Keeps its original size, centered. It may be cut off or leave empty space. | +| Fill | Fills the shape exactly; the image is squashed or stretched if its shape differs. | +| Uniform | Fits inside the shape without being cut off, leaving empty space at the sides or top and bottom. | +| Uniform to fill (default) | Covers the shape without distortion, cutting off whatever doesn't fit. | + +Ratios can be decimals, such as 1.85 : 1. Very thin or tall shapes are limited to between 4 : 1 and 1 : 4. + +**Presets**, next to each ratio, fills in a common shape: DVD Box (27 : 38), Epic Games Store (3 : 4), +GOG Galaxy 2.0 (22 : 31), IGDB (3 : 4), Square (1 : 1), Steam Banner (92 : 43), Steam Vertical Cover (2 : 3) or +Twitch (3 : 4). The preset matching the current ratio is ticked. + ## Creating and editing a collection | Field | Notes | @@ -46,7 +71,8 @@ editing a collection. - Between blocks, choose **AND** or **OR**. Blocks combine from top to bottom, so *A OR B AND C* means *(A or B) and C*. - The bar at the bottom shows how many games currently match, and some of their names. -- Hidden games are never included. +- Games hidden in Playnite are left out unless you tick **Include hidden games** below the blocks. When it's on, + the collection's rules summary says *(including hidden games)*. Hiding or unhiding a game updates the collection. | You can filter by | Conditions | |---|---| diff --git a/manifests/installer_manifest.yaml b/manifests/installer_manifest.yaml index cfb38a8..5a5f6cb 100644 --- a/manifests/installer_manifest.yaml +++ b/manifests/installer_manifest.yaml @@ -1,5 +1,14 @@ AddonId: GameCollections_3f6b8d2e-5c41-4a7e-9e0b-6d2f1a8c7b54 Packages: + - Version: 1.4.0 + RequiredApiVersion: 6.11.0 + ReleaseDate: 2026-11-24 + PackageUrl: https://github.com/X4Lo/GameCollections/releases/download/v1.4.0/GameCollections_3f6b8d2e-5c41-4a7e-9e0b-6d2f1a8c7b54_1_4_0.pext + Changelog: + - 'Changed: Sidebar icon matches the theme''s other icons, including hover and selected shades' + - 'Added: Colored, white and black sidebar icon options' + - 'Added: Aspect ratio and stretch mode settings for collection posters and game covers, with presets' + - 'Added: Option to include hidden games in a dynamic collection' - Version: 1.3.0 RequiredApiVersion: 6.11.0 ReleaseDate: 2026-11-06 diff --git a/source/GameCollections/GameCollections.csproj b/source/GameCollections/GameCollections.csproj index b8a02aa..4ee7001 100644 --- a/source/GameCollections/GameCollections.csproj +++ b/source/GameCollections/GameCollections.csproj @@ -7,7 +7,7 @@ GameCollections GameCollections 7.3 - 1.3.0 + 1.4.0 Game Collections false false @@ -26,7 +26,8 @@ - + + Open in Collections diff --git a/source/GameCollections/Models/DynamicRules.cs b/source/GameCollections/Models/DynamicRules.cs index f35c43a..220a346 100644 --- a/source/GameCollections/Models/DynamicRules.cs +++ b/source/GameCollections/Models/DynamicRules.cs @@ -129,5 +129,11 @@ namespace GameCollections.Models public class DynamicRules { public List Blocks { get; set; } = new List(); + + /// + /// Whether games hidden in Playnite can match. Off by default, as it was before the option existed, + /// so older data files need no migration. + /// + public bool IncludeHidden { get; set; } } } diff --git a/source/GameCollections/Services/RuleEngine.cs b/source/GameCollections/Services/RuleEngine.cs index bf4a7aa..c55a843 100644 --- a/source/GameCollections/Services/RuleEngine.cs +++ b/source/GameCollections/Services/RuleEngine.cs @@ -139,8 +139,8 @@ namespace GameCollections.Services /// /// Builds a predicate for the rules. Blocks are combined strictly from top to bottom, matching how - /// they read in the editor. Hidden games never match, and neither do damaged or incomplete rules, - /// so a broken rule can never fill a collection with the whole library. + /// they read in the editor. Hidden games match only when the rules include them. Damaged or incomplete + /// rules never match, so a broken rule can never fill a collection with the whole library. /// public static Func Compile(DynamicRules rules, DateTime now) { @@ -152,10 +152,11 @@ namespace GameCollections.Services var blocks = rules.Blocks .Select(b => new { b.Join, Test = CompileBlock(b, now) }) .ToList(); + var includeHidden = rules.IncludeHidden; return game => { - if (game == null || game.Hidden) + if (game == null || (game.Hidden && !includeHidden)) { return false; } diff --git a/source/GameCollections/Services/RuleText.cs b/source/GameCollections/Services/RuleText.cs index da523a3..d6f9c9e 100644 --- a/source/GameCollections/Services/RuleText.cs +++ b/source/GameCollections/Services/RuleText.cs @@ -89,6 +89,11 @@ namespace GameCollections.Services parts.Add(rules.Blocks.Count > 1 ? "(" + text + ")" : text); } + if (rules.IncludeHidden) + { + parts.Add(Loc.Get("LOCGameCollections_RuleIncludesHiddenSuffix")); + } + return string.Join(" ", parts); } diff --git a/source/GameCollections/Settings/GameCollectionsSettings.cs b/source/GameCollections/Settings/GameCollectionsSettings.cs index ae7a0dc..1987f27 100644 --- a/source/GameCollections/Settings/GameCollectionsSettings.cs +++ b/source/GameCollections/Settings/GameCollectionsSettings.cs @@ -1,13 +1,119 @@ using GameCollections.Models; +using GameCollections.Services; using Playnite.SDK; using Playnite.SDK.Data; using System; using System.Collections.Generic; +using System.Windows.Media; namespace GameCollections.Settings { + /// + /// Which version of the extension's icon the sidebar shows. + /// + public enum SidebarIconStyle + { + Colored = 0, + White = 1, + Black = 2, + Theme = 3 + } + + /// + /// A choice in one of the settings view's dropdowns. + /// + public class SettingOption + { + public object Value { get; } + public string Label { get; } + + public SettingOption(object value, string label) + { + Value = value; + Label = label; + } + } + + /// + /// A common cover shape that fills both aspect ratio fields at once. + /// + public class AspectPreset + { + public string Name { get; } + public double Width { get; } + public double Height { get; } + public string Label => $"{Name} ({Width}:{Height})"; + + public AspectPreset(string name, double width, double height) + { + Name = name; + Width = width; + Height = height; + } + + public bool Matches(double width, double height) + { + return Math.Abs(width - Width) < 1e-9 && Math.Abs(height - Height) < 1e-9; + } + } + public class GameCollectionsSettings : ObservableObject { + // Ratios outside this range would make cards absurdly thin or tall. + private const double MinAspectRatio = 0.25; + private const double MaxAspectRatio = 4; + private const double DefaultAspectRatio = 1.5; + + private SidebarIconStyle sidebarIcon = SidebarIconStyle.Theme; + public SidebarIconStyle SidebarIcon { get => sidebarIcon; set => SetValue(ref sidebarIcon, value); } + + // Shape of collection posters on the Collections page, as width : height, and how images fill it. + private double collectionPosterAspectWidth = 2; + public double CollectionPosterAspectWidth { get => collectionPosterAspectWidth; set => SetValue(ref collectionPosterAspectWidth, value); } + + private double collectionPosterAspectHeight = 3; + public double CollectionPosterAspectHeight { get => collectionPosterAspectHeight; set => SetValue(ref collectionPosterAspectHeight, value); } + + private Stretch collectionPosterStretch = Stretch.UniformToFill; + public Stretch CollectionPosterStretch { get => collectionPosterStretch; set => SetValue(ref collectionPosterStretch, value); } + + // The same for game covers on a collection's page. + private double gameCoverAspectWidth = 2; + public double GameCoverAspectWidth { get => gameCoverAspectWidth; set => SetValue(ref gameCoverAspectWidth, value); } + + private double gameCoverAspectHeight = 3; + public double GameCoverAspectHeight { get => gameCoverAspectHeight; set => SetValue(ref gameCoverAspectHeight, value); } + + private Stretch gameCoverStretch = Stretch.UniformToFill; + public Stretch GameCoverStretch { get => gameCoverStretch; set => SetValue(ref gameCoverStretch, value); } + + /// + /// Height of a collection poster per unit of width. + /// + [DontSerialize] + public double CollectionPosterRatio => Ratio(collectionPosterAspectWidth, collectionPosterAspectHeight); + + /// + /// Height of a game cover per unit of width. + /// + [DontSerialize] + public double GameCoverRatio => Ratio(gameCoverAspectWidth, gameCoverAspectHeight); + + private static double Ratio(double width, double height) + { + if (!IsValidAspectValue(width) || !IsValidAspectValue(height)) + { + return DefaultAspectRatio; + } + + return Math.Max(MinAspectRatio, Math.Min(MaxAspectRatio, height / width)); + } + + public static bool IsValidAspectValue(double value) + { + return value > 0 && !double.IsInfinity(value) && !double.IsNaN(value); + } + // Remembered UI state rather than a user-facing option, so it is not shown in the settings view. private CollectionsViewMode viewMode = CollectionsViewMode.Grid; public CollectionsViewMode ViewMode { get => viewMode; set => SetValue(ref viewMode, value); } @@ -52,6 +158,36 @@ namespace GameCollections.Settings } } + public IReadOnlyList SidebarIconOptions { get; } = new List + { + new SettingOption(SidebarIconStyle.Colored, Loc.Get("LOCGameCollections_SettingIconColored")), + new SettingOption(SidebarIconStyle.Theme, Loc.Get("LOCGameCollections_SettingIconTheme")), + new SettingOption(SidebarIconStyle.White, Loc.Get("LOCGameCollections_SettingIconWhite")), + new SettingOption(SidebarIconStyle.Black, Loc.Get("LOCGameCollections_SettingIconBlack")) + }; + + public IReadOnlyList StretchOptions { get; } = new List + { + new SettingOption(Stretch.None, Loc.Get("LOCGameCollections_StretchNone")), + new SettingOption(Stretch.Fill, Loc.Get("LOCGameCollections_StretchFill")), + new SettingOption(Stretch.Uniform, Loc.Get("LOCGameCollections_StretchUniform")), + new SettingOption(Stretch.UniformToFill, Loc.Get("LOCGameCollections_StretchUniformToFill")) + }; + + public IReadOnlyList AspectPresets => Presets; + + public static readonly IReadOnlyList Presets = new List + { + new AspectPreset(Loc.Get("LOCGameCollections_PresetDvdBox"), 27, 38), + new AspectPreset(Loc.Get("LOCGameCollections_PresetEpic"), 3, 4), + new AspectPreset(Loc.Get("LOCGameCollections_PresetGog"), 22, 31), + new AspectPreset(Loc.Get("LOCGameCollections_PresetIgdb"), 3, 4), + new AspectPreset(Loc.Get("LOCGameCollections_PresetSquare"), 1, 1), + new AspectPreset(Loc.Get("LOCGameCollections_PresetSteamBanner"), 92, 43), + new AspectPreset(Loc.Get("LOCGameCollections_PresetSteamCover"), 2, 3), + new AspectPreset(Loc.Get("LOCGameCollections_PresetTwitch"), 3, 4) + }; + public GameCollectionsSettingsViewModel(GameCollectionsPlugin plugin) { // The plugin instance is required for Save/Load because Playnite stores data per plugin. @@ -84,7 +220,19 @@ namespace GameCollections.Settings public bool VerifySettings(out List errors) { errors = new List(); - return true; + if (!GameCollectionsSettings.IsValidAspectValue(Settings.CollectionPosterAspectWidth) || + !GameCollectionsSettings.IsValidAspectValue(Settings.CollectionPosterAspectHeight)) + { + errors.Add(Loc.Get("LOCGameCollections_SettingCollectionAspectInvalid")); + } + + if (!GameCollectionsSettings.IsValidAspectValue(Settings.GameCoverAspectWidth) || + !GameCollectionsSettings.IsValidAspectValue(Settings.GameCoverAspectHeight)) + { + errors.Add(Loc.Get("LOCGameCollections_SettingGameAspectInvalid")); + } + + return errors.Count == 0; } } } diff --git a/source/GameCollections/Settings/GameCollectionsSettingsView.xaml b/source/GameCollections/Settings/GameCollectionsSettingsView.xaml index 37ab9ee..ff7b2e9 100644 --- a/source/GameCollections/Settings/GameCollectionsSettingsView.xaml +++ b/source/GameCollections/Settings/GameCollectionsSettingsView.xaml @@ -4,26 +4,121 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - d:DesignHeight="200" d:DesignWidth="600"> - - - - - - - - + d:DesignHeight="600" d:DesignWidth="600"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +