Small cleanup zip export screen

This commit is contained in:
jdescottes 2014-08-27 01:12:29 +02:00
parent 913ef272cf
commit 32e528525c
2 changed files with 8 additions and 5 deletions

View File

@ -8,7 +8,9 @@
}; };
ns.PngExportController.prototype.init = function () { ns.PngExportController.prototype.init = function () {
this.previewContainerEl = document.querySelectorAll(".png-export-preview")[0]; this.previewContainerEl = document.querySelector(".png-export-preview");
this.pngFilePrefixInput = document.getElementById('zip-prefix-name');
this.pngFilePrefixInput.value = 'sprite_';
document.querySelector(".png-download-button").addEventListener('click', this.onPngDownloadButtonClick_.bind(this)); document.querySelector(".png-download-button").addEventListener('click', this.onPngDownloadButtonClick_.bind(this));
@ -30,7 +32,7 @@
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 basename = document.getElementById("zip-file-name").value || "sprite_"; var basename = this.pngFilePrefixInput.value;
var filename = basename + (i+1) + ".png"; 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});
} }

View File

@ -11,10 +11,11 @@
Export as ZIP Export as ZIP
</div> </div>
<div class="settings-item"> <div class="settings-item">
<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> <span class="settings-description">ZIP with one PNG file per frame.</span>
<span class="settings-description" style="display:block">File names will start with the prefix below.</span>
<div class="settings-item"> <div class="settings-item">
<label for="zip-file-name">File prefix:</label> <label for="zip-prefix-name">Prefix:</label>
<input id="zip-file-name" type="text" class="textfield" placeholder="sprite_"> <input id="zip-prefix-name" type="text" class="textfield" placeholder="PNG file prefix ...">
</div> </div>
<button type="button" class="button button-primary zip-generate-button"/>Download ZIP</button> <button type="button" class="button button-primary zip-generate-button"/>Download ZIP</button>
</div> </div>