Issue #727 - skip import steps if current piskel is empty

This commit is contained in:
Julian Descottes 2017-10-01 13:58:48 +02:00
parent 95c8df1224
commit bf4cc3302a
3 changed files with 16 additions and 3 deletions

View File

@ -80,7 +80,13 @@
var step = this.wizard.getCurrentStep(); var step = this.wizard.getCurrentStep();
if (step.name === 'IMAGE_IMPORT') { if (step.name === 'IMAGE_IMPORT') {
this.wizard.goTo('SELECT_MODE'); if (this.piskelController.isEmpty()) {
// If the current sprite is empty finalize immediately and replace the current sprite.
this.mergeData.importMode = ns.steps.SelectMode.MODES.REPLACE;
this.finalizeImport_();
} else {
this.wizard.goTo('SELECT_MODE');
}
} else if (step.name === 'SELECT_MODE') { } else if (step.name === 'SELECT_MODE') {
if (this.mergeData.importMode === ns.steps.SelectMode.MODES.REPLACE) { if (this.mergeData.importMode === ns.steps.SelectMode.MODES.REPLACE) {
this.finalizeImport_(); this.finalizeImport_();

View File

@ -42,12 +42,17 @@
this.addEventListener(this.frameOffsetY, 'keyup', this.onFrameInputKeyUp_); this.addEventListener(this.frameOffsetY, 'keyup', this.onFrameInputKeyUp_);
pskl.utils.FileUtils.readImageFile(this.file_, this.onImageLoaded_.bind(this)); pskl.utils.FileUtils.readImageFile(this.file_, this.onImageLoaded_.bind(this));
if (this.piskelController.isEmpty()) {
this.nextButton.textContent = 'import';
}
}; };
ns.ImageImport.prototype.onNextClick = function () { ns.ImageImport.prototype.onNextClick = function () {
this.container.classList.add('import-image-loading'); this.container.classList.add('import-image-loading');
this.createPiskelFromImage().then(function (piskel) { this.createPiskelFromImage().then(function (piskel) {
this.mergeData.mergePiskel = piskel; this.mergeData.mergePiskel = piskel;
this.container.classList.remove('import-image-loading');
this.superclass.onNextClick.call(this); this.superclass.onNextClick.call(this);
}.bind(this)).catch(function (e) { }.bind(this)).catch(function (e) {
console.error(e); console.error(e);
@ -257,9 +262,7 @@
context.lineTo(maxWidth * scaleX, y * scaleY); context.lineTo(maxWidth * scaleX, y * scaleY);
} }
// Set the line style to dashed
context.lineWidth = 1; context.lineWidth = 1;
// context.setLineDash([2, 1]);
context.strokeStyle = 'gold'; context.strokeStyle = 'gold';
context.stroke(); context.stroke();

View File

@ -297,4 +297,8 @@
ns.PiskelController.prototype.serialize = function () { ns.PiskelController.prototype.serialize = function () {
return pskl.utils.serialization.Serializer.serialize(this.piskel); return pskl.utils.serialization.Serializer.serialize(this.piskel);
}; };
ns.PiskelController.prototype.isEmpty = function () {
return pskl.app.currentColorsService.getCurrentColors().length === 0;
};
})(); })();