feat(saves): show read-only per-slot thumbnails, location, era, progress stats, and full date/time #253

Open
Jer9 wants to merge 1 commit from Jer9/LongshotLauncher:feat/saves-slot-previews-main into main
First-time contributor

Players with multiple saves on the Saves tab can currently only see "Slot 1 / Slot 2" and a date (without the time for older saves), making it hard to tell which playthrough is which. This adds strictly read-only per-slot previews (caption.sav / progress.sav) and full date+time timestamps to the Saves tab without writing to save files or changing SavesConfirmViewModel.

Summary

  • Read-only slot preview parser (Core/SaveSlotPreview.cs):
    • Strictly read-only (FileAccess.Read, FileShare.ReadWrite | FileShare.Delete) and bounds-checked (<= 8 MiB for caption.sav, <= 4 MiB for progress.sav).
    • Refuses symlinks and NTFS junctions (LinkTarget != null || FileAttributes.ReparsePoint) on both the slot_NN directory (trimming trailing directory separators) and leaf files (caption.sav / progress.sav), including on direct ReadCaption / ReadProgress calls.
    • Parses caption.sav area name via SaveEditorText.Humanize, Child/Adult era from the scene path at offset 748, and bounded embedded JPEG thumbnail at offset 1396 (validating SOI/SOF/EOI markers, <= 4096×4096, <= 8 MP, aspect ratio before decoding).
    • Parses progress.sav hearts/20, rupees, 3 Spiritual Stones, 6 Sage Medallions, Gold Skulltulas, and 9-item main-quest progress (SaveEditorText.Percent, never showing 100% until all 9 are collected), handling trailing bytes, ignoring duplicate field IDs, and rejecting out-of-range values. Missing, truncated, or unrecognized files degrade cleanly to the slot-number badge without throwing.
  • Full date + time (Core/MakeGameRun.cs):
    • Adds Durations.WhenFull routing older dates through Tr.F("{0}, {1}", Date(t, now), time) for Saves-tab rows while leaving Durations.When and SavesConfirmViewModel (FromSlots/ToSlots) unchanged.
  • Saves tab UI & resource cleanup (App/ViewModels/SavesViewModel.cs, App/Views/SavesView.axaml):
    • Displays a 16:9 thumbnail (or slot-number fallback), a Grid-based Title + Era badge layout so long area names ellipsize without clipping the Child/Adult badge, pluralized Tr.P rupee/skulltula counts (matching SaveEditorViewModel), a clearly labeled Main quest X/9 (Y%) readout (distinct from the save editor's full-game completion %), and Launcher's <c:Bar> control.
    • Implements IDisposable on SlotRowViewModel and ILeavingPage on SavesViewModel so decoded row Bitmaps are disposed on every Reload() and when switching away to another top-level tab (while kept alive across Backups/Progress/SavesConfirm sub-pages).
  • Docs, tests & screenshots (docs/saves.md, tests/launcher_core/SaveSlotPreviewChecks.cs, tests/launcher_app/Program.cs, tools/screenshots/Program.cs):
    • Reconciles docs/saves.md (clarifying lightweight read-only Saves-list previews vs. full Progress save editor).
    • Adds 22 core checks (caption/progress parsing, trailing bytes, digit-to-upper/underscore location names, duplicate IDs, out-of-range values, oversized JPEG rejection, truncated/missing fallbacks, directory junction + trailing-separator + file symlink refusal, Durations.WhenFull), app-level ViewModel/disposal checks (asserting IsDisposed on Reload() and tab switches), and synthetic procedural gradient JPEGs for headless screenshots.

Prior work & credits

  • Field hashes adapted from Traiver/OOT-SW2SE (MIT notice retained in Core/SaveSlotPreview.cs) and @Anarkkie's read-only caption.sav/progress.sav reader layout in #55. Scoped strictly to lightweight read-only Saves-tab previews (no player profiles, no asset extractor, no save mutations), matching the #55 review suggestion and keeping slot reordering in a separate stacked WIP PR.

Screenshots

See the attached screenshots in the first comment below (both real local 543×306 in-game caption.sav thumbnails inspected read-only and synthetic mid/late-game progress fixtures; no save files committed).

Testing

Tested (Windows 11, .NET SDK 10.0.404):

  • dotnet build LongshotLauncher.slnx -c Release -p:RestoreLockedMode=true: 0 warnings, 0 errors (Core, App, Screenshots); LauncherCoreTests.csproj: 0 warnings, 0 errors; zero packages.lock.json changes.
  • dotnet format Core/LongshotLauncher.Core.csproj --verify-no-changes --include Core/SaveSlotPreview.cs: PASS (exit 0) (note: solution-wide dotnet format --verify-no-changes fails on pre-existing single-line { ... } blocks across untouched repo files because the repo has no .editorconfig).
  • dotnet run --project tests/launcher_app/LauncherAppTests.csproj -c Release -p:RestoreLockedMode=true: PASS (includes SaveSlotPreviews plural/label/timestamp/IsDisposed checks on Reload() and ILeavingPage).
  • Core checks on compiled LauncherCoreTests.dll: SaveSlotPreviewChecks 22/22 passed (including live NTFS directory junction + trailing-separator refusal via FileLinks.TryDirectoryLink; leaf-file symbolic link sub-check skipped on Windows without Developer Mode), plus SaveArchiveChecks (78/78), SaveBackupsChecks (30/30), PadChecks, IconChecks, TranslationChecks, and ShownProfileChecks all PASS.
  • scripts/translations.py: 0 new faults (only the 4 pre-existing leftover #244 keys per catalog on main fixed by #246).
  • Headless screenshots (saves-backups-listed, saves-progress, narrow 760×640 German --lang de, plus real-save read-only capture): rendered and visually inspected — Title ellipsizes cleanly while the Child/Adult badge never clips and <c:Bar> aligns with the card layout.

Still to test:

  • Full Linux CI run (including leaf-file symbolic link check in SaveSlotPreviewChecks and SavesChecks.LinkSavesChecks).

Risks

  • Low. Strictly read-only, refuses symlinks/junctions and oversized files/images, disposes decoded Bitmaps on reload and tab leave, and falls back to the existing Slot N badge on any unknown or corrupt file.

Assisted-by: Antigravity

Players with multiple saves on the Saves tab can currently only see "Slot 1 / Slot 2" and a date (without the time for older saves), making it hard to tell which playthrough is which. This adds strictly read-only per-slot previews (`caption.sav` / `progress.sav`) and full date+time timestamps to the Saves tab without writing to save files or changing `SavesConfirmViewModel`. ## Summary - **Read-only slot preview parser (`Core/SaveSlotPreview.cs`):** - Strictly read-only (`FileAccess.Read`, `FileShare.ReadWrite | FileShare.Delete`) and bounds-checked (`<= 8 MiB` for `caption.sav`, `<= 4 MiB` for `progress.sav`). - Refuses symlinks and NTFS junctions (`LinkTarget != null || FileAttributes.ReparsePoint`) on both the `slot_NN` directory (trimming trailing directory separators) and leaf files (`caption.sav` / `progress.sav`), including on direct `ReadCaption` / `ReadProgress` calls. - Parses `caption.sav` area name via `SaveEditorText.Humanize`, `Child`/`Adult` era from the scene path at offset 748, and bounded embedded JPEG thumbnail at offset 1396 (validating SOI/SOF/EOI markers, `<= 4096×4096`, `<= 8 MP`, aspect ratio before decoding). - Parses `progress.sav` hearts/20, rupees, 3 Spiritual Stones, 6 Sage Medallions, Gold Skulltulas, and 9-item main-quest progress (`SaveEditorText.Percent`, never showing 100% until all 9 are collected), handling trailing bytes, ignoring duplicate field IDs, and rejecting out-of-range values. Missing, truncated, or unrecognized files degrade cleanly to the slot-number badge without throwing. - **Full date + time (`Core/MakeGameRun.cs`):** - Adds `Durations.WhenFull` routing older dates through `Tr.F("{0}, {1}", Date(t, now), time)` for Saves-tab rows while leaving `Durations.When` and `SavesConfirmViewModel` (`FromSlots`/`ToSlots`) unchanged. - **Saves tab UI & resource cleanup (`App/ViewModels/SavesViewModel.cs`, `App/Views/SavesView.axaml`):** - Displays a 16:9 thumbnail (or slot-number fallback), a `Grid`-based Title + Era badge layout so long area names ellipsize without clipping the `Child`/`Adult` badge, pluralized `Tr.P` rupee/skulltula counts (matching `SaveEditorViewModel`), a clearly labeled `Main quest X/9 (Y%)` readout (distinct from the save editor's full-game completion `%`), and Launcher's `<c:Bar>` control. - Implements `IDisposable` on `SlotRowViewModel` and `ILeavingPage` on `SavesViewModel` so decoded row `Bitmap`s are disposed on every `Reload()` and when switching away to another top-level tab (while kept alive across `Backups`/`Progress`/`SavesConfirm` sub-pages). - **Docs, tests & screenshots (`docs/saves.md`, `tests/launcher_core/SaveSlotPreviewChecks.cs`, `tests/launcher_app/Program.cs`, `tools/screenshots/Program.cs`):** - Reconciles `docs/saves.md` (clarifying lightweight read-only Saves-list previews vs. full Progress save editor). - Adds 22 core checks (caption/progress parsing, trailing bytes, digit-to-upper/underscore location names, duplicate IDs, out-of-range values, oversized JPEG rejection, truncated/missing fallbacks, directory junction + trailing-separator + file symlink refusal, `Durations.WhenFull`), app-level ViewModel/disposal checks (asserting `IsDisposed` on `Reload()` and tab switches), and synthetic procedural gradient JPEGs for headless screenshots. ## Prior work & credits - Field hashes adapted from [Traiver/OOT-SW2SE](https://github.com/Traiver/OOT-SW2SE) (MIT notice retained in `Core/SaveSlotPreview.cs`) and `@Anarkkie`'s read-only `caption.sav`/`progress.sav` reader layout in #55. Scoped strictly to lightweight read-only Saves-tab previews (no player profiles, no asset extractor, no save mutations), matching the #55 review suggestion and keeping slot reordering in a separate stacked WIP PR. ## Screenshots See the attached screenshots in the first comment below (both real local `543×306` in-game `caption.sav` thumbnails inspected read-only and synthetic mid/late-game progress fixtures; no save files committed). ## Testing **Tested** (Windows 11, .NET SDK `10.0.404`): - `dotnet build LongshotLauncher.slnx -c Release -p:RestoreLockedMode=true`: **0 warnings, 0 errors** (`Core`, `App`, `Screenshots`); `LauncherCoreTests.csproj`: **0 warnings, 0 errors**; zero `packages.lock.json` changes. - `dotnet format Core/LongshotLauncher.Core.csproj --verify-no-changes --include Core/SaveSlotPreview.cs`: **PASS (exit 0)** *(note: solution-wide `dotnet format --verify-no-changes` fails on pre-existing single-line `{ ... }` blocks across untouched repo files because the repo has no `.editorconfig`)*. - `dotnet run --project tests/launcher_app/LauncherAppTests.csproj -c Release -p:RestoreLockedMode=true`: **PASS** (includes `SaveSlotPreviews` plural/label/timestamp/`IsDisposed` checks on `Reload()` and `ILeavingPage`). - Core checks on compiled `LauncherCoreTests.dll`: `SaveSlotPreviewChecks` **22/22 passed** (including live NTFS directory junction + trailing-separator refusal via `FileLinks.TryDirectoryLink`; leaf-file symbolic link sub-check skipped on Windows without Developer Mode), plus `SaveArchiveChecks` (78/78), `SaveBackupsChecks` (30/30), `PadChecks`, `IconChecks`, `TranslationChecks`, and `ShownProfileChecks` all **PASS**. - `scripts/translations.py`: **0 new faults** (only the 4 pre-existing leftover #244 keys per catalog on `main` fixed by #246). - Headless screenshots (`saves-backups-listed`, `saves-progress`, narrow `760×640` German `--lang de`, plus real-save read-only capture): rendered and visually inspected — `Title` ellipsizes cleanly while the `Child`/`Adult` badge never clips and `<c:Bar>` aligns with the card layout. **Still to test:** - Full Linux CI run (including leaf-file symbolic link check in `SaveSlotPreviewChecks` and `SavesChecks.LinkSavesChecks`). ## Risks - **Low.** Strictly read-only, refuses symlinks/junctions and oversized files/images, disposes decoded `Bitmap`s on reload and tab leave, and falls back to the existing `Slot N` badge on any unknown or corrupt file. Assisted-by: Antigravity
feat(saves): show read-only per-slot thumbnails, location, era, progress stats, and full date/time
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
84f94a3ea5
Adds a strictly read-only, bounded parser (Core/SaveSlotPreview.cs) for caption.sav (area name via SaveEditorText.Humanize, Child/Adult era, and bounded JPEG thumbnail) and progress.sav (hearts, rupees, 3 Spiritual Stones, 6 Sage Medallions, Gold Skulltulas, and main-quest progress), plus Durations.WhenFull for full date+time on the Saves tab.

- Core/SaveSlotPreview.cs: refuses symlinks/junctions via LinkTarget and FileAttributes.ReparsePoint on both the slot directory and leaf files, bounds file sizes and JPEG SOF dimensions before decoding, ignores duplicate field IDs and out-of-range values, handles trailing bytes, and degrades cleanly to the slot-number badge.
- Core/MakeGameRun.cs: adds Durations.WhenFull using Tr.F("{0}, {1}", Date(t, now), time) without changing Durations.When or SavesConfirmViewModel timestamps.
- App/ViewModels/SavesViewModel.cs & App/Views/SavesView.axaml: displays 16:9 thumbnail with fallback, Grid-based Title + Era badge (no badge clipping on truncation), Tr.P pluralized rupees/skulltulas, Launcher's <c:Bar> with clarified Main quest X/9 (Y%) label, and IDisposable cleanup of previous row Bitmaps on Reload().
- docs/saves.md, tests/launcher_core/SaveSlotPreviewChecks.cs, tests/launcher_app/Program.cs, tools/screenshots/Program.cs: reconciled docs, 21 core checks (trailing bytes, duplicate IDs, out-of-range values, directory/file link refusal, WhenFull), app ViewModel checks, and synthetic gradient JPEGs for headless screenshots.

Field hashes adapted from Traiver/OOT-SW2SE (MIT) and Anarkkie's LongshotLauncher#55 layout.

Assisted-by: Antigravity
Author
First-time contributor

Screenshots

Real local saves (read-only, actual 543×306 caption.sav thumbnails; no save files committed):

Saves tab with real 543x306 caption.sav thumbnails, Kokiri Forest location, Child badge, full date+time, and Main quest bar

Synthetic mid/late-game fixtures (tools/screenshots saves scene, showing 0%, 55%, and 88% <c:Bar> quest progress, Child/Adult badges, rupees, and Skulltulas):

Saves tab with synthetic fixtures showing 0%, 55%, and 88% main quest progress bars

### Screenshots **Real local saves (read-only, actual 543×306 `caption.sav` thumbnails; no save files committed):** ![Saves tab with real 543x306 caption.sav thumbnails, Kokiri Forest location, Child badge, full date+time, and Main quest bar](https://git.magicbean.dev/attachments/132acc6b-a6c1-4336-9403-8052fb326935) **Synthetic mid/late-game fixtures (`tools/screenshots` `saves` scene, showing 0%, 55%, and 88% `<c:Bar>` quest progress, Child/Adult badges, rupees, and Skulltulas):** ![Saves tab with synthetic fixtures showing 0%, 55%, and 88% main quest progress bars](https://git.magicbean.dev/attachments/f9f9bbdf-41e0-4cfa-93fe-5476d8b92083)
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/saves-slot-previews-main:Jer9-feat/saves-slot-previews-main'
git switch 'Jer9-feat/saves-slot-previews-main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!253
No description provided.