Skip to content

fix(states-editor): painter freeze fix + demote-to-province picker#9

Merged
barrulus merged 4 commits into
mainfrom
fix/states-merge-painter-batch
Jun 10, 2026
Merged

fix(states-editor): painter freeze fix + demote-to-province picker#9
barrulus merged 4 commits into
mainfrom
fix/states-merge-painter-batch

Conversation

@barrulus

Copy link
Copy Markdown
Owner

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

  1. 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.

  2. 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. mergeStates was lifted to module scope for reuse.

  3. 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 matches Provinces.generate.

  4. Keep the capital's icon when demoting to a province. mergeStates re-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 --check passes 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).

barrulus added 4 commits June 10, 2026 10:07
…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.
@barrulus barrulus merged commit 500498e into main Jun 10, 2026
2 checks passed
@barrulus barrulus deleted the fix/states-merge-painter-batch branch June 10, 2026 14:42
@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for bazgaars-fmg ready!

Name Link
🔨 Latest commit 9723d36
🔍 Latest deploy log https://app.netlify.com/projects/bazgaars-fmg/deploys/6a29769a86e40b00083ad82f
😎 Deploy Preview https://deploy-preview-9--bazgaars-fmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant