Fixes for background tile widget

This commit is contained in:
Mal
2025-05-17 00:56:06 +02:00
parent fc990c12aa
commit 8d4bcf7c31
3 changed files with 6 additions and 2 deletions

View File

@@ -31,10 +31,13 @@ export default class BackgroundPickerWidget extends Widget
loadTileset()
{
if (this.tileset.background === null) {
this.disable();
this.htmlElement.style.backgroundImage = 'none';
return;
}
this.enable();
for (let t = -2; t >= -this.tileset.background.tiles - 1; t--) {
console.log(t);
const button = new ButtonBackgroundTile(this.tileset, t);
@@ -79,7 +82,7 @@ export default class BackgroundPickerWidget extends Widget
setTile(index)
{
this.htmlElement.style.backgroundPosition = String(-this.tileset.getTileWidth() * index) + 'px ' + String(this.tileset.getTileHeight()) + 'px';
this.htmlElement.style.backgroundPosition = String(((index + 2) % this.tileset.background.tiles) * this.tileset.getTileWidth()) + 'px ' + String(this.tileset.getTileHeight()) + 'px';
}
getElement()