diff --git a/static/admin.js b/static/admin.js index b9c5626..86f675a 100644 --- a/static/admin.js +++ b/static/admin.js @@ -153,8 +153,11 @@ function scaleSpritePreview(source) { break; } } - tokenCX.value = Number(tokenWidth.value)/2; - tokenCY.value = Number(tokenHeight.value)/2; + if (!tokenCX.value || source) { + tokenCX.value = Number(tokenWidth.value)/2; + } if (!tokenCY.value || source) { + tokenCY.value = Number(tokenHeight.value)/2; + } drawTokenOrigin(); } } @@ -187,20 +190,26 @@ function drawTokenOrigin() { } } -function reinitializeSpritePreview() { +function reinitializeSpritePreview(existing = false) { const img = document.createElement("img"); img.src = tokenSpriteDropdown[tokenSpriteDropdown.selectedIndex].value; - const tokenNameParts = tokenSpriteDropdown[tokenSpriteDropdown.selectedIndex].text.split("."); - tokenNameParts.pop(); - tokenName.value = tokenNameParts.join("."); + if (!existing) { + const tokenNameParts = tokenSpriteDropdown[tokenSpriteDropdown.selectedIndex].text.split("."); + tokenNameParts.pop(); + tokenName.value = tokenNameParts.join("."); + } img.onload = () => { const w = img.naturalWidth; const h = img.naturalHeight; + if (!existing) { tokenWidth.value = w; tokenHeight.value = h; + tokenCX.value = "" + tokenCY.value = "" + } scaleSpritePreview(); } @@ -261,7 +270,7 @@ function previewExistingToken(id) { break; } } - reinitializeSpritePreview(); + reinitializeSpritePreview(true); } } @@ -500,7 +509,7 @@ function setTokenCreateFormVisible(v) { } createTokenForm.style.display = v ? "block" : "none"; tokenZone.style.display = v ? "none" : "block"; - reinitializeSpritePreview(); + previewZone.innerHTML = ""; } } diff --git a/static/index.html b/static/index.html index 2942138..f4cef00 100644 --- a/static/index.html +++ b/static/index.html @@ -146,13 +146,13 @@ -
felt v0.2.0 (license) | built with leaflet (license)
+
felt v0.2.1 (license) | built with leaflet (license)
- - - - - + + + + + \ No newline at end of file diff --git a/static/map.js b/static/map.js index e2974ae..ea631e5 100644 --- a/static/map.js +++ b/static/map.js @@ -20,6 +20,7 @@ function initializeMap(mapImgUrl) { if (init) { map.setView([0,0], 2); } + resizeMarkers(); } // this works but assumes the map is square (reasonable limitation I think) diff --git a/static/socket.js b/static/socket.js index 76a6301..5963402 100644 --- a/static/socket.js +++ b/static/socket.js @@ -88,10 +88,12 @@ function renderTokenSelect() { // the following few functions aren't socket related but they directly relate to the previous function function initSpritePreviewById(id) { - const img = document.createElement("img"); const token = tokens.find(t=>t.t.id == id); + let img = null; if (token && id) { + + img = document.createElement("img"); img.src = token.t.sprite; secondaryPreviewIdInput.value = id; @@ -102,7 +104,9 @@ function initSpritePreviewById(id) { } dismissPreviewBtn.style.display = (token && id) ? "block" : "none"; secondaryPreviewZone.innerHTML = ""; - secondaryPreviewZone.appendChild(img); + if (img) { + secondaryPreviewZone.appendChild(img); + } } function dismissPreview() { diff --git a/templates/error.html b/templates/error.html index b1e3709..a73919c 100644 --- a/templates/error.html +++ b/templates/error.html @@ -15,6 +15,6 @@

Get back to gaming...

- + \ No newline at end of file diff --git a/templates/register.html b/templates/register.html index 72ceb5c..9d1bb91 100644 --- a/templates/register.html +++ b/templates/register.html @@ -23,5 +23,5 @@ {{end}} - + \ No newline at end of file diff --git a/templates/registered.html b/templates/registered.html index 1c5f484..434a4b0 100644 --- a/templates/registered.html +++ b/templates/registered.html @@ -19,5 +19,5 @@ {{end}} - + \ No newline at end of file