mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fix #718 - when dropping image, only use import wizard for big images
This commit is contained in:
parent
8a2c0191f9
commit
183133496e
@ -35,13 +35,9 @@
|
|||||||
var isPiskel = /\.piskel$/i.test(file.name);
|
var isPiskel = /\.piskel$/i.test(file.name);
|
||||||
var isPalette = /\.(gpl|txt|pal)$/i.test(file.name);
|
var isPalette = /\.(gpl|txt|pal)$/i.test(file.name);
|
||||||
if (isImage) {
|
if (isImage) {
|
||||||
$.publish(Events.DIALOG_SHOW, {
|
pskl.utils.FileUtils.readImageFile(file, function (image) {
|
||||||
dialogId : 'import',
|
this.onImageLoaded_(image, file);
|
||||||
initArgs : {
|
}.bind(this));
|
||||||
rawFiles: [file]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// pskl.utils.FileUtils.readImageFile(file, this.onImageLoaded_.bind(this));
|
|
||||||
} else if (isPiskel) {
|
} else if (isPiskel) {
|
||||||
pskl.utils.PiskelFileUtils.loadFromFile(file, this.onPiskelFileLoaded_, this.onPiskelFileError_);
|
pskl.utils.PiskelFileUtils.loadFromFile(file, this.onPiskelFileLoaded_, this.onPiskelFileError_);
|
||||||
} else if (isPalette) {
|
} else if (isPalette) {
|
||||||
@ -65,10 +61,23 @@
|
|||||||
$.publish(Events.PISKEL_FILE_IMPORT_FAILED, [reason]);
|
$.publish(Events.PISKEL_FILE_IMPORT_FAILED, [reason]);
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.FileDropperService.prototype.onImageLoaded_ = function (importedImage) {
|
ns.FileDropperService.prototype.onImageLoaded_ = function (importedImage, file) {
|
||||||
|
var piskelWidth = pskl.app.piskelController.getWidth();
|
||||||
|
var piskelHeight = pskl.app.piskelController.getHeight();
|
||||||
|
|
||||||
if (this.isMultipleFiles_) {
|
if (this.isMultipleFiles_) {
|
||||||
this.piskelController.addFrameAtCurrentIndex();
|
this.piskelController.addFrameAtCurrentIndex();
|
||||||
this.piskelController.selectNextFrame();
|
this.piskelController.selectNextFrame();
|
||||||
|
} else if (importedImage.width > piskelWidth || importedImage.height > piskelHeight) {
|
||||||
|
// For single file imports, if the file is too big, trigger the import wizard.
|
||||||
|
$.publish(Events.DIALOG_SHOW, {
|
||||||
|
dialogId : 'import',
|
||||||
|
initArgs : {
|
||||||
|
rawFiles: [file]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentFrame = this.piskelController.getCurrentFrame();
|
var currentFrame = this.piskelController.getCurrentFrame();
|
||||||
|
Loading…
Reference in New Issue
Block a user