When running in Node-Webkit, hold onto the full savePath when opening.piskel files via the gui or drag and drop.

This commit is contained in:
Lee Grey 2015-03-22 00:39:23 +13:00
parent 6a6f75b3ce
commit c9b581f6db
3 changed files with 15 additions and 5 deletions

View File

@ -34,12 +34,12 @@
ns.DesktopStorageService.prototype.openPiskel = function () {
pskl.utils.FileUtilsDesktop.chooseFileDialog(function(filename){
var chosenFilename = filename;
pskl.utils.FileUtilsDesktop.readFile(chosenFilename, function(content){
var savePath = filename;
pskl.utils.FileUtilsDesktop.readFile(savePath, function(content){
pskl.utils.PiskelFileUtils.decodePiskelFile(content, function (piskel, descriptor, fps) {
piskel.setDescriptor(descriptor);
// store save path so we can re-save without opening the save dialog
piskel.savePath = chosenFilename;
piskel.savePath = savePath;
pskl.app.piskelController.setPiskel(piskel);
pskl.app.animationController.setFPS(fps);
});

View File

@ -8,7 +8,6 @@
this.stateQueue = [];
this.currentIndex = -1;
this.lastLoadState = -1;
this.saveNextAsSnapshot = false;

View File

@ -13,7 +13,18 @@
loadFromFile : function (file, onSuccess, onError) {
pskl.utils.FileUtils.readFile(file, function (content) {
var rawPiskel = pskl.utils.Base64.toText(content);
ns.PiskelFileUtils.decodePiskelFile(rawPiskel, onSuccess, onError);
ns.PiskelFileUtils.decodePiskelFile(
rawPiskel,
function (piskel, descriptor, fps) {
// if using Node-Webkit, store the savePath on load
// Note: the 'path' property is unique to Node-Webkit, and holds the full path
if (pskl.utils.Environment.detectNodeWebkit()) {
piskel.savePath = file.path;
}
onSuccess(piskel, descriptor, fps);
},
onError
);
});
},