From 089f3e0f23d9fbdf9621c403b0690ab92cdb4f1f Mon Sep 17 00:00:00 2001 From: X4Lo Date: Fri, 6 Nov 2026 15:59:16 +0000 Subject: [PATCH] feat: add collapsible header and groups, card size slider and Crowdin translations - Add a button that collapses a collection page's header to its title, game count and dynamic badge. The choice is remembered for all collections. - Make each group on a collection page collapsible, with a Collapse all / Expand all button next to Group by. Games hidden by a collapse leave the selection. - Add a card size slider to the collection page toolbar, remembered for all collections. - Match the search box and sort button height to the dropdowns. - Add Crowdin configuration and a workflow that uploads the English strings and opens pull requests with new translations. - Add CONTRIBUTING.md and a Translations section to the README. - Run the build workflow on master instead of main. - Bump the version to 1.3.0 and update the docs, changelog and manifest. --- .github/workflows/build.yml | 2 +- .github/workflows/crowdin.yml | 43 ++++++ CHANGELOG.md | 8 ++ CONTRIBUTING.md | 74 +++++++++++ README.md | 16 ++- crowdin.yml | 12 ++ docs/developer-guide.md | 19 ++- docs/user-guide.md | 7 + manifests/installer_manifest.yaml | 10 ++ source/GameCollections/GameCollections.csproj | 2 +- .../GameCollections/Localization/en_US.xaml | 7 + .../Settings/GameCollectionsSettings.cs | 7 + .../ViewModels/CollectionDetailsViewModel.cs | 123 ++++++++++++++++++ .../ViewModels/CollectionsRootViewModel.cs | 3 + .../Views/CollectionDetailsView.xaml | 97 ++++++++++---- .../Views/CollectionDetailsView.xaml.cs | 92 ++++++++++++- source/GameCollections/extension.yaml | 2 +- 17 files changed, 494 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/crowdin.yml create mode 100644 CONTRIBUTING.md create mode 100644 crowdin.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0b1436d..230541c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build on: push: - branches: [main] + branches: [master] tags: ['v*'] pull_request: diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml new file mode 100644 index 0000000..eb7be34 --- /dev/null +++ b/.github/workflows/crowdin.yml @@ -0,0 +1,43 @@ +name: Crowdin + +# Uploads the English strings to Crowdin when they change, and opens a pull request with the latest translations. +on: + push: + branches: [master] + paths: + - source/GameCollections/Localization/en_US.xaml + - crowdin.yml + schedule: + # Every Monday, so new translations arrive without a push. + - cron: '0 6 * * 1' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +concurrency: + group: crowdin + cancel-in-progress: false + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: crowdin/github-action@v2 + with: + upload_sources: true + upload_translations: false + download_translations: true + localization_branch_name: l10n_crowdin + commit_message: 'chore: update translations from Crowdin' + create_pull_request: true + pull_request_title: 'Update translations from Crowdin' + pull_request_body: 'New and updated translations from Crowdin.' + pull_request_base_branch_name: master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index cd06bc8..bea75ab 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.3.0 – 2026-11-06 + +- Added: Collapse a collection page's header to just its title, game count and dynamic badge. +- Added: Collapse or expand each group on a collection page, or all of them at once. +- Added: Slider to change the size of the game cards on a collection page. +- Added: Translations through Crowdin. Missing strings fall back to English. +- Fixed: The search box on a collection page was taller than the Sort by and Group by dropdowns. + ## 1.2.0 – 2026-11-02 - Added: Group games on a collection's page by platform, series, genre, developer, publisher, category, feature, tag, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..d8fbbc3 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,74 @@ +# Contributing to Game Collections + +Thanks for helping. There are three ways to contribute: translating, reporting problems, and changing the code. + +## Translating + +Translations are managed on [Crowdin](https://crowdin.com/project/game-collections). Join the project, pick your +language and translate there; no coding or GitHub account is needed. New translations are added to the extension in +its next release, and any string that isn't translated yet is shown in English. + +- **Don't edit the translation files in this repository** (anything in `source/GameCollections/Localization/` other + than `en_US.xaml`). They're generated by Crowdin and overwritten on every sync, so pull requests that change them + can't be merged. +- To request a language that isn't on Crowdin yet, [open an issue](https://github.com/X4Lo/GameCollections/issues). +- If an English string is unclear or wrong, comment on it in Crowdin or open an issue. + +## Reporting a bug or requesting a feature + +[Open an issue](https://github.com/X4Lo/GameCollections/issues). For bugs, the form asks for the extension and +Playnite versions, and what you did, what you expected and what happened instead. Mention the theme you use too, +since many display problems depend on it. + +Playnite's log (`extensions.log` in Playnite's folder, or `%AppData%\Playnite` for an installed copy) usually shows +the cause, so attach it if you can. Check the open issues first, in case it has already been reported. + +## Changing the code + +Before starting on anything large, open an issue to discuss it, so your work fits where the extension is going. + +### Setting up + +You need Windows, the .NET SDK and a Playnite 10 installation to try your changes. Build with: + +``` +dotnet build source/GameCollections.sln -c Release +``` + +The `.pext` package is written to `dist/`; open it to install your build in Playnite. See +[Architecture and development](docs/architecture.md) for the repository layout and the +[Developer guide](docs/developer-guide.md) for how everything works. + +### Rules to follow + +- **Target what Playnite runs:** .NET Framework 4.6.2 and C# 7.3. Don't add NuGet packages that Playnite doesn't + already ship without discussing it first. +- **Match the surrounding code:** its naming, comment style and MVVM structure. +- **No user-visible text in code or XAML.** Add a `LOCGameCollections_*` key to + `source/GameCollections/Localization/en_US.xaml` only, and read it with `Loc` in code or `DynamicResource` in XAML. + Crowdin picks up new and changed strings automatically. +- **Use theme resources** (`DynamicResource` brushes, fonts and styles) rather than fixed colours, so light and dark + themes both work. +- **Changing the data file:** if a change to `collections.json` means existing data has to be converted, bump + `SchemaVersion` and add a migration step, as described in the developer guide. Adding a field with a safe default + doesn't need one. +- **The build must have no warnings.** + +### Testing + +There's no automated test project yet. Test your change by hand in Playnite, in a light and a dark theme, and go +through the checklist in the [Developer guide](docs/developer-guide.md#testing) for the areas you touched. + +### Pull requests + +- Keep each pull request to one change, and describe what it does and how you tested it. Screenshots help for + anything visible. +- Write commit messages in the [Conventional Commits](https://www.conventionalcommits.org) style used in this + repository, such as `feat: add card size slider` or `fix: search box height on collection page`. +- Don't change the version number, `CHANGELOG.md` or `manifests/installer_manifest.yaml`; they're updated when a + release is made. + +## License + +By contributing, you agree that your contributions are licensed under the [MIT License](LICENSE), like the rest of +the project. diff --git a/README.md b/README.md index d01fd13..c463812 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ - **Collections** in the sidebar: every collection in a grid or a list (your choice is remembered), with search and create, edit and delete. - **Collection pages** show the poster, description, rating and games. You can search, sort by name, release date, - last played, time played or date added, show installed games only, and Play/Install, Show in library or - Remove games. + last played, time played or date added, group them by platform, genre, series and more, show installed games + only, and Play/Install, Show in library or Remove games. Collapse the header or groups, and resize the game cards. - **Manual order**: drag games into the order you want, or use the right-click menu or Alt+arrow keys. - **Dynamic collections** fill themselves from your rules, for example *Platform is PS1 and Genres include Indie*. Combine conditions into blocks, join blocks with AND or OR, and see the matching games live while you edit. @@ -61,6 +61,18 @@ Requires a recent Playnite 10 release (extension SDK 6.11 or later), in Desktop Theme authors can choose where the collections list appears and bind to the extension's settings. See [Theme integration](docs/theme-integration.md). +## Translations + +Translations are managed on [Crowdin](https://crowdin.com/project/game-collections). Anyone can join the project +and translate the extension into their language, with no coding needed. New translations are added to the +extension in its next release, and any string that isn't translated yet is shown in English. + +To request a language that isn't listed, open an issue. + +## Contributing + +Bug reports, feature ideas, translations and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md). + ## Building ``` diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000..4ab5c7d --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,12 @@ +# Crowdin configuration, used by the Crowdin workflow (.github/workflows/crowdin.yml) and the Crowdin CLI. +# The project ID and API token come from environment variables, never from this file. +project_id_env: CROWDIN_PROJECT_ID +api_token_env: CROWDIN_PERSONAL_TOKEN + +preserve_hierarchy: true + +files: + # Playnite loads Localization/.xaml from the plugin folder, using names such as de_DE and pt_BR, + # and falls back to en_US for any string a translation is missing. + - source: /source/GameCollections/Localization/en_US.xaml + translation: /source/GameCollections/Localization/%locale_with_underscore%.xaml diff --git a/docs/developer-guide.md b/docs/developer-guide.md index f75940f..12b9685 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -286,7 +286,24 @@ Before a release, check these by hand in Playnite: - `ApplicationMode` other than Desktop is untested, and the views need Desktop theme styles. - A search of the library in the rule preview runs on the UI thread. Very large libraries could feel it while editing. -- Only `en_US` strings exist so far. +- Translations come from Crowdin, so a release only includes the languages that were merged before it was built. + +## Translations + +`Localization/en_US.xaml` is the only file edited by hand. Everything else in `Localization/` comes from +[Crowdin](https://crowdin.com/project/game-collections) and is overwritten on every sync, so never edit it here. + +- [`crowdin.yml`](../crowdin.yml) maps `en_US.xaml` to `Localization/.xaml`, using Crowdin's + `%locale_with_underscore%` names (`de_DE`, `pt_BR`, `zh_CN`). These are the names Playnite looks for. +- Playnite loads `en_US.xaml` first, then the file for the user's language on top of it, so a missing string falls + back to English. The plugin needs no code for this; the files only have to be copied to the output folder, which + `GameCollections.csproj` does for every `Localization\*.xaml`. +- The [Crowdin workflow](../.github/workflows/crowdin.yml) uploads `en_US.xaml` whenever it changes on `master`, and + every Monday (or when run by hand from the Actions tab) opens a pull request from `l10n_crowdin` with the latest + translations. Merge it before building a release. +- It needs the `CROWDIN_PROJECT_ID` and `CROWDIN_PERSONAL_TOKEN` repository secrets. +- When you add or change a key, change only `en_US.xaml`. Crowdin marks changed strings for re-translation, and + removed keys disappear from the translations on the next sync. ## Releasing diff --git a/docs/user-guide.md b/docs/user-guide.md index c409f0c..0682d3e 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -103,12 +103,19 @@ not show it. List view has no details panel, so it doesn't appear there. Theme a - Header with poster, title, rating, game count and description, plus **Edit**, **Select in library** and **Delete**. Dynamic collections also show their rules and a **Refresh now** button. +- The arrow button at the header's top right **collapses the header** to just the title, game count and Dynamic badge, + leaving more room for games. Press it again to expand it. This is remembered for all collections. - **Search** the collection's games by name. - **Sort** by collection order (the order you arranged, or the order games were added), name, release date, last played, time played or date added, ascending or descending. - **Group by** shows the games in labelled groups, such as by platform, series, genre or release year. Each collection remembers its own choice. A game with several values, such as two genres, appears in each group. Games with no value go in a **Not set** group at the end. + - Click a group's header to collapse or expand it, or use **Collapse all** / **Expand all** next to Group by. + Collapsed groups reset when you leave the page or change the grouping. + - Collapsing a group deselects its games, unless they also appear in a group that's still open. +- **Card size**, the slider at the right of the toolbar, makes the game cards bigger or smaller. It's remembered for + all collections. - **Installed only** hides games that aren't installed (uninstalled games are dimmed otherwise). - For each game (right-click, or keyboard): - **Play** / **Install** – double-click or **Enter**. diff --git a/manifests/installer_manifest.yaml b/manifests/installer_manifest.yaml index 201a753..cfb38a8 100644 --- a/manifests/installer_manifest.yaml +++ b/manifests/installer_manifest.yaml @@ -1,5 +1,15 @@ AddonId: GameCollections_3f6b8d2e-5c41-4a7e-9e0b-6d2f1a8c7b54 Packages: + - Version: 1.3.0 + RequiredApiVersion: 6.11.0 + ReleaseDate: 2026-11-06 + PackageUrl: https://github.com/X4Lo/GameCollections/releases/download/v1.3.0/GameCollections_3f6b8d2e-5c41-4a7e-9e0b-6d2f1a8c7b54_1_3_0.pext + Changelog: + - 'Added: Collapse a collection page''s header to just its title, game count and dynamic badge' + - 'Added: Collapse or expand each group on a collection page, or all of them at once' + - 'Added: Slider to change the size of the game cards on a collection page' + - 'Added: Translations through Crowdin' + - 'Fixed: Search box on a collection page taller than the dropdowns next to it' - Version: 1.2.0 RequiredApiVersion: 6.11.0 ReleaseDate: 2026-11-02 diff --git a/source/GameCollections/GameCollections.csproj b/source/GameCollections/GameCollections.csproj index 1a4f322..b8a02aa 100644 --- a/source/GameCollections/GameCollections.csproj +++ b/source/GameCollections/GameCollections.csproj @@ -7,7 +7,7 @@ GameCollections GameCollections 7.3 - 1.2.0 + 1.3.0 Game Collections false false diff --git a/source/GameCollections/Localization/en_US.xaml b/source/GameCollections/Localization/en_US.xaml index 105c48a..9b337db 100644 --- a/source/GameCollections/Localization/en_US.xaml +++ b/source/GameCollections/Localization/en_US.xaml @@ -154,6 +154,13 @@ Install status Installed Not installed + Collapse all + Expand all + + + Collapse header + Expand header + Card size Move to top diff --git a/source/GameCollections/Settings/GameCollectionsSettings.cs b/source/GameCollections/Settings/GameCollectionsSettings.cs index a546abf..ae7a0dc 100644 --- a/source/GameCollections/Settings/GameCollectionsSettings.cs +++ b/source/GameCollections/Settings/GameCollectionsSettings.cs @@ -12,6 +12,13 @@ namespace GameCollections.Settings private CollectionsViewMode viewMode = CollectionsViewMode.Grid; public CollectionsViewMode ViewMode { get => viewMode; set => SetValue(ref viewMode, value); } + // Also remembered UI state: the collection page's header and the size of its game cards. + private bool collectionHeaderCollapsed; + public bool CollectionHeaderCollapsed { get => collectionHeaderCollapsed; set => SetValue(ref collectionHeaderCollapsed, value); } + + private double gameCardWidth = 130; + public double GameCardWidth { get => gameCardWidth; set => SetValue(ref gameCardWidth, value); } + private bool showDynamicCollectionsInDetails = true; public bool ShowDynamicCollectionsInDetails { get => showDynamicCollectionsInDetails; set => SetValue(ref showDynamicCollectionsInDetails, value); } diff --git a/source/GameCollections/ViewModels/CollectionDetailsViewModel.cs b/source/GameCollections/ViewModels/CollectionDetailsViewModel.cs index 3ff7170..6621a90 100644 --- a/source/GameCollections/ViewModels/CollectionDetailsViewModel.cs +++ b/source/GameCollections/ViewModels/CollectionDetailsViewModel.cs @@ -11,6 +11,7 @@ using System.Globalization; using System.Linq; using System.Windows.Data; using System.Windows.Input; +using System.Windows.Threading; namespace GameCollections.ViewModels { @@ -238,12 +239,74 @@ namespace GameCollections.ViewModels set { manager.SetGroupBy(CollectionId, value); + collapsedGroups.Clear(); ApplyGrouping(); OnPropertyChanged(); + OnPropertyChanged(nameof(IsGrouped)); RaiseReorderChanged(); } } + public bool IsGrouped => GroupBy != GameGroupField.None; + + // Names of the groups the user has collapsed. Kept by name so the state survives the + // groups being rebuilt when the search or filters change. + private readonly HashSet collapsedGroups = new HashSet(); + + /// + /// Raised when groups are collapsed or expanded from the view model, so the view can update its expanders. + /// + public event EventHandler GroupExpansionChanged; + + private IEnumerable GroupNames => GamesView.Groups?.Cast().Select(g => (string)g.Name) ?? Enumerable.Empty(); + public bool AllGroupsCollapsed => IsGrouped && GroupNames.Any() && GroupNames.All(collapsedGroups.Contains); + public string ToggleAllGroupsText => Loc.Get(AllGroupsCollapsed ? "LOCGameCollections_ExpandAllGroups" : "LOCGameCollections_CollapseAllGroups"); + + /// + /// Hides the poster, description and buttons, leaving the title, game count and dynamic badge. + /// Shared by all collection pages and remembered between sessions. + /// + public bool IsHeaderCollapsed + { + get => root.Settings.Settings.CollectionHeaderCollapsed; + set + { + root.Settings.Settings.CollectionHeaderCollapsed = value; + root.Settings.Save(); + OnPropertyChanged(); + OnPropertyChanged(nameof(HeaderToggleGlyph)); + OnPropertyChanged(nameof(HeaderToggleTooltip)); + } + } + + public string HeaderToggleGlyph => IsHeaderCollapsed ? DescendingGlyph : AscendingGlyph; + public string HeaderToggleTooltip => Loc.Get(IsHeaderCollapsed ? "LOCGameCollections_ExpandHeader" : "LOCGameCollections_CollapseHeader"); + + public const double MinCardWidth = 80; + public const double MaxCardWidth = 260; + private const double CardAspectRatio = 1.5; + + /// + /// Width of the game cards, set with the size slider. Shared by all collection pages. + /// + public double CardWidth + { + get => Math.Max(MinCardWidth, Math.Min(MaxCardWidth, root.Settings.Settings.GameCardWidth)); + set + { + root.Settings.Settings.GameCardWidth = Math.Max(MinCardWidth, Math.Min(MaxCardWidth, value)); + OnPropertyChanged(); + OnPropertyChanged(nameof(CardHeight)); + // The slider changes the value many times a second, so the settings file is written once it settles. + cardSizeSaveTimer.Stop(); + cardSizeSaveTimer.Start(); + } + } + + public double CardHeight => CardWidth * CardAspectRatio; + + private readonly DispatcherTimer cardSizeSaveTimer; + public bool IsEmpty => Games.Count == 0; public bool HasNoResults => !IsEmpty && GamesView.Count == 0; // With groups, a game can be in the view several times but is still one game. @@ -260,6 +323,8 @@ namespace GameCollections.ViewModels public RelayCommand PlaySelectedCommand { get; } public RelayCommand RefreshCommand { get; } public RelayCommand OpenInCollectionsCommand { get; } + public RelayCommand ToggleHeaderCommand { get; } + public RelayCommand ToggleAllGroupsCommand { get; } public CollectionDetailsViewModel(IPlayniteAPI playniteApi, CollectionManager manager, CollectionsRootViewModel root, CollectionCardViewModel header) { @@ -268,6 +333,13 @@ namespace GameCollections.ViewModels this.root = root; Header = header; + cardSizeSaveTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) }; + cardSizeSaveTimer.Tick += (s, e) => + { + cardSizeSaveTimer.Stop(); + root.Settings.Save(); + }; + GamesView = new ListCollectionView(Games) { Filter = FilterGame }; ApplySort(); ApplyGrouping(); @@ -289,6 +361,8 @@ namespace GameCollections.ViewModels PlaySelectedCommand = new RelayCommand(PlaySelected); RefreshCommand = new RelayCommand(() => manager.RefreshCollection(CollectionId)); OpenInCollectionsCommand = new RelayCommand(() => root.ShowInCollectionsSection(CollectionId)); + ToggleHeaderCommand = new RelayCommand(() => IsHeaderCollapsed = !IsHeaderCollapsed); + ToggleAllGroupsCommand = new RelayCommand(ToggleAllGroups); Reload(); } @@ -448,6 +522,54 @@ namespace GameCollections.ViewModels return selected.Contains(tile) ? selected : new List { tile }; } + public bool IsGroupCollapsed(object groupName) + { + return groupName is string name && collapsedGroups.Contains(name); + } + + /// + /// Records a group being collapsed or expanded by its own header. + /// + public void SetGroupCollapsed(object groupName, bool collapsed) + { + if (!(groupName is string name)) + { + return; + } + + if (collapsed) + { + collapsedGroups.Add(name); + } + else + { + collapsedGroups.Remove(name); + } + + RaiseGroupStateChanged(); + } + + private void ToggleAllGroups() + { + if (AllGroupsCollapsed) + { + collapsedGroups.Clear(); + } + else + { + collapsedGroups.UnionWith(GroupNames); + } + + GroupExpansionChanged?.Invoke(this, EventArgs.Empty); + RaiseGroupStateChanged(); + } + + private void RaiseGroupStateChanged() + { + OnPropertyChanged(nameof(AllGroupsCollapsed)); + OnPropertyChanged(nameof(ToggleAllGroupsText)); + } + private void RaiseReorderChanged() { OnPropertyChanged(nameof(CanReorder)); @@ -535,6 +657,7 @@ namespace GameCollections.ViewModels OnPropertyChanged(nameof(IsEmpty)); OnPropertyChanged(nameof(HasNoResults)); OnPropertyChanged(nameof(VisibleCountText)); + RaiseGroupStateChanged(); } private class GameTileComparer : IComparer diff --git a/source/GameCollections/ViewModels/CollectionsRootViewModel.cs b/source/GameCollections/ViewModels/CollectionsRootViewModel.cs index 5621375..6514f25 100644 --- a/source/GameCollections/ViewModels/CollectionsRootViewModel.cs +++ b/source/GameCollections/ViewModels/CollectionsRootViewModel.cs @@ -34,11 +34,14 @@ namespace GameCollections.ViewModels public GameSortField GameSortField { get; set; } = GameSortField.CollectionOrder; public bool GameSortDescending { get; set; } + public GameCollectionsSettingsViewModel Settings { get; } + public CollectionsRootViewModel(IPlayniteAPI playniteApi, CollectionManager manager, DialogService dialogs, GameCollectionsSettingsViewModel settings) { this.playniteApi = playniteApi; this.manager = manager; this.dialogs = dialogs; + Settings = settings; Home = new CollectionsHomeViewModel(manager, this, settings); CurrentPage = Home; manager.CollectionsChanged += OnCollectionsChanged; diff --git a/source/GameCollections/Views/CollectionDetailsView.xaml b/source/GameCollections/Views/CollectionDetailsView.xaml index 95bcc8c..d28d72b 100644 --- a/source/GameCollections/Views/CollectionDetailsView.xaml +++ b/source/GameCollections/Views/CollectionDetailsView.xaml @@ -41,8 +41,9 @@ - - + + + + + - - + + + - + + VerticalAlignment="Top" Margin="16,8,0,0" /> + + + + - - -