Allow changing glyph when editing palette entries

This commit is contained in:
Jared Miller 2026-02-07 20:58:24 -05:00
parent b46b1709b4
commit a746c6c0ee
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -791,7 +791,7 @@ ${paletteStr}"""
charInput.value = existing.char; charInput.value = existing.char;
labelInput.value = existing.label; labelInput.value = existing.label;
colorInput.value = existing.color; colorInput.value = existing.color;
charInput.disabled = true; charInput.disabled = false;
} else { } else {
charInput.value = ''; charInput.value = '';
labelInput.value = ''; labelInput.value = '';
@ -802,8 +802,7 @@ ${paletteStr}"""
form.style.display = 'block'; form.style.display = 'block';
form.dataset.editing = existing ? existing.char : ''; form.dataset.editing = existing ? existing.char : '';
if (!existing) charInput.focus(); charInput.focus();
else labelInput.focus();
} }
function hidePaletteForm() { function hidePaletteForm() {
@ -825,6 +824,30 @@ ${paletteStr}"""
if (entry) { if (entry) {
entry.label = label; entry.label = label;
entry.color = color; 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 { } else {
const existing = palette.find(e => e.char === char); const existing = palette.find(e => e.char === char);