Allow changing glyph when editing palette entries
This commit is contained in:
parent
b46b1709b4
commit
a746c6c0ee
1 changed files with 26 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue