fix token preview, copy; bump to v0.2.1
This commit is contained in:
parent
f1c56f63f1
commit
331150a0ff
7 changed files with 33 additions and 19 deletions
|
@ -153,8 +153,11 @@ function scaleSpritePreview(source) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
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 = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,13 +146,13 @@
|
|||
</form>
|
||||
</details>
|
||||
<div id="lag" style="display:none;">lag...</div>
|
||||
<div class="ui_win" id="felt_info"><a href="https://hacklab.nilfm.cc/felt">felt v0.2.0</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LICENSE">license</a>) | built with <a href="https://leafletjs.com">leaflet</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LEAFLET_LICENSE">license</a>) </div>
|
||||
<div class="ui_win" id="felt_info"><a href="https://hacklab.nilfm.cc/felt">felt v0.2.1</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LICENSE">license</a>) | built with <a href="https://leafletjs.com">leaflet</a> (<a href="https://hacklab.nilfm.cc/felt/raw/main/LEAFLET_LICENSE">license</a>) </div>
|
||||
</nav>
|
||||
</body>
|
||||
<script src="./leaflet.js?v=1.9.4" type="text/javascript"></script>
|
||||
<script src="./util.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./map.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./socket.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./dice.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./admin.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./util.js?v=0.2.1" type="text/javascript"></script>
|
||||
<script src="./map.js?v=0.2.1" type="text/javascript"></script>
|
||||
<script src="./socket.js?v=0.2.1" type="text/javascript"></script>
|
||||
<script src="./dice.js?v=0.2.1" type="text/javascript"></script>
|
||||
<script src="./admin.js?v=0.2.1" type="text/javascript"></script>
|
||||
</html>
|
|
@ -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)
|
||||
|
|
|
@ -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,8 +104,10 @@ function initSpritePreviewById(id) {
|
|||
}
|
||||
dismissPreviewBtn.style.display = (token && id) ? "block" : "none";
|
||||
secondaryPreviewZone.innerHTML = "";
|
||||
if (img) {
|
||||
secondaryPreviewZone.appendChild(img);
|
||||
}
|
||||
}
|
||||
|
||||
function dismissPreview() {
|
||||
initSpritePreviewById(null);
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
<p><a href="/table">Get back to gaming...</a></p>
|
||||
</main>
|
||||
</body>
|
||||
<script src="./util.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="./util.js?v=0.2.1" type="text/javascript"></script>
|
||||
</html>
|
||||
<html>
|
|
@ -23,5 +23,5 @@
|
|||
{{end}}
|
||||
</main>
|
||||
</body>
|
||||
<script src="/table/util.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="/table/util.js?v=0.2.1" type="text/javascript"></script>
|
||||
</html>
|
|
@ -19,5 +19,5 @@
|
|||
{{end}}
|
||||
</main>
|
||||
</body>
|
||||
<script src="/table/util.js?v=0.2.0" type="text/javascript"></script>
|
||||
<script src="/table/util.js?v=0.2.1" type="text/javascript"></script>
|
||||
</html>
|
Loading…
Reference in a new issue