Add real-time preview support to FloorplanEditor

Add onTilemapChange callback that fires after every renderTiles() call,
enabling the UI layer to react to tilemap mutations in real-time.

Co-Authored-By: medievalshell <medievalshell@users.noreply.github.com>
This commit is contained in:
simoleo89
2026-03-16 22:08:37 +01:00
parent 19857075c0
commit 31de6daac5
@@ -25,6 +25,8 @@ export class FloorplanEditor
private _image: HTMLImageElement;
public onTilemapChange: (() => void) | null = null;
constructor()
{
const width = TILE_SIZE * MAX_NUM_TILE_PER_AXIS + 20;
@@ -297,6 +299,8 @@ export class FloorplanEditor
}
this.renderSquareSelectionPreview();
if(this.onTilemapChange) this.onTilemapChange();
}
private renderSquareSelectionPreview(): void
@@ -473,6 +477,7 @@ export class FloorplanEditor
this._squareSelectStart = null;
this._squareSelectEnd = null;
this.clearCanvas();
this.onTilemapChange = null;
}