diff --git a/index.html b/index.html index b982c6751..be3c1c81d 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@

Universal LPC Spritesheet Generator

+
diff --git a/source_index.html b/source_index.html index f58278b80..d944d3412 100755 --- a/source_index.html +++ b/source_index.html @@ -26,6 +26,7 @@

Universal LPC Spritesheet Generator

+
diff --git a/sources/chargen.js b/sources/chargen.js index c44a310c3..ecafa29b4 100755 --- a/sources/chargen.js +++ b/sources/chargen.js @@ -194,6 +194,17 @@ $(document).ready(function() { document.removeChild(a); }); + $(".importFromClipboard").click(async function() { + var clipboardText = await navigator.clipboard.readText(); + var spritesheet = JSON.parse(clipboardText)["layers"]; + window.setTimeout(function() { + $("#resetAll").click(); //Reset first so defaults are set properly + },1,false); + window.setTimeout(function() { + setParamsFromImport(spritesheet); //wait for reset function(s) to complete then apply spritesheet + },2,false); + }); + $(".exportToClipboard").click(function() { var spritesheet = {}; Object.assign(spritesheet, itemsMeta); @@ -624,6 +635,23 @@ $(document).ready(function() { jHash.val(params); } + function setParamsFromImport(spritesheet){ + spritesheet.forEach((sprite)=>{ + var custom_animation = sprite.custom_animation; + var fileName = sprite.fileName; + var name = sprite.name; + var parentName = sprite.parentName; + var variant = sprite.variant; + var zPos = sprite.zPos; + const assetType = name.replaceAll(" ", "_"); + const assetVariant = variant.replaceAll(" ", "_") + const assetToSelect = parentName + "-" + assetType + "_" + assetVariant; + $(`#${assetToSelect}`).prop("checked", true); + + }); + setParams(); + } + function getImage(imgRef) { if (images[imgRef]) return images[imgRef];