fix(states-editor): painter freeze fix + demote-to-province picker#9
Merged
Conversation
…ed row The previous painter fix rendered every state row while in manual-assignment mode so off-page states would be selectable. On large maps that re-rendered every state's COA emblem at once (millions of SVG nodes), pinning the CPU at 100% and freezing the tab — pagination existed specifically to avoid that. Revert to the normal paginated row list and instead choose the brush target from a lightweight "Paint as" <select> that lists every state as plain text (no emblems). Selection is now driven by the dropdown: - changeStateForSelection reads getBrushStateId() instead of the .selected row, so the target no longer has to be on the current page. - Clicking a row or clicking a state on the map sets the dropdown value (map clicks no longer bail when the row is off-page); the row highlight is now purely cosmetic via highlightBrushRow(). - The dropdown is ordered by the editor's active sort, matching the list.
…rovince Adds a "demote clicked state to a province" checkbox to the manual-assignment (paint) toolbar. With it on, the state dropdown becomes the receiving state and clicking any state on the map stages that entire state for demotion into a single province of the receiving state — keeping its name, government form, colour and emblem, exactly like the merge dialog's "merge down to provinces". - Picks stage as a recoloured preview in #temp (tagged data-demote) and are undoable like brush strokes; nothing changes until Apply. - On Apply, staged demotions are grouped by receiving state and committed via mergeStates(ids, owner, true). To enable that reuse, mergeStates (and its demoteStateToProvince helper) is lifted from the merge-dialog closure to module scope; the dialog still calls it unchanged. - Cell brushing is disabled while picker mode is on (click = pick a state). Bump states-editor cache-bust token to 1.122.16.
…MixedColor) A demoted state's new province stored the raw state colour. Province fills render at full opacity (#provs has opacity:1, fill:#000000), and generated provinces avoid looking garish by using getMixedColor(state.color) — a mixed, brightened shade. Storing the raw colour instead made dark-themed states (orks, undead, etc.) render as solid black provinces and others look over-saturated. Use getMixedColor(state.color) to match Provinces.generate, so demoted provinces blend into the normal province palette while still keeping ~80% of the state's colour (recognisable as the former state). Bump cache-bust token to 1.122.17.
…ovince mergeStates downgraded every absorbed capital with Burgs.changeGroup(burg), which re-buckets the burg by population and redraws it — so demoting a state spawned a town/village icon over each former capital. Correct for a plain merge, wrong when demoting to a province, where the capital should stay the province's centre. Skip changeGroup when mergeToProvinces: still clear the state-capital flag and reassign the burg's state, but leave its icon and label untouched. Bump cache-bust token to 1.122.18.
✅ Deploy Preview for bazgaars-fmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #8, which was merged after only its first commit — these four commits never reached main, including a critical fix for a painter freeze.
Commits
Fix painter freeze (critical). fix(states-editor): painter pagination, merge sort, visible province demotion #8's painter fix rendered every state row in paint mode so off-page states were selectable; on large maps that re-rendered every COA emblem at once (millions of SVG nodes), pinning CPU at 100% and freezing the tab. Reverts to the paginated row list and instead picks the brush target from a lightweight plain-text "Paint as" dropdown listing every state.
Paint-mode picker to demote a whole state to a province. A "demote clicked state to a province" checkbox: with it on, the dropdown is the receiving state and clicking a state on the map stages it for demotion into a single province of that state (name/form/colour/emblem preserved), committed on Apply via the shared
mergeStates(..., toProvinces)path.mergeStateswas lifted to module scope for reuse.Colour demoted provinces with
getMixedColor. Province fills render at full opacity, so generated provinces use a mixed/brightened shade. The demote stored the raw state colour, making dark-themed states render solid black. Now matchesProvinces.generate.Keep the capital's icon when demoting to a province.
mergeStatesre-bucketed each absorbed capital by population (changeGroup), spawning a town/village icon over the former capital. Skipped when demoting to a province.Cache-bust token bumped to 1.122.18.
Verification
node --checkpasses on both files; remaining TS diagnostics are pre-existing deprecation noise. Validated by tracing the style preset + generators; iteratively confirmed in-browser by the maintainer on the Alvios map (colours, icons, province identity).