From 62f95ec04ed1a25958de9346d4cf39dff7de697d Mon Sep 17 00:00:00 2001 From: Marc Emmanuel Date: Thu, 5 Mar 2026 09:26:20 +0100 Subject: [PATCH] fix: enhance emblem rendering for states and burgs in the editor --- public/modules/ui/tools.js | 15 +++++++++------ src/modules/burgs-generator.ts | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/modules/ui/tools.js b/public/modules/ui/tools.js index eade993f..34c1cd12 100644 --- a/public/modules/ui/tools.js +++ b/public/modules/ui/tools.js @@ -101,14 +101,17 @@ function processFeatureRegeneration(event, button) { async function openEmblemEditor() { let type, id, el; - if (pack.states[1]?.coa) { + const firstState = pack.states.find(s => s.i && !s.removed && s.coa); + const firstBurg = pack.burgs.find(b => b.i && !b.removed && b.coa); + + if (firstState) { type = "state"; - id = "stateCOA1"; - el = pack.states[1]; - } else if (pack.burgs[1]?.coa) { + id = `stateCOA${firstState.i}`; + el = firstState; + } else if (firstBurg) { type = "burg"; - id = "burgCOA1"; - el = pack.burgs[1]; + id = `burgCOA${firstBurg.i}`; + el = firstBurg; } else { tip("No emblems to edit, please generate states and burgs first", false, "error"); return; diff --git a/src/modules/burgs-generator.ts b/src/modules/burgs-generator.ts index 6fccd517..debdab69 100644 --- a/src/modules/burgs-generator.ts +++ b/src/modules/burgs-generator.ts @@ -676,6 +676,7 @@ class BurgModule { }; this.definePopulation(burg); this.defineEmblem(burg); + COArenderer.add("burg", burgId, burg.coa, x, y); this.defineFeatures(burg); const populations = pack.burgs