hmmm, stuff

This commit is contained in:
Rusty Striker 2025-07-17 20:05:30 +03:00
parent 2ed7602595
commit 5979e53d91
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
3 changed files with 32 additions and 23 deletions

View file

@ -192,19 +192,23 @@ tavern.onmovetoken = (m) => {
}
tavern.onshowscene = (show) => {
let map = document.getElementById('map');
map.style.visibility = show.background == undefined ? 'hidden' : 'visible';
// Remove existing tokens
Array.from(map.children).filter(c => c.classList.contains('token')).forEach(c => map.removeChild(c));
let background = document.getElementById('map-background');
gridOffset = show.grid_offset;
Array.from(document.getElementsByClassName('token')).forEach(t => {
t.children[0].style.width = `${gridSize}px`;
t.children[0].style.height = `${gridSize}px`;
});
// I think this is pointless as we remove all the tokens just a couple of lines above
// Array.from(document.getElementsByClassName('token')).forEach(t => {
// t.children[0].style.width = `${gridSize}px`;
// t.children[0].style.height = `${gridSize}px`;
// });
gridSize = show.grid_cell_size;
background.src = show.background ?? '';
for (let token of show.tokens) {
tavern.onspawntoken(token);
if (show.background != undefined) {
background.src = show.background;
for (let token of show.tokens) {
tavern.onspawntoken(token);
}
}
}
tavern.onscenelist = (list) => {