feat: add collapsible header and groups, card size slider and Crowdin translations
Build / build (push) Canceled after 0s
Crowdin / sync (push) Canceled after 0s

- 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.
This commit is contained in:
X4Lo committed 2026-11-06 15:59:16 +00:00
1 parent b9a6bf891d
commit 089f3e0f23
17 files changed
+485 -21

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ name: Build
on:
push:
branches: [main]
branches: [master]
tags: ['v*']
pull_request:
+43
View File
@@ -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 }}
+8
View File
@@ -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,
+74
View File
@@ -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.
+14 -2
View File
@@ -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
```
+12
View File
@@ -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/<language>.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
+18 -1
View File
@@ -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/<locale>.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
+7
View File
@@ -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**.
+10
View File
@@ -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
@@ -7,7 +7,7 @@
<RootNamespace>GameCollections</RootNamespace>
<AssemblyName>GameCollections</AssemblyName>
<LangVersion>7.3</LangVersion>
<Version>1.2.0</Version>
<Version>1.3.0</Version>
<Product>Game Collections</Product>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
@@ -154,6 +154,13 @@
<sys:String x:Key="LOCGameCollections_GroupInstallStatus">Install status</sys:String>
<sys:String x:Key="LOCGameCollections_GroupInstalled">Installed</sys:String>
<sys:String x:Key="LOCGameCollections_GroupNotInstalled">Not installed</sys:String>
<sys:String x:Key="LOCGameCollections_CollapseAllGroups">Collapse all</sys:String>
<sys:String x:Key="LOCGameCollections_ExpandAllGroups">Expand all</sys:String>
<!-- Collection page layout -->
<sys:String x:Key="LOCGameCollections_CollapseHeader">Collapse header</sys:String>
<sys:String x:Key="LOCGameCollections_ExpandHeader">Expand header</sys:String>
<sys:String x:Key="LOCGameCollections_CardSize">Card size</sys:String>
<!-- Manual order -->
<sys:String x:Key="LOCGameCollections_MoveToTop">Move to top</sys:String>
@@ -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); }
@@ -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<string> collapsedGroups = new HashSet<string>();
/// <summary>
/// Raised when groups are collapsed or expanded from the view model, so the view can update its expanders.
/// </summary>
public event EventHandler GroupExpansionChanged;
private IEnumerable<string> GroupNames => GamesView.Groups?.Cast<CollectionViewGroup>().Select(g => (string)g.Name) ?? Enumerable.Empty<string>();
public bool AllGroupsCollapsed => IsGrouped && GroupNames.Any() && GroupNames.All(collapsedGroups.Contains);
public string ToggleAllGroupsText => Loc.Get(AllGroupsCollapsed ? "LOCGameCollections_ExpandAllGroups" : "LOCGameCollections_CollapseAllGroups");
/// <summary>
/// Hides the poster, description and buttons, leaving the title, game count and dynamic badge.
/// Shared by all collection pages and remembered between sessions.
/// </summary>
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;
/// <summary>
/// Width of the game cards, set with the size slider. Shared by all collection pages.
/// </summary>
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<CollectionGameViewModel> { tile };
}
public bool IsGroupCollapsed(object groupName)
{
return groupName is string name && collapsedGroups.Contains(name);
}
/// <summary>
/// Records a group being collapsed or expanded by its own header.
/// </summary>
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
@@ -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;
@@ -41,8 +41,9 @@
</Style>
<DataTemplate x:Key="GameTemplate" DataType="{x:Type vm:CollectionGameViewModel}">
<StackPanel Width="130">
<Grid Width="130" Height="195">
<!-- Sized by the card size slider on the page. -->
<StackPanel Width="{Binding DataContext.CardWidth, RelativeSource={RelativeSource AncestorType=ListBox}}">
<Grid Height="{Binding DataContext.CardHeight, RelativeSource={RelativeSource AncestorType=ListBox}}">
<local:PosterImage GlyphSize="40" Glyph="&#xea30;" Source="{Binding Cover}" />
<!-- Dim games that are not installed, as Playnite's own grid does. -->
<Border Background="#80000000" CornerRadius="4" IsHitTestVisible="False"
@@ -69,25 +70,38 @@
</Button>
<!-- Collection header -->
<!-- Collapsing it leaves only the title, game count and dynamic badge. -->
<Grid DockPanel.Dock="Top" Margin="0,15,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<local:PosterImage Width="140" Height="210" GlyphSize="52" Source="{Binding Header.Poster}" VerticalAlignment="Top" />
<StackPanel Grid.Column="1" Margin="20,0,0,0">
<local:PosterImage Width="140" Height="210" GlyphSize="52" Source="{Binding Header.Poster}" VerticalAlignment="Top"
Margin="0,0,20,0"
Visibility="{Binding IsHeaderCollapsed, Converter={StaticResource InverseBoolToVisibility}}" />
<Button Grid.Column="2" Style="{StaticResource GcIconButton}" VerticalAlignment="Top" Margin="10,0,0,0"
Content="{Binding HeaderToggleGlyph}"
Command="{Binding ToggleHeaderCommand}"
ToolTip="{Binding HeaderToggleTooltip}"
AutomationProperties.Name="{Binding HeaderToggleTooltip}" />
<StackPanel Grid.Column="1">
<TextBlock Text="{Binding Header.Title}" Style="{StaticResource GcPageTitleText}" TextWrapping="Wrap" />
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<StackPanel Orientation="Horizontal"
Visibility="{Binding IsHeaderCollapsed, Converter={StaticResource InverseBoolToVisibility}}">
<TextBlock Text="&#xf000;" Style="{StaticResource GcGlyph}"
Foreground="{DynamicResource GlyphBrush}" Margin="0,0,5,0" />
<TextBlock Text="{Binding Header.RatingText}" Style="{StaticResource GcText}" />
<TextBlock Text="•" Style="{StaticResource GcMutedText}" Margin="10,0" />
</StackPanel>
<TextBlock Text="{Binding Header.GameCountText}" Style="{StaticResource GcMutedText}" />
<Border Style="{StaticResource GcBadge}" Margin="10,0,0,0"
Visibility="{Binding IsDynamic, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{DynamicResource LOCGameCollections_DynamicBadge}" Style="{StaticResource GcBadgeText}" />
</Border>
</StackPanel>
<StackPanel Visibility="{Binding IsHeaderCollapsed, Converter={StaticResource InverseBoolToVisibility}}">
<TextBlock Text="{Binding RulesSummary}" Style="{StaticResource GcMutedText}"
TextWrapping="Wrap" Margin="0,8,0,0"
Visibility="{Binding RulesSummary, Converter={StaticResource HasValueToVisibility}}" />
@@ -126,25 +140,41 @@
</Button>
</WrapPanel>
</StackPanel>
</StackPanel>
</Grid>
<!-- Toolbar: search, sort, filter -->
<!-- Toolbar: search, sort, group, filter. The search box and buttons take the dropdowns'
height, which comes from the theme, so the row lines up in any theme. -->
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,10">
<TextBlock DockPanel.Dock="Right" Text="{Binding VisibleCountText}" Style="{StaticResource GcMutedText}"
VerticalAlignment="Top" Margin="10,8,0,0" />
VerticalAlignment="Top" Margin="16,8,0,0" />
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Top" Margin="16,0,0,0"
Height="{Binding ActualHeight, ElementName=SortCombo}">
<TextBlock Text="{DynamicResource LOCGameCollections_CardSize}" Style="{StaticResource GcText}"
VerticalAlignment="Center" Margin="0,0,8,0" />
<Slider Width="110" VerticalAlignment="Center"
Minimum="{x:Static vm:CollectionDetailsViewModel.MinCardWidth}"
Maximum="{x:Static vm:CollectionDetailsViewModel.MaxCardWidth}"
SmallChange="10" LargeChange="30"
Value="{Binding CardWidth}"
ToolTip="{DynamicResource LOCGameCollections_CardSize}"
AutomationProperties.Name="{DynamicResource LOCGameCollections_CardSize}" />
</StackPanel>
<WrapPanel Orientation="Horizontal">
<local:SearchBox Width="240" Height="32" Margin="0,0,0,4"
<local:SearchBox Width="240" Margin="0,0,0,4" VerticalAlignment="Center"
Height="{Binding ActualHeight, ElementName=SortCombo}"
Text="{Binding SearchText}"
Placeholder="{DynamicResource LOCGameCollections_SearchGames}" />
<TextBlock Text="{DynamicResource LOCGameCollections_SortBy}" Style="{StaticResource GcText}"
VerticalAlignment="Center" Margin="16,0,8,0" />
<ComboBox MinWidth="150" VerticalAlignment="Center"
<ComboBox x:Name="SortCombo" MinWidth="150" VerticalAlignment="Center"
ItemsSource="{Binding SortOptions}"
DisplayMemberPath="Label"
SelectedValuePath="Field"
SelectedValue="{Binding SortField}"
AutomationProperties.Name="{DynamicResource LOCGameCollections_SortBy}" />
<Button Style="{StaticResource GcIconButton}" Height="32" Margin="5,0,0,0"
<Button Style="{StaticResource GcIconButton}" Margin="5,0,0,0"
Height="{Binding ActualHeight, ElementName=SortCombo}"
Content="{Binding SortDirectionGlyph}"
Command="{Binding ToggleSortDirectionCommand}"
ToolTip="{Binding SortDirectionTooltip}"
@@ -157,6 +187,11 @@
SelectedValuePath="Field"
SelectedValue="{Binding GroupBy}"
AutomationProperties.Name="{DynamicResource LOCGameCollections_GroupBy}" />
<Button Style="{StaticResource GcButton}" Margin="5,0,0,0" Padding="10,0"
Height="{Binding ActualHeight, ElementName=SortCombo}"
Content="{Binding ToggleAllGroupsText}"
Command="{Binding ToggleAllGroupsCommand}"
Visibility="{Binding IsGrouped, Converter={StaticResource BoolToVisibility}}" />
<CheckBox VerticalAlignment="Center" Margin="16,0,0,0"
IsChecked="{Binding InstalledOnly}"
Content="{DynamicResource LOCGameCollections_InstalledOnly}" />
@@ -183,17 +218,33 @@
SizeChanged="GamesList_SizeChanged"
AutomationProperties.Name="{Binding Header.Title}">
<ListBox.GroupStyle>
<!-- Each group is an expander so it can be collapsed. Its state is kept by the
view model and applied in GroupExpander_Loaded. -->
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,8,0,8">
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<Expander IsExpanded="True" Margin="0,0,0,8"
Loaded="GroupExpander_Loaded"
Expanded="GroupExpander_Toggled"
Collapsed="GroupExpander_Toggled">
<Expander.Header>
<StackPanel Orientation="Horizontal" Margin="0,4,0,4">
<TextBlock Text="{Binding Name}" Style="{StaticResource GcItemTitleText}"
FontSize="{DynamicResource FontSizeLarge}" />
<TextBlock Text="{Binding ItemCount}" Style="{StaticResource GcMutedText}"
VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</Expander.Header>
<ItemsPresenter Margin="0,8,0,0" />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
<ListBox.ItemsPanel>
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
@@ -35,7 +36,7 @@ namespace GameCollections.Views
};
GamesList.SelectionChanged += (s, e) => SyncSelection();
DataContextChanged += (s, e) => SyncSelection();
DataContextChanged += OnDataContextChanged;
Loaded += OnLoaded;
Unloaded += (s, e) => coverTimer.Stop();
}
@@ -56,6 +57,78 @@ namespace GameCollections.Views
ScheduleCoverRequest();
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is CollectionDetailsViewModel oldViewModel)
{
oldViewModel.GroupExpansionChanged -= OnGroupExpansionChanged;
}
if (e.NewValue is CollectionDetailsViewModel newViewModel)
{
newViewModel.GroupExpansionChanged += OnGroupExpansionChanged;
}
SyncSelection();
}
private void GroupExpander_Loaded(object sender, RoutedEventArgs e)
{
// Groups are rebuilt whenever the search or filters change, so each one takes its state from the view model.
var expander = (Expander)sender;
if (ViewModel != null)
{
expander.IsExpanded = !ViewModel.IsGroupCollapsed((expander.DataContext as CollectionViewGroup)?.Name);
}
}
private void GroupExpander_Toggled(object sender, RoutedEventArgs e)
{
var expander = (Expander)sender;
if (e.OriginalSource != expander || ViewModel == null)
{
return;
}
ViewModel.SetGroupCollapsed((expander.DataContext as CollectionViewGroup)?.Name, !expander.IsExpanded);
if (expander.IsExpanded)
{
ScheduleCoverRequest();
}
else
{
Dispatcher.BeginInvoke(new Action(DeselectHiddenGames), DispatcherPriority.Loaded);
}
}
private void OnGroupExpansionChanged(object sender, EventArgs e)
{
foreach (var expander in FindDescendants<Expander>(GamesList))
{
GroupExpander_Loaded(expander, null);
}
}
/// <summary>
/// Drops games that are only in collapsed groups from the selection, so Delete or Enter
/// never acts on a game the user can't see.
/// </summary>
private void DeselectHiddenGames()
{
if (GamesList.SelectedItems.Count == 0)
{
return;
}
var items = new List<ListBoxItem>();
CollectItems(GamesList, items);
var shown = new HashSet<object>(items.Where(i => i.IsVisible).Select(i => i.DataContext));
foreach (var game in GamesList.SelectedItems.Cast<object>().Where(g => !shown.Contains(g)).ToList())
{
GamesList.SelectedItems.Remove(game);
}
}
private void SyncSelection()
{
if (ViewModel != null)
@@ -364,6 +437,23 @@ namespace GameCollections.Views
}
}
private static IEnumerable<T> FindDescendants<T>(DependencyObject parent) where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is T match)
{
yield return match;
}
foreach (var nested in FindDescendants<T>(child))
{
yield return nested;
}
}
}
private static T FindDescendant<T>(DependencyObject parent) where T : DependencyObject
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
+1 -1
View File
@@ -1,7 +1,7 @@
Id: GameCollections_3f6b8d2e-5c41-4a7e-9e0b-6d2f1a8c7b54
Name: Game Collections
Author: X4Lo
Version: 1.2.0
Version: 1.3.0
Module: GameCollections.dll
Type: GenericPlugin
Icon: icon.png