Graphic set preview icons can now be specified

This commit is contained in:
Mal
2023-09-27 22:05:06 +02:00
parent d41f7eaeed
commit feb3f9c844
4 changed files with 17 additions and 6 deletions

View File

@@ -100,7 +100,12 @@ export default class Dialog
let htmlThumbnail = document.createElement('div');
htmlThumbnail.classList.add('tileset-thumbnail');
htmlThumbnail.style.backgroundImage = 'url("../' + Setting.TILESET_LOCATION + graphicSet.tileset + '")';
const image = new Image();
image.src = '../' + Setting.TILESET_LOCATION + graphicSet.tileset;
htmlThumbnail.style.backgroundImage = 'url(' + image.src + ')';
htmlThumbnail.style.backgroundPositionX = -(image.width / graphicSet.tiles) * graphicSet.tilePreview + 'px';
htmlTilesetElement.appendChild(htmlThumbnail);
let htmlTitleElement = document.createElement('div');
@@ -112,7 +117,9 @@ export default class Dialog
'click',
() => {
htmlListElement.style.display = 'none';
htmlAvatarElement.style.backgroundImage = 'url("../' + Setting.TILESET_LOCATION + GraphicSet[index].tileset + '")';
htmlAvatarElement.style.backgroundImage = 'url(' + image.src + ')';
htmlAvatarElement.style.backgroundPositionX = -96 * graphicSet.tilePreview + 'px';
window.dispatchEvent(new TilorswiftTilesetSelectedEvent(index));
}
);