diff --git a/src/js/utils/PiskelFileUtils.js b/src/js/utils/PiskelFileUtils.js index 07bf2ede..989965fb 100644 --- a/src/js/utils/PiskelFileUtils.js +++ b/src/js/utils/PiskelFileUtils.js @@ -11,26 +11,32 @@ * @param {Function} onError NOT USED YET */ 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( - content, - function (piskel, extra) { + 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, extra); + onSuccess(piskel, descriptor, fps); }, onError ); }); }, - decodePiskelFile : function (serializedPiskel, onSuccess, onError) { - pskl.utils.serialization.Deserializer.deserialize(serializedPiskel, function (piskel, extra) { - onSuccess(piskel, extra); + decodePiskelFile : function (rawPiskel, onSuccess, onError) { + var serializedPiskel = JSON.parse(rawPiskel); + 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); }); } + }; -})(); +})(); \ No newline at end of file