Allow to rename basename for PNG in ZIP export option.

This may helps #192
This commit is contained in:
Eduardo San Martin Morote 2014-08-22 11:27:45 +02:00
parent 17824ae1c4
commit 978319af20
2 changed files with 12 additions and 6 deletions

View File

@ -30,7 +30,8 @@
for (var i = 0; i < this.piskelController.getFrameCount(); i++) { for (var i = 0; i < this.piskelController.getFrameCount(); i++) {
var frame = this.piskelController.getFrameAt(i); var frame = this.piskelController.getFrameAt(i);
var canvas = this.getFrameAsCanvas_(frame); var canvas = this.getFrameAsCanvas_(frame);
var filename = "sprite_" + (i+1) + ".png"; var basename = document.getElementById("zip-file-name").value || "sprite_";
var filename = basename + (i+1) + ".png";
zip.file(filename, pskl.CanvasUtils.getBase64FromCanvas(canvas) + '\n', {base64: true}); zip.file(filename, pskl.CanvasUtils.getBase64FromCanvas(canvas) + '\n', {base64: true});
} }
@ -85,4 +86,4 @@
} }
return url; return url;
}; };
})(); })();

View File

@ -7,11 +7,16 @@
<span class="settings-description">PNG with all frames side by side.</span> <span class="settings-description">PNG with all frames side by side.</span>
<button type="button" class="button button-primary png-download-button">Download PNG</button> <button type="button" class="button button-primary png-download-button">Download PNG</button>
</div> </div>
<div class="settings-title">
Export as ZIP
</div>
<div class="settings-item"> <div class="settings-item">
<span class="settings-description">ZIP with one PNG file per frame.</span> <span class="settings-description">ZIP with one PNG file per frame. Name will use the prefix above and append the frame index, ex: sprite_1.png</span>
<div> <div class="settings-item">
<button type="button" class="button button-primary zip-generate-button"/>Download ZIP</button> <label for="zip-file-name">File prefix:</label>
<input id="zip-file-name" type="text" class="textfield" placeholder="sprite_">
</div> </div>
<button type="button" class="button button-primary zip-generate-button"/>Download ZIP</button>
</div> </div>
<div class="settings-title"> <div class="settings-title">
Export to Animated GIF Export to Animated GIF
@ -37,4 +42,4 @@
<span class="gif-export-progress-status"></span> <span class="gif-export-progress-status"></span>
<div class="gif-export-progress-bar"></div> <div class="gif-export-progress-bar"></div>
</div> </div>
</div> </div>