Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
601bbf4a8b |
No files matched your search
@@ -28,6 +28,18 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- **A game's page shows its artwork** (owner request 2026-10-14, decisions D60/D61). At the top of the page: the
|
||||
banner and the cover the Steam or GOG GALAXY app already keeps on your PC for the game it installed — read where that
|
||||
app keeps them, never downloaded and never copied — or an image you choose yourself in **Edit… ▸ Choose image…** (a
|
||||
copy is kept in the data folder's `covers` folder; **Use the store's image** goes back). The band they sit in takes the
|
||||
picture's main colour, never so strongly that a text on it gets hard to read (primary and secondary text keep 4.5:1,
|
||||
the faintest 3:1, in both themes), and follows a theme switch. A game from itch, the Epic Games Launcher or another
|
||||
store has a picture only once you choose one, because those apps keep no image files. **Settings ▸ Games** has *Show
|
||||
game artwork* and *Colour the game page from its artwork*, both on. **Privacy Policy 2.11** names the images read and
|
||||
the copies kept; FrameLedger still makes no request to any store.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A game's page opens and changes session without freezing the window** (owner request 2026-10-14). Measured on the
|
||||
|
||||
@@ -177,6 +177,15 @@ you accept the prompt. Turn it on only if you trust everything that runs under y
|
||||
that one from its store or its own shortcut — nor a game whose recording is off: FrameLedger starts only what it
|
||||
records. While FrameLedger itself runs as administrator, Play starts every game directly, with your standard rights.
|
||||
|
||||
## Game artwork
|
||||
|
||||
- **Only the Steam and GOG GALAXY apps keep pictures FrameLedger can show** (since 0.1.0-beta.23). A game's page shows
|
||||
the cover and banner those apps keep on your PC for a game they installed, read where they keep them — nothing is
|
||||
downloaded or copied. A game from itch, the Epic Games Launcher or another store, or one whose `.exe` is outside a
|
||||
store's own folder, shows a picture only once you choose one (**Edit… ▸ Choose image…**). A GOG picture needs Windows'
|
||||
WebP support, which Windows 11 and most Windows 10 installs have. ([Game page](docs/08_UI.md))
|
||||
- The pictures belong to the games' owners; FrameLedger ships none ([names and trademarks](legal/TRADEMARKS.md)).
|
||||
|
||||
## Your data
|
||||
|
||||
- Everything stays on your computer (`%LOCALAPPDATA%\FrameLedger`). FrameLedger sends no telemetry; its only
|
||||
|
||||
@@ -135,7 +135,8 @@ logs\ui-*.log, agent-*.log, overlay-<pid>-*.log (native log flushed at session
|
||||
crashdumps\*.dmp
|
||||
breadcrumbs\<pid>.json (corrected 2026-10-04: never created — the breadcrumb is the .partial file's header and notes)
|
||||
tmp\<sessionGuid>.partial crash-safety flush of raw buffers, every 60 s (04_CAPTURE §Ring draining)
|
||||
covers\*.jpg (corrected 2026-10-04: never created — nothing writes games.cover_path)
|
||||
covers\game-<id>-<ms>.png the images users chose for their games (beta.23, D60) — ~~covers\*.jpg, never created~~;
|
||||
a store app's own artwork is shown from where that app keeps it, never copied here
|
||||
```
|
||||
|
||||
*(beta.15, D52: `FrameLedger.exe --data-dir <folder>` reads a COPY of this folder instead — a viewer that starts and
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ Requirement IDs (`FR-x`, `NFR-x`) are referenced by other docs, commits, and tes
|
||||
### FR-1 Game library
|
||||
- FR-1.1 Add game by picking an `.exe`, or drag-dropping an exe/shortcut.
|
||||
- FR-1.2 Auto-import from Steam, GOG Galaxy, Epic, itch.io with a review checklist. **Import never enables hooking for anything.**
|
||||
- FR-1.3 Editable metadata (name, cover, publisher, version, notes); auto-detected fields badged and overridable.
|
||||
- FR-1.3 Editable metadata (name, cover, publisher, version, notes); auto-detected fields badged and overridable. *(The cover is built since beta.23, D60: the user's own image, else the Steam or GOG GALAXY app's artwork on this PC — `08_UI` §Games.)*
|
||||
- FR-1.4 Remove game (asks whether to keep or delete its sessions).
|
||||
- FR-1.5 "Supports" row shows shipped-capability hints (DLSS/FSR/XeSS/FG) — visually distinct from measured per-session values (`05_DETECTION` §Capability hints).
|
||||
- FR-1.7 Delete all sessions (beta.11, owner decision D40): of one game from its page, or of every game from Settings ▸ Data, after a confirmation that says how many — with their frame and sensor series and notes; the library, the settings and every consent stay. The Agent deletes them (the rows are its, `06_DATA_MODEL` §Writer ownership) and refuses while a session it would delete under is being recorded.
|
||||
|
||||
@@ -318,6 +318,14 @@ engine compiled only, reads as not found. One Ren'Py install was measured.
|
||||
| itch.io | `.itch\receipt.json.gz` | **`%APPDATA%\itch\db\butler.db`** (`install_locations` + `caves`, butler's `verdict` names the executable) since 2026-09-16, then the receipt JSON: title, id |
|
||||
| None/Manual | fallback | PE VersionInfo |
|
||||
|
||||
> **The stores' artwork on this PC (beta.23, owner decision D60).** A game's page shows the cover and banner the Steam and
|
||||
> GOG GALAXY apps already keep — Steam's `appcache\librarycache\<appid>\` (files flat or in hash-named folders), GOG
|
||||
> GALAXY's `webcache\<user>\gog\<productId>\` — found for the store whose own records own the game's folder
|
||||
> (`StoreRecords.Owning`, as Play finds it). `Infrastructure.Art.SteamArtCache` and `GogArtCache` read them; nothing is
|
||||
> downloaded, so the *(opt-in)* online lookup in the publisher/version order below still does not exist. Epic, itch and
|
||||
> other stores keep no image files: their games show the image the user chooses, or none. The detail: `08_UI` §Games ›
|
||||
> Game detail, *The header's cover*.
|
||||
|
||||
**Auto-import (FR-1.2):** Steam via `libraryfolders.vdf` → all `appmanifest_*.acf` except `SteamLibrarySource.KnownTools` (2026-09-22: Steamworks Common Redistributables, Borderless Gaming, Wallpaper Engine, SteamVR, the Proton and Steam Linux Runtime entries, Blender — tools Steam's manifests do not distinguish from games, and which became library rows the watcher recorded); GOG via `HKLM\SOFTWARE\WOW6432Node\GOG.com\Games\*`; Epic via `Manifests\*.item`; itch by receipt scan. Import presents a review checklist; nothing is launched, nothing is hooked on import.
|
||||
|
||||
> **Built 2026-09-14 (P4 PR-4).** `Application.Import.LibraryImporter` over four `IStoreLibrarySource` adapters in
|
||||
|
||||
@@ -53,7 +53,10 @@ CREATE TABLE games (
|
||||
-- beta.20 renpy_vc_version; or the
|
||||
-- rule's extractor type); NULL for a version the user typed. Written with the version only (05_DETECTION §Engine version)
|
||||
publisher TEXT, game_version TEXT,
|
||||
cover_path TEXT, notes TEXT,
|
||||
cover_path TEXT, notes TEXT, -- cover_path: written since beta.23 (D60) — the image the user chose, as
|
||||
-- covers\game-<id>-<unix ms>.png relative to the data folder (a PNG copy
|
||||
-- <= 1200 px); followed only when it is one of those names under covers\
|
||||
-- (a viewer's copy could name a share); NULL = the store app's own artwork
|
||||
removed_at INTEGER, -- schema 0002 (P3 PR-3): FR-1.4 "remove, keep sessions" — the row stays
|
||||
-- (sessions.game_id is NOT NULL, ON DELETE CASCADE) but leaves the
|
||||
-- library; a later launch of the same exe restores it (removed_at = NULL)
|
||||
@@ -436,6 +439,8 @@ switch's rule); integers are invariant-culture within an inclusive range; choice
|
||||
| `ui.fps_decimals` | bool | `0` | | UI (beta.8, 2026-09-25): every FPS figure with two decimals ("62.40") instead of a whole number |
|
||||
| `ui.hide_scrollbars` | bool | `0` | | UI (beta.14, 2026-10-05): no scroll bar drawn anywhere; every scroller still scrolls with the wheel, the keyboard and touch (`App.Services.ScrollBarHiding`, `08_UI` §Settings) |
|
||||
| `ui.library_view` | choice `grid`\|`list` | `grid` | | UI (beta.11, 2026-10-03): the Games library as a grid of cards that fills the width, or as a list; written by the page's own switch, no Settings row (`08_UI` §Games) |
|
||||
| `ui.game_art` | bool | `1` | | UI (beta.23, owner decision D60): a game's page shows its artwork — the image the user chose, else what the Steam or GOG GALAXY app keeps on this PC; nothing is downloaded. Settings ▸ Games (`08_UI` §Games) |
|
||||
| `ui.game_art_tint` | bool | `1` | | UI (beta.23, owner decision D61): the page's header band takes the artwork's colour, at the strongest opacity that keeps its text readable. Settings ▸ Games |
|
||||
| `ui.play_mode` | choice `store`\|`direct` | `store` | | UI (beta.21, owner decision D59): what Play does — `store` hands the game to the app of the store whose own records name its folder, and the agent starts it where none does; `direct` has the agent start it (`LaunchGame`, launch mode). Settings ▸ Games (`08_UI` §Games) |
|
||||
| `capture.background` | bool | `1` | | ~~Agent~~ nobody *(corrected 2026-10-04: no Agent code ever read it, so the watcher recorded every tracked game whatever it said; beta.12 removed its switch from Settings and reserved the key — `SettingsRegistry.CaptureBackground`. Since beta.21 the App can start a game (Play), and the key stays reserved: a game Play starts is recorded as any other start)* |
|
||||
| `hooking.kill_switch` | bool | `0` | | Agent (FR-2.4, since P2 PR-F) |
|
||||
|
||||
+35
-3
@@ -303,7 +303,7 @@ All screens are `Page`s registered with the navigation page provider and navigat
|
||||
> `…TheImportChecklistRendersWithTheExistingRowsShown`.
|
||||
>
|
||||
- **Game detail:**
|
||||
- Header: cover, name, publisher, version, platform, engine+version, API + Present Mode of last session, `FpsReadout` (lifetime avg), TriState chips, Edit button.
|
||||
- Header: cover *(built in beta.23, the note below)*, name, publisher, version, platform, engine+version, API + Present Mode of last session, `FpsReadout` (lifetime avg), TriState chips, Edit button.
|
||||
- **Two clearly separated rows** (`05_DETECTION` §Capability hints — conflating these was the old design's core mistake):
|
||||
- **Supports** — greyed capability chips from files on disk ("Supports DLSS-G", "Supports XeSS"). Static inference. With none: *not scanned yet* until the Agent's sweep has read the executable, then *none found* (beta.21 — it read "not scanned yet" for every game that ships none of the files).
|
||||
- **Last session measured** — accent chips with real values ("DLSS Quality · 1440p → 2160p", "Frame Generation DLSS-G ×1.9", "Ray Tracing: Yes"). Measured.
|
||||
@@ -320,6 +320,29 @@ All screens are `Page`s registered with the navigation page provider and navigat
|
||||
> line) is worked out there once (`Charts.SeriesDigest`): choosing such a session froze the window 0.8–1.0 s, 17 ms now.
|
||||
> Whether the executable is on disk is asked off the UI thread, as the library page has asked since beta.19.
|
||||
|
||||
> **The header's cover, built in beta.23 (owner decisions D60/D61, request 2026-10-14) — never before: the line above said
|
||||
> "cover" from the first draft and nothing drew one.** The image the user chose (Edit… ▸ *Choose image…*, a PNG copy ≤ 1200 px
|
||||
> in the data folder's `covers\game-<id>-<unix ms>.png`, `games.cover_path` relative to the data folder; *Use the store's
|
||||
> image* drops it), else what the app of the store that installed the game keeps on this PC — Steam's
|
||||
> `appcache\librarycache\<appid>\` (its files flat or in hash-named folders: `library_600x900.jpg` / `library_capsule.jpg`,
|
||||
> `library_hero.jpg`, `header.jpg` / `library_header.jpg`) and GOG GALAXY's `webcache\<user>\gog\<productId>\`
|
||||
> (`*_glx_vertical_cover.webp`, `*_glx_bg_top_padding_*.webp`). Which store installed the game is asked of the stores' own
|
||||
> records, as Play asks (`StoreRecords.Owning`, D59) — Steam's and GOG's only, cached two minutes; nothing is downloaded
|
||||
> (`privacy.online_metadata` stays reserved). The page: a band (`ArtBand`, rounded) holding the banner (`ui:Image`, as tall
|
||||
> as its proportions make it, ≤ 240, fading into the band through an alpha mask set in code) above the usual header with the
|
||||
> cover beside the name (120×180, or 230×107 for a landscape header); a game with no artwork shows no band. No text is
|
||||
> drawn on a picture. **The band's colour** (`Controls.ArtTint`, D61): the cover's dominant colour (`Services.ColorMath`: a
|
||||
> hue histogram of a 48-px copy, vivid pixels weighted, a grey picture none) over the card's fill at the strongest opacity
|
||||
> — ≤ 30 % on a dark theme, ≤ 22 % on a light one — at which primary and secondary text keep 4.5:1, tertiary 3:1, and the
|
||||
> pills' and the warning's text 4.5:1 on their fills; recomputed through a resource reference when the theme changes;
|
||||
> untinted with the option off, a grey picture or high contrast. Everything is read and decoded on the thread pool
|
||||
> (`Services.GameArt`; the twelve newest images kept); the text shows first and the picture when ready. A chosen image's
|
||||
> path is followed only when it is one of these names under the folder's `covers` — a viewer's copy (D52) could name a
|
||||
> share. Settings ▸ Games: *Show game artwork* (`ui.game_art`) and *Colour the game page from its artwork*
|
||||
> (`ui.game_art_tint`), both on. Tests: `GameArtTests`, `CoverStoreTests`, `ColorMathTests` (the hardest colours in both
|
||||
> themes against the tests' own WCAG), `EditGameViewModelTests`, `PagesLoadTests.EveryTextIsReadableInBothThemes` (the
|
||||
> surfaces' game page has artwork) and `…TheArtworkBandFollowsAThemeSwitch`. The library's cards still have no image.
|
||||
|
||||
> **Built 2026-09-14 (P3 PR-5): the grid, the detail page's header, the two rows, the hooking control and
|
||||
> the Sessions tab.** Grid: `ui:CardAction` cards with platform / engine / hooking badges, sessions, playtime,
|
||||
> last played (~~the sparkline is PR-6's~~ no sparkline was built — corrected 2026-10-04); search and sort in memory; FR-1.1 by File ▸ Add game…, the page's
|
||||
@@ -687,6 +710,11 @@ Tail view of `ui-*.log` / `agent-*.log` (toggle), level filter, search (`ui:Auto
|
||||
> `PagesLoadTests`.
|
||||
|
||||
### Settings
|
||||
> **beta.23 (owner decisions D60/D61).** The Games section has, under the Play button, **Show game artwork**
|
||||
> (`ui.game_art`, on) and **Colour the game page from its artwork** (`ui.game_art_tint`, on; disabled while the first is
|
||||
> off) — the game page's artwork and its band's colour (§Games › Game detail, *The header's cover*). Neither downloads
|
||||
> anything; the App reads both at each page load, the Agent neither.
|
||||
>
|
||||
> **beta.14 (owner request 2026-10-05: "an option to hide the scroll bars but still scroll").** The Window section has
|
||||
> **Hide scroll bars** (`ui.hide_scrollbars`, off by default). A bar's visibility is bound inside its scroller's template,
|
||||
> which no style reaches, so `Services.ScrollBarHiding` sets the scrollers themselves: ~~one class handler on
|
||||
@@ -877,8 +905,12 @@ which is why the handler is ours.
|
||||
|
||||
Colours come from the WPF UI theme dictionaries and nothing else, so contrast is the Fluent themes' — both of which
|
||||
meet it — and cannot be broken locally: `AccessibilityTests.NoXamlHardCodesAColour` fails on any `#RRGGBB` or named
|
||||
colour in the App's XAML. The chart palette is the one deliberate exception (`16_WPFUI_SYNTAX` §ScottPlot: one
|
||||
palette per theme, chosen with the theme).
|
||||
colour in the App's XAML. The chart palette is ~~the one~~ a deliberate exception (`16_WPFUI_SYNTAX` §ScottPlot: one
|
||||
palette per theme, chosen with the theme). *(Corrected 2026-10-14, beta.23: the game page's artwork band is the second —
|
||||
a colour worked out at run time from the artwork and the theme's own text and fill colours, at the strongest opacity at
|
||||
which every text on it keeps 4.5:1 (tertiary 3:1), so it is held by construction rather than by the theme;
|
||||
`ColorMathTests` checks the hardest colours in both themes against the tests' own WCAG, and `PagesLoadTests` measures the
|
||||
rendered band. Its banner's fade is an alpha mask set in code, no colour at all.)*
|
||||
|
||||
> **"Cannot be broken locally" had a hole, closed 2026-09-16.** `ui:Badge Appearance="Info"` — the Games card's
|
||||
> "Hooking on/off" and the edit dialog's "Detected" — paints its background with WPF UI's `PaletteLightBlueBrush`, a
|
||||
|
||||
+2
-1
@@ -79,7 +79,8 @@ harness, run `hook-harness.exe --real --hold-presenting N`, then the Agent's `--
|
||||
SQLite's online backup, which is consistent while the Agent writes — in Python,
|
||||
`sqlite3.connect("file:C:/Users/<you>/AppData/Local/FrameLedger/ledger.db?mode=ro", uri=True).backup(sqlite3.connect(r"<copy>\ledger.db"))`
|
||||
— or copy the whole folder with every FrameLedger process stopped
|
||||
(closing the App does not stop the Agent). The App opens the copy, migrating it if your build is newer, which is exactly
|
||||
(closing the App does not stop the Agent). A copy of the database alone has no `covers\`: the games whose image the user
|
||||
chose show the store's artwork instead (beta.23), and choosing one in the viewer writes into the copy's own `covers\`. The App opens the copy, migrating it if your build is newer, which is exactly
|
||||
why it must be a copy, and writes its log and crash dumps beside it. It is a viewer: no Agent is started or contacted and
|
||||
nothing on the PC is changed (`08_UI` §Shell). It refuses the profile's own folder however it is spelled, and a folder
|
||||
that does not exist.
|
||||
|
||||
@@ -155,6 +155,11 @@ Native `Menu`, `TabControl`, `ComboBox`, `Slider`~~, `ListView`~~ are fine — t
|
||||
- **Every `Page` root sets `Foreground="{DynamicResource TextFillColorPrimaryBrush}"`** (2026-10-07): the navigation's
|
||||
Frame passes no text colour into a page, and a text with none is black (§Gotchas).
|
||||
- Exception to the no-hex rule: the chart palette — defined once per theme in ~~`Styles/ChartPalette.xaml` (two dictionaries)~~ `Styles/ChartPalette.Dark.xaml` and `ChartPalette.Light.xaml` (corrected 2026-10-04), never inline.
|
||||
- Second exception (beta.23, D61): the game page's artwork band, `Controls/ArtTint` — a colour worked out in code from the
|
||||
artwork and the theme's own text and fill colours, the strongest tint at which every text on it still reads (4.5:1,
|
||||
tertiary 3:1). It follows a theme switch through a **resource reference on the band** (`SetResourceReference` on a
|
||||
private attached property bound to `ApplicationBackgroundColor`), not through `ApplicationThemeManager.Changed`, which
|
||||
only `ApplicationThemeManager.Apply` raises — a page made and switched in the tests' harness would never hear it.
|
||||
|
||||
## FlowDocument (rendered documents, beta.12)
|
||||
|
||||
@@ -236,6 +241,12 @@ On startup and on `ApplicationThemeManager.Changed`: for every live plot set fig
|
||||
reaches: the import list was white text on white in the dark theme (owner's screenshot, beta.14). Base it on
|
||||
`DefaultDataGridRowStyle`. `AccessibilityTests.NoStyleIsBasedOnAnImplicitStyleTheThemeDoesNotDefine` refuses any
|
||||
`BasedOn` a type the App's dictionaries hold no style for, and `ImportReviewRenderTests` measures the rendered rows.
|
||||
- [ ] **A style of the App's for a WPF UI control replaces the style that holds its template** (beta.23). WPF UI 4.3.0 gives
|
||||
its controls their templates in its own styles (`DefaultImageStyle`, …), applied only to a control with no style of its
|
||||
own: a local `<Style TargetType="ui:Image">` with no `BasedOn` leaves the control with no template, and it takes its
|
||||
place and draws nothing — the game page's cover was an empty space beside the name while the banner above it, with no
|
||||
style, drew (caught in a render before it shipped). Base it on WPF UI's (`BasedOn="{StaticResource DefaultImageStyle}"`).
|
||||
`AccessibilityTests.NoStyleOfAWpfUiControlLeavesOutItsTemplate`, `PagesLoadTests.TheGamePagesArtworkIsDrawn`.
|
||||
- [ ] **WPF UI's `CheckBox` is `MinWidth` 120 with an 11 px padding**: in a narrow grid column it draws a sliver of the box.
|
||||
`MinWidth="0" Padding="0"` there. A `DataGridCheckBoxColumn` uses WPF's own element style, an Aero2 box — use a template
|
||||
column (`AccessibilityTests.NoDataGridCheckBoxColumn`).
|
||||
|
||||
@@ -4374,7 +4374,7 @@ Each of these is referenced by an existing doc but specified nowhere.
|
||||
| ~~**Legal doc versioning**~~ | ~~FR-11 re-shows documents "when a document version increments". Nothing says where the current version lives, who writes `legal_acceptance.version`, or how the markdown is rendered in-app~~ **Answered 2026-09-14 (P3 PR-9):** the version is the document's own `**Version:**` line, read from the copy embedded in the App at build (`App.Services.LegalDocuments`); the App writes `legal_acceptance.version` on the one Accept and re-shows any document whose embedded version differs from its row; ~~the markdown is shown as text with authoring comments stripped, not rendered~~ the markdown is shown with authoring comments stripped and, since beta.12, rendered (`08_UI` §Menu, *Documents are rendered*; §First-run flow built note) | FR-11, `06_DATA_MODEL` |
|
||||
| **Accessibility / DPI** | NFR-9 states requirements; no design anywhere | NFR-9, `08_UI` |
|
||||
| **Uninstall / data deletion** | One Velopack clause. No in-app "delete all my data", despite the privacy position | `12_BUILD`, `legal/PRIVACY_POLICY.md` |
|
||||
| **Cover art** | Appears in the schema, the data directory and the UI; nothing says where it comes from or the licence position on downloaded store art | `06_DATA_MODEL`, `05_DETECTION` |
|
||||
| ~~**Cover art**~~ | ~~Appears in the schema, the data directory and the UI; nothing says where it comes from or the licence position on downloaded store art~~ **Answered 2026-10-14 (beta.23, owner decisions D60/D61):** from the user's own image (a copy in `covers\`) or what the Steam and GOG GALAXY apps already keep on this PC — nothing is downloaded, so no store art is redistributed or fetched; the art stays its owners' (`legal/TRADEMARKS.md`), the Privacy Policy 2.11 names the files read. `08_UI` §Games › Game detail. **Row closed** | `06_DATA_MODEL`, `05_DETECTION` |
|
||||
| **Tier-2 mechanism** *(was: PresentMon distribution)* | **By what mechanism does a shipped build reach a no-injection MEASUREMENT?** Nothing names one. Since 2026-08-28 the ladder is two rungs and Tier 2 is explicitly not a measurement — duration, sensors and the reason — so this row is no longer about degraded fidelity but about whether that capability returns at all. **It now owns TWO casualties, not one:** the frame-generation oracle §S31 spent four attempts looking for, and `14_TESTING`'s Tier-1 accuracy cross-check, struck the same day because it required a second instrument measuring the same frames. **One mechanism would restore both**, which is the strongest argument for costing it. Constraints on any answer: `README`'s capture-tier table and its **safety** row *"always a way out"*, `legal/DISCLAIMER.md` §73 and `legal/EULA.md` §33; ETW needs elevation whatever the tool; and `15_ROADMAP` has no v2 fallback either | `README`, `legal/DISCLAIMER.md`, `legal/EULA.md`, `04_CAPTURE`, `14_TESTING`, `15_ROADMAP` |
|
||||
|
||||
---
|
||||
|
||||
@@ -63,6 +63,15 @@ are kept because they record what each version changed and why (owner decision D
|
||||
>
|
||||
> Version 2.5 (2026-09-27, 0.1.0-beta.10) adds how a tracked game's window is shown — read from Windows — and the engine build name read from an Unreal Engine game's executable. It is also the first version to say two things the software already did: it reads the **content** of a library game's executable (markers in its first 8 MB and its import table, since the detection of engines and features; and, when a session starts, the graphics-library markers in the whole file), and it reads the processor load and the memory in use (since 0.1.0-beta.3). Nothing here leaves your device, as before.
|
||||
|
||||
### What version 2.11 of the Privacy Policy changed (0.1.0-beta.23)
|
||||
|
||||
A game's page shows its artwork (beta.23 PR-3, owner decisions D60/D61; the wording approved with the plan). §1 adds the
|
||||
images a user chooses for a game, kept as a copy in the data folder's `covers` folder and deleted when the store's image
|
||||
is chosen again or the game is removed with its sessions. §4 adds the cover and banner images the Steam and GOG GALAXY apps
|
||||
keep on the disk for a library game, read to show them on its page and never copied or sent, and says that Steam's and
|
||||
GOG GALAXY's lists of installed games are now also read when a game's page opens, to find that artwork. §2 is unchanged:
|
||||
nothing is downloaded, and the software still looks nothing up on any store. Nothing here leaves your device, as before.
|
||||
|
||||
### What version 2.10 of the Privacy Policy changed (0.1.0-beta.21)
|
||||
|
||||
§4 names the lists of installed games the Steam, GOG GALAXY, Epic Games and itch apps keep on the disk, and where GOG
|
||||
|
||||
@@ -11,7 +11,9 @@ nothing is uploaded. The only network requests are the update check and the upda
|
||||
|
||||
Your game library; your sessions — frame times when a game was measured, the statistics, your PC's sensors, the game's
|
||||
own memory use, how the game's window was shown; a short description of your hardware for each session; your tags and
|
||||
notes; your settings. The [Privacy Policy](../legal/PRIVACY_POLICY.md) lists all of it.
|
||||
notes; your settings; and, in the `covers` folder, a copy of each picture you chose for a game. The pictures the Steam and
|
||||
GOG GALAXY apps keep for your games are shown from where those apps keep them, never copied. The
|
||||
[Privacy Policy](../legal/PRIVACY_POLICY.md) lists all of it.
|
||||
|
||||
## How much is kept
|
||||
|
||||
@@ -21,7 +23,8 @@ in **Settings ▸ Recording ▸ Raw series kept per game** (0 keeps everything).
|
||||
## Back it up
|
||||
|
||||
**Tools ▸ Database maintenance… ▸ Back up…** writes a consistent copy of the database to a file you choose, even while
|
||||
a game is being recorded. Backing up is up to you — FrameLedger does not do it by itself.
|
||||
a game is being recorded. The pictures you chose for games are not in it: copy the data folder's `covers` folder too.
|
||||
Backing up is up to you — FrameLedger does not do it by itself.
|
||||
|
||||
## Delete it
|
||||
|
||||
|
||||
+6
-3
@@ -70,9 +70,12 @@ stopped, hooking turned off — each with one button that only says you have rea
|
||||
|
||||
## A game's page
|
||||
|
||||
- **At the top:** the name, publisher, version, store and engine, the `.exe` path, the last session, the last measured
|
||||
session's frame rate and its ray-tracing chips. **Play** starts the game: through the store that installed it, or
|
||||
directly — **Settings ▸ Games ▸ Play button** chooses. **Edit…** changes the name, publisher, version and notes. **Change
|
||||
- **At the top:** the game's picture — a banner and its cover, from the Steam or GOG GALAXY app on your PC or the image
|
||||
you chose — in a band that takes the picture's colour; then the name, publisher, version, store and engine, the `.exe`
|
||||
path, the last session, the last measured session's frame rate and its ray-tracing chips. A game with no picture shows
|
||||
none (**Settings ▸ Games** turns the picture and its colour off). **Play** starts the game: through the store that
|
||||
installed it, or directly — **Settings ▸ Games ▸ Play button** chooses. **Edit…** changes the name, publisher, version
|
||||
and notes, and the picture: **Choose image…** (kept as a copy once you save) or **Use the store's image**. **Change
|
||||
executable…** points the entry at another `.exe` and turns hooking back off; its file dialog opens in the game's own
|
||||
folder. **Remove…** asks whether to keep the game's sessions.
|
||||
- **Recording** — off, FrameLedger ignores the program completely: for a launcher or a tool that is not a game.
|
||||
|
||||
@@ -48,6 +48,8 @@ The link under them, *Read what the hook does and does not do*, opens the safety
|
||||
|
||||
| Setting | What it does | Default |
|
||||
|---|---|---|
|
||||
| **Show game artwork** | A game's page shows a picture of the game: the image you chose for it (**Edit…**), or else the cover and banner the Steam or GOG GALAXY app already keeps on your PC. Nothing is downloaded; a game from another store shows a picture only once you choose one. | On |
|
||||
| **Colour the game page from its artwork** | The band at the top of a game's page takes the picture's main colour — never so strongly that a text on it gets hard to read. Off, the band keeps the plain card colour. | On |
|
||||
| **Play button** | What **Play** does, on a game's page and on each game in the library. *Through the store*: Steam or the Epic Games Launcher starts the game, GOG GALAXY runs it, and the itch app asks which copy to launch — each store's app does what it does when you start a game from it. A game no store installed, and a GOG game without GOG GALAXY, is started by FrameLedger instead; so is every game while FrameLedger itself runs as administrator, so that the game does not. *Start directly*: FrameLedger's agent starts the game, recorded from its first frame, with your standard rights; it does not start a game whose recording is off, or one that asks to run as administrator. | Through the store |
|
||||
|
||||
## Window
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# FrameLedger — Privacy Policy
|
||||
|
||||
**Version:** 2.10 · **Effective:** {{RELEASE_DATE}}
|
||||
**Version:** 2.11 · **Effective:** {{RELEASE_DATE}}
|
||||
|
||||
**Short version: everything stays on your PC. FrameLedger has no accounts, no telemetry, no analytics, and never uploads your data anywhere.**
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
Stored in `%LOCALAPPDATA%\FrameLedger` on your device:
|
||||
|
||||
- Your game library entries (names, executable paths, metadata you or the app filled in, and whether each one is recorded).
|
||||
- Images you choose for a game (Edit…), copied into the `covers` folder; choosing the store's image again, or removing the game together with its sessions, deletes the copy. Artwork a store's app keeps on your PC is shown from where it is and not copied.
|
||||
- Performance sessions: frame timing series, computed statistics, hardware sensor series (temperatures, load, power, memory usage, and the graphics card's clock speeds, fan speed, memory temperature and whether its power limit or heat held it back), the game's own memory use (its dedicated and shared video memory, private working set, working set and commit, once a second), session duration, crash flags, the graphics driver's settings the game ran under (NVIDIA only), how the game's window was shown (full-screen, borderless or windowed, for how long, its size and the monitor's), tags and notes you write.
|
||||
- A hardware snapshot per session (CPU/GPU model, driver version, RAM size, OS build, display mode) used for the "what changed between sessions" feature.
|
||||
- App settings, logs (rotated daily — the app keeps 7 days, the capture agent 14 — including the logs written by the component loaded into games), and, after a crash of the app itself, crash dump files.
|
||||
@@ -41,7 +42,7 @@ An exported session (CSV or JSON) and a bug report can contain your games' names
|
||||
|
||||
## 4. What the app can technically observe
|
||||
|
||||
To do its job, FrameLedger observes: which of *your tracked* executables — the entries in your library whose recording is on — are running, and their process trees; the parameters your games pass to the graphics APIs it intercepts (presentation, upscaling, ray tracing, pipeline creation); the memory use of a tracked game's process — its dedicated and shared video memory, from Windows' GPU performance counters, and its working sets and commit, from Windows' process-memory information, for which a game it does not inject into is opened with the least access Windows offers and closed again (never its memory's content); loaded module names of a game being captured (for detection and for the anti-cheat safety check); the names of the files in each library game's install folder, the version information of its executable and of the upscaling libraries it ships, the content of its executable file (the markers of the engine and of the graphics libraries it carries, the libraries it imports, and the engine build name an Unreal Engine game carries), the version marks an engine keeps in its own files (Unity's player library and the header of its data file, the header of a Godot data pack, an RPG Maker game's title, core script and Game.ini, the library Game.ini names, and the version file of a Ren'Py game's engine), and the store files that name it (Steam's and GOG's, on your disk) — to detect its engine, its engine version and its features and to check it for anti-cheat before any injection is possible; the lists of installed games that the Steam, GOG GALAXY, Epic Games and itch apps keep on your disk, and where GOG GALAXY is installed — read when you import your library and when you press Play, to find the store that installed a game and hand the game to that store's app; the size, position and state of a tracked game's window and the monitor it is on, read from Windows and not from the game, and — for a game FrameLedger injects into — whether the game asked for exclusive full-screen; the NVIDIA driver's settings for your tracked executables (read only: the DLSS and frame-generation overrides the NVIDIA App set); hardware sensor values from your graphics driver's own libraries; how busy the processor is and how much memory is in use, from Windows' own counters; the crash reports Windows keeps in its Application log about a tracked game's executable while it ran (to tell a crash from an ordinary exit — the reports are read, never sent anywhere); and the names of the programs a tracked game starts, so that a game's own crash reporter is recognised.
|
||||
To do its job, FrameLedger observes: which of *your tracked* executables — the entries in your library whose recording is on — are running, and their process trees; the parameters your games pass to the graphics APIs it intercepts (presentation, upscaling, ray tracing, pipeline creation); the memory use of a tracked game's process — its dedicated and shared video memory, from Windows' GPU performance counters, and its working sets and commit, from Windows' process-memory information, for which a game it does not inject into is opened with the least access Windows offers and closed again (never its memory's content); loaded module names of a game being captured (for detection and for the anti-cheat safety check); the names of the files in each library game's install folder, the version information of its executable and of the upscaling libraries it ships, the content of its executable file (the markers of the engine and of the graphics libraries it carries, the libraries it imports, and the engine build name an Unreal Engine game carries), the version marks an engine keeps in its own files (Unity's player library and the header of its data file, the header of a Godot data pack, an RPG Maker game's title, core script and Game.ini, the library Game.ini names, and the version file of a Ren'Py game's engine), and the store files that name it (Steam's and GOG's, on your disk) — to detect its engine, its engine version and its features and to check it for anti-cheat before any injection is possible; the lists of installed games that the Steam, GOG GALAXY, Epic Games and itch apps keep on your disk, and where GOG GALAXY is installed — read when you import your library and when you press Play, to find the store that installed a game and hand the game to that store's app — Steam's and GOG GALAXY's also when you open a game's page, to find the artwork their apps keep for it; the cover and banner images that the Steam and GOG GALAXY apps keep on your disk for a game in your library — read to show them on its page, never copied or sent anywhere; the size, position and state of a tracked game's window and the monitor it is on, read from Windows and not from the game, and — for a game FrameLedger injects into — whether the game asked for exclusive full-screen; the NVIDIA driver's settings for your tracked executables (read only: the DLSS and frame-generation overrides the NVIDIA App set); hardware sensor values from your graphics driver's own libraries; how busy the processor is and how much memory is in use, from Windows' own counters; the crash reports Windows keeps in its Application log about a tracked game's executable while it ran (to tell a crash from an ordinary exit — the reports are read, never sent anywhere); and the names of the programs a tracked game starts, so that a game's own crash reporter is recognised.
|
||||
|
||||
It does **not** read game memory outside those API parameters, and does not read game saves, chat, input content, network traffic, or anything unrelated to performance measurement. It records only for programs you added to your library and did not switch recording off for — a program whose recording is off is not watched at all — and injects only into games you individually enabled.
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ Any proposal to add a vendor SDK must first pass the checklist in `docs/18_GPU_V
|
||||
|---|---|---|
|
||||
| **PawnIO** | Optional kernel driver required by LibreHardwareMonitor for CPU/motherboard sensors; installed separately by the user from <https://pawnio.eu/> | Its own license and signing; not distributed by FrameLedger |
|
||||
| Windows ETW, DXGI, Event Log | OS facilities | Microsoft Windows license |
|
||||
| Steam / GOG Galaxy / Epic Games Launcher / itch.io | Local manifest files read for library import | Respective platform terms; read-only local access |
|
||||
| Steam / GOG Galaxy / Epic Games Launcher / itch.io | Local manifest files read for library import and Play; the artwork the Steam and GOG Galaxy apps keep on disk, shown on a game's page (beta.23) | Respective platform terms; read-only local access, nothing copied or downloaded |
|
||||
|
||||
## Trademarks
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ companies, by any game's developer or publisher, or by any anti-cheat vendor, an
|
||||
into a game protected by them; the list says nothing else about them.
|
||||
- The games named in `docs/LIST_GAME_TESTED.md` are games the developer ran FrameLedger with, on one machine; the list is
|
||||
not a benchmark claim and not a recommendation.
|
||||
- **A game's artwork belongs to its owners.** FrameLedger ships none and downloads none: a game's page shows the image you
|
||||
chose for it, or the cover and banner the Steam or GOG GALAXY app already keeps on your PC, read from where that app
|
||||
keeps it and never copied (since 0.1.0-beta.23).
|
||||
|
||||
## The name FrameLedger
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using FrameLedger.Application.Import;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Application.Settings;
|
||||
using FrameLedger.Application.Watch;
|
||||
using FrameLedger.Infrastructure.Art;
|
||||
using FrameLedger.Infrastructure.Diagnostics;
|
||||
using FrameLedger.Infrastructure.Import;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
@@ -112,10 +113,7 @@ public partial class App : System.Windows.Application
|
||||
Log.Information("ui: started ({Version}), ledger {Ledger}", UiIdentity.Version, UiPaths.Database);
|
||||
// beta.21: tier 0 is software rendering (a VM without a GPU, Remote Desktop) - every scroll drawn on the CPU.
|
||||
Log.Information("ui: render tier {Tier} (2 = the GPU draws; 0 = software)", System.Windows.Media.RenderCapability.Tier >> 16);
|
||||
if (UiPaths.IsViewer)
|
||||
{
|
||||
Log.Warning("ui: a VIEWER over {Folder} (--data-dir, D52): no Agent is started or contacted, nothing on this PC is changed", UiPaths.DataDirectory);
|
||||
}
|
||||
NoteTheFolder(_host);
|
||||
|
||||
// A second start of the App hands over to this one: bring the window forward, from the tray too.
|
||||
if (Instance is not null)
|
||||
@@ -209,6 +207,41 @@ public partial class App : System.Windows.Application
|
||||
Shutdown(exitCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A viewer says what it is (D52); the App over its own folder tidies its covers (beta.23, D60) — the images no row names
|
||||
/// any more, a game deleted or removed by the agent (D55) — in the background.
|
||||
/// </summary>
|
||||
private static void NoteTheFolder(IHost host)
|
||||
{
|
||||
if (UiPaths.IsViewer)
|
||||
{
|
||||
Log.Warning("ui: a VIEWER over {Folder} (--data-dir, D52): no Agent is started or contacted, nothing on this PC is changed", UiPaths.DataDirectory);
|
||||
return;
|
||||
}
|
||||
|
||||
_ = PruneCoversAsync(host.Services.GetRequiredService<CoverStore>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (D60): deletes the chosen images no row names any more, on the thread pool; a failure is logged and nothing
|
||||
/// else — the images are a convenience, never a reason for the App to stop.
|
||||
/// </summary>
|
||||
private static async Task PruneCoversAsync(CoverStore covers)
|
||||
{
|
||||
try
|
||||
{
|
||||
int deleted = await Task.Run(() => covers.PruneAsync()).ConfigureAwait(false);
|
||||
if (deleted > 0)
|
||||
{
|
||||
Log.Information("art: {Count} image(s) no game names any more deleted from {Folder}", deleted, covers.Folder);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning(ex, "art: the covers folder could not be tidied");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits for a stop request ON the dispatcher, and stops nothing: <see cref="TearDownAsync"/> stops the host once,
|
||||
/// from the UI thread. <c>WaitForShutdownAsync</c> resumed on the thread pool (it awaits with
|
||||
@@ -440,6 +473,19 @@ public partial class App : System.Windows.Application
|
||||
// beta.11: the Games page on screen reloads when an import adds games (navigating to itself does nothing).
|
||||
services.AddSingleton<LibraryChanges>();
|
||||
services.AddSingleton<ImportLibraryFlow>();
|
||||
|
||||
// beta.23 (owner decisions D60/D61): a game's artwork — the image the user chose (kept in the data folder's covers),
|
||||
// else what the Steam and GOG GALAXY apps keep on this PC, found through the same store records Play reads.
|
||||
services.AddSingleton<Application.Art.IStoreArtCache>(static _ => new SteamArtCache());
|
||||
services.AddSingleton<Application.Art.IStoreArtCache>(static _ => new GogArtCache());
|
||||
services.AddSingleton(static sp => new StoreRecordsReader(sp.GetServices<IStoreLibrarySource>()));
|
||||
services.AddSingleton(static sp => new GameArt(
|
||||
sp.GetRequiredService<Application.Settings.RegisteredSettings>(),
|
||||
sp.GetRequiredService<StoreRecordsReader>(),
|
||||
sp.GetServices<Application.Art.IStoreArtCache>(),
|
||||
sp.GetRequiredService<UiMode>()));
|
||||
services.AddSingleton(static sp => new CoverStore(sp.GetRequiredService<UiMode>(), sp.GetRequiredService<IGameRepository>()));
|
||||
services.AddSingleton<IImagePicker, ImagePicker>();
|
||||
}
|
||||
|
||||
/// <summary><c>10_LOGGING</c> §Serilog configuration: <c>logs/ui-.log</c>, daily, 7 kept, 10 MB, the one template; the level follows <c>log.debug</c> at runtime.</summary>
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// The colour of the game page's artwork band (beta.23, owner decision D61), set on its <see cref="Border"/>: nothing at all
|
||||
/// while the game shows no artwork — the page is as it was —, the card's own fill when it shows some untinted (the option is
|
||||
/// off, the picture has no colour, the system's high-contrast mode is on), and otherwise the picture's dominant colour over
|
||||
/// that fill at the strongest opacity (at most 30 % on a dark theme, 22 % on a light one) at which every text the header
|
||||
/// shows still reads — primary and secondary text 4.5:1, tertiary 3:1, the pills' and the warning's text 4.5:1 on their
|
||||
/// fills (<see cref="ColorMath.Tint"/>).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The second colour the App works out rather than takes from the theme, after the chart palettes (<c>08_UI</c> §Contrast).
|
||||
/// It follows a theme switch through a resource reference on the band itself — a private attached property bound to
|
||||
/// <c>ApplicationBackgroundColor</c>, whose change recomputes it — never through <c>ApplicationThemeManager.Changed</c>:
|
||||
/// only <c>ApplicationThemeManager.Apply</c> raises that, and the tests switch themes by replacing the theme dictionary.
|
||||
/// </remarks>
|
||||
public static class ArtTint
|
||||
{
|
||||
public static readonly DependencyProperty ShowsArtProperty = DependencyProperty.RegisterAttached(
|
||||
"ShowsArt", typeof(bool), typeof(ArtTint), new PropertyMetadata(false, OnChanged));
|
||||
|
||||
public static readonly DependencyProperty ColorProperty = DependencyProperty.RegisterAttached(
|
||||
"Color", typeof(Color?), typeof(ArtTint), new PropertyMetadata(null, OnChanged));
|
||||
|
||||
// The theme, heard through a resource reference on the band (set the first time either property above changes).
|
||||
private static readonly DependencyProperty _themeProperty = DependencyProperty.RegisterAttached(
|
||||
"Theme", typeof(object), typeof(ArtTint), new PropertyMetadata(null, OnChanged));
|
||||
|
||||
private static readonly string[] _keys = ["ApplicationBackgroundColor", "CardBackgroundFillColorDefault", "TextFillColorPrimary",
|
||||
"TextFillColorSecondary", "TextFillColorTertiary", "ControlFillColorDefault", "SystemFillColorCautionBackground"];
|
||||
|
||||
/// <summary>The banner's fade into the band: opaque for its upper half, transparent at its foot — alpha only.</summary>
|
||||
public static Brush Fade { get; } = CreateFade();
|
||||
|
||||
public static bool GetShowsArt(DependencyObject element) => (bool)(element ?? throw new ArgumentNullException(nameof(element))).GetValue(ShowsArtProperty);
|
||||
|
||||
public static void SetShowsArt(DependencyObject element, bool value) => (element ?? throw new ArgumentNullException(nameof(element))).SetValue(ShowsArtProperty, value);
|
||||
|
||||
public static Color? GetColor(DependencyObject element) => (Color?)(element ?? throw new ArgumentNullException(nameof(element))).GetValue(ColorProperty);
|
||||
|
||||
public static void SetColor(DependencyObject element, Color? value) => (element ?? throw new ArgumentNullException(nameof(element))).SetValue(ColorProperty, value);
|
||||
|
||||
/// <summary>The band's colour for the theme its resources hold now, or null for the card's own fill.</summary>
|
||||
internal static Color? BandColour(FrameworkElement element, Color dominant)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(element);
|
||||
Color?[] c = [.. _keys.Select(k => ColourOf(element.TryFindResource(k)))];
|
||||
if (c.Any(static x => x is null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Color background = ColorMath.Over(c[1]!.Value, c[0]!.Value);
|
||||
ColorMath.Pair[] pairs =
|
||||
[
|
||||
new(c[2]!.Value, null, 4.5),
|
||||
new(c[3]!.Value, null, 4.5),
|
||||
new(c[4]!.Value, null, 3.0),
|
||||
new(c[3]!.Value, c[5], 4.5),
|
||||
new(c[2]!.Value, c[6], 4.5),
|
||||
];
|
||||
|
||||
// A dark theme's text is light: the band may take more colour before the light text stops reading.
|
||||
bool dark = ColorMath.Luminance(background) < 0.18;
|
||||
return ColorMath.Tint(background, dominant, pairs, dark ? 0.30 : 0.22);
|
||||
}
|
||||
|
||||
private static void OnChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not Border band)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Property != _themeProperty && band.ReadLocalValue(_themeProperty) == DependencyProperty.UnsetValue)
|
||||
{
|
||||
band.SetResourceReference(_themeProperty, "ApplicationBackgroundColor");
|
||||
}
|
||||
|
||||
Apply(band);
|
||||
}
|
||||
|
||||
private static void Apply(Border band)
|
||||
{
|
||||
if (!GetShowsArt(band))
|
||||
{
|
||||
band.ClearValue(Border.BackgroundProperty);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetColor(band) is { } dominant && !SystemParameters.HighContrast && BandColour(band, dominant) is { } colour)
|
||||
{
|
||||
var brush = new SolidColorBrush(colour);
|
||||
brush.Freeze();
|
||||
band.Background = brush;
|
||||
return;
|
||||
}
|
||||
|
||||
band.SetResourceReference(Border.BackgroundProperty, "CardBackgroundFillColorDefaultBrush");
|
||||
}
|
||||
|
||||
private static LinearGradientBrush CreateFade()
|
||||
{
|
||||
var fade = new LinearGradientBrush { StartPoint = new Point(0, 0), EndPoint = new Point(0, 1) };
|
||||
fade.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 0));
|
||||
fade.GradientStops.Add(new GradientStop(Color.FromArgb(255, 0, 0, 0), 0.55));
|
||||
fade.GradientStops.Add(new GradientStop(Color.FromArgb(0, 0, 0, 0), 1));
|
||||
fade.Freeze();
|
||||
return fade;
|
||||
}
|
||||
|
||||
private static Color? ColourOf(object? resource) => resource switch
|
||||
{
|
||||
Color colour => colour,
|
||||
SolidColorBrush brush => brush.Color,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
@@ -46,5 +46,36 @@
|
||||
|
||||
<ui:TextBlock Style="{StaticResource SecondaryText}" Text="{x:Static vm:EditGameViewModel.NotesLabel}" />
|
||||
<ui:TextBox Margin="0,4,0,0" MinHeight="72" AutomationProperties.Name="{x:Static vm:EditGameViewModel.NotesLabel}" AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding Notes, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<!-- beta.23 (D60): the game's image — the user's own, copied on Save, or the store's; a preview here, nothing written before Save. -->
|
||||
<StackPanel Margin="0,12,0,0" Visibility="{Binding ImageEditable, Converter={StaticResource BoolToVis}}">
|
||||
<ui:TextBlock Style="{StaticResource SecondaryText}" Text="{x:Static vm:EditGameViewModel.ImageLabel}" />
|
||||
<Grid Margin="0,4,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Width="64" Height="96" CornerRadius="4" Background="{DynamicResource ControlFillColorDefaultBrush}">
|
||||
<Grid>
|
||||
<ui:TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource TertiaryText}" FontTypography="Caption" TextAlignment="Center" TextWrapping="Wrap"
|
||||
Text="{x:Static vm:EditGameViewModel.ImageNoneText}"
|
||||
Visibility="{Binding HasImagePreview, Converter={StaticResource InverseBoolToVis}}" />
|
||||
<ui:Image CornerRadius="4" Stretch="UniformToFill" Source="{Binding ImagePreview}" RenderOptions.BitmapScalingMode="HighQuality"
|
||||
AutomationProperties.Name="{x:Static vm:EditGameViewModel.CoverName}"
|
||||
Visibility="{Binding HasImagePreview, Converter={StaticResource BoolToVis}}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<StackPanel Grid.Column="1" Margin="12,0,0,0" VerticalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ui:Button Command="{Binding ChooseImageCommand}" Content="{x:Static vm:EditGameViewModel.ChooseImageText}" Icon="{ui:SymbolIcon Image24}" />
|
||||
<ui:Button Margin="8,0,0,0" Appearance="Secondary" Command="{Binding UseStoreImageCommand}" Content="{x:Static vm:EditGameViewModel.UseStoreImageText}"
|
||||
Visibility="{Binding CanUseStoreImage, Converter={StaticResource BoolToVis}}" />
|
||||
</StackPanel>
|
||||
<ui:TextBlock Margin="0,6,0,0" MaxWidth="300" HorizontalAlignment="Left" Style="{StaticResource TertiaryText}" TextWrapping="Wrap" Text="{x:Static vm:EditGameViewModel.ImageNote}" />
|
||||
<ui:TextBlock Margin="0,4,0,0" MaxWidth="300" HorizontalAlignment="Left" Style="{StaticResource SecondaryText}" TextWrapping="Wrap" Text="{Binding ImageError}"
|
||||
Visibility="{Binding ImageError, Converter={StaticResource NullToCollapsed}}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -25,13 +25,67 @@
|
||||
Text="{x:Static vm:GameDetailViewModel.NotFoundText}"
|
||||
Visibility="{Binding ViewModel.NotFound, Converter={StaticResource BoolToVis}}" />
|
||||
|
||||
<!-- header -->
|
||||
<Grid Margin="0,8,0,0">
|
||||
<!--
|
||||
header. beta.23 (owner decisions D60/D61): the game's artwork — the image the user chose, else what Steam's or GOG
|
||||
GALAXY's app keeps on this PC — as a banner above and a cover beside the name, in a band that takes the
|
||||
artwork's colour as far as every text on it stays readable (Controls/ArtTint). No text is ever drawn on a
|
||||
picture. A game with no artwork shows no band, and the header is as it was.
|
||||
-->
|
||||
<Border x:Name="ArtBand" Margin="0,8,0,0" CornerRadius="8"
|
||||
controls:ArtTint.ShowsArt="{Binding ViewModel.HasArt}"
|
||||
controls:ArtTint.Color="{Binding ViewModel.ArtTint}">
|
||||
<Border.Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ViewModel.HasArt}" Value="True">
|
||||
<Setter Property="Padding" Value="0,0,0,16" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<StackPanel>
|
||||
<!-- The banner: as tall as its proportions make it at this width, no taller than 240, fading into the band (its mask is set in code). -->
|
||||
<ui:Image x:Name="Hero" MaxHeight="240" CornerRadius="8,8,0,0" Stretch="UniformToFill" Source="{Binding ViewModel.ArtHero}" RenderOptions.BitmapScalingMode="HighQuality"
|
||||
AutomationProperties.Name="{x:Static res:Strings.Art_Banner_Name}" ToolTip="{Binding ViewModel.ArtSource}"
|
||||
Visibility="{Binding ViewModel.ArtHero, Converter={StaticResource NullToCollapsed}}" />
|
||||
<Grid>
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ViewModel.HasArt}" Value="True">
|
||||
<Setter Property="Margin" Value="16,16,16,0" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<!--
|
||||
The cover: portrait, or the store's landscape header when it keeps no portrait. Its style is based on WPF UI's
|
||||
DefaultImageStyle, which holds the template: a ui:Image with a Style of its own and no template draws nothing.
|
||||
-->
|
||||
<ui:Image Grid.Column="0" Margin="0,0,16,0" VerticalAlignment="Top" CornerRadius="6" Stretch="UniformToFill" Source="{Binding ViewModel.ArtCover}" RenderOptions.BitmapScalingMode="HighQuality"
|
||||
AutomationProperties.Name="{x:Static res:Strings.Art_Cover_Name}" ToolTip="{Binding ViewModel.ArtSource}"
|
||||
Visibility="{Binding ViewModel.ArtCover, Converter={StaticResource NullToCollapsed}}">
|
||||
<ui:Image.Style>
|
||||
<Style TargetType="ui:Image" BasedOn="{StaticResource DefaultImageStyle}">
|
||||
<Setter Property="Width" Value="120" />
|
||||
<Setter Property="Height" Value="180" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ViewModel.ArtCoverIsLandscape}" Value="True">
|
||||
<Setter Property="Width" Value="230" />
|
||||
<Setter Property="Height" Value="107" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ui:Image.Style>
|
||||
</ui:Image>
|
||||
<StackPanel Grid.Column="1">
|
||||
<ui:TextBlock FontTypography="Title" Text="{Binding ViewModel.Name}" />
|
||||
<ui:TextBlock Style="{StaticResource SecondaryText}" Text="{Binding ViewModel.Subtitle}" />
|
||||
<ui:TextBlock Style="{StaticResource TertiaryText}" TextTrimming="CharacterEllipsis" Text="{Binding ViewModel.ExecutableText}" ToolTip="{Binding ViewModel.ExecutableText}" />
|
||||
@@ -56,7 +110,7 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<!-- beta.21 (D59): Play, through the store that installed the game or started directly (Settings ▸ Games). -->
|
||||
<ui:Button Margin="0,0,8,0" Appearance="Primary" Command="{Binding ViewModel.PlayCommand}" Content="{x:Static vm:GameDetailViewModel.PlayText}"
|
||||
Icon="{ui:SymbolIcon Play24}" IsEnabled="{Binding ViewModel.ActsOnThisPc}" ToolTip="{Binding ViewModel.PlayToolTip}" />
|
||||
@@ -65,6 +119,8 @@
|
||||
<ui:Button Appearance="Danger" Command="{Binding ViewModel.RemoveCommand}" Content="{x:Static vm:GameDetailViewModel.RemoveText}" Icon="{ui:SymbolIcon Delete24}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- the two rows, clearly separated (05_DETECTION §Capability hints) -->
|
||||
<Grid Margin="0,20,0,0">
|
||||
|
||||
@@ -15,6 +15,9 @@ public partial class GameDetailPage : INavigableView<GameDetailViewModel>
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
|
||||
// beta.23 (D60): the banner fades into the band below it — an alpha mask, set here because it is no theme colour.
|
||||
Hero.OpacityMask = Controls.ArtTint.Fade;
|
||||
ViewModel.SelectionPresented += OnSelectionPresented;
|
||||
ViewModel.TrendPresented += OnTrendPresented;
|
||||
Overview.SessionClicked += OnOverviewClicked;
|
||||
|
||||
@@ -316,6 +316,27 @@
|
||||
SelectedValue="{Binding ViewModel.PlayMode, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
<!-- beta.23 (owner decisions D60/D61): a game page's artwork — local files only, nothing downloaded — and its colour. -->
|
||||
<ui:CardControl Margin="0,8,0,0" Icon="{ui:SymbolIcon Image24}">
|
||||
<ui:CardControl.Header>
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_GameArt_Label}" />
|
||||
<ui:TextBlock MaxWidth="520" HorizontalAlignment="Left" Style="{StaticResource SecondaryText}" TextWrapping="Wrap"
|
||||
Text="{x:Static res:Strings.Settings_GameArt_Body}" />
|
||||
</StackPanel>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_GameArt_Label}" IsChecked="{Binding ViewModel.GameArt, Mode=TwoWay}" />
|
||||
</ui:CardControl>
|
||||
<ui:CardControl Margin="0,8,0,0" Icon="{ui:SymbolIcon ColorBackground24}" IsEnabled="{Binding ViewModel.GameArt}">
|
||||
<ui:CardControl.Header>
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_GameArtTint_Label}" />
|
||||
<ui:TextBlock MaxWidth="520" HorizontalAlignment="Left" Style="{StaticResource SecondaryText}" TextWrapping="Wrap"
|
||||
Text="{x:Static res:Strings.Settings_GameArtTint_Body}" />
|
||||
</StackPanel>
|
||||
</ui:CardControl.Header>
|
||||
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_GameArtTint_Label}" IsChecked="{Binding ViewModel.GameArtTint, Mode=TwoWay}" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Window_Header}" />
|
||||
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Power24}">
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The arithmetic of the game page's artwork tint (beta.23, owner decision D61): WCAG 2.1's relative luminance and contrast
|
||||
/// ratio, source-over compositing, an artwork's dominant colour, and the strongest tint that keeps every text pair the
|
||||
/// header shows readable. The tests check it with their own, separate copy of the WCAG formulas (<c>Wcag</c>), so a mistake
|
||||
/// here cannot also be the check's.
|
||||
/// </summary>
|
||||
internal static class ColorMath
|
||||
{
|
||||
/// <summary>A text pair the tint must keep readable: the text's colour, an optional fill under it (a pill), and the ratio it needs.</summary>
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
internal readonly record struct Pair(Color Text, Color? Fill, double Minimum);
|
||||
|
||||
/// <summary>WCAG 2.1 relative luminance of an opaque colour.</summary>
|
||||
public static double Luminance(Color c)
|
||||
{
|
||||
static double Channel(byte v)
|
||||
{
|
||||
double s = v / 255.0;
|
||||
return s <= 0.03928 ? s / 12.92 : Math.Pow((s + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
return (0.2126 * Channel(c.R)) + (0.7152 * Channel(c.G)) + (0.0722 * Channel(c.B));
|
||||
}
|
||||
|
||||
/// <summary>WCAG 2.1 contrast ratio between two opaque colours.</summary>
|
||||
public static double Contrast(Color a, Color b)
|
||||
{
|
||||
double la = Luminance(a);
|
||||
double lb = Luminance(b);
|
||||
return (Math.Max(la, lb) + 0.05) / (Math.Min(la, lb) + 0.05);
|
||||
}
|
||||
|
||||
/// <summary>Source-over: <paramref name="top"/>, with its own alpha, on an opaque <paramref name="under"/>.</summary>
|
||||
public static Color Over(Color top, Color under)
|
||||
{
|
||||
double a = top.A / 255.0;
|
||||
return Color.FromRgb(
|
||||
(byte)Math.Round((top.R * a) + (under.R * (1 - a))),
|
||||
(byte)Math.Round((top.G * a) + (under.G * (1 - a))),
|
||||
(byte)Math.Round((top.B * a) + (under.B * (1 - a))));
|
||||
}
|
||||
|
||||
/// <summary><paramref name="colour"/> laid over <paramref name="under"/> at <paramref name="alpha"/> (0–1), opaque.</summary>
|
||||
public static Color Mix(Color under, Color colour, double alpha) =>
|
||||
Over(Color.FromArgb((byte)Math.Round(Math.Clamp(alpha, 0, 1) * 255), colour.R, colour.G, colour.B), under);
|
||||
|
||||
/// <summary>
|
||||
/// The colour an artwork reads as, from its pixels (BGRA, 8 bits each): the hue that carries the most of its vivid pixels —
|
||||
/// each weighted by its saturation and brightness, near-black and near-white ones not counted — averaged over the pixels of
|
||||
/// that hue and its two neighbours. Null for an image with nothing vivid in it (grey, black and white, a dark poster):
|
||||
/// such an image tints nothing.
|
||||
/// </summary>
|
||||
public static Color? Dominant(ReadOnlySpan<byte> bgra)
|
||||
{
|
||||
const int hues = 36;
|
||||
Span<double> weight = stackalloc double[hues];
|
||||
Span<double> r = stackalloc double[hues];
|
||||
Span<double> g = stackalloc double[hues];
|
||||
Span<double> b = stackalloc double[hues];
|
||||
double total = 0;
|
||||
int pixels = 0;
|
||||
for (int i = 0; i + 3 < bgra.Length; i += 4)
|
||||
{
|
||||
if (bgra[i + 3] < 128)
|
||||
{
|
||||
continue; // transparent: not part of the picture
|
||||
}
|
||||
|
||||
pixels++;
|
||||
(double h, double s, double v) = Hsv(bgra[i + 2], bgra[i + 1], bgra[i]);
|
||||
if (v < 0.15 || s < 0.15)
|
||||
{
|
||||
continue; // near-black, or grey and near-white: no colour to give
|
||||
}
|
||||
|
||||
double w = s * v;
|
||||
int bin = Math.Min(hues - 1, (int)(h / 360.0 * hues));
|
||||
weight[bin] += w;
|
||||
r[bin] += bgra[i + 2] * w;
|
||||
g[bin] += bgra[i + 1] * w;
|
||||
b[bin] += bgra[i] * w;
|
||||
total += w;
|
||||
}
|
||||
|
||||
// Fewer than a twentieth of the picture's pixels' worth of colour: it is a grey picture with a few coloured specks.
|
||||
return pixels == 0 || total < pixels * 0.05 ? null : AverageAroundHeaviest(weight, r, g, b);
|
||||
}
|
||||
|
||||
/// <summary>The weighted average colour of the heaviest hue and its two neighbours.</summary>
|
||||
private static Color AverageAroundHeaviest(ReadOnlySpan<double> weight, ReadOnlySpan<double> r, ReadOnlySpan<double> g, ReadOnlySpan<double> b)
|
||||
{
|
||||
int hues = weight.Length;
|
||||
int best = 0;
|
||||
double bestWeight = -1;
|
||||
for (int bin = 0; bin < hues; bin++)
|
||||
{
|
||||
double around = weight[bin] + weight[(bin + 1) % hues] + weight[(bin + hues - 1) % hues];
|
||||
if (around > bestWeight)
|
||||
{
|
||||
bestWeight = around;
|
||||
best = bin;
|
||||
}
|
||||
}
|
||||
|
||||
double sw = 0;
|
||||
double sr = 0;
|
||||
double sg = 0;
|
||||
double sb = 0;
|
||||
foreach (int bin in new[] { (best + hues - 1) % hues, best, (best + 1) % hues })
|
||||
{
|
||||
sw += weight[bin];
|
||||
sr += r[bin];
|
||||
sg += g[bin];
|
||||
sb += b[bin];
|
||||
}
|
||||
|
||||
return Color.FromRgb((byte)Math.Round(sr / sw), (byte)Math.Round(sg / sw), (byte)Math.Round(sb / sw));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The band's colour: <paramref name="dominant"/> over <paramref name="background"/> at the largest opacity, at most
|
||||
/// <paramref name="maxAlpha"/>, at which every pair in <paramref name="pairs"/> still reads at its minimum — tried from
|
||||
/// <paramref name="maxAlpha"/> down in steps of one hundredth, because the luminance of a mix need not move one way as it
|
||||
/// deepens. The background itself when even the faintest tint would cost a pair its contrast.
|
||||
/// </summary>
|
||||
public static Color Tint(Color background, Color dominant, IReadOnlyList<Pair> pairs, double maxAlpha)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(pairs);
|
||||
for (int step = (int)Math.Round(Math.Clamp(maxAlpha, 0, 1) * 100); step > 0; step--)
|
||||
{
|
||||
Color band = Mix(background, dominant, step / 100.0);
|
||||
if (pairs.All(p => Reads(p, band)))
|
||||
{
|
||||
return band;
|
||||
}
|
||||
}
|
||||
|
||||
return background;
|
||||
}
|
||||
|
||||
/// <summary>Whether <paramref name="pair"/> reads at its minimum on <paramref name="band"/>.</summary>
|
||||
public static bool Reads(Pair pair, Color band)
|
||||
{
|
||||
Color under = pair.Fill is { } fill ? Over(fill, band) : band;
|
||||
return Contrast(Over(pair.Text, under), under) >= pair.Minimum;
|
||||
}
|
||||
|
||||
private static (double H, double S, double V) Hsv(byte red, byte green, byte blue)
|
||||
{
|
||||
double r = red / 255.0;
|
||||
double g = green / 255.0;
|
||||
double b = blue / 255.0;
|
||||
double max = Math.Max(r, Math.Max(g, b));
|
||||
double min = Math.Min(r, Math.Min(g, b));
|
||||
double delta = max - min;
|
||||
double h = delta == 0 ? 0
|
||||
: max == r ? 60 * (((g - b) / delta) % 6)
|
||||
: max == g ? 60 * (((b - r) / delta) + 2)
|
||||
: 60 * (((r - g) / delta) + 4);
|
||||
if (h < 0)
|
||||
{
|
||||
h += 360;
|
||||
}
|
||||
|
||||
return (h, max == 0 ? 0 : delta / max, max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The images users choose for their games (beta.23, owner decision D60), kept in the data folder's <c>covers</c> folder as
|
||||
/// <c>game-<id>-<unix ms>.png</c> — a copy, re-encoded and no larger than 1200 pixels a side, so the user's own
|
||||
/// file can move or go — and named in <c>games.cover_path</c> relative to the data folder (<c>covers\…</c>), so a copied data
|
||||
/// folder still finds them. Each choice is a new name: a replaced image is never written over while it is shown, and the old
|
||||
/// file goes once the row names the new one.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <b>A row's <c>cover_path</c> is followed only when it is one of these names</b>, in the folder itself and never through a
|
||||
/// junction or a symbolic link. A viewer (D52) opens a copy of a ledger that may have come from anywhere, and a path read
|
||||
/// from it — rooted, a share (<c>\\host\…</c>, which would make Windows offer this user's credentials to that host), or
|
||||
/// <c>..</c> out of the folder — is never opened.
|
||||
/// </remarks>
|
||||
public sealed class CoverStore
|
||||
{
|
||||
public const string FolderName = "covers";
|
||||
private const int _largestSide = 1200;
|
||||
private static readonly TimeSpan _leftoverAfter = TimeSpan.FromHours(1);
|
||||
|
||||
private readonly string _dataDirectory;
|
||||
private readonly IGameRepository _games;
|
||||
private readonly TimeProvider _clock;
|
||||
|
||||
public CoverStore(UiMode mode, IGameRepository games, TimeProvider? clock = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(mode);
|
||||
_dataDirectory = mode.DataDirectory;
|
||||
_games = games ?? throw new ArgumentNullException(nameof(games));
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
public string Folder => Path.Combine(_dataDirectory, FolderName);
|
||||
|
||||
/// <summary>The full path of the image <paramref name="coverPath"/> names, when it is one of ours and is there; null otherwise.</summary>
|
||||
public static string? Resolve(string dataDirectory, string? coverPath)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(dataDirectory);
|
||||
if (string.IsNullOrWhiteSpace(coverPath) || Path.IsPathRooted(coverPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] parts = coverPath.Split('\\', '/');
|
||||
if (parts.Length != 2 || !string.Equals(parts[0], FolderName, StringComparison.OrdinalIgnoreCase) || ParseName(parts[1]) is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Nor through a link, the folder's or the file's: the folder is looked at before anything under it is touched.
|
||||
var folder = new DirectoryInfo(Path.GetFullPath(Path.Combine(dataDirectory, FolderName)));
|
||||
var file = new FileInfo(Path.GetFullPath(Path.Combine(folder.FullName, parts[1])));
|
||||
return string.Equals(file.DirectoryName, folder.FullName, StringComparison.OrdinalIgnoreCase)
|
||||
&& folder.Exists && !IsLink(folder) && file.Exists && !IsLink(file)
|
||||
? file.FullName
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether <paramref name="entry"/> is a link to another place — a junction or a symbolic link, which could lead anywhere,
|
||||
/// a share included. Other reparse points (a OneDrive file, a deduplicated one) are the entry itself.
|
||||
/// </summary>
|
||||
private static bool IsLink(FileSystemInfo entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return entry.LinkTarget is not null;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The game id an image's file name carries — <c>game-<id>-<unix ms>.png</c> — or null for any other name.</summary>
|
||||
internal static long? ParseName(string name)
|
||||
{
|
||||
if (!name.StartsWith("game-", StringComparison.Ordinal) || !name.EndsWith(".png", StringComparison.Ordinal))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] middle = name["game-".Length..^".png".Length].Split('-');
|
||||
return middle.Length == 2 && middle.All(static p => p.Length is > 0 and <= 19 && p.All(char.IsAsciiDigit))
|
||||
&& long.TryParse(middle[0], NumberStyles.None, CultureInfo.InvariantCulture, out long id) && long.TryParse(middle[1], NumberStyles.None, CultureInfo.InvariantCulture, out _)
|
||||
? id
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The picked file, copied as a PNG for <paramref name="gameId"/>; the <c>cover_path</c> that names it, or null when the file
|
||||
/// is not an image Windows can read, or the folder cannot be written (it is a link to elsewhere, the disk refused).
|
||||
/// </summary>
|
||||
public Task<string?> ImportAsync(long gameId, string source, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(source);
|
||||
return Task.Run(() => Import(gameId, source), ct);
|
||||
}
|
||||
|
||||
/// <summary>Deletes the image <paramref name="coverPath"/> names, when it is one of ours.</summary>
|
||||
public void Delete(string? coverPath)
|
||||
{
|
||||
if (Resolve(_dataDirectory, coverPath) is not { } full)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(full);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Information("art: {File} could not be deleted ({Message}); it goes at the next start", Path.GetFileName(full), ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The images no row names any more — a game deleted with its sessions, removed by the agent (D55), an image replaced
|
||||
/// while a delete failed — and a half-written copy older than an hour, deleted; the count. Only files of our own name in
|
||||
/// the folder are touched, and a row removed with its sessions kept still owns its image (adding the game back restores
|
||||
/// it). Run on the App's own data folder, never a viewer's.
|
||||
/// </summary>
|
||||
public async Task<int> PruneAsync(CancellationToken ct = default)
|
||||
{
|
||||
var folder = new DirectoryInfo(Folder);
|
||||
if (!folder.Exists || IsLink(folder))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deleted = 0;
|
||||
foreach (FileInfo file in folder.EnumerateFiles().ToList())
|
||||
{
|
||||
ct.ThrowIfCancellationRequested();
|
||||
bool leftover = file.Name.EndsWith(".png.tmp", StringComparison.Ordinal) && ParseName(file.Name[..^".tmp".Length]) is not null
|
||||
&& _clock.GetUtcNow() - new DateTimeOffset(file.LastWriteTimeUtc, TimeSpan.Zero) > _leftoverAfter;
|
||||
bool orphan = false;
|
||||
if (ParseName(file.Name) is long id)
|
||||
{
|
||||
GameRow? row = await _games.FindByIdAsync(id, ct).ConfigureAwait(false);
|
||||
orphan = row is null || !string.Equals(row.CoverPath, FolderName + "\\" + file.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
if (leftover || orphan)
|
||||
{
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
deleted++;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Information("art: {File} could not be deleted ({Message})", file.Name, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
private string? Import(long gameId, string source)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] png = Reencode(File.ReadAllBytes(source));
|
||||
var folder = new DirectoryInfo(Folder);
|
||||
folder.Create();
|
||||
if (IsLink(folder))
|
||||
{
|
||||
Log.Warning("art: {Folder} is a link to another place; no image is written there", folder.FullName);
|
||||
return null;
|
||||
}
|
||||
|
||||
string name = string.Create(CultureInfo.InvariantCulture, $"game-{gameId}-{_clock.GetUtcNow().ToUnixTimeMilliseconds()}.png");
|
||||
string target = Path.Combine(folder.FullName, name);
|
||||
string temporary = target + ".tmp";
|
||||
File.WriteAllBytes(temporary, png);
|
||||
File.Move(temporary, target, overwrite: false);
|
||||
return FolderName + "\\" + name;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or NotSupportedException or FileFormatException
|
||||
or COMException or ArgumentException or InvalidOperationException or OverflowException)
|
||||
{
|
||||
Log.Information("art: the chosen image could not be used ({Message})", ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The image as a PNG no larger than 1200 pixels a side.</summary>
|
||||
internal static byte[] Reencode(byte[] bytes)
|
||||
{
|
||||
BitmapSource image = GameArt.DecodeFile(bytes, 0, 0);
|
||||
double scale = Math.Min(1, _largestSide / (double)Math.Max(image.PixelWidth, image.PixelHeight));
|
||||
BitmapSource sized = scale < 1 ? new TransformedBitmap(image, new ScaleTransform(scale, scale)) : image;
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(sized));
|
||||
using var output = new MemoryStream();
|
||||
encoder.Save(output);
|
||||
return output.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ public sealed class EditGamePrompt : IEditGamePrompt
|
||||
|
||||
public EditGamePrompt(IContentDialogService dialogs) => _dialogs = dialogs ?? throw new ArgumentNullException(nameof(dialogs));
|
||||
|
||||
public async Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default)
|
||||
public async Task<GameEdit?> EditAsync(GameMetadata current, string? provenanceJson, EditImage? image = null, CancellationToken ct = default)
|
||||
{
|
||||
var viewModel = new EditGameViewModel(current, provenanceJson);
|
||||
var viewModel = new EditGameViewModel(current, provenanceJson, image);
|
||||
var dialog = new ContentDialog
|
||||
{
|
||||
Title = EditGameViewModel.Title,
|
||||
@@ -31,6 +31,6 @@ public sealed class EditGamePrompt : IEditGamePrompt
|
||||
_ = dialog.SetBinding(ContentDialog.IsPrimaryButtonEnabledProperty, new Binding(nameof(EditGameViewModel.CanSave)) { Source = viewModel, Mode = BindingMode.OneWay });
|
||||
|
||||
ContentDialogResult result = await _dialogs.ShowAsync(dialog, ct).ConfigureAwait(true);
|
||||
return result == ContentDialogResult.Primary && viewModel.CanSave ? viewModel.Result() : null;
|
||||
return result == ContentDialogResult.Primary && viewModel.CanSave ? viewModel.Edit() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The game's image for the edit dialog (beta.23, D60): what the page shows now and whether it is the user's own, the store's
|
||||
/// own cover for "Use the store's image", the picker, and how a picked file is previewed.
|
||||
/// </summary>
|
||||
public sealed record EditImage(ImageSource? Current, bool CurrentIsOwn, ImageSource? Store, IImagePicker Picker, Func<string, Task<ImageSource?>> Preview);
|
||||
@@ -0,0 +1,239 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using FrameLedger.Application.Art;
|
||||
using FrameLedger.Application.Import;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Application.Play;
|
||||
using FrameLedger.Application.Settings;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A game's artwork for its page (beta.23, owner decision D60): the image the user chose for it (Edit…), else what the app of
|
||||
/// the store that installed it keeps on this PC — Steam's and GOG GALAXY's (<see cref="IStoreArtCache"/>) — and the colour
|
||||
/// the page's band takes from it (D61). Which store installed the game is asked of the stores' own records, as Play asks
|
||||
/// (<see cref="StoreRecords.Owning"/>), and only of those two: an itch or Epic game, whose apps keep no image files, has its
|
||||
/// own image or none. Nothing is downloaded and nothing of a store's is copied.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Everything here runs on the thread pool — the records, the files, the decoding, the colour — and the decoded images are
|
||||
/// frozen, so the page only binds them. The stores' records are read the first time a page asks and kept two minutes (a
|
||||
/// Steam library is files on whatever drive it is on); decoded images are kept for the twelve most recent files.
|
||||
/// </remarks>
|
||||
public sealed class GameArt
|
||||
{
|
||||
private const int _keep = 12;
|
||||
private const long _largestFile = 32L * 1024 * 1024;
|
||||
private static readonly TimeSpan _recordsFor = TimeSpan.FromMinutes(2);
|
||||
|
||||
private readonly RegisteredSettings _settings;
|
||||
private readonly StoreRecordsReader _stores;
|
||||
private readonly Dictionary<string, IStoreArtCache> _caches;
|
||||
private readonly string _dataDirectory;
|
||||
private readonly TimeProvider _clock;
|
||||
private readonly Lock _lock = new();
|
||||
private readonly LinkedList<(string Key, BitmapSource Image)> _decoded = new();
|
||||
private readonly HashSet<string> _unreadable = new(StringComparer.OrdinalIgnoreCase);
|
||||
private (DateTimeOffset At, IReadOnlyList<StoreGame> Records)? _records;
|
||||
|
||||
public GameArt(RegisteredSettings settings, StoreRecordsReader stores, IEnumerable<IStoreArtCache> caches, UiMode mode, TimeProvider? clock = null)
|
||||
{
|
||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||
_stores = stores ?? throw new ArgumentNullException(nameof(stores));
|
||||
ArgumentNullException.ThrowIfNull(caches);
|
||||
ArgumentNullException.ThrowIfNull(mode);
|
||||
_caches = caches.ToDictionary(static c => c.Platform, StringComparer.Ordinal);
|
||||
_dataDirectory = mode.DataDirectory;
|
||||
_clock = clock ?? TimeProvider.System;
|
||||
}
|
||||
|
||||
/// <summary>The game's artwork, or null when there is none to show or Settings ▸ Games turned it off.</summary>
|
||||
public Task<GameArtView?> ForAsync(GameRow game, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(game);
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
if (!await _settings.GetBooleanAsync(SettingsRegistry.UiGameArt, ct).ConfigureAwait(false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
bool tint = await _settings.GetBooleanAsync(SettingsRegistry.UiGameArtTint, ct).ConfigureAwait(false);
|
||||
IReadOnlyList<StoreGame> records = await RecordsAsync().ConfigureAwait(false);
|
||||
return Resolve(game, records, tint);
|
||||
}, ct);
|
||||
}
|
||||
|
||||
/// <summary>The image at <paramref name="path"/>, decoded no larger than <paramref name="maxHeight"/> — the edit dialog's preview of a picked file.</summary>
|
||||
public Task<BitmapSource?> PreviewAsync(string path, int maxHeight, CancellationToken ct = default) =>
|
||||
Task.Run(() => Decode(path, maxWidth: 0, maxHeight), ct);
|
||||
|
||||
private GameArtView? Resolve(GameRow game, IReadOnlyList<StoreGame> records, bool tint)
|
||||
{
|
||||
GameArtFiles files = GameArtFiles.None;
|
||||
string? platform = null;
|
||||
if (StoreRecords.Owning(game.Fingerprint.ExePath, game.StoreId, records) is { } record && _caches.TryGetValue(record.Platform, out IStoreArtCache? cache))
|
||||
{
|
||||
files = cache.Find(record.StoreId);
|
||||
platform = record.Platform;
|
||||
}
|
||||
|
||||
// The cover slot: the user's image, else the store's portrait cover, else its landscape header.
|
||||
BitmapSource? storeCover = Decode(files.Cover, 0, 450);
|
||||
bool landscape = false;
|
||||
if (storeCover is null && Decode(files.Header, 460, 0) is { } header)
|
||||
{
|
||||
storeCover = header;
|
||||
landscape = true;
|
||||
}
|
||||
|
||||
BitmapSource? own = CoverStore.Resolve(_dataDirectory, game.CoverPath) is { } mine ? Decode(mine, 0, 900) : null;
|
||||
BitmapSource? hero = Decode(files.Hero, 1920, 0);
|
||||
BitmapSource? cover = own ?? storeCover;
|
||||
if (cover is null && hero is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Color? colour = tint ? DominantOf(cover ?? hero!) : null;
|
||||
string source = own is not null ? Strings.Art_Source_Yours
|
||||
: string.Equals(platform, "gog", StringComparison.Ordinal) ? Strings.Art_Source_Gog
|
||||
: Strings.Art_Source_Steam;
|
||||
return new GameArtView(cover, own is not null, own is null && landscape, storeCover, hero, colour, source);
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyList<StoreGame>> RecordsAsync()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_records is { } cached && _clock.GetUtcNow() - cached.At < _recordsFor)
|
||||
{
|
||||
return cached.Records;
|
||||
}
|
||||
}
|
||||
|
||||
// Two pages opening at once may both read; the second answer simply replaces the first.
|
||||
IReadOnlyList<StoreGame> read = await _stores.ReadAsync("art", _caches.Keys).ConfigureAwait(false);
|
||||
lock (_lock)
|
||||
{
|
||||
_records = (_clock.GetUtcNow(), read);
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The file decoded and frozen — no wider than <paramref name="maxWidth"/> nor taller than <paramref name="maxHeight"/>
|
||||
/// (0: no limit), never enlarged — or null: no file, an empty or outsized one, or one Windows' codecs cannot read (a WebP
|
||||
/// without the WebP codec, a damaged file). A file that would not decode is said in the log once.
|
||||
/// </summary>
|
||||
private BitmapSource? Decode(string? path, int maxWidth, int maxHeight)
|
||||
{
|
||||
if (path is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var info = new FileInfo(path);
|
||||
if (!info.Exists || info.Length == 0 || info.Length > _largestFile)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string key = string.Join('|', info.FullName, info.Length, info.LastWriteTimeUtc.Ticks, maxWidth, maxHeight);
|
||||
lock (_lock)
|
||||
{
|
||||
for (LinkedListNode<(string Key, BitmapSource Image)>? node = _decoded.First; node is not null; node = node.Next)
|
||||
{
|
||||
if (string.Equals(node.Value.Key, key, StringComparison.Ordinal))
|
||||
{
|
||||
_decoded.Remove(node);
|
||||
_decoded.AddFirst(node);
|
||||
return node.Value.Image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BitmapSource image = DecodeFile(File.ReadAllBytes(info.FullName), maxWidth, maxHeight);
|
||||
lock (_lock)
|
||||
{
|
||||
_decoded.AddFirst((key, image));
|
||||
while (_decoded.Count > _keep)
|
||||
{
|
||||
_decoded.RemoveLast();
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or NotSupportedException or FileFormatException
|
||||
or COMException or ArgumentException or InvalidOperationException or OverflowException)
|
||||
{
|
||||
bool first;
|
||||
lock (_lock)
|
||||
{
|
||||
first = _unreadable.Add(path);
|
||||
}
|
||||
|
||||
if (first)
|
||||
{
|
||||
Log.Information("art: {Path} could not be read as an image ({Message})", path, ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Decodes bytes into a frozen image no larger than the limits; read whole first, so no file stays open.</summary>
|
||||
internal static BitmapSource DecodeFile(byte[] bytes, int maxWidth, int maxHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(bytes);
|
||||
int width;
|
||||
int height;
|
||||
using (var probe = new MemoryStream(bytes, writable: false))
|
||||
{
|
||||
BitmapFrame frame = BitmapDecoder.Create(probe, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None).Frames[0];
|
||||
width = frame.PixelWidth;
|
||||
height = frame.PixelHeight;
|
||||
}
|
||||
|
||||
using var stream = new MemoryStream(bytes, writable: false);
|
||||
var image = new BitmapImage();
|
||||
image.BeginInit();
|
||||
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||
image.StreamSource = stream;
|
||||
if (maxWidth > 0 && width > maxWidth && (maxHeight <= 0 || (double)width / maxWidth >= (double)height / maxHeight))
|
||||
{
|
||||
image.DecodePixelWidth = maxWidth;
|
||||
}
|
||||
else if (maxHeight > 0 && height > maxHeight)
|
||||
{
|
||||
image.DecodePixelHeight = maxHeight;
|
||||
}
|
||||
|
||||
image.EndInit();
|
||||
image.Freeze();
|
||||
return image;
|
||||
}
|
||||
|
||||
/// <summary>The image's dominant colour (<see cref="ColorMath.Dominant"/>), read from a 48-pixel-wide copy.</summary>
|
||||
internal static Color? DominantOf(BitmapSource image)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(image);
|
||||
double scale = Math.Min(1, 48.0 / Math.Max(1, image.PixelWidth));
|
||||
BitmapSource small = scale < 1 ? new TransformedBitmap(image, new ScaleTransform(scale, scale)) : image;
|
||||
var bgra = new FormatConvertedBitmap(small, PixelFormats.Bgra32, null, 0);
|
||||
int stride = bgra.PixelWidth * 4;
|
||||
byte[] pixels = new byte[stride * bgra.PixelHeight];
|
||||
bgra.CopyPixels(pixels, stride, 0);
|
||||
return ColorMath.Dominant(pixels);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A game's artwork as its page shows it (beta.23, D60): the cover slot's image (the user's own, or the store's portrait
|
||||
/// cover, or its landscape header), the store's own cover for the edit dialog's "use the store's image", the banner, the
|
||||
/// band's colour (null: untinted), and where the images came from, for the tooltip.
|
||||
/// </summary>
|
||||
public sealed record GameArtView(ImageSource? Cover, bool CoverIsOwn, bool CoverIsLandscape, ImageSource? StoreCover, ImageSource? Hero, Color? Tint, string Source);
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// What the edit dialog answered: the metadata to store — its <c>CoverPath</c> null when the user went back to the store's
|
||||
/// image — and the image file the user picked, which is copied only once the dialog closed with Save (beta.23).
|
||||
/// </summary>
|
||||
public sealed record GameEdit(GameMetadata Metadata, string? PickedImage);
|
||||
@@ -5,8 +5,13 @@ using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>FR-1.3's edit dialog as a question: the current metadata in, the edited metadata out, or null when cancelled.</summary>
|
||||
/// <summary>FR-1.3's edit dialog as a question: the current metadata in, the edit out, or null when cancelled.</summary>
|
||||
public interface IEditGamePrompt
|
||||
{
|
||||
Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default);
|
||||
/// <summary>Shows the dialog; the edit, or null when the user cancelled.</summary>
|
||||
/// <param name="current">What the row holds.</param>
|
||||
/// <param name="provenanceJson">Which of its fields detection filled in (badged in the dialog).</param>
|
||||
/// <param name="image">The game's image as its page shows it (beta.23, D60); null leaves the dialog without an image row.</param>
|
||||
/// <param name="ct">Cancels the dialog.</param>
|
||||
Task<GameEdit?> EditAsync(GameMetadata current, string? provenanceJson, EditImage? image = null, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>The edit dialog's "Choose image…" (beta.23, D60), behind an interface so a test can answer it without a dialog.</summary>
|
||||
public interface IImagePicker
|
||||
{
|
||||
/// <summary>The chosen image's full path, or null when the user cancelled.</summary>
|
||||
string? PickImage();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>The WPF <see cref="OpenFileDialog"/> for a game's image (beta.23, D60): the formats Windows' own codecs read.</summary>
|
||||
public sealed class ImagePicker : IImagePicker
|
||||
{
|
||||
public string? PickImage()
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = Strings.ImagePicker_Title,
|
||||
Filter = Strings.ImagePicker_Filter,
|
||||
CheckFileExists = true,
|
||||
Multiselect = false,
|
||||
};
|
||||
|
||||
return dialog.ShowDialog() == true ? dialog.FileName : null;
|
||||
}
|
||||
}
|
||||
Generated
+51
@@ -80,6 +80,12 @@ public static class Strings
|
||||
nameof(Arch_Unknown),
|
||||
nameof(Arch_X64),
|
||||
nameof(Arch_X86),
|
||||
nameof(Art_Banner_Name),
|
||||
nameof(Art_Cover_Name),
|
||||
nameof(Art_ImportFailed),
|
||||
nameof(Art_Source_Gog),
|
||||
nameof(Art_Source_Steam),
|
||||
nameof(Art_Source_Yours),
|
||||
nameof(Blocked_Directory_Format),
|
||||
nameof(Blocked_Executable_Format),
|
||||
nameof(Blocked_File_Format),
|
||||
@@ -260,13 +266,18 @@ public static class Strings
|
||||
nameof(Display_WindowOnMonitorHz_Format),
|
||||
nameof(Document_OnGitHub),
|
||||
nameof(Document_Pages),
|
||||
nameof(EditGame_ChooseImage),
|
||||
nameof(EditGame_Detected),
|
||||
nameof(EditGame_Image),
|
||||
nameof(EditGame_ImageNone),
|
||||
nameof(EditGame_ImageNote),
|
||||
nameof(EditGame_Name),
|
||||
nameof(EditGame_Notes),
|
||||
nameof(EditGame_Publisher),
|
||||
nameof(EditGame_Save),
|
||||
nameof(EditGame_Saved),
|
||||
nameof(EditGame_Title),
|
||||
nameof(EditGame_UseStoreImage),
|
||||
nameof(EditGame_Version),
|
||||
nameof(End_AttachRefused),
|
||||
nameof(End_ExecutableUnreadable),
|
||||
@@ -556,6 +567,8 @@ public static class Strings
|
||||
nameof(Guard_TargetIsWow64),
|
||||
nameof(Guide_Title),
|
||||
nameof(Hooking_NotX64_Format),
|
||||
nameof(ImagePicker_Filter),
|
||||
nameof(ImagePicker_Title),
|
||||
nameof(Import_Add),
|
||||
nameof(Import_Column_Exe),
|
||||
nameof(Import_Column_Name),
|
||||
@@ -836,6 +849,10 @@ public static class Strings
|
||||
nameof(Settings_Exceptions_Withdraw),
|
||||
nameof(Settings_FpsDecimals_Body),
|
||||
nameof(Settings_FpsDecimals_Label),
|
||||
nameof(Settings_GameArt_Body),
|
||||
nameof(Settings_GameArt_Label),
|
||||
nameof(Settings_GameArtTint_Body),
|
||||
nameof(Settings_GameArtTint_Label),
|
||||
nameof(Settings_Games_Header),
|
||||
nameof(Settings_Header),
|
||||
nameof(Settings_HideAntiCheatHooking_Body),
|
||||
@@ -1205,6 +1222,18 @@ public static class Strings
|
||||
|
||||
public static string Arch_X86 => ResourceManager.GetString(nameof(Arch_X86), Culture) ?? nameof(Arch_X86);
|
||||
|
||||
public static string Art_Banner_Name => ResourceManager.GetString(nameof(Art_Banner_Name), Culture) ?? nameof(Art_Banner_Name);
|
||||
|
||||
public static string Art_Cover_Name => ResourceManager.GetString(nameof(Art_Cover_Name), Culture) ?? nameof(Art_Cover_Name);
|
||||
|
||||
public static string Art_ImportFailed => ResourceManager.GetString(nameof(Art_ImportFailed), Culture) ?? nameof(Art_ImportFailed);
|
||||
|
||||
public static string Art_Source_Gog => ResourceManager.GetString(nameof(Art_Source_Gog), Culture) ?? nameof(Art_Source_Gog);
|
||||
|
||||
public static string Art_Source_Steam => ResourceManager.GetString(nameof(Art_Source_Steam), Culture) ?? nameof(Art_Source_Steam);
|
||||
|
||||
public static string Art_Source_Yours => ResourceManager.GetString(nameof(Art_Source_Yours), Culture) ?? nameof(Art_Source_Yours);
|
||||
|
||||
public static string Blocked_Directory_Format => ResourceManager.GetString(nameof(Blocked_Directory_Format), Culture) ?? nameof(Blocked_Directory_Format);
|
||||
|
||||
public static string Blocked_Executable_Format => ResourceManager.GetString(nameof(Blocked_Executable_Format), Culture) ?? nameof(Blocked_Executable_Format);
|
||||
@@ -1565,8 +1594,16 @@ public static class Strings
|
||||
|
||||
public static string Document_Pages => ResourceManager.GetString(nameof(Document_Pages), Culture) ?? nameof(Document_Pages);
|
||||
|
||||
public static string EditGame_ChooseImage => ResourceManager.GetString(nameof(EditGame_ChooseImage), Culture) ?? nameof(EditGame_ChooseImage);
|
||||
|
||||
public static string EditGame_Detected => ResourceManager.GetString(nameof(EditGame_Detected), Culture) ?? nameof(EditGame_Detected);
|
||||
|
||||
public static string EditGame_Image => ResourceManager.GetString(nameof(EditGame_Image), Culture) ?? nameof(EditGame_Image);
|
||||
|
||||
public static string EditGame_ImageNone => ResourceManager.GetString(nameof(EditGame_ImageNone), Culture) ?? nameof(EditGame_ImageNone);
|
||||
|
||||
public static string EditGame_ImageNote => ResourceManager.GetString(nameof(EditGame_ImageNote), Culture) ?? nameof(EditGame_ImageNote);
|
||||
|
||||
public static string EditGame_Name => ResourceManager.GetString(nameof(EditGame_Name), Culture) ?? nameof(EditGame_Name);
|
||||
|
||||
public static string EditGame_Notes => ResourceManager.GetString(nameof(EditGame_Notes), Culture) ?? nameof(EditGame_Notes);
|
||||
@@ -1579,6 +1616,8 @@ public static class Strings
|
||||
|
||||
public static string EditGame_Title => ResourceManager.GetString(nameof(EditGame_Title), Culture) ?? nameof(EditGame_Title);
|
||||
|
||||
public static string EditGame_UseStoreImage => ResourceManager.GetString(nameof(EditGame_UseStoreImage), Culture) ?? nameof(EditGame_UseStoreImage);
|
||||
|
||||
public static string EditGame_Version => ResourceManager.GetString(nameof(EditGame_Version), Culture) ?? nameof(EditGame_Version);
|
||||
|
||||
public static string End_AttachRefused => ResourceManager.GetString(nameof(End_AttachRefused), Culture) ?? nameof(End_AttachRefused);
|
||||
@@ -2157,6 +2196,10 @@ public static class Strings
|
||||
|
||||
public static string Hooking_NotX64_Format => ResourceManager.GetString(nameof(Hooking_NotX64_Format), Culture) ?? nameof(Hooking_NotX64_Format);
|
||||
|
||||
public static string ImagePicker_Filter => ResourceManager.GetString(nameof(ImagePicker_Filter), Culture) ?? nameof(ImagePicker_Filter);
|
||||
|
||||
public static string ImagePicker_Title => ResourceManager.GetString(nameof(ImagePicker_Title), Culture) ?? nameof(ImagePicker_Title);
|
||||
|
||||
public static string Import_Add => ResourceManager.GetString(nameof(Import_Add), Culture) ?? nameof(Import_Add);
|
||||
|
||||
public static string Import_Column_Exe => ResourceManager.GetString(nameof(Import_Column_Exe), Culture) ?? nameof(Import_Column_Exe);
|
||||
@@ -2717,6 +2760,14 @@ public static class Strings
|
||||
|
||||
public static string Settings_FpsDecimals_Label => ResourceManager.GetString(nameof(Settings_FpsDecimals_Label), Culture) ?? nameof(Settings_FpsDecimals_Label);
|
||||
|
||||
public static string Settings_GameArt_Body => ResourceManager.GetString(nameof(Settings_GameArt_Body), Culture) ?? nameof(Settings_GameArt_Body);
|
||||
|
||||
public static string Settings_GameArt_Label => ResourceManager.GetString(nameof(Settings_GameArt_Label), Culture) ?? nameof(Settings_GameArt_Label);
|
||||
|
||||
public static string Settings_GameArtTint_Body => ResourceManager.GetString(nameof(Settings_GameArtTint_Body), Culture) ?? nameof(Settings_GameArtTint_Body);
|
||||
|
||||
public static string Settings_GameArtTint_Label => ResourceManager.GetString(nameof(Settings_GameArtTint_Label), Culture) ?? nameof(Settings_GameArtTint_Label);
|
||||
|
||||
public static string Settings_Games_Header => ResourceManager.GetString(nameof(Settings_Games_Header), Culture) ?? nameof(Settings_Games_Header);
|
||||
|
||||
public static string Settings_Header => ResourceManager.GetString(nameof(Settings_Header), Culture) ?? nameof(Settings_Header);
|
||||
|
||||
@@ -4321,4 +4321,72 @@
|
||||
<value>キャプチャ エージェントが応答しなかったため、この操作が行われたかどうかは分かりません。エージェントが接続してから、もう一度確認してください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Label" xml:space="preserve">
|
||||
<value>ゲームのアートワークを表示</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Body" xml:space="preserve">
|
||||
<value>ゲームのページに、そのゲームに選んだ画像、なければ Steam または GOG GALAXY のアプリがこの PC に保存しているカバーとバナーを表示します。何もダウンロードしません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Label" xml:space="preserve">
|
||||
<value>アートワークの色でゲームのページを彩る</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Body" xml:space="preserve">
|
||||
<value>ページ上部の帯がアートワークの主な色になります。その上の文字が読みにくくなるほど濃くはしません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_Source_Steam" xml:space="preserve">
|
||||
<value>この PC の Steam アプリのアートワーク</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_Source_Gog" xml:space="preserve">
|
||||
<value>この PC の GOG GALAXY アプリのアートワーク</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_Source_Yours" xml:space="preserve">
|
||||
<value>このゲームに選んだ画像</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_Cover_Name" xml:space="preserve">
|
||||
<value>カバーアート</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_Banner_Name" xml:space="preserve">
|
||||
<value>バナーアート</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Art_ImportFailed" xml:space="preserve">
|
||||
<value>この画像は使えません。Windows で読み込めません。ゲームの画像はそのままです。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="EditGame_Image" xml:space="preserve">
|
||||
<value>画像</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="EditGame_ChooseImage" xml:space="preserve">
|
||||
<value>画像を選ぶ…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="EditGame_UseStoreImage" xml:space="preserve">
|
||||
<value>ストアの画像を使う</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="EditGame_ImageNone" xml:space="preserve">
|
||||
<value>画像なし</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="EditGame_ImageNote" xml:space="preserve">
|
||||
<value>コピーが FrameLedger のデータ フォルダーに保存されるので、選んだファイルは移動や削除をしても構いません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="ImagePicker_Title" xml:space="preserve">
|
||||
<value>ゲームの画像を選択</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="ImagePicker_Filter" xml:space="preserve">
|
||||
<value>画像 (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -3251,4 +3251,55 @@ The documents below are the full terms; this summary does not replace them.</val
|
||||
<data name="Agent_Unanswered" xml:space="preserve">
|
||||
<value>The capture agent did not answer, so whether this was done is not known. Check again once it is connected.</value>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Label" xml:space="preserve">
|
||||
<value>Show game artwork</value>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Body" xml:space="preserve">
|
||||
<value>A game's page shows the image you chose for it, or else the cover and banner the Steam or GOG GALAXY app keeps on this PC. Nothing is downloaded.</value>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Label" xml:space="preserve">
|
||||
<value>Colour the game page from its artwork</value>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Body" xml:space="preserve">
|
||||
<value>The band at the top of the page takes the artwork's main colour, never so strongly that a text on it stops being easy to read.</value>
|
||||
</data>
|
||||
<data name="Art_Source_Steam" xml:space="preserve">
|
||||
<value>Artwork from the Steam app on this PC</value>
|
||||
</data>
|
||||
<data name="Art_Source_Gog" xml:space="preserve">
|
||||
<value>Artwork from the GOG GALAXY app on this PC</value>
|
||||
</data>
|
||||
<data name="Art_Source_Yours" xml:space="preserve">
|
||||
<value>The image you chose for this game</value>
|
||||
</data>
|
||||
<data name="Art_Cover_Name" xml:space="preserve">
|
||||
<value>Cover art</value>
|
||||
</data>
|
||||
<data name="Art_Banner_Name" xml:space="preserve">
|
||||
<value>Banner art</value>
|
||||
</data>
|
||||
<data name="Art_ImportFailed" xml:space="preserve">
|
||||
<value>The image could not be used: Windows cannot read it. The game keeps the image it had.</value>
|
||||
</data>
|
||||
<data name="EditGame_Image" xml:space="preserve">
|
||||
<value>Image</value>
|
||||
</data>
|
||||
<data name="EditGame_ChooseImage" xml:space="preserve">
|
||||
<value>Choose image…</value>
|
||||
</data>
|
||||
<data name="EditGame_UseStoreImage" xml:space="preserve">
|
||||
<value>Use the store's image</value>
|
||||
</data>
|
||||
<data name="EditGame_ImageNone" xml:space="preserve">
|
||||
<value>No image</value>
|
||||
</data>
|
||||
<data name="EditGame_ImageNote" xml:space="preserve">
|
||||
<value>A copy is kept in FrameLedger's data folder, so the file you pick can move or go.</value>
|
||||
</data>
|
||||
<data name="ImagePicker_Title" xml:space="preserve">
|
||||
<value>Choose an image for the game</value>
|
||||
</data>
|
||||
<data name="ImagePicker_Filter" xml:space="preserve">
|
||||
<value>Images (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -3246,4 +3246,55 @@ Các văn bản bên dưới là điều khoản đầy đủ; bản tóm tắt
|
||||
<data name="Agent_Unanswered" xml:space="preserve">
|
||||
<value>Capture agent không trả lời, nên không biết việc này đã được thực hiện hay chưa. Hãy kiểm tra lại khi agent đã kết nối.</value>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Label" xml:space="preserve">
|
||||
<value>Hiện ảnh của game</value>
|
||||
</data>
|
||||
<data name="Settings_GameArt_Body" xml:space="preserve">
|
||||
<value>Trang của game hiện ảnh bạn đã chọn cho nó, nếu không có thì ảnh bìa và banner mà ứng dụng Steam hoặc GOG GALAXY lưu sẵn trên máy này. Không tải gì về.</value>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Label" xml:space="preserve">
|
||||
<value>Tô màu trang game theo ảnh</value>
|
||||
</data>
|
||||
<data name="Settings_GameArtTint_Body" xml:space="preserve">
|
||||
<value>Dải đầu trang lấy màu chủ đạo của ảnh, không bao giờ đậm tới mức chữ trên đó khó đọc.</value>
|
||||
</data>
|
||||
<data name="Art_Source_Steam" xml:space="preserve">
|
||||
<value>Ảnh từ ứng dụng Steam trên máy này</value>
|
||||
</data>
|
||||
<data name="Art_Source_Gog" xml:space="preserve">
|
||||
<value>Ảnh từ ứng dụng GOG GALAXY trên máy này</value>
|
||||
</data>
|
||||
<data name="Art_Source_Yours" xml:space="preserve">
|
||||
<value>Ảnh bạn đã chọn cho game này</value>
|
||||
</data>
|
||||
<data name="Art_Cover_Name" xml:space="preserve">
|
||||
<value>Ảnh bìa</value>
|
||||
</data>
|
||||
<data name="Art_Banner_Name" xml:space="preserve">
|
||||
<value>Ảnh banner</value>
|
||||
</data>
|
||||
<data name="Art_ImportFailed" xml:space="preserve">
|
||||
<value>Không dùng được ảnh này: Windows không đọc được nó. Game giữ ảnh cũ.</value>
|
||||
</data>
|
||||
<data name="EditGame_Image" xml:space="preserve">
|
||||
<value>Ảnh</value>
|
||||
</data>
|
||||
<data name="EditGame_ChooseImage" xml:space="preserve">
|
||||
<value>Chọn ảnh…</value>
|
||||
</data>
|
||||
<data name="EditGame_UseStoreImage" xml:space="preserve">
|
||||
<value>Dùng ảnh của store</value>
|
||||
</data>
|
||||
<data name="EditGame_ImageNone" xml:space="preserve">
|
||||
<value>Không có ảnh</value>
|
||||
</data>
|
||||
<data name="EditGame_ImageNote" xml:space="preserve">
|
||||
<value>Một bản sao được giữ trong thư mục dữ liệu của FrameLedger, nên tệp bạn chọn có thể dời đi hoặc xoá.</value>
|
||||
</data>
|
||||
<data name="ImagePicker_Title" xml:space="preserve">
|
||||
<value>Chọn ảnh cho game</value>
|
||||
</data>
|
||||
<data name="ImagePicker_Filter" xml:space="preserve">
|
||||
<value>Ảnh (*.png;*.jpg;*.jpeg;*.bmp;*.webp)|*.png;*.jpg;*.jpeg;*.bmp;*.webp</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -2,20 +2,47 @@
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Windows.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// FR-1.3: the four fields a user edits most (name, publisher, version, notes); the rest of <see cref="GameMetadata"/>
|
||||
/// passes through unchanged. A field detection filled in (<c>field_provenance</c> = <c>detected</c>) is badged so the
|
||||
/// user knows what they are overriding.
|
||||
/// FR-1.3: the four fields a user edits most (name, publisher, version, notes) and, since beta.23 (D60), the game's image;
|
||||
/// the rest of <see cref="GameMetadata"/> passes through unchanged. A field detection filled in (<c>field_provenance</c> =
|
||||
/// <c>detected</c>) is badged so the user knows what they are overriding.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A picked image is only previewed here: it is copied into the data folder once the dialog closed with Save
|
||||
/// (<see cref="GameEdit.PickedImage"/>), so Cancel leaves nothing behind.
|
||||
/// </remarks>
|
||||
public sealed partial class EditGameViewModel : ObservableObject
|
||||
{
|
||||
private readonly GameMetadata _original;
|
||||
private readonly EditImage? _image;
|
||||
|
||||
// The user went back to the store's image: the row's own image is dropped on Save.
|
||||
private bool _dropOwn;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(HasImagePreview))]
|
||||
private ImageSource? _imagePreview;
|
||||
|
||||
/// <summary>The image file picked in this dialog, copied on Save; null when none was picked.</summary>
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(CanUseStoreImage))]
|
||||
private string? _pickedImage;
|
||||
|
||||
/// <summary>The last pick could not be read as an image (shown under the buttons); null otherwise.</summary>
|
||||
[ObservableProperty]
|
||||
private string? _imageError;
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(CanUseStoreImage))]
|
||||
private bool _showsOwnImage;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _name;
|
||||
@@ -29,9 +56,12 @@ public sealed partial class EditGameViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _notes;
|
||||
|
||||
public EditGameViewModel(GameMetadata current, string? provenanceJson)
|
||||
public EditGameViewModel(GameMetadata current, string? provenanceJson, EditImage? image = null)
|
||||
{
|
||||
_original = current ?? throw new ArgumentNullException(nameof(current));
|
||||
_image = image;
|
||||
_imagePreview = image?.Current;
|
||||
_showsOwnImage = image is { CurrentIsOwn: true };
|
||||
_name = current.Name;
|
||||
_publisher = current.Publisher ?? string.Empty;
|
||||
_version = current.GameVersion ?? string.Empty;
|
||||
@@ -60,17 +90,76 @@ public sealed partial class EditGameViewModel : ObservableObject
|
||||
|
||||
public static string DetectedBadge => Strings.EditGame_Detected;
|
||||
|
||||
public static string ImageLabel => Strings.EditGame_Image;
|
||||
|
||||
public static string ChooseImageText => Strings.EditGame_ChooseImage;
|
||||
|
||||
public static string UseStoreImageText => Strings.EditGame_UseStoreImage;
|
||||
|
||||
public static string ImageNoneText => Strings.EditGame_ImageNone;
|
||||
|
||||
public static string ImageNote => Strings.EditGame_ImageNote;
|
||||
|
||||
public static string CoverName => Strings.Art_Cover_Name;
|
||||
|
||||
/// <summary>Whether the dialog has an image row: the game page passed what it shows.</summary>
|
||||
public bool ImageEditable => _image is not null;
|
||||
|
||||
public bool HasImagePreview => ImagePreview is not null;
|
||||
|
||||
/// <summary>The image shown is the user's own (kept or just picked), so going back to the store's means something.</summary>
|
||||
public bool CanUseStoreImage => PickedImage is not null || ShowsOwnImage;
|
||||
|
||||
public bool CanSave => !string.IsNullOrWhiteSpace(Name);
|
||||
|
||||
/// <summary>The metadata to store: the four fields as typed (blank → null), everything else as it was.</summary>
|
||||
/// <summary>
|
||||
/// The metadata to store: the four fields as typed (blank → null), the row's own image dropped when the user went back to
|
||||
/// the store's, everything else as it was.
|
||||
/// </summary>
|
||||
public GameMetadata Result() => _original with
|
||||
{
|
||||
Name = Name.Trim(),
|
||||
Publisher = Blank(Publisher),
|
||||
GameVersion = Blank(Version),
|
||||
Notes = Blank(Notes),
|
||||
CoverPath = _dropOwn ? null : _original.CoverPath,
|
||||
};
|
||||
|
||||
/// <summary>What Save answers: <see cref="Result"/> and the image picked in this dialog.</summary>
|
||||
public GameEdit Edit() => new(Result(), PickedImage);
|
||||
|
||||
/// <summary>"Choose image…": the picked file previewed; it is copied only on Save, and one that cannot be read is said here.</summary>
|
||||
[RelayCommand]
|
||||
private async Task ChooseImageAsync()
|
||||
{
|
||||
if (_image?.Picker.PickImage() is not { } path)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (await _image.Preview(path).ConfigureAwait(true) is { } preview)
|
||||
{
|
||||
PickedImage = path;
|
||||
ImagePreview = preview;
|
||||
ImageError = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageError = Strings.Art_ImportFailed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Use the store's image": the pick and the row's own image dropped; the page shows the store's again.</summary>
|
||||
[RelayCommand]
|
||||
private void UseStoreImage()
|
||||
{
|
||||
PickedImage = null;
|
||||
_dropOwn = _original.CoverPath is not null;
|
||||
ShowsOwnImage = false;
|
||||
ImagePreview = _image?.Store;
|
||||
ImageError = null;
|
||||
}
|
||||
|
||||
partial void OnNameChanged(string value) => OnPropertyChanged(nameof(CanSave));
|
||||
|
||||
private static string? Blank(string value) => string.IsNullOrWhiteSpace(value) ? null : value.Trim();
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Charts;
|
||||
@@ -50,6 +51,9 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
private readonly AntiCheatExceptions? _exceptions;
|
||||
private readonly SessionDeletion? _deletion;
|
||||
private readonly Func<string, bool> _exists;
|
||||
private readonly GameArt? _art;
|
||||
private readonly CoverStore? _covers;
|
||||
private readonly IImagePicker? _images;
|
||||
private readonly long? _gameId;
|
||||
|
||||
// ui.hide_anticheat_hooking (2026-09-25), read at each load; on until the settings say otherwise, as its default is.
|
||||
@@ -88,6 +92,37 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
// Why the executable is missing, from the last load's check (beta.23); null while it was found.
|
||||
private string? _executableMissingWhy;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (D60): the game's artwork — the image the user chose, else the store's own cover, else its landscape header;
|
||||
/// null with none. Shown in the header band beside the name.
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private ImageSource? _artCover;
|
||||
|
||||
/// <summary>The cover slot holds the store's landscape header (no portrait cover): drawn wider and shorter.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _artCoverIsLandscape;
|
||||
|
||||
/// <summary>The store's wide banner, above the header band; null without one.</summary>
|
||||
[ObservableProperty]
|
||||
private ImageSource? _artHero;
|
||||
|
||||
/// <summary>D61: the colour the header band takes from the artwork; null leaves it the card's own fill.</summary>
|
||||
[ObservableProperty]
|
||||
private Color? _artTint;
|
||||
|
||||
/// <summary>The page shows artwork: the band, the cover, the banner.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _hasArt;
|
||||
|
||||
/// <summary>Where the artwork came from, for its tooltip.</summary>
|
||||
[ObservableProperty]
|
||||
private string? _artSource;
|
||||
|
||||
// What the edit dialog needs: whether the cover is the user's own, and the store's own cover to go back to.
|
||||
private bool _artCoverIsOwn;
|
||||
private ImageSource? _artStoreCover;
|
||||
|
||||
/// <summary>What Play will do, in the mode Settings ▸ Games has now (beta.21, D59).</summary>
|
||||
[ObservableProperty]
|
||||
private string _playToolTip = Strings.Play_ToolTip_Store;
|
||||
@@ -245,8 +280,12 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
IConfirmations confirmations, IEditGamePrompt edit, IMessageStrip strip, ISessionSummaryOpener summaries,
|
||||
SessionSeriesLoader loader, IHardwareSnapshotRepository hardware, SessionSelection sessionSelection, IGamePicker picker,
|
||||
RegisteredSettings? settings = null, IAgentLink? agent = null, AntiCheatExceptions? exceptions = null, SessionDeletion? deletion = null,
|
||||
UiMode? mode = null, GamePlayer? player = null, Func<string, bool>? executableExists = null)
|
||||
UiMode? mode = null, GamePlayer? player = null, Func<string, bool>? executableExists = null, GameArt? art = null, CoverStore? covers = null,
|
||||
IImagePicker? images = null)
|
||||
{
|
||||
_art = art;
|
||||
_covers = covers;
|
||||
_images = images;
|
||||
// beta.23: whether the executable is on disk is a question for its drive, which can take seconds to answer (the
|
||||
// owner's games are on a USB drive), so it is asked off the UI thread, as the library page has asked since beta.19.
|
||||
_exists = executableExists ?? GameLibrary.ExecutableExists;
|
||||
@@ -483,7 +522,24 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
Present(detail);
|
||||
AnyLatency = detail.Sessions.Any(static s => s.ReflexActive == true);
|
||||
ChooseDefaultMetric(detail);
|
||||
|
||||
// beta.23 (D60): the artwork is looked for and decoded on the thread pool while the trend is drawn; the page's text is
|
||||
// already there, and a reload keeps the picture it has until the new one is ready.
|
||||
Task<GameArtView?> art = _art?.ForAsync(detail.Row, ct) ?? Task.FromResult<GameArtView?>(null);
|
||||
await RebuildTrendAsync(ct).ConfigureAwait(true);
|
||||
PresentArt(await art.ConfigureAwait(true));
|
||||
}
|
||||
|
||||
private void PresentArt(GameArtView? view)
|
||||
{
|
||||
ArtCover = view?.Cover;
|
||||
ArtCoverIsLandscape = view?.CoverIsLandscape ?? false;
|
||||
ArtHero = view?.Hero;
|
||||
ArtTint = view?.Tint;
|
||||
ArtSource = view?.Source;
|
||||
_artCoverIsOwn = view?.CoverIsOwn ?? false;
|
||||
_artStoreCover = view?.StoreCover;
|
||||
HasArt = view is not null;
|
||||
}
|
||||
|
||||
partial void OnSelectedSessionChanged(SessionItemViewModel? value)
|
||||
@@ -853,13 +909,39 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
|
||||
GameMetadata? edited = await _edit.EditAsync(GameMetadata.Of(Game), Game.FieldProvenanceJson).ConfigureAwait(true);
|
||||
if (edited is null)
|
||||
// beta.23 (D60): the dialog's image row, when this page has artwork to show and somewhere to keep a chosen image.
|
||||
GameArt? art = _art;
|
||||
EditImage? image = art is not null && _covers is not null && _images is not null
|
||||
? new EditImage(ArtCover, _artCoverIsOwn, _artStoreCover, _images, async path => await art.PreviewAsync(path, 192).ConfigureAwait(true))
|
||||
: null;
|
||||
GameEdit? edit = await _edit.EditAsync(GameMetadata.Of(Game), Game.FieldProvenanceJson, image).ConfigureAwait(true);
|
||||
if (edit is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameMetadata edited = edit.Metadata;
|
||||
string? before = Game.CoverPath;
|
||||
if (edit.PickedImage is { } picked && _covers is not null)
|
||||
{
|
||||
// Copied only now that the dialog closed with Save; a file that cannot be used leaves the image the game had.
|
||||
if (await _covers.ImportAsync(Game.Id, picked).ConfigureAwait(true) is { } copied)
|
||||
{
|
||||
edited = edited with { CoverPath = copied };
|
||||
}
|
||||
else
|
||||
{
|
||||
edited = edited with { CoverPath = before };
|
||||
_strip.Warn(Strings.EditGame_Title, Strings.Art_ImportFailed);
|
||||
}
|
||||
}
|
||||
|
||||
await _library.UpdateMetadataAsync(Game.Id, edited).ConfigureAwait(true);
|
||||
if (before is not null && !string.Equals(before, edited.CoverPath, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_covers?.Delete(before);
|
||||
}
|
||||
|
||||
_strip.Success(Strings.EditGame_Title, Strings.EditGame_Saved);
|
||||
await LoadAsync().ConfigureAwait(true);
|
||||
}
|
||||
@@ -955,7 +1037,17 @@ public sealed partial class GameDetailViewModel : ObservableObject
|
||||
}
|
||||
|
||||
string name = Game.Name;
|
||||
await _library.RemoveAsync(Game.Id, keepSessions: choice == RemoveGameChoice.KeepSessions).ConfigureAwait(true);
|
||||
string? cover = Game.CoverPath;
|
||||
bool keepSessions = choice == RemoveGameChoice.KeepSessions;
|
||||
bool removed = await _library.RemoveAsync(Game.Id, keepSessions).ConfigureAwait(true);
|
||||
|
||||
// beta.23 (D60): a game removed with its sessions is gone, and its own image with it; one removed with its sessions
|
||||
// kept comes back with them when it is added again, and keeps its image.
|
||||
if (removed && !keepSessions)
|
||||
{
|
||||
_covers?.Delete(cover);
|
||||
}
|
||||
|
||||
_strip.Info(Strings.Games_Header, string.Format(CultureInfo.CurrentCulture, Strings.RemoveGame_Removed_Format, name));
|
||||
_navigator.Navigate<GamesPage>();
|
||||
}
|
||||
|
||||
@@ -120,6 +120,14 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _onlineMetadata;
|
||||
|
||||
/// <summary><c>ui.game_art</c> (beta.23, D60): a game's page shows its artwork — the user's image, else the store app's own.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _gameArt = true;
|
||||
|
||||
/// <summary><c>ui.game_art_tint</c> (beta.23, D61): the page's header band takes the artwork's colour, as far as its text stays readable.</summary>
|
||||
[ObservableProperty]
|
||||
private bool _gameArtTint = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _updateChannel = "stable";
|
||||
|
||||
@@ -491,6 +499,10 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
|
||||
partial void OnOnlineMetadataChanged(bool value) => Persist(SettingsRegistry.PrivacyOnlineMetadata, value);
|
||||
|
||||
partial void OnGameArtChanged(bool value) => Persist(SettingsRegistry.UiGameArt, value);
|
||||
|
||||
partial void OnGameArtTintChanged(bool value) => Persist(SettingsRegistry.UiGameArtTint, value);
|
||||
|
||||
partial void OnUpdateChannelChanged(string value) => Persist(SettingsRegistry.UpdateChannel, value);
|
||||
|
||||
partial void OnPlayModeChanged(string value) => Persist(SettingsRegistry.UiPlayMode, value);
|
||||
@@ -562,6 +574,8 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
FpsTwoDecimals = await _settings.GetBooleanAsync(SettingsRegistry.UiFpsDecimals).ConfigureAwait(true);
|
||||
HideScrollBars = await _settings.GetBooleanAsync(SettingsRegistry.UiHideScrollBars).ConfigureAwait(true);
|
||||
OnlineMetadata = await _settings.GetBooleanAsync(SettingsRegistry.PrivacyOnlineMetadata).ConfigureAwait(true);
|
||||
GameArt = await _settings.GetBooleanAsync(SettingsRegistry.UiGameArt).ConfigureAwait(true);
|
||||
GameArtTint = await _settings.GetBooleanAsync(SettingsRegistry.UiGameArtTint).ConfigureAwait(true);
|
||||
UpdateChannel = await _settings.GetAsync(SettingsRegistry.UpdateChannel).ConfigureAwait(true);
|
||||
PlayMode = await _settings.GetAsync(SettingsRegistry.UiPlayMode).ConfigureAwait(true);
|
||||
AutoCheckUpdates = await _settings.GetBooleanAsync(SettingsRegistry.UpdateAutoCheck).ConfigureAwait(true);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Application.Art;
|
||||
|
||||
/// <summary>
|
||||
/// The artwork a store's own app keeps on this PC for one game (beta.23, owner decision D60): the full paths of its portrait
|
||||
/// cover, its wide banner and its landscape header, each null when that app keeps none. FrameLedger downloads none of it and
|
||||
/// copies none of it; it shows these files from where the store's app put them.
|
||||
/// </summary>
|
||||
public sealed record GameArtFiles(string? Cover, string? Hero, string? Header)
|
||||
{
|
||||
/// <summary>No artwork: the store keeps none, is not installed, or the id is not one of its own.</summary>
|
||||
public static GameArtFiles None { get; } = new(null, null, null);
|
||||
|
||||
public bool IsEmpty => Cover is null && Hero is null && Header is null;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.Application.Art;
|
||||
|
||||
/// <summary>
|
||||
/// One store app's own artwork folder on this PC (beta.23, owner decision D60): Steam's <c>appcache\librarycache</c>, GOG
|
||||
/// GALAXY's <c>webcache</c>. Read-only. A store that is not installed, an id that is not of the store's own shape, or a
|
||||
/// folder with nothing in it answers <see cref="GameArtFiles.None"/>, never an error. Which store installed a game is
|
||||
/// asked of the stores' own records, as Play asks (<c>Play.StoreRecords.Owning</c>) — never of the row's platform alone.
|
||||
/// </summary>
|
||||
public interface IStoreArtCache
|
||||
{
|
||||
/// <summary><c>steam</c> · <c>gog</c> — <c>games.platform</c>'s vocabulary.</summary>
|
||||
string Platform { get; }
|
||||
|
||||
GameArtFiles Find(string storeId);
|
||||
}
|
||||
@@ -103,6 +103,29 @@ public static class SettingsRegistry
|
||||
Choices = ["store", "direct"],
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether a game's page shows its artwork (beta.23, owner decision D60): the image the user chose for it, else the one
|
||||
/// the app of the store that installed it keeps on this PC — Steam's and GOG GALAXY's; nothing is downloaded. On by
|
||||
/// default. Settings ▸ Games; the Agent never reads it.
|
||||
/// </summary>
|
||||
public static readonly SettingDefinition UiGameArt = new()
|
||||
{
|
||||
Key = "ui.game_art",
|
||||
Kind = SettingKind.Boolean,
|
||||
Default = "1",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether the band at the top of a game's page takes the colour of its artwork (beta.23, owner decision D61), at the
|
||||
/// strongest opacity that keeps every text on it readable. On by default (owner's choice). Settings ▸ Games.
|
||||
/// </summary>
|
||||
public static readonly SettingDefinition UiGameArtTint = new()
|
||||
{
|
||||
Key = "ui.game_art_tint",
|
||||
Kind = SettingKind.Boolean,
|
||||
Default = "1",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Agent's watcher records tracked games that the App did not launch (FR-3.1/FR-3.3). <b>Reserved since
|
||||
/// beta.12:</b> the App showed a switch for it ("Record games launched outside FrameLedger") and no Agent code ever read
|
||||
@@ -245,7 +268,7 @@ public static class SettingsRegistry
|
||||
public static IReadOnlyList<SettingDefinition> All { get; } =
|
||||
[
|
||||
UiLanguage, UiTheme, UiStartWithWindows, UiMinimizeToTray, UiHideAntiCheatHooking, UiFpsDecimals, UiHideScrollBars, UiLibraryView, UiPlayMode,
|
||||
CaptureBackground, HookingKillSwitch, HookingUserModeExceptions, CaptureRunElevated, CaptureMinSessionSeconds, TelemetryIntervalMs, RetentionRawSessionsPerGame,
|
||||
UiGameArt, UiGameArtTint, CaptureBackground, HookingKillSwitch, HookingUserModeExceptions, CaptureRunElevated, CaptureMinSessionSeconds, TelemetryIntervalMs, RetentionRawSessionsPerGame,
|
||||
RetentionRemoveUninstalledGames, UpdateChannel, UpdateAutoCheck, PrivacyOnlineMetadata, LogDebug,
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FrameLedger.Application.Art;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Art;
|
||||
|
||||
/// <summary>
|
||||
/// The artwork GOG GALAXY keeps for each game in its library (beta.23, owner decision D60), under
|
||||
/// <c>%ProgramData%\GOG.com\Galaxy\webcache\<user>\gog\<productId>\</c> — read on the owner's PC on 2026-10-14 (80
|
||||
/// products): <c><sha256>_glx_vertical_cover.webp</c> (the cover), <c><sha256>_glx_bg_top_padding_7.webp</c> (the
|
||||
/// banner) and a square icon, WebP that Windows' own WebP codec decodes (an optional Store component: without it the
|
||||
/// game simply has no image). Every Galaxy user's folder is looked in, the newest copy wins. GOG keeps no header.
|
||||
/// </summary>
|
||||
public sealed class GogArtCache(string? webcacheRoot = null) : IStoreArtCache
|
||||
{
|
||||
public static string DefaultRoot => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GOG.com", "Galaxy", "webcache");
|
||||
|
||||
public string Platform => "gog";
|
||||
|
||||
public GameArtFiles Find(string storeId)
|
||||
{
|
||||
if (!SteamArtCache.IsNumericId(storeId))
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var root = new DirectoryInfo(webcacheRoot ?? DefaultRoot);
|
||||
if (!root.Exists)
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
|
||||
List<FileInfo> files = [];
|
||||
foreach (DirectoryInfo user in root.EnumerateDirectories().Where(static d => !d.Attributes.HasFlag(FileAttributes.ReparsePoint)))
|
||||
{
|
||||
var product = new DirectoryInfo(Path.Combine(user.FullName, "gog", storeId));
|
||||
if (product.Exists && !product.Attributes.HasFlag(FileAttributes.ReparsePoint))
|
||||
{
|
||||
files.AddRange(product.EnumerateFiles());
|
||||
}
|
||||
}
|
||||
|
||||
return new GameArtFiles(Newest(files, "_glx_vertical_cover."), Newest(files, "_glx_bg_top_padding_") ?? Newest(files, "_glx_background"), null);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException)
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
}
|
||||
|
||||
private static string? Newest(IEnumerable<FileInfo> files, string marker) => files
|
||||
.Where(f => f.Name.Contains(marker, StringComparison.OrdinalIgnoreCase) && f.Length > 0)
|
||||
.OrderByDescending(static f => f.LastWriteTimeUtc)
|
||||
.FirstOrDefault()?.FullName;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FrameLedger.Application.Art;
|
||||
using FrameLedger.Infrastructure.Import;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Art;
|
||||
|
||||
/// <summary>
|
||||
/// The artwork the Steam app keeps for each game it shows (beta.23, owner decision D60), under
|
||||
/// <c><Steam>\appcache\librarycache\<appid>\</c> — read on the owner's PC on 2026-10-14 (3,082 app folders) in two
|
||||
/// layouts, sometimes both in one folder: the files directly in the app's folder (<c>library_600x900.jpg</c>,
|
||||
/// <c>library_hero.jpg</c>, <c>header.jpg</c>), or each in a folder named by a hash (<c>library_capsule.jpg</c>,
|
||||
/// <c>library_hero.jpg</c>, <c>library_header.jpg</c>). The cover is 300×450, the banner 1920×620, the header 460×215 as Steam
|
||||
/// keeps them. The folder's own index (<c>assetcache.vdf</c>) is binary and not read: the names say what each file is, and
|
||||
/// where an asset was replaced its newest copy wins. The Steam root is <c>HKCU\Software\Valve\Steam\SteamPath</c>, as the
|
||||
/// import reads it, unless a test hands one in.
|
||||
/// </summary>
|
||||
public sealed class SteamArtCache(string? steamRoot = null) : IStoreArtCache
|
||||
{
|
||||
private static readonly string[] _covers = ["library_600x900_2x.jpg", "library_600x900.jpg", "library_capsule.jpg"];
|
||||
private static readonly string[] _heroes = ["library_hero.jpg"];
|
||||
private static readonly string[] _headers = ["header.jpg", "library_header.jpg"];
|
||||
|
||||
public string Platform => "steam";
|
||||
|
||||
public GameArtFiles Find(string storeId)
|
||||
{
|
||||
if (!IsNumericId(storeId) || (steamRoot ?? SteamLibrarySource.InstalledRoot()) is not { } root)
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var folder = new DirectoryInfo(Path.Combine(root, "appcache", "librarycache", storeId));
|
||||
if (!folder.Exists)
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
|
||||
List<FileInfo> files = [.. folder.EnumerateFiles()];
|
||||
foreach (DirectoryInfo hashed in folder.EnumerateDirectories().Where(static d => !d.Attributes.HasFlag(FileAttributes.ReparsePoint)))
|
||||
{
|
||||
files.AddRange(hashed.EnumerateFiles());
|
||||
}
|
||||
|
||||
return new GameArtFiles(Newest(files, _covers), Newest(files, _heroes), Newest(files, _headers));
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or System.Security.SecurityException)
|
||||
{
|
||||
return GameArtFiles.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A store id that is digits only — Steam's app ids and GOG's product ids are — so a row's id can name no other folder
|
||||
/// (<c>..\</c>, a rooted path) when it is joined to the store's own.
|
||||
/// </summary>
|
||||
internal static bool IsNumericId(string? id) => id is { Length: > 0 and <= 12 } && id.All(char.IsAsciiDigit);
|
||||
|
||||
/// <summary>The first of <paramref name="names"/>, in order of preference, that is there and not empty; the newest copy of it.</summary>
|
||||
internal static string? Newest(IReadOnlyList<FileInfo> files, IReadOnlyList<string> names)
|
||||
{
|
||||
foreach (string name in names)
|
||||
{
|
||||
FileInfo? newest = files
|
||||
.Where(f => string.Equals(f.Name, name, StringComparison.OrdinalIgnoreCase) && f.Length > 0)
|
||||
.OrderByDescending(static f => f.LastWriteTimeUtc)
|
||||
.FirstOrDefault();
|
||||
if (newest is not null)
|
||||
{
|
||||
return newest.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,8 @@ public sealed class SteamLibrarySource(string? steamRoot = null) : IStoreLibrary
|
||||
return new StoreGame("steam", appId, name, Path.Combine(steamapps, "common", installDir), ExePath: null, state.Value("buildid"));
|
||||
}
|
||||
|
||||
private static string? InstalledRoot()
|
||||
/// <summary>Steam's folder as its own registry value names it (<c>HKCU\Software\Valve\Steam\SteamPath</c>), or null; the artwork reads it too (beta.23).</summary>
|
||||
internal static string? InstalledRoot()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -160,6 +160,41 @@ public sealed class AccessibilityTests
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A WPF UI control's template is in WPF UI's own style for it (<c>DefaultImageStyle</c>, …), applied only when the
|
||||
/// control has no style of its own. A style of the App's that targets the control without being based on WPF UI's leaves
|
||||
/// it with no template: it takes its place and draws nothing — the game page's cover was an empty space beside the
|
||||
/// name (beta.23), which no colour or text check can see. Every such style is based on WPF UI's or brings a template.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void NoStyleOfAWpfUiControlLeavesOutItsTemplate()
|
||||
{
|
||||
XNamespace wpfUi = "http://schemas.lepo.co/wpfui/2022/xaml";
|
||||
var targetType = new Regex(@"^(?:\{x:Type\s+)?(?<prefix>\w+):(?<type>\w+)\}?$", RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, TimeSpan.FromSeconds(1));
|
||||
var found = new List<string>();
|
||||
foreach ((string file, XDocument xaml) in AppXaml())
|
||||
{
|
||||
foreach (XElement style in xaml.Descendants().Where(static e => string.Equals(e.Name.LocalName, "Style", StringComparison.Ordinal)))
|
||||
{
|
||||
Match match = targetType.Match(style.Attribute("TargetType")?.Value.Trim() ?? string.Empty);
|
||||
if (style.Attribute("BasedOn") is not null || !match.Success || style.GetNamespaceOfPrefix(match.Groups["prefix"].Value) != wpfUi)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Type? control = typeof(Wpf.Ui.Controls.Image).Assembly.GetType("Wpf.Ui.Controls." + match.Groups["type"].Value);
|
||||
bool templated = control is not null && typeof(System.Windows.Controls.Control).IsAssignableFrom(control);
|
||||
bool bringsTemplate = style.Elements().Any(static s => string.Equals((string?)s.Attribute("Property"), "Template", StringComparison.Ordinal));
|
||||
if (templated && !bringsTemplate)
|
||||
{
|
||||
found.Add($"{file}: a Style for ui:{match.Groups["type"].Value} with no BasedOn");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found.Should().BeEmpty("WPF UI's template is in its own style; base the App's on it (BasedOn=\"{StaticResource DefaultImageStyle}\", …)");
|
||||
}
|
||||
|
||||
/// <summary>A <c>DataGridCheckBoxColumn</c>'s box is WPF's own element style — an Aero2 box on the Fluent grid (beta.14).</summary>
|
||||
[Fact]
|
||||
public void NoDataGridCheckBoxColumn()
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Markup;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (owner decision D61): an artwork's dominant colour and the band's tint, checked against the tests' own copy of
|
||||
/// the WCAG formulas (<see cref="Wcag"/>) — for the colours that are hardest on each theme's text — so the tint can never
|
||||
/// cost a text its contrast.
|
||||
/// </summary>
|
||||
public sealed class ColorMathTests
|
||||
{
|
||||
private static byte[] Pixels(params (Color Colour, int Count)[] runs)
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
foreach ((Color c, int count) in runs)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
bytes.AddRange([c.B, c.G, c.R, c.A]);
|
||||
}
|
||||
}
|
||||
|
||||
return [.. bytes];
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheArithmeticAgreesWithTheTestsOwnWcag()
|
||||
{
|
||||
Color[] samples = [Colors.White, Colors.Black, Color.FromRgb(0x20, 0x20, 0x20), Color.FromRgb(0xF3, 0xF3, 0xF3), Color.FromRgb(0xC8, 0x28, 0x28), Color.FromRgb(0x28, 0xC8, 0x64)];
|
||||
foreach (Color a in samples)
|
||||
{
|
||||
foreach (Color b in samples)
|
||||
{
|
||||
ColorMath.Contrast(a, b).Should().BeApproximately(Wcag.Ratio(a, b), 1e-9);
|
||||
}
|
||||
}
|
||||
|
||||
ColorMath.Over(Color.FromArgb(0x80, 0xFF, 0x00, 0x00), Colors.Black).Should().Be(Wcag.Over(Color.FromArgb(0x80, 0xFF, 0x00, 0x00), Colors.Black));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheDominantColourIsTheVividHueTheGreyAndBlackAroundItGiveNothing()
|
||||
{
|
||||
Color red = Color.FromRgb(200, 30, 40);
|
||||
Color blue = Color.FromRgb(30, 60, 210);
|
||||
ColorMath.Dominant(Pixels((red, 100))).Should().Be(red);
|
||||
ColorMath.Dominant(Pixels((Colors.White, 60), (Colors.Black, 20), (blue, 20)))!.Value.Should().Be(blue, "white and black carry no colour");
|
||||
ColorMath.Dominant(Pixels((Color.FromRgb(120, 120, 120), 99), (red, 1))).Should().BeNull("a grey picture with a speck of colour tints nothing");
|
||||
ColorMath.Dominant(Pixels((Color.FromArgb(0, 255, 0, 0), 50))).Should().BeNull("transparent pixels are not the picture");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The hardest colours for each theme: saturated yellow and white lift the dark theme's background toward its light text;
|
||||
/// black, deep blue and red pull the light theme's toward its dark text. Every text pair the header shows keeps its floor.
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData(ApplicationTheme.Dark)]
|
||||
[InlineData(ApplicationTheme.Light)]
|
||||
public async Task TheTintKeepsEveryTextOnTheBandReadableForTheHardestColours(ApplicationTheme theme)
|
||||
{
|
||||
Color[] hardest = [Colors.White, Colors.Black, Color.FromRgb(255, 230, 0), Color.FromRgb(0, 30, 200), Color.FromRgb(220, 0, 0), Color.FromRgb(0, 200, 120), Color.FromRgb(128, 128, 128)];
|
||||
|
||||
List<string> faint = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var themed = new ThemesDictionary { Theme = theme };
|
||||
var band = new Border();
|
||||
band.Resources.MergedDictionaries.Add(themed);
|
||||
Color window = Wcag.Resolve(themed, "ApplicationBackgroundColor");
|
||||
Color card = Wcag.Over(Wcag.Resolve(themed, "CardBackgroundFillColorDefault"), window);
|
||||
var found = new List<string>();
|
||||
foreach (Color dominant in hardest)
|
||||
{
|
||||
Color tinted = ArtTint.BandColour(band, dominant)!.Value;
|
||||
foreach ((string text, string? fill, double floor) in new[]
|
||||
{
|
||||
("TextFillColorPrimary", (string?)null, 4.5), ("TextFillColorSecondary", null, 4.5), ("TextFillColorTertiary", null, 3.0),
|
||||
("TextFillColorSecondary", "ControlFillColorDefault", 4.5), ("TextFillColorPrimary", "SystemFillColorCautionBackground", 4.5),
|
||||
})
|
||||
{
|
||||
Color under = fill is null ? tinted : Wcag.Over(Wcag.Resolve(themed, fill), tinted);
|
||||
double ratio = Wcag.Ratio(Wcag.Over(Wcag.Resolve(themed, text), under), under);
|
||||
if (ratio < floor)
|
||||
{
|
||||
found.Add($"{dominant} {text}/{fill}: {ratio:0.00} < {floor}");
|
||||
}
|
||||
}
|
||||
|
||||
// The tint never goes past its cap: at most 30 % (dark) or 22 % (light) of the colour over the card.
|
||||
double mix = Math.Max(Math.Abs(tinted.R - card.R), Math.Max(Math.Abs(tinted.G - card.G), Math.Abs(tinted.B - card.B)));
|
||||
double reach = Math.Max(Math.Abs(dominant.R - card.R), Math.Max(Math.Abs(dominant.G - card.G), Math.Abs(dominant.B - card.B)));
|
||||
if (reach > 0 && mix / reach > (theme == ApplicationTheme.Dark ? 0.30 : 0.22) + 0.01)
|
||||
{
|
||||
found.Add($"{dominant}: {mix / reach:0.00} of the colour");
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
});
|
||||
|
||||
faint.Should().BeEmpty($"every text on the tinted band keeps its floor in the {theme} theme");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ATintIsColourWhereTheThemeLeavesRoomForIt()
|
||||
{
|
||||
Color tinted = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var band = new Border();
|
||||
band.Resources.MergedDictionaries.Add(new ThemesDictionary { Theme = ApplicationTheme.Dark });
|
||||
return ArtTint.BandColour(band, Color.FromRgb(200, 30, 40))!.Value;
|
||||
});
|
||||
|
||||
tinted.R.Should().BeGreaterThan((byte)(tinted.G + 20), "a red cover reddens the dark band — it is a tint, not the card's fill");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (owner decision D60): the images users choose for their games — a re-encoded copy in the data folder's
|
||||
/// <c>covers</c>, a new name for each choice — and the tidying that deletes the ones no row names any more.
|
||||
/// </summary>
|
||||
public sealed class CoverStoreTests : IDisposable
|
||||
{
|
||||
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-covers-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
public CoverStoreTests() => Directory.CreateDirectory(_dir);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// A junction a test made goes on its own first: met inside a recursive delete, it is unmounted as a volume would be,
|
||||
// which Windows refuses without elevation (UnauthorizedAccessException) — though the link itself is then removed.
|
||||
var covers = new DirectoryInfo(Path.Combine(Data, "covers"));
|
||||
if (covers.Exists && covers.LinkTarget is not null)
|
||||
{
|
||||
covers.Delete();
|
||||
}
|
||||
|
||||
Directory.Delete(_dir, recursive: true);
|
||||
}
|
||||
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
private string Data => Path.Combine(_dir, "data");
|
||||
|
||||
[Fact]
|
||||
public async Task APickedImageIsCopiedAsAPngNoLargerThan1200PixelsUnderANewName()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var store = new CoverStore(new UiMode(false, Data), s.Games);
|
||||
string picked = TestImages.Write(Path.Combine(_dir, "mine.png"), TestImages.Png(1600, 2400, Color.FromRgb(10, 120, 200)));
|
||||
|
||||
string first = (await store.ImportAsync(7, picked, Ct))!;
|
||||
string second = (await store.ImportAsync(7, picked, Ct))!;
|
||||
|
||||
first.Should().MatchRegex(@"^covers\\game-7-\d+\.png$");
|
||||
second.Should().NotBe(first, "each choice is a new file, so a shown image is never written over");
|
||||
string full = CoverStore.Resolve(Data, first)!;
|
||||
BitmapFrame copy = BitmapDecoder.Create(new Uri(full), BitmapCreateOptions.None, BitmapCacheOption.OnLoad).Frames[0];
|
||||
copy.PixelHeight.Should().Be(1200);
|
||||
copy.PixelWidth.Should().Be(800);
|
||||
Directory.EnumerateFiles(Path.Combine(Data, "covers"), "*.tmp").Should().BeEmpty();
|
||||
File.Exists(picked).Should().BeTrue("the user's own file is read, never moved");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AFileThatIsNotAnImageIsRefusedAndLeavesNothing()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var store = new CoverStore(new UiMode(false, Data), s.Games);
|
||||
string notAnImage = TestImages.Write(Path.Combine(_dir, "notes.png"), "not an image"u8.ToArray());
|
||||
|
||||
(await store.ImportAsync(7, notAnImage, Ct)).Should().BeNull();
|
||||
(Directory.Exists(Path.Combine(Data, "covers")) ? Directory.EnumerateFiles(Path.Combine(Data, "covers")) : []).Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TidyingDeletesWhatNoRowNamesAndKeepsWhatARemovedRowStillOwns()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow kept = await s.GameAsync("Kept");
|
||||
GameRow removed = await s.GameAsync("Removed");
|
||||
string covers = Path.Combine(Data, "covers");
|
||||
string keptFile = "game-" + kept.Id + "-100.png";
|
||||
string removedFile = "game-" + removed.Id + "-100.png";
|
||||
foreach (string name in new[] { keptFile, removedFile, "game-" + kept.Id + "-99.png", "game-999999-1.png", "readme.txt" })
|
||||
{
|
||||
_ = TestImages.Write(Path.Combine(covers, name), [1]);
|
||||
}
|
||||
|
||||
string stale = TestImages.Write(Path.Combine(covers, "game-" + kept.Id + "-98.png.tmp"), [1]);
|
||||
File.SetLastWriteTimeUtc(stale, DateTime.UtcNow.AddHours(-2));
|
||||
string fresh = TestImages.Write(Path.Combine(covers, "game-" + kept.Id + "-101.png.tmp"), [1]);
|
||||
await s.Games.UpdateMetadataAsync(kept.Id, GameMetadata.Of(kept) with { CoverPath = "covers\\" + keptFile }, Ct);
|
||||
await s.Games.UpdateMetadataAsync(removed.Id, GameMetadata.Of(removed) with { CoverPath = "covers\\" + removedFile }, Ct);
|
||||
(await s.Games.RemoveAsync(removed.Id, keepSessions: true, Ct)).Should().BeTrue();
|
||||
|
||||
int deleted = await new CoverStore(new UiMode(false, Data), s.Games).PruneAsync(Ct);
|
||||
|
||||
deleted.Should().Be(3, "the replaced image, the deleted game's, and the copy half-written two hours ago");
|
||||
Directory.EnumerateFiles(covers).Select(Path.GetFileName).Should().BeEquivalentTo([keptFile, removedFile, "readme.txt", Path.GetFileName(fresh)],
|
||||
"a row removed with its sessions kept comes back with its image; another file's name is not ours to touch");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeletingFollowsOnlyOurOwnNames()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var store = new CoverStore(new UiMode(false, Data), s.Games);
|
||||
string outside = TestImages.Write(Path.Combine(_dir, "precious.png"), [1]);
|
||||
string ours = TestImages.Write(Path.Combine(Data, "covers", "game-3-4.png"), [1]);
|
||||
|
||||
store.Delete("covers\\..\\..\\precious.png");
|
||||
store.Delete(outside);
|
||||
store.Delete("covers\\game-3-4.png");
|
||||
|
||||
File.Exists(outside).Should().BeTrue();
|
||||
File.Exists(ours).Should().BeFalse();
|
||||
}
|
||||
|
||||
/// <summary>A <c>covers</c> folder that is a junction leads to another place: nothing behind it is shown, deleted, written or tidied.</summary>
|
||||
[Fact]
|
||||
public async Task ACoversFolderThatIsALinkIsNeverFollowed()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha");
|
||||
string elsewhere = Path.Combine(_dir, "elsewhere");
|
||||
string there = TestImages.Write(Path.Combine(elsewhere, "game-" + game.Id + "-1.png"), TestImages.Png(4, 4, Color.FromRgb(200, 30, 30)));
|
||||
_ = Directory.CreateDirectory(Data);
|
||||
Junction(Path.Combine(Data, "covers"), elsewhere);
|
||||
var store = new CoverStore(new UiMode(false, Data), s.Games);
|
||||
string picked = TestImages.Write(Path.Combine(_dir, "mine.png"), TestImages.Png(4, 4, Color.FromRgb(10, 120, 200)));
|
||||
|
||||
CoverStore.Resolve(Data, "covers\\" + Path.GetFileName(there)).Should().BeNull("the folder is a link");
|
||||
store.Delete("covers\\" + Path.GetFileName(there));
|
||||
(await store.ImportAsync(game.Id, picked, Ct)).Should().BeNull("no image is written through a link");
|
||||
(await store.PruneAsync(Ct)).Should().Be(0);
|
||||
|
||||
Directory.EnumerateFiles(elsewhere).Should().BeEquivalentTo([there], "nothing behind the link was deleted or written");
|
||||
}
|
||||
|
||||
private static void Junction(string link, string target)
|
||||
{
|
||||
var start = new ProcessStartInfo("cmd.exe") { CreateNoWindow = true, UseShellExecute = false };
|
||||
foreach (string arg in new[] { "/c", "mklink", "/J", link, target })
|
||||
{
|
||||
start.ArgumentList.Add(arg);
|
||||
}
|
||||
|
||||
using Process mklink = Process.Start(start)!;
|
||||
mklink.WaitForExit();
|
||||
mklink.ExitCode.Should().Be(0, "a junction needs no privilege");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.ViewModels;
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (owner decision D60): the edit dialog's image row. A picked image is previewed and copied only on Save; going
|
||||
/// back to the store's image drops the row's own; a file that is no image is said, and nothing is kept of it.
|
||||
/// </summary>
|
||||
public sealed class EditGameViewModelTests
|
||||
{
|
||||
private static readonly ImageSource _store = Frozen();
|
||||
private static readonly ImageSource _own = Frozen();
|
||||
private static readonly ImageSource _picked = Frozen();
|
||||
|
||||
private static BitmapSource Frozen()
|
||||
{
|
||||
BitmapSource image = BitmapSource.Create(2, 3, 96, 96, PixelFormats.Bgra32, null, new byte[24], 8);
|
||||
image.Freeze();
|
||||
return image;
|
||||
}
|
||||
|
||||
private sealed class Picker(string? path) : IImagePicker
|
||||
{
|
||||
public int Asked { get; private set; }
|
||||
|
||||
public string? PickImage()
|
||||
{
|
||||
Asked++;
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
private static EditImage Image(Picker picker, bool own, bool readable = true) =>
|
||||
new(own ? _own : _store, own, _store, picker, _ => Task.FromResult(readable ? _picked : null));
|
||||
|
||||
[Fact]
|
||||
public void WithoutAnImageRowTheDialogIsAsItWas()
|
||||
{
|
||||
var vm = new EditGameViewModel(new GameMetadata { Name = "Alpha", CoverPath = "covers\\game-1-2.png" }, provenanceJson: null);
|
||||
|
||||
vm.ImageEditable.Should().BeFalse();
|
||||
GameEdit edit = vm.Edit();
|
||||
edit.PickedImage.Should().BeNull();
|
||||
edit.Metadata.CoverPath.Should().Be("covers\\game-1-2.png", "an edit that did not touch the image keeps the row's");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task APickedImageIsPreviewedAndHandedOnOnlyWithTheSave()
|
||||
{
|
||||
var picker = new Picker(@"C:\Pictures\alpha.png");
|
||||
var vm = new EditGameViewModel(new GameMetadata { Name = "Alpha" }, null, Image(picker, own: false));
|
||||
vm.ImagePreview.Should().BeSameAs(_store);
|
||||
vm.CanUseStoreImage.Should().BeFalse("the store's image is the one shown");
|
||||
|
||||
await vm.ChooseImageCommand.ExecuteAsync(null);
|
||||
|
||||
vm.ImagePreview.Should().BeSameAs(_picked);
|
||||
vm.PickedImage.Should().Be(@"C:\Pictures\alpha.png");
|
||||
vm.CanUseStoreImage.Should().BeTrue();
|
||||
vm.Edit().PickedImage.Should().Be(@"C:\Pictures\alpha.png", "Save hands the file on to be copied");
|
||||
|
||||
vm.UseStoreImageCommand.Execute(null);
|
||||
vm.ImagePreview.Should().BeSameAs(_store);
|
||||
vm.Edit().PickedImage.Should().BeNull("going back to the store's image drops the pick");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AFileThatIsNoImageIsSaidAndNotKept()
|
||||
{
|
||||
var vm = new EditGameViewModel(new GameMetadata { Name = "Alpha" }, null, Image(new Picker(@"C:\notes.txt"), own: false, readable: false));
|
||||
|
||||
await vm.ChooseImageCommand.ExecuteAsync(null);
|
||||
|
||||
vm.ImageError.Should().Be(Strings.Art_ImportFailed);
|
||||
vm.PickedImage.Should().BeNull();
|
||||
vm.ImagePreview.Should().BeSameAs(_store);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UsingTheStoresImageDropsTheRowsOwnAndACancelledPickChangesNothing()
|
||||
{
|
||||
var picker = new Picker(null);
|
||||
var vm = new EditGameViewModel(new GameMetadata { Name = "Alpha", CoverPath = "covers\\game-1-2.png" }, null, Image(picker, own: true));
|
||||
vm.CanUseStoreImage.Should().BeTrue("the user's own image is the one shown");
|
||||
|
||||
await vm.ChooseImageCommand.ExecuteAsync(null);
|
||||
picker.Asked.Should().Be(1);
|
||||
vm.ImagePreview.Should().BeSameAs(_own, "a cancelled pick changes nothing");
|
||||
|
||||
vm.UseStoreImageCommand.Execute(null);
|
||||
vm.Edit().Metadata.CoverPath.Should().BeNull("Save drops the row's own image");
|
||||
vm.ImagePreview.Should().BeSameAs(_store);
|
||||
vm.CanUseStoreImage.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Art;
|
||||
using FrameLedger.Application.Import;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Application.Settings;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (owner decisions D60/D61): a game's artwork — the user's own image first, else what the app of the store that
|
||||
/// installed it keeps on this PC, found through that store's own records as Play finds it — and the colour it gives the band.
|
||||
/// </summary>
|
||||
[Collection(StringsCultureCollection.Name)]
|
||||
public sealed class GameArtTests : IDisposable
|
||||
{
|
||||
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-gameart-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
public GameArtTests() => Directory.CreateDirectory(_dir);
|
||||
|
||||
public void Dispose() => Directory.Delete(_dir, recursive: true);
|
||||
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
private string Install => Path.Combine(_dir, "Steam", "steamapps", "common", "Alpha");
|
||||
|
||||
private GameArt Art(MemorySettings settings, IStoreLibrarySource store, IStoreArtCache cache) =>
|
||||
new(new RegisteredSettings(settings), new StoreRecordsReader([store]), [cache], new UiMode(false, Path.Combine(_dir, "data")));
|
||||
|
||||
private (IStoreLibrarySource Store, TestImages.ArtCache Cache) SteamWith(bool cover = true, bool hero = true)
|
||||
{
|
||||
string? c = cover ? TestImages.Write(Path.Combine(_dir, "cache", "library_600x900.jpg"), TestImages.Png(30, 45, Color.FromRgb(200, 40, 40))) : null;
|
||||
string? h = hero ? TestImages.Write(Path.Combine(_dir, "cache", "library_hero.jpg"), TestImages.Png(96, 31, Color.FromRgb(40, 40, 200))) : null;
|
||||
var store = new TestImages.Store("steam", new StoreGame("steam", "374320", "Alpha", Install, null, null));
|
||||
return (store, new TestImages.ArtCache("steam", "374320", new GameArtFiles(c, h, null)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheStoresCoverAndBannerShowWithTheColourOfTheCover()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(Install, "Alpha.exe"));
|
||||
(IStoreLibrarySource store, TestImages.ArtCache cache) = SteamWith();
|
||||
|
||||
GameArtView view = (await Art(new MemorySettings(), store, cache).ForAsync(game, Ct))!;
|
||||
|
||||
view.Cover.Should().NotBeNull();
|
||||
view.Hero.Should().NotBeNull();
|
||||
view.CoverIsOwn.Should().BeFalse();
|
||||
view.Source.Should().Be(Strings.Art_Source_Steam);
|
||||
view.Tint.Should().NotBeNull("the cover is red; the band takes it");
|
||||
view.Tint!.Value.R.Should().BeGreaterThan(view.Tint.Value.B, "the cover's colour, not the banner's");
|
||||
view.Cover!.IsFrozen.Should().BeTrue("decoded off the UI thread, so frozen to be bound on it");
|
||||
cache.Asked.Should().Equal("374320");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheUsersOwnImageComesBeforeTheStoresAndAMissingOneFallsBackToIt()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(Install, "Alpha.exe"));
|
||||
(IStoreLibrarySource store, TestImages.ArtCache cache) = SteamWith();
|
||||
_ = TestImages.Write(Path.Combine(_dir, "data", "covers", "game-" + game.Id + "-5.png"), TestImages.Png(20, 30, Color.FromRgb(20, 160, 60)));
|
||||
GameRow own = game with { CoverPath = "covers\\game-" + game.Id + "-5.png" };
|
||||
GameArt art = Art(new MemorySettings(), store, cache);
|
||||
|
||||
GameArtView mine = (await art.ForAsync(own, Ct))!;
|
||||
mine.CoverIsOwn.Should().BeTrue();
|
||||
mine.Source.Should().Be(Strings.Art_Source_Yours);
|
||||
mine.StoreCover.Should().NotBeNull("the edit dialog's \"use the store's image\" needs it");
|
||||
mine.Tint!.Value.G.Should().BeGreaterThan(mine.Tint.Value.R, "the band takes the user's image's colour");
|
||||
|
||||
GameArtView gone = (await art.ForAsync(game with { CoverPath = "covers\\game-" + game.Id + "-6.png" }, Ct))!;
|
||||
gone.CoverIsOwn.Should().BeFalse("a chosen image whose file is gone is the store's again");
|
||||
gone.Source.Should().Be(Strings.Art_Source_Steam);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("C:\\Windows\\Web\\Wallpaper\\img0.jpg")]
|
||||
[InlineData("\\\\server\\share\\x.png")]
|
||||
[InlineData("covers\\..\\..\\x.png")]
|
||||
[InlineData("covers\\anything.png")]
|
||||
[InlineData("other\\game-1-5.png")]
|
||||
public void ACoverPathThatIsNotOneOfOursIsNeverFollowed(string coverPath)
|
||||
{
|
||||
// A viewer opens a copy of a ledger that may come from anywhere: a share would have Windows offer this user's credentials.
|
||||
_ = TestImages.Write(Path.Combine(_dir, "data", "covers", "anything.png"), TestImages.Png(4, 4, Colors.Gray));
|
||||
CoverStore.Resolve(Path.Combine(_dir, "data"), coverPath).Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AGameNoArtStoreInstalledHasNoneWhateverItsPlatformSays()
|
||||
{
|
||||
// D59: detection rewrites platform (an itch build that ships Steam's API reads as Steam) while the id stays the
|
||||
// importer's; the store is asked of the records, and no Steam folder holds an itch install.
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(_dir, "itch", "apps", "alpha", "Alpha.exe"));
|
||||
GameRow claimsSteam = game with { Platform = "steam", StoreId = "374320" };
|
||||
(IStoreLibrarySource store, TestImages.ArtCache cache) = SteamWith();
|
||||
|
||||
(await Art(new MemorySettings(), store, cache).ForAsync(claimsSteam, Ct)).Should().BeNull();
|
||||
cache.Asked.Should().BeEmpty("no Steam record owns the folder, so Steam's artwork is never asked");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OffInSettingsNothingIsReadAndUntintedTheBandKeepsTheCardsFill()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(Install, "Alpha.exe"));
|
||||
(IStoreLibrarySource store, TestImages.ArtCache cache) = SteamWith();
|
||||
var off = new MemorySettings();
|
||||
off.Rows[SettingsRegistry.UiGameArt.Key] = "0";
|
||||
var noTint = new MemorySettings();
|
||||
noTint.Rows[SettingsRegistry.UiGameArtTint.Key] = "0";
|
||||
|
||||
(await Art(off, store, cache).ForAsync(game, Ct)).Should().BeNull();
|
||||
((TestImages.Store)store).Reads.Should().Be(0, "with the artwork off no store's records are read");
|
||||
GameArtView untinted = (await Art(noTint, store, cache).ForAsync(game, Ct))!;
|
||||
untinted.Cover.Should().NotBeNull();
|
||||
untinted.Tint.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ADamagedFileIsNoImageAndAGreyPictureTintsNothing()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(Install, "Alpha.exe"));
|
||||
string damaged = TestImages.Write(Path.Combine(_dir, "cache", "library_600x900.jpg"), [0x42, 0x41, 0x44]);
|
||||
string grey = TestImages.Write(Path.Combine(_dir, "cache", "library_hero.jpg"), TestImages.Png(64, 20, Color.FromRgb(128, 128, 128)));
|
||||
var store = new TestImages.Store("steam", new StoreGame("steam", "374320", "Alpha", Install, null, null));
|
||||
var cache = new TestImages.ArtCache("steam", "374320", new GameArtFiles(damaged, grey, null));
|
||||
|
||||
GameArtView view = (await Art(new MemorySettings(), store, cache).ForAsync(game, Ct))!;
|
||||
|
||||
view.Cover.Should().BeNull("a file Windows cannot read as an image is no image, never an error");
|
||||
view.Hero.Should().NotBeNull();
|
||||
view.Tint.Should().BeNull("a grey picture has no colour to give");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheStoresRecordsAreReadOnceForPagesOpenedTogether()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(Install, "Alpha.exe"));
|
||||
(IStoreLibrarySource store, TestImages.ArtCache cache) = SteamWith();
|
||||
GameArt art = Art(new MemorySettings(), store, cache);
|
||||
|
||||
_ = await art.ForAsync(game, Ct);
|
||||
_ = await art.ForAsync(game, Ct);
|
||||
|
||||
((TestImages.Store)store).Reads.Should().Be(1, "Steam's records are kept two minutes, not read at every page");
|
||||
}
|
||||
}
|
||||
@@ -82,9 +82,16 @@ public sealed class GameDetailViewModelTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class FakeEdit(GameMetadata? answer) : IEditGamePrompt
|
||||
private sealed class FakeEdit(GameMetadata? answer, string? picked = null) : IEditGamePrompt
|
||||
{
|
||||
public Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default) => Task.FromResult(answer);
|
||||
/// <summary>The image the page handed the dialog (beta.23), for a test to look at.</summary>
|
||||
public EditImage? Image { get; private set; }
|
||||
|
||||
public Task<GameEdit?> EditAsync(GameMetadata current, string? provenanceJson, EditImage? image = null, CancellationToken ct = default)
|
||||
{
|
||||
Image = image;
|
||||
return Task.FromResult(answer is null ? null : new GameEdit(answer, picked));
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NoSummaries : ISessionSummaryOpener
|
||||
@@ -1073,6 +1080,67 @@ public sealed class GameDetailViewModelTests
|
||||
vm.ExecutableMissingMessage.Should().StartWith(GameDetailViewModel.ExecutableMissingText).And.Contain(Path.GetFileName(game.Fingerprint.ExePath));
|
||||
}
|
||||
|
||||
/// <summary>An image picker the page hands the edit dialog; the fake dialog answers the pick itself.</summary>
|
||||
private sealed class NoImagePicker : IImagePicker
|
||||
{
|
||||
public string? PickImage() => null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (D60): the page shows the store's artwork; an image picked in Edit is copied on Save and becomes the page's,
|
||||
/// the one it replaced is deleted, and removing the game with its sessions deletes the last.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task ThePagesArtworkFollowsTheImageChosenInEditAndGoesWithTheGame()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
string dir = Path.Combine(Path.GetTempPath(), "fl-detail-art-" + Guid.NewGuid().ToString("N"));
|
||||
try
|
||||
{
|
||||
string install = Path.Combine(dir, "Steam", "steamapps", "common", "Alpha");
|
||||
GameRow game = await s.GameAsync("Alpha", Path.Combine(install, "Alpha.exe"));
|
||||
string storeCover = TestImages.Write(Path.Combine(dir, "cache", "library_600x900.jpg"), TestImages.Png(30, 45, System.Windows.Media.Color.FromRgb(200, 40, 40)));
|
||||
var store = new TestImages.Store("steam", new Application.Import.StoreGame("steam", "374320", "Alpha", install, null, null));
|
||||
var cache = new TestImages.ArtCache("steam", "374320", new Application.Art.GameArtFiles(storeCover, null, null));
|
||||
var mode = new UiMode(false, Path.Combine(dir, "data"));
|
||||
var art = new GameArt(new RegisteredSettings(new MemorySettings()), new StoreRecordsReader([store]), [cache], mode);
|
||||
var covers = new CoverStore(mode, s.Games);
|
||||
string first = TestImages.Write(Path.Combine(dir, "first.png"), TestImages.Png(40, 60, System.Windows.Media.Color.FromRgb(20, 160, 60)));
|
||||
string second = TestImages.Write(Path.Combine(dir, "second.png"), TestImages.Png(40, 60, System.Windows.Media.Color.FromRgb(20, 60, 160)));
|
||||
|
||||
GameDetailViewModel Page(string? picked, RemoveGameChoice remove = RemoveGameChoice.Cancel) => new(s.Library, new GameSelection { GameId = game.Id },
|
||||
new HookingConsent(new FakeAgent(), new FakePrompt()), new FakeNavigator(), new FakeConfirmations(remove), new FakeEdit(GameMetadata.Of(game), picked),
|
||||
new FakeStrip(), new NoSummaries(), new Charts.SessionSeriesLoader(s.Sessions), new Infrastructure.Persistence.SqliteHardwareSnapshotRepository(s.Db),
|
||||
new SessionSelection(), new FakePicker(null), art: art, covers: covers, images: new NoImagePicker());
|
||||
|
||||
GameDetailViewModel vm = Page(first);
|
||||
await vm.Pending;
|
||||
vm.HasArt.Should().BeTrue();
|
||||
vm.ArtSource.Should().Be(Strings.Art_Source_Steam);
|
||||
vm.ArtTint.Should().NotBeNull();
|
||||
|
||||
await vm.EditCommand.ExecuteAsync(null);
|
||||
string? firstCopy = vm.Game!.CoverPath;
|
||||
firstCopy.Should().StartWith(@"covers\game-" + game.Id + "-");
|
||||
vm.ArtSource.Should().Be(Strings.Art_Source_Yours, "the page reloads with the image just chosen");
|
||||
File.Exists(CoverStore.Resolve(mode.DataDirectory, firstCopy)).Should().BeTrue();
|
||||
|
||||
GameDetailViewModel again = Page(second, RemoveGameChoice.DeleteSessions);
|
||||
await again.Pending;
|
||||
await again.EditCommand.ExecuteAsync(null);
|
||||
string? secondCopy = again.Game!.CoverPath;
|
||||
secondCopy.Should().NotBe(firstCopy);
|
||||
Directory.EnumerateFiles(Path.Combine(mode.DataDirectory, "covers")).Should().ContainSingle("the image it replaced is deleted once the row names the new one");
|
||||
|
||||
await again.RemoveCommand.ExecuteAsync(null);
|
||||
Directory.EnumerateFiles(Path.Combine(mode.DataDirectory, "covers")).Should().BeEmpty("a game removed with its sessions takes its image with it");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>beta.8: a session that was not hooked has its sensors, and the Sensors tab draws them instead of saying "not hooked".</summary>
|
||||
[Fact]
|
||||
public async Task ATierTwoSessionsSensorsAreTheSensorsTabs()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Charts;
|
||||
using FrameLedger.App.Controls;
|
||||
@@ -86,8 +87,19 @@ public sealed partial class PagesLoadTests
|
||||
Games = new GamesViewModel(s.Library, selection, nav, new AddGameFlow(s.Library, new NoPicker(), selection, nav, strip));
|
||||
Task pending2 = Games.Pending;
|
||||
await pending2.ConfigureAwait(false);
|
||||
// beta.23 (D60/D61): the game page with artwork — a banner and a saturated cover — so every text on the tinted band is
|
||||
// measured in both themes and through a switch; the store app's folder is one this test draws.
|
||||
string artDirectory = Path.Combine(Path.GetTempPath(), "fl-surfaces-art-" + Guid.NewGuid().ToString("N"));
|
||||
Own(new DeletesOnDispose(artDirectory));
|
||||
GameRow game = (await s.Games.FindByIdAsync(gameId).ConfigureAwait(false))!;
|
||||
string cover = TestImages.Write(Path.Combine(artDirectory, "library_600x900.jpg"), TestImages.Png(30, 45, System.Windows.Media.Color.FromRgb(230, 200, 20)));
|
||||
string hero = TestImages.Write(Path.Combine(artDirectory, "library_hero.jpg"), TestImages.Png(96, 31, System.Windows.Media.Color.FromRgb(30, 60, 210)));
|
||||
var art = new GameArt(new RegisteredSettings(new MemorySettings()),
|
||||
new StoreRecordsReader([new TestImages.Store("steam", new Application.Import.StoreGame("steam", "374320", "Alpha", Path.GetDirectoryName(game.Fingerprint.ExePath)!, null, null))]),
|
||||
[new TestImages.ArtCache("steam", "374320", new Application.Art.GameArtFiles(cover, hero, null))],
|
||||
new UiMode(false, artDirectory));
|
||||
Detail = new GameDetailViewModel(s.Library, selection, consent, nav, new NoConfirm(), new NoEdit(), strip, new NoSummaries(),
|
||||
new SessionSeriesLoader(s.Sessions), new SqliteHardwareSnapshotRepository(s.Db), new SessionSelection(), new NoPicker());
|
||||
new SessionSeriesLoader(s.Sessions), new SqliteHardwareSnapshotRepository(s.Db), new SessionSelection(), new NoPicker(), art: art);
|
||||
Task pending3 = Detail.Pending;
|
||||
await pending3.ConfigureAwait(false);
|
||||
Compare = new CompareViewModel(s.Library, new SessionSeriesLoader(s.Sessions), new NoMixed(), new NoSaver(), strip);
|
||||
@@ -130,6 +142,11 @@ public sealed partial class PagesLoadTests
|
||||
("Bug report preview", () => new BugReportPreviewContent(new BugReportPreviewViewModel(new BugReportPreviewModel(@"C:\data\bug-report.zip",
|
||||
["logs/ui-20261007.log", "system.txt"], new Uri("https://github.com/poli0981/frameledger/issues/new"), "## What happened")))),
|
||||
("Edit game", () => new EditGameContent(new EditGameViewModel(new GameMetadata { Name = "Alpha" }, provenanceJson: null))),
|
||||
// beta.23 (D60): the image row, with no image (its caption shows) and with the user's own (the store's button shows).
|
||||
("Edit game, no image", () => new EditGameContent(new EditGameViewModel(new GameMetadata { Name = "Alpha" }, provenanceJson: null,
|
||||
new EditImage(null, CurrentIsOwn: false, null, new NoImages(), static _ => Task.FromResult<System.Windows.Media.ImageSource?>(null))))),
|
||||
("Edit game, own image", () => new EditGameContent(new EditGameViewModel(new GameMetadata { Name = "Alpha" }, provenanceJson: null,
|
||||
new EditImage(Detail.ArtCover, CurrentIsOwn: true, Detail.ArtCover, new NoImages(), static _ => Task.FromResult<System.Windows.Media.ImageSource?>(null))))),
|
||||
("Override", () => new TriStateOverrideContent(new TriStateOverrideViewModel(new TriStateChipModel("RT", Tri.Yes, TriStateSource.Measured)))),
|
||||
("Bug bundle options", () => new BugBundleOptionsContent(new BugBundleOptionsViewModel(new BugBundleOffer(
|
||||
new CrashDumpInfo(@"C:\data\crashdumps\ui-20261007-010203-42.dmp", DateTimeOffset.UtcNow, 2 * 1024 * 1024), new LastSessionInfo(1, "Alpha", DateTimeOffset.UtcNow))))),
|
||||
@@ -168,4 +185,19 @@ public sealed partial class PagesLoadTests
|
||||
return disposable;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A folder the test made, deleted with the surfaces.</summary>
|
||||
private sealed class DeletesOnDispose(string directory) : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(directory, recursive: true);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,4 +206,53 @@ public sealed partial class PagesLoadTests
|
||||
private readonly record struct DrawnText(string Path, string Text, string Colour, bool Shown);
|
||||
|
||||
private static Color Solid(Brush brush) => brush is SolidColorBrush solid ? solid.Color : throw new InvalidOperationException("a text whose foreground is not a solid colour");
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (D61): the artwork band's colour is worked out from the theme's own colours and follows a switch — a band made
|
||||
/// under Dark and switched to Light is the band a page made under Light draws. The text check above cannot see it: it
|
||||
/// compares texts' colours, and a band left in the old theme keeps every text's colour and loses its contrast.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task TheArtworkBandFollowsAThemeSwitch()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
using Surfaces surfaces = await Surfaces.LoadAsync(s);
|
||||
surfaces.Detail.HasArt.Should().BeTrue("the surfaces' game has a cover and a banner");
|
||||
surfaces.Detail.ArtTint.Should().NotBeNull();
|
||||
|
||||
(Color Dark, Color Switched, Color Fresh) bands = await OnStaAsync(() =>
|
||||
{
|
||||
(Window host, FrameworkElement switched) = Hosted(() => new Pages.GameDetailPage(surfaces.Detail));
|
||||
try
|
||||
{
|
||||
Lay(switched);
|
||||
Color dark = BandOf(switched);
|
||||
return Visuals.UnderTheme(ApplicationTheme.Light, () =>
|
||||
{
|
||||
Lay(switched);
|
||||
(Window freshHost, FrameworkElement fresh) = Hosted(() => new Pages.GameDetailPage(surfaces.Detail));
|
||||
try
|
||||
{
|
||||
Lay(fresh);
|
||||
return (dark, BandOf(switched), BandOf(fresh));
|
||||
}
|
||||
finally
|
||||
{
|
||||
freshHost.Close();
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Close();
|
||||
}
|
||||
});
|
||||
|
||||
bands.Switched.Should().Be(bands.Fresh, "the switched band is the one a fresh page draws under the new theme");
|
||||
bands.Switched.Should().NotBe(bands.Dark, "the band changed with the theme");
|
||||
}
|
||||
|
||||
/// <summary>The artwork band's colour, under the frame a page is hosted in.</summary>
|
||||
private static Color BandOf(FrameworkElement root) =>
|
||||
Solid(Visuals.FindAll<System.Windows.Controls.Border>(root).First(static b => string.Equals(b.Name, "ArtBand", StringComparison.Ordinal)).Background);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Charts;
|
||||
using FrameLedger.App.Controls;
|
||||
@@ -82,7 +83,7 @@ public sealed partial class PagesLoadTests
|
||||
|
||||
private sealed class NoEdit : IEditGamePrompt
|
||||
{
|
||||
public Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default) => Task.FromResult<GameMetadata?>(null);
|
||||
public Task<GameEdit?> EditAsync(GameMetadata current, string? provenanceJson, EditImage? image = null, CancellationToken ct = default) => Task.FromResult<GameEdit?>(null);
|
||||
}
|
||||
|
||||
private sealed class NoStrip : IMessageStrip
|
||||
@@ -132,6 +133,11 @@ public sealed partial class PagesLoadTests
|
||||
public string? PickExecutable(string? initialDirectory = null) => null;
|
||||
}
|
||||
|
||||
private sealed class NoImages : IImagePicker
|
||||
{
|
||||
public string? PickImage() => null;
|
||||
}
|
||||
|
||||
private sealed class NoTheme : IThemeApplier
|
||||
{
|
||||
public void Apply(AppTheme theme, Window? window)
|
||||
@@ -533,6 +539,38 @@ public sealed partial class PagesLoadTests
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (D60): the game page's artwork is drawn — the banner and the cover are each a WPF UI <c>Image</c>, whose
|
||||
/// template holds the picture. A <c>ui:Image</c> given a Style of its own that is not based on WPF UI's
|
||||
/// <c>DefaultImageStyle</c> has no template: it takes its place and draws nothing. The cover did exactly that — an empty
|
||||
/// space beside the game's name, the banner above it drawn — and no text check can see a picture.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task TheGamePagesArtworkIsDrawn()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
using Surfaces surfaces = await Surfaces.LoadAsync(s);
|
||||
|
||||
List<string> images = await OnStaAsync(() =>
|
||||
{
|
||||
(Window host, FrameworkElement root) = Hosted(() => new GameDetailPage(surfaces.Detail));
|
||||
try
|
||||
{
|
||||
Lay(root);
|
||||
return Visuals.FindAll<Wpf.Ui.Controls.Image>(root)
|
||||
.Select(static image => AutomationProperties.GetName(image) + (Visuals.Find<System.Windows.Controls.Image>(image) is { Source: not null, ActualWidth: > 0, ActualHeight: > 0 }
|
||||
? ": drawn" : ": nothing drawn"))
|
||||
.ToList();
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Close();
|
||||
}
|
||||
});
|
||||
|
||||
images.Should().Equal([Strings.Art_Banner_Name + ": drawn", Strings.Art_Cover_Name + ": drawn"], "the surfaces' game has a banner and a cover, and both are on its page");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EveryPageLoadsUnderTheThemeDictionaries()
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ public sealed class SessionDeletionAndOverviewTests
|
||||
|
||||
private sealed class NoEdit : IEditGamePrompt
|
||||
{
|
||||
public Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default) => Task.FromResult<GameMetadata?>(null);
|
||||
public Task<GameEdit?> EditAsync(GameMetadata current, string? provenanceJson, EditImage? image = null, CancellationToken ct = default) => Task.FromResult<GameEdit?>(null);
|
||||
}
|
||||
|
||||
private sealed class NoSummaries : ISessionSummaryOpener
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using FrameLedger.Application.Art;
|
||||
using FrameLedger.Application.Import;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>Images and stores for the artwork checks (beta.23, D60/D61): PNGs drawn here, never a store's real artwork.</summary>
|
||||
internal static class TestImages
|
||||
{
|
||||
/// <summary>A PNG of <paramref name="width"/> × <paramref name="height"/>, its left part <paramref name="left"/> and the rest <paramref name="right"/>.</summary>
|
||||
public static byte[] Png(int width, int height, Color left, Color? right = null, double leftShare = 1)
|
||||
{
|
||||
int stride = width * 4;
|
||||
byte[] pixels = new byte[stride * height];
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
Color c = x < width * leftShare ? left : right ?? left;
|
||||
int i = (y * stride) + (x * 4);
|
||||
pixels[i] = c.B;
|
||||
pixels[i + 1] = c.G;
|
||||
pixels[i + 2] = c.R;
|
||||
pixels[i + 3] = c.A;
|
||||
}
|
||||
}
|
||||
|
||||
BitmapSource image = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgra32, null, pixels, stride);
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(image));
|
||||
using var output = new MemoryStream();
|
||||
encoder.Save(output);
|
||||
return output.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>Writes <paramref name="bytes"/> at <paramref name="path"/>, its folder made first; the path.</summary>
|
||||
public static string Write(string path, byte[] bytes)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
File.WriteAllBytes(path, bytes);
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>A store whose records are the ones given.</summary>
|
||||
internal sealed class Store(string platform, params StoreGame[] games) : IStoreLibrarySource
|
||||
{
|
||||
public string Platform => platform;
|
||||
|
||||
public int Reads { get; private set; }
|
||||
|
||||
public ValueTask<IReadOnlyList<StoreGame>> ListAsync(CancellationToken ct = default)
|
||||
{
|
||||
Reads++;
|
||||
return ValueTask.FromResult<IReadOnlyList<StoreGame>>(games);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A store app's artwork folder that answers the files given for one id.</summary>
|
||||
internal sealed class ArtCache(string platform, string storeId, GameArtFiles files) : IStoreArtCache
|
||||
{
|
||||
public string Platform => platform;
|
||||
|
||||
public List<string> Asked { get; } = [];
|
||||
|
||||
public GameArtFiles Find(string id)
|
||||
{
|
||||
Asked.Add(id);
|
||||
return string.Equals(id, storeId, StringComparison.Ordinal) ? files : GameArtFiles.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.Application.Art;
|
||||
using FrameLedger.Infrastructure.Art;
|
||||
|
||||
namespace FrameLedger.Infrastructure.Tests.Import;
|
||||
|
||||
/// <summary>
|
||||
/// beta.23 (owner decision D60): the artwork the Steam and GOG GALAXY apps keep on this PC, found in the layouts read on the
|
||||
/// owner's PC on 2026-10-14 — Steam's files directly in the app's folder, in hash-named folders, or both; GOG's per user
|
||||
/// and per product — and never outside the store's own folder.
|
||||
/// </summary>
|
||||
public sealed class StoreArtCachesTests : IDisposable
|
||||
{
|
||||
private readonly string _dir = Path.Combine(Path.GetTempPath(), "fl-art-" + Guid.NewGuid().ToString("N"));
|
||||
|
||||
public StoreArtCachesTests() => Directory.CreateDirectory(_dir);
|
||||
|
||||
public void Dispose() => Directory.Delete(_dir, recursive: true);
|
||||
|
||||
private string Touch(DateTime writtenUtc, params string[] parts)
|
||||
{
|
||||
string path = Path.Combine([_dir, .. parts]);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
File.WriteAllBytes(path, [1, 2, 3]);
|
||||
File.SetLastWriteTimeUtc(path, writtenUtc);
|
||||
return path;
|
||||
}
|
||||
|
||||
private string Steam(string appId, params string[] parts) => Touch(DateTime.UtcNow, ["Steam", "appcache", "librarycache", appId, .. parts]);
|
||||
|
||||
[Fact]
|
||||
public void SteamFindsTheFilesInTheAppsFolder()
|
||||
{
|
||||
string cover = Steam("374320", "library_600x900.jpg");
|
||||
string hero = Steam("374320", "library_hero.jpg");
|
||||
string header = Steam("374320", "header.jpg");
|
||||
_ = Steam("374320", "library_hero_blur.jpg");
|
||||
_ = Steam("374320", "logo.png");
|
||||
|
||||
GameArtFiles files = new SteamArtCache(Path.Combine(_dir, "Steam")).Find("374320");
|
||||
|
||||
files.Should().Be(new GameArtFiles(cover, hero, header));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SteamFindsTheFilesInHashNamedFoldersAndPrefersTheBetterCoverAndTheNewestCopy()
|
||||
{
|
||||
DateTime old = DateTime.UtcNow.AddDays(-30);
|
||||
_ = Touch(old, "Steam", "appcache", "librarycache", "1091500", "aaaa", "library_hero.jpg");
|
||||
string newerHero = Steam("1091500", "bbbb", "library_hero.jpg");
|
||||
string capsule = Steam("1091500", "cccc", "library_capsule.jpg");
|
||||
string header = Steam("1091500", "dddd", "library_header.jpg");
|
||||
|
||||
GameArtFiles files = new SteamArtCache(Path.Combine(_dir, "Steam")).Find("1091500");
|
||||
|
||||
files.Cover.Should().Be(capsule);
|
||||
files.Hero.Should().Be(newerHero, "an asset Steam replaced has a newer copy in a new folder");
|
||||
files.Header.Should().Be(header);
|
||||
|
||||
string portrait = Steam("1091500", "library_600x900.jpg");
|
||||
new SteamArtCache(Path.Combine(_dir, "Steam")).Find("1091500").Cover.Should().Be(portrait, "the 600x900 portrait is preferred over the capsule");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("..")]
|
||||
[InlineData("..\\..\\Windows")]
|
||||
[InlineData("C:\\")]
|
||||
[InlineData("12a")]
|
||||
public void AnIdThatIsNotTheStoresOwnShapeNamesNoFolder(string id)
|
||||
{
|
||||
_ = Steam("374320", "library_600x900.jpg");
|
||||
new SteamArtCache(Path.Combine(_dir, "Steam")).Find(id).Should().Be(GameArtFiles.None);
|
||||
new GogArtCache(Path.Combine(_dir, "webcache")).Find(id).Should().Be(GameArtFiles.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NothingThereIsNoneNeverAnError()
|
||||
{
|
||||
new SteamArtCache(Path.Combine(_dir, "no-steam")).Find("374320").Should().Be(GameArtFiles.None);
|
||||
new GogArtCache(Path.Combine(_dir, "no-galaxy")).Find("1125815775").Should().Be(GameArtFiles.None);
|
||||
_ = Directory.CreateDirectory(Path.Combine(_dir, "Steam", "appcache", "librarycache", "220"));
|
||||
new SteamArtCache(Path.Combine(_dir, "Steam")).Find("220").IsEmpty.Should().BeTrue("Steam keeps a folder with no artwork in it for some apps");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GogFindsTheCoverAndTheBannerInAnyUsersFolder()
|
||||
{
|
||||
_ = Touch(DateTime.UtcNow.AddDays(-2), "webcache", "111", "gog", "1125815775", "00aa_glx_vertical_cover.webp");
|
||||
string cover = Touch(DateTime.UtcNow, "webcache", "222", "gog", "1125815775", "11bb_glx_vertical_cover.webp");
|
||||
string banner = Touch(DateTime.UtcNow, "webcache", "222", "gog", "1125815775", "22cc_glx_bg_top_padding_7.webp");
|
||||
_ = Touch(DateTime.UtcNow, "webcache", "222", "gog", "1125815775", "33dd_glx_square_icon_v2.webp");
|
||||
_ = Directory.CreateDirectory(Path.Combine(_dir, "webcache", "common"));
|
||||
|
||||
GameArtFiles files = new GogArtCache(Path.Combine(_dir, "webcache")).Find("1125815775");
|
||||
|
||||
files.Should().Be(new GameArtFiles(cover, banner, null), "the newest copy wins across users, and GOG keeps no header");
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,9 @@ Japanese wait for a human reviewer, never a machine draft ([`docs/09_I18N.md`](.
|
||||
Colours come only from WPF UI's theme brushes, by `DynamicResource` — never a hex value, never `StaticResource` for a
|
||||
theme brush. Muted text uses the App's `SecondaryText` and `TertiaryText` styles (`src/FrameLedger.App/Styles/FrameLedger.xaml`),
|
||||
and every page sets the theme's text colour on its root.
|
||||
The chart palettes are the one place a colour is written out, once per theme.
|
||||
The chart palettes are the one place a colour is written out, once per theme. The game page's artwork band is the one
|
||||
colour worked out in code: the artwork's own, as strongly as every text on it still reads, recomputed when the theme
|
||||
changes.
|
||||
|
||||
## The traps of WPF UI 4.3.0
|
||||
|
||||
|
||||
Reference in new issue
Block a user