Fix : frame and layer should be correctly selected when loading a snapshot state

This commit is contained in:
jdescottes 2014-04-18 13:13:42 +02:00
parent 0cecdc74eb
commit b7e4deae00

View File

@ -1,7 +1,7 @@
(function () {
var ns = $.namespace('pskl.service');
var SNAPSHOT_PERIOD = 5000;
var SNAPSHOT_PERIOD = 5;
ns.HistoryService = function (piskelController) {
this.piskelController = piskelController;
@ -86,16 +86,23 @@
ns.HistoryService.prototype.onPiskelLoadedCallback = function (index, snapshotIndex, piskel) {
for (var i = snapshotIndex + 1 ; i <= index ; i++) {
var state = this.stateQueue[i];
this.piskelController.setCurrentFrameIndex(state.frameIndex);
this.piskelController.setCurrentLayerIndex(state.layerIndex);
this.setupState(state);
this.replayState(state);
}
var lastState = this.stateQueue[index];
this.setupState(lastState);
this.piskelController.voice();
$.subscribe(Events.PISKEL_SAVE_STATE, this.saveState__b);
$.publish(Events.PISKEL_RESET);
};
ns.HistoryService.prototype.setupState = function (state) {
this.piskelController.setCurrentFrameIndex(state.frameIndex);
this.piskelController.setCurrentLayerIndex(state.layerIndex);
};
ns.HistoryService.prototype.loadPiskel = function (piskel, callback) {
var descriptor = this.piskelController.piskel.getDescriptor();
pskl.utils.serialization.Deserializer.deserialize(piskel, function (piskel) {