Migrate UI editors#1520
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/ice-editor.js to src/controllers/ice-editor.ts following the migration guide (strict d3 v7). The controller owns its dialog HTML (injected on open, cleared on close), registers via the Controllers registry, and drops the legacy global editIce(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/notes-editor.js to src/controllers/notes-editor.ts following the migration guide (strict d3 v7). The controller owns its dialog HTML (injected on open, cleared on close via removeEditor). Replace the legacy global editNotes() with Controllers.NotesEditor.open() at every call site (river/route/regiment/burg controllers plus the classic labels/lakes/markers/tools/hotkeys modules) and drop the editNotes global. Add typed globals for generateWithAi and tinymce. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/lakes-editor.js to src/controllers/lakes-editor.ts following the migration guide (strict d3 v7: select/drag/polygon* named imports, event-arg drag handlers). The controller owns its dialog HTML (injected on open, cleared on close), registers as Controllers.LakesEditor, and replaces the global editLake() at the editors.js call site. Add drawBiomes to global.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/markers-editor.js to src/controllers/markers-editor.ts following the migration guide (strict d3 v7 drag; module-scoped selected marker/element instead of closures). The controller owns its dialog HTML (injected on open, cleared on close) so listeners drop with the markup, registers as Controllers.MarkersEditor, and replaces editMarker() at the editors.js and markers-overview.js call sites. Extend the Marker interface with the size/pin/fill/stroke/hidden fields the editor manages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/units-editor.js to src/controllers/units-editor.ts following the migration guide (strict d3 v7: select/drag, event-arg ruler gestures). The #unitsEditor markup stays in index.html because its inputs (distanceUnitInput, heightUnit, temperatureScale, …) are app-wide settings cached as globals at load; listeners are wired once behind an initialized flag. Register as Controllers.UnitsEditor and replace editUnits() at the main.js, load.ts, tools.js and hotkeys.js call sites; drop the editUnits global. Add toggleRulers, calculateFriendlyGridSize, RouteOpisometer globals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/relief-editor.js to src/controllers/relief-editor.ts following the migration guide (strict d3 v7: select/drag/quadtree/range/ pointer named imports, event-arg drag/brush handlers). The large static #reliefEditor icon palette stays in index.html (queried, not created); listeners wire once behind an initialized flag. Register as Controllers.ReliefEditor, replace editReliefIcon() at the editors.js call site. Add toggleRelief global. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/labels-editor.js to src/controllers/labels-editor.ts following the migration guide (strict d3 v7: select/drag/pointer/line/ curveNatural named imports, event-arg drag and control-point handlers, module-local line generator). The static #labelEditor toggle sections stay in index.html; listeners wire once behind an initialized flag. Register as Controllers.LabelsEditor and replace editLabel() at the editors.js call site. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/biomes-editor.js to src/controllers/biomes-editor.ts following the migration guide (strict d3 v7: select/drag/pointer/sum/ transition/easeSinIn named imports, event-arg brush handlers). The static #biomesEditor chrome stays in index.html (rows generated at runtime); listeners wire once behind an initialized flag. Register as Controllers.BiomesEditor and replace editBiomes() at the tools.js and hotkeys.js call sites. Add recalculatePopulation/findAll globals and the runtime stat fields (cells/area/rural/urban) to biomesData. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/zones-editor.js to src/controllers/zones-editor.ts following the migration guide (strict d3 v7: select/drag/pointer/sum named imports, event-arg brush handlers, typed data-join datum). The static #zonesEditor chrome stays in index.html (rows generated at runtime); listeners wire once behind an initialized flag. Register as Controllers.ZonesEditor and replace editZones() at the tools.js and hotkeys.js call sites. Add toggleZones global and hidden? to the Zone type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/diplomacy-editor.js to src/controllers/diplomacy-editor.ts following the migration guide (strict d3 v7: select/pointer/interpolateString/ color named imports, event-arg map-click handler). The static #diplomacyEditor chrome stays in index.html (rows generated at runtime); listeners wire once behind an initialized flag. State 0's diplomacy field (the chronicle) is cast to string[][] at the boundary. Register as Controllers.DiplomacyEditor and replace editDiplomacy() at the tools.js and hotkeys.js call sites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/emblems-editor.js to src/controllers/emblems-editor.ts following the migration guide (strict d3 v7: select/drag named imports, event-arg drag handler; module-scoped selected type/id/el instead of closures). The static #emblemEditor markup stays in index.html; onX handlers are idempotent so they wire on every open. Register as Controllers.EmblemsEditor and replace editEmblem() everywhere (states/burg controllers, tools/editors/ provinces classic modules); drop the editEmblem global, add highlightEmblemElement. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/provinces-editor.js (1372 lines) to src/controllers/provinces-editor.ts following the migration guide (strict d3 v7: select/drag/pointer/stratify/treemap/transition/color/interpolate named imports, event-arg brush and treemap handlers). The static #provincesEditor chrome stays in index.html (rows generated at runtime); listeners wire once behind initialized flags. Register as Controllers.ProvincesEditor and replace editProvinces() at the tools.js and hotkeys.js call sites. Extend the Province interface with the editor's computed stat fields (area/rural/urban/burgs). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port public/modules/ui/heightmap-editor.js (1713 lines) to src/controllers/heightmap-editor.ts following the migration guide (strict d3 v7: select/drag/pointer/range/hsl/lab/leastIndex/interpolateRound named imports, event-arg brush handlers, d3.scan→leastIndex). Covers all tools: mode selection, brush painting, fill/line brushes, template editor DSL, image converter, preview, and the erase/keep/risk finalize-and-regenerate paths. The static #customizationMenu markup stays in index.html; panel listeners wire once behind init flags. Register as Controllers.HeightmapEditor and replace editHeightmap() at the heightmap-selection/tools/hotkeys call sites; drop the editHeightmap global. Add color/edits/undraw/rankCells/ generatePrecipitation/changeViewMode/resetZoom/RgbQuant globals and Culture x/y transient fields. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…oller Port the editCoastline() vertex/group editor from public/modules/ui/coastline-editor.js to src/controllers/coastline-vertex-editor.ts following the migration guide (strict d3 v7: select/drag/polygonArea, event-arg vertex drag). Named CoastlineVertexEditor to avoid collision with the existing Coastline Settings CoastlineEditor. Owns its dialog HTML (injected on open, cleared on close), registered in the Controllers registry, replaces editCoastline() at the editors.js call site. This was the last remaining *-editor.js in public/modules/ui. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the UI migration from legacy public/modules/ui/* editor modules to lazy‑loaded TypeScript controllers under src/controllers, and rewires the remaining legacy entrypoints (tools menu, hotkeys, click routing, scale bar) to open the new controllers via window.Controllers.
Changes:
- Migrated multiple editors (Units, Notes, Markers, Labels, Lakes, Ice, Relief, Coastline vertex) into
src/controllers/*and registered them in the controller registry for lazy loading. - Removed legacy editor scripts and large chunks of static dialog markup from
src/index.html, leaving placeholder dialog containers for controller-owned DOM. - Extended global typings and several generator interfaces to include editor-computed/transient fields used by the migrated editors.
Reviewed changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/global.ts | Updates global typings for new controller-driven editor globals and utilities |
| src/services/io/load.ts | Rewires scale bar click to open the Units controller |
| src/index.html | Removes legacy dialog markup and legacy editor script tags; keeps dialog placeholders |
| src/generators/zones-generator.ts | Adds hidden? to zones data model for editor usage |
| src/generators/provinces-generator.ts | Adds editor-computed statistics fields to provinces |
| src/generators/markers-generator.ts | Adds marker presentation fields used by the marker editor |
| src/generators/cultures-generator.ts | Adds transient x/y fields used by heightmap editor workflows |
| src/controllers/units-editor.ts | New lazy-loadable Units editor controller |
| src/controllers/states-editor.ts | Uses Controllers.EmblemsEditor instead of legacy emblem editor function |
| src/controllers/route-editor.ts | Uses Controllers.NotesEditor instead of legacy notes editor function |
| src/controllers/river-editor.ts | Uses Controllers.NotesEditor instead of legacy notes editor function |
| src/controllers/relief-editor.ts | New lazy-loadable Relief editor controller |
| src/controllers/regiment-editor.ts | Uses Controllers.NotesEditor instead of legacy notes editor function |
| src/controllers/notes-editor.ts | New lazy-loadable Notes editor controller (TinyMCE integration) |
| src/controllers/markers-editor.ts | New lazy-loadable Markers editor controller |
| src/controllers/lakes-editor.ts | New lazy-loadable Lakes editor controller |
| src/controllers/labels-editor.ts | New lazy-loadable Labels editor controller |
| src/controllers/index.ts | Registers new editors in the lazy controller registry |
| src/controllers/ice-editor.ts | New lazy-loadable Ice editor controller |
| src/controllers/heightmap-selection.ts | Rewires to Controllers.HeightmapEditor |
| src/controllers/coastline-vertex-editor.ts | New controller for coastline vertex/group editing dialog |
| src/controllers/burg-editor.ts | Uses Controllers.EmblemsEditor / Controllers.NotesEditor |
| public/modules/ui/zones-editor.js | Deletes legacy Zones editor implementation |
| public/modules/ui/units-editor.js | Deletes legacy Units editor implementation |
| public/modules/ui/tools.js | Rewires tool buttons to open controllers instead of legacy functions |
| public/modules/ui/relief-editor.js | Deletes legacy Relief editor implementation |
| public/modules/ui/notes-editor.js | Deletes legacy Notes editor implementation |
| public/modules/ui/markers-overview.js | Rewires marker overview to open Controllers.MarkersEditor |
| public/modules/ui/markers-editor.js | Deletes legacy Markers editor implementation |
| public/modules/ui/lakes-editor.js | Deletes legacy Lakes editor implementation |
| public/modules/ui/labels-editor.js | Deletes legacy Labels editor implementation |
| public/modules/ui/ice-editor.js | Deletes legacy Ice editor implementation |
| public/modules/ui/hotkeys.js | Rewires hotkeys to open controllers instead of legacy functions |
| public/modules/ui/emblems-editor.js | Deletes legacy Emblems editor implementation |
| public/modules/ui/editors.js | Rewires map click routing to open controllers instead of legacy functions |
| public/modules/ui/diplomacy-editor.js | Deletes legacy Diplomacy editor implementation |
| public/modules/ui/coastline-editor.js | Deletes legacy Coastline editor implementation |
| public/modules/ui/biomes-editor.js | Deletes legacy Biomes editor implementation |
| public/main.js | Rewires scale bar click to open the Units controller |
| docs/architecture/migration_guide.md | Strengthens migration guidance for controller-owned DOM lifecycle |
…ator into migrate-ui-editors
… event handling - Removed redundant body element references and replaced them with direct element queries. - Consolidated dialog rendering logic into dedicated functions for better readability. - Updated event listeners to target specific sections instead of the entire body. - Enhanced state and religion management by ensuring proper handling of extinct and selected states/religions. - Improved percentage mode toggling and CSV download functionality for states and religions.
…in editor dialogs
- Moved dialog HTML templates to render functions in rivers-overview, route-creator, route-editor, route-groups-editor, routes-overview, and trade-animation-editor. - Replaced direct innerHTML assignments with dynamic rendering and destruction of dialogs to improve maintainability and prevent memory leaks. - Updated event listener assignments to occur after dialog rendering. - Removed unused dialog elements from index.html to clean up the codebase.
…ator into migrate-ui-editors
…t visibility handling
…; add check for removed cultures
…lectors - Updated selections in ice-editor, labels-editor, lakes-editor, provinces-editor, relief-editor, units-editor, and zones-editor to use specific IDs instead of relying on node()! for better clarity and maintainability. - Introduced randomness parameters in heightmap-generator for more flexible terrain generation. - Adjusted save functionality to ensure proper SVG element selection when saving map data.
…ator into migrate-ui-editors
…grating last selected group retrieval
…ator into migrate-ui-editors
barrulus
added a commit
to barrulus/Fantasy-Map-Generator
that referenced
this pull request
Jul 21, 2026
Syncs the fork onto Azgaar upstream master (tip 73e43d2), pulling in three large refactors — UI-editor migration (Azgaar#1520), pointer/d3.v5 selection replacement (Azgaar#1537), and module migration (Azgaar#1538) — plus market relocation, temperature-unit and dropbox fixes, and the Europe North preset restore. 16 conflicts resolved. Key decisions: - Editor pagination (fork) reconciled with upstream's renderDialog() migration across rivers/routes/cultures/religions/burgs/states overviews; page state kept module-scoped, reset on open/search/sort. - WebGL burg icon/label guards preserved over upstream's select("#id") switch. - Fork CSV exports kept (read pack.* not the DOM) to avoid paginated truncation. - States editor: fork dropdown/demote-picker brush kept over upstream's div.selected mechanism; dropped upstream's in-loop footer accumulators to avoid double-counting the visible page. - Seam-wrapping getWrappedLength kept in routes-generator. - Legacy heightmap/provinces editor JS deleted upstream; fork's Uint32Array burg-array widening and GPU-label capital-zoom fallback ported to the new TS controllers. - Burg-editor trade-role/flying/skyport/altitude and burgs-overview pagination/skyburg markup re-homed from index.html into controller templates. tsc clean, 308 tests pass (1 skipped), production build succeeds.
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.
Description