This commit is contained in:
2025-10-05 06:13:39 +02:00
parent e9585f8570
commit 1640101f65
6 changed files with 243 additions and 16 deletions
+11 -2
View File
@@ -22,7 +22,7 @@ class ContextMenu extends HTMLElement {
id="nameInput"
placeholder="Building name..."
style="width: 100%; margin-bottom: 8px;"
maxlength="30"
maxlength="20"
/>
</div>
`;
@@ -69,6 +69,13 @@ class ContextMenu extends HTMLElement {
this.currentX = tileX;
this.currentY = tileY;
// Store current building info for editing
this.currentBuilding = null;
if (this.app && this.app.gameState && this.app.gameState.buildings) {
const key = `${tileX},${tileY}`;
this.currentBuilding = this.app.gameState.buildings[key];
}
this.style.left = x + 'px';
this.style.top = y + 'px';
this.style.display = 'block';
@@ -87,8 +94,10 @@ class ContextMenu extends HTMLElement {
this.querySelector('#editForm').style.display = 'block';
const input = this.querySelector('#nameInput');
input.value = '';
// Pre-fill with current building name if it exists
input.value = (this.currentBuilding && this.currentBuilding.name) ? this.currentBuilding.name : '';
input.focus();
input.select(); // Select all text for easy replacement
} else if (action === 'delete') {
if (confirm('Delete this building?')) {
if (this.app) {