diff --git a/scripts/map_editor.html b/scripts/map_editor.html index c772a94..c5b8fb3 100644 --- a/scripts/map_editor.html +++ b/scripts/map_editor.html @@ -791,7 +791,7 @@ ${paletteStr}""" charInput.value = existing.char; labelInput.value = existing.label; colorInput.value = existing.color; - charInput.disabled = true; + charInput.disabled = false; } else { charInput.value = ''; labelInput.value = ''; @@ -802,8 +802,7 @@ ${paletteStr}""" form.style.display = 'block'; form.dataset.editing = existing ? existing.char : ''; - if (!existing) charInput.focus(); - else labelInput.focus(); + charInput.focus(); } function hidePaletteForm() { @@ -825,6 +824,30 @@ ${paletteStr}""" if (entry) { entry.label = label; entry.color = color; + + // If char changed, update grid and symbols + if (char !== editingChar) { + entry.char = char; + + // Update all cells in grid + for (let y = 0; y < gridHeight; y++) { + for (let x = 0; x < gridWidth; x++) { + if (grid[y][x] === editingChar) { + grid[y][x] = char; + } + } + } + + // Update symbols if they match old char + if (symbols.m1 === editingChar) { + symbols.m1 = char; + m1Slot.textContent = char; + } + if (symbols.m2 === editingChar) { + symbols.m2 = char; + m2Slot.textContent = char; + } + } } } else { const existing = palette.find(e => e.char === char);