Fix regression when loading piskel files

This commit is contained in:
Julian Descottes 2016-11-12 18:32:21 +01:00
parent 4a01f5625c
commit 440c28d0fd

View File

@ -11,26 +11,32 @@
* @param {Function} onError NOT USED YET * @param {Function} onError NOT USED YET
*/ */
loadFromFile : function (file, onSuccess, onError) { loadFromFile : function (file, onSuccess, onError) {
pskl.utils.FileUtils.readFileAsArrayBuffer(file, function (content) { pskl.utils.FileUtils.readFile(file, function (content) {
var rawPiskel = pskl.utils.Base64.toText(content);
ns.PiskelFileUtils.decodePiskelFile( ns.PiskelFileUtils.decodePiskelFile(
content, rawPiskel,
function (piskel, extra) { function (piskel, descriptor, fps) {
// if using Node-Webkit, store the savePath on load // if using Node-Webkit, store the savePath on load
// Note: the 'path' property is unique to Node-Webkit, and holds the full path // Note: the 'path' property is unique to Node-Webkit, and holds the full path
if (pskl.utils.Environment.detectNodeWebkit()) { if (pskl.utils.Environment.detectNodeWebkit()) {
piskel.savePath = file.path; piskel.savePath = file.path;
} }
onSuccess(piskel, extra); onSuccess(piskel, descriptor, fps);
}, },
onError onError
); );
}); });
}, },
decodePiskelFile : function (serializedPiskel, onSuccess, onError) { decodePiskelFile : function (rawPiskel, onSuccess, onError) {
pskl.utils.serialization.Deserializer.deserialize(serializedPiskel, function (piskel, extra) { var serializedPiskel = JSON.parse(rawPiskel);
onSuccess(piskel, extra); var fps = serializedPiskel.piskel.fps;
var piskel = serializedPiskel.piskel;
var descriptor = new pskl.model.piskel.Descriptor(piskel.name, piskel.description, true);
pskl.utils.serialization.Deserializer.deserialize(serializedPiskel, function (piskel) {
onSuccess(piskel, descriptor, fps);
}); });
} }
}; };
})(); })();