Uppdate
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user