feat(ui): Phase 29 map visibility toggles
Adds the gear-icon popover on the map view with per-game persistence of every category toggle plus the wrap-mode radio. Hide-by-id and visibility-fog facilities land on the renderer so every flip applies within one frame without a Pixi remount; the wrap-mode toggle keeps its existing remount + camera-preserve path. A new server-side turn force-resets every flag to defaults so a hidden category never makes the player miss the next turn's news. Also fixes the FligthDistance → FlightDistance typo in pkg/calc/race.go (plus the single Go caller); the TS side keeps duplicating the formula until a race-level WASM bridge lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -116,6 +116,44 @@ explores history, so the pending-turn toast continues to work.
|
||||
map view's effect picks the change up and re-mounts the renderer
|
||||
with the new mode.
|
||||
|
||||
## Map visibility toggles
|
||||
|
||||
Phase 29 adds a `mapToggles: MapToggles` rune that drives the
|
||||
gear popover in the map view. Every flag defaults to `true` —
|
||||
including `unreachablePlanets` (showing every planet by default)
|
||||
and `visibilityFog` (the fog overlay on by default). The
|
||||
exhaustive shape lives in `src/lib/game-state.svelte.ts`; the
|
||||
gear popover (`src/lib/active-view/map-toggles.svelte`) is a
|
||||
thin view of the rune.
|
||||
|
||||
`setMapToggle(key, value)` flips one entry in place and
|
||||
persists the whole blob to `Cache` under the
|
||||
`game-map-toggles/{gameId}` key. The blob carries a companion
|
||||
`lastResetTurn` number — the turn at which the toggles were last
|
||||
reset to defaults — so the new-turn reset path (below) can detect
|
||||
a stale blob even across a cross-session gap.
|
||||
|
||||
### New-turn reset
|
||||
|
||||
A new server-side turn force-resets every toggle to defaults so a
|
||||
hidden category never makes the player miss what changed:
|
||||
|
||||
- `setGame` reads the persisted `{toggles, lastResetTurn}` blob.
|
||||
If `lastResetTurn < currentTurn`, the rune is overwritten with
|
||||
`DEFAULT_MAP_TOGGLES` and the blob is rewritten with
|
||||
`lastResetTurn = currentTurn` before the report load. Otherwise
|
||||
the persisted overrides are restored.
|
||||
- `advanceToPending` (the user's explicit jump onto the new turn)
|
||||
calls the same reset path after `loadTurn(currentTurn, …)`
|
||||
succeeds, updating `lastResetTurn` to the freshly-loaded
|
||||
current turn.
|
||||
- `viewTurn` (history mode) does NOT reset — toggles are a
|
||||
single shared state per game, not per turn.
|
||||
- `refresh()` does not advance turns, so it does not reset.
|
||||
|
||||
The cache namespace and blob shape are documented in
|
||||
`storage.md`.
|
||||
|
||||
## History mode
|
||||
|
||||
Phase 26 lets the user step backward through the report timeline
|
||||
|
||||
Reference in New Issue
Block a user