Add a SpireLens sort menu to the deck view's sort row #325

Merged
nelsong6 merged 23 commits from claude/deck-filter-menu-damage-473e2f into main 2026-09-09 15:50:32 -07:00
nelsong6 commented 2026-09-09 00:02:21 -07:00 (Migrated from github.com)

What

The deck screen's four sort buttons (Obtained / Type / Cost / Alphabetical) are the game's own, and none of them can reach a SpireLens-tracked number. This adds a fifth entry to that row: a dropdown of SpireLens metrics, starting with Total damage — the same effective-damage figure the card tooltip prints under that name (HP this physical card actually removed across the run).

Picking the active metric again flips the direction. "Off" hands sorting back to the game.

How it reaches the grid

NCardGrid.SetCards only runs its own comparator when sortingPriority[0] is something other than Ascending/Descending — with Ascending at the head it renders the supplied list verbatim. So a SpireLens ordering is just "reorder _cards, then pin Ascending", applied from the DisplayCards prefix that already decides which cards are on screen. No new Harmony target, and no patch on the shared card grid.

Handing ordering back to the stock sorters

The four stock handlers mutate _sortingPriority and their own direction flag. OnObtainedSort's ascending result is byte-identical to the head we pin, so the priority list cannot tell us a stock sorter ran — the direction flags can, and they flip on release for mouse and controller alike. We snapshot all four each time we order and stand down as soon as one moves. The clear happens before we reorder, so the render that noticed already honours the player's choice: no stale frame, no second DisplayCards pass.

Notes

  • Cards with no tracked damage score 0 and trail rather than disappearing; ordering is stable, so ties keep the game's order.
  • The run-history deck viewer is excluded on both the UI and the ordering side — it reuses NDeckViewScreen but its pile is a historical reconstruction, so ordering it by the live run's aggregates would be quietly wrong.
  • Sort state is session-only. Persisting it would need a new Loader bridge method, which a Core hot reload cannot add, and a view ordering is not worth a game restart.
  • The trigger is a plain Godot Button rather than a cloned NCardViewSortButton: the game's sort buttons resolve %ButtonImage/%Label/%Image through scene-unique names and share a ShaderMaterial with their duplication source, so a clone that gets either wrong drives the original button's visuals — the trap already documented on the tickbox clone. The deck view already carries a plain injected Button.
  • Adding a second metric is one entry in DeckViewSpireLensSort.Metrics; rows, ordering, and the stock-sorter handoff are all metric-agnostic.

Verification

Not run — per the repo's user-owned verification policy. Built, deployed, and hot-reloaded into the running game (reload 3): --- HOT RELOAD DONE ---, Core.Initialize complete, Patch install: 432 classes patched, 0 failed/skipped — the same count as before the reload, as expected for a change that adds no patch classes.

No restart needed. Both hooks this rides on (NCardsViewScreen.ConnectSignals postfix, NDeckViewScreen.DisplayCards prefix) were already installed in this process before the reload; no Harmony target is new.

🤖 Generated with Claude Code

## What The deck screen's four sort buttons (Obtained / Type / Cost / Alphabetical) are the game's own, and none of them can reach a SpireLens-tracked number. This adds a fifth entry to that row: a dropdown of SpireLens metrics, starting with **Total damage** — the same effective-damage figure the card tooltip prints under that name (HP this physical card actually removed across the run). Picking the active metric again flips the direction. "Off" hands sorting back to the game. ## How it reaches the grid `NCardGrid.SetCards` only runs its own comparator when `sortingPriority[0]` is something other than `Ascending`/`Descending` — with `Ascending` at the head it renders the supplied list verbatim. So a SpireLens ordering is just "reorder `_cards`, then pin `Ascending`", applied from the `DisplayCards` prefix that already decides *which* cards are on screen. **No new Harmony target**, and no patch on the shared card grid. ## Handing ordering back to the stock sorters The four stock handlers mutate `_sortingPriority` and their own direction flag. `OnObtainedSort`'s ascending result is byte-identical to the head we pin, so the priority list cannot tell us a stock sorter ran — the direction flags can, and they flip on release for mouse and controller alike. We snapshot all four each time we order and stand down as soon as one moves. The clear happens *before* we reorder, so the render that noticed already honours the player's choice: no stale frame, no second `DisplayCards` pass. ## Notes - Cards with no tracked damage score 0 and trail rather than disappearing; ordering is stable, so ties keep the game's order. - The run-history deck viewer is excluded on both the UI and the ordering side — it reuses `NDeckViewScreen` but its pile is a historical reconstruction, so ordering it by the *live* run's aggregates would be quietly wrong. - Sort state is session-only. Persisting it would need a new Loader bridge method, which a Core hot reload cannot add, and a view ordering is not worth a game restart. - The trigger is a plain Godot `Button` rather than a cloned `NCardViewSortButton`: the game's sort buttons resolve `%ButtonImage`/`%Label`/`%Image` through scene-unique names and share a `ShaderMaterial` with their duplication source, so a clone that gets either wrong drives the *original* button's visuals — the trap already documented on the tickbox clone. The deck view already carries a plain injected `Button`. - Adding a second metric is one entry in `DeckViewSpireLensSort.Metrics`; rows, ordering, and the stock-sorter handoff are all metric-agnostic. ## Verification Not run — per the repo's user-owned verification policy. Built, deployed, and hot-reloaded into the running game (reload 3): `--- HOT RELOAD DONE ---`, `Core.Initialize complete`, `Patch install: 432 classes patched, 0 failed/skipped` — the same count as before the reload, as expected for a change that adds no patch classes. **No restart needed.** Both hooks this rides on (`NCardsViewScreen.ConnectSignals` postfix, `NDeckViewScreen.DisplayCards` prefix) were already installed in this process before the reload; no Harmony target is new. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
romaine-life/spirelens!325
No description provided.