fixed fps when restoring backup

This commit is contained in:
jdescottes 2014-07-14 14:39:21 +02:00
parent 19c99d1aa7
commit b556143b66
3 changed files with 21 additions and 9 deletions

View File

@ -81,9 +81,11 @@
}; };
ns.AnimatedPreviewController.prototype.setFPS = function (fps) { ns.AnimatedPreviewController.prototype.setFPS = function (fps) {
this.fps = fps; if (fps) {
$("#preview-fps").val(this.fps); this.fps = fps;
$("#display-fps").html(this.fps + " FPS"); $("#preview-fps").val(this.fps);
$("#display-fps").html(this.fps + " FPS");
}
}; };
ns.AnimatedPreviewController.prototype.getFPS = function () { ns.AnimatedPreviewController.prototype.getFPS = function () {

View File

@ -27,6 +27,10 @@
var currentFrameIndex = this.piskelController.getCurrentFrameIndex(); var currentFrameIndex = this.piskelController.getCurrentFrameIndex();
var currentLayerIndex = this.piskelController.getCurrentLayerIndex(); var currentLayerIndex = this.piskelController.getCurrentLayerIndex();
var downLayers = layers.slice(0, currentLayerIndex);
var upLayers = layers.slice(currentLayerIndex + 1, layers.length);
var serializedRendering = [ var serializedRendering = [
this.getZoom(), this.getZoom(),
this.getGridWidth(), this.getGridWidth(),
@ -34,8 +38,8 @@
offset.y, offset.y,
size.width, size.width,
size.height, size.height,
currentFrameIndex, this.getHashForLayersAt_(currentFrameIndex, downLayers),
currentLayerIndex, this.getHashForLayersAt_(currentFrameIndex, upLayers),
layers.length layers.length
].join("-"); ].join("-");
@ -45,18 +49,15 @@
this.clear(); this.clear();
var downLayers = layers.slice(0, currentLayerIndex);
if (downLayers.length > 0) { if (downLayers.length > 0) {
var downFrame = this.getFrameForLayersAt_(currentFrameIndex, downLayers); var downFrame = this.getFrameForLayersAt_(currentFrameIndex, downLayers);
this.belowRenderer.render(downFrame); this.belowRenderer.render(downFrame);
} }
var upLayers = layers.slice(currentLayerIndex + 1, layers.length);
if (upLayers.length > 0) { if (upLayers.length > 0) {
var upFrame = this.getFrameForLayersAt_(currentFrameIndex, upLayers); var upFrame = this.getFrameForLayersAt_(currentFrameIndex, upLayers);
this.aboveRenderer.render(upFrame); this.aboveRenderer.render(upFrame);
} }
} }
}; };
@ -80,6 +81,13 @@
return pskl.utils.FrameUtils.merge(frames); return pskl.utils.FrameUtils.merge(frames);
}; };
ns.LayersRenderer.prototype.getHashForLayersAt_ = function (frameIndex, layers) {
var hash = layers.map(function (l) {
return l.getFrameAt(frameIndex).getHash();
});
return hash.join('-');
};
ns.LayersRenderer.prototype.flush = function () { ns.LayersRenderer.prototype.flush = function () {
this.serializedRendering = ''; this.serializedRendering = '';
}; };

View File

@ -24,6 +24,7 @@
var info = { var info = {
name : descriptor.name, name : descriptor.name,
description : descriptor.info, description : descriptor.info,
fps : this.piskelController.getFPS(),
date : Date.now(), date : Date.now(),
hash : hash hash : hash
}; };
@ -54,6 +55,7 @@
pskl.utils.serialization.Deserializer.deserialize(previousPiskel, function (piskel) { pskl.utils.serialization.Deserializer.deserialize(previousPiskel, function (piskel) {
piskel.setDescriptor(new pskl.model.piskel.Descriptor(previousInfo.name, previousInfo.description, true)); piskel.setDescriptor(new pskl.model.piskel.Descriptor(previousInfo.name, previousInfo.description, true));
pskl.app.piskelController.setPiskel(piskel); pskl.app.piskelController.setPiskel(piskel);
pskl.app.animationController.setFPS(previousInfo.fps);
}); });
}; };
})(); })();