mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fix : frame and layer should be correctly selected when loading a snapshot state
This commit is contained in:
parent
0cecdc74eb
commit
b7e4deae00
@ -1,7 +1,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace('pskl.service');
|
var ns = $.namespace('pskl.service');
|
||||||
|
|
||||||
var SNAPSHOT_PERIOD = 5000;
|
var SNAPSHOT_PERIOD = 5;
|
||||||
|
|
||||||
ns.HistoryService = function (piskelController) {
|
ns.HistoryService = function (piskelController) {
|
||||||
this.piskelController = piskelController;
|
this.piskelController = piskelController;
|
||||||
@ -86,16 +86,23 @@
|
|||||||
ns.HistoryService.prototype.onPiskelLoadedCallback = function (index, snapshotIndex, piskel) {
|
ns.HistoryService.prototype.onPiskelLoadedCallback = function (index, snapshotIndex, piskel) {
|
||||||
for (var i = snapshotIndex + 1 ; i <= index ; i++) {
|
for (var i = snapshotIndex + 1 ; i <= index ; i++) {
|
||||||
var state = this.stateQueue[i];
|
var state = this.stateQueue[i];
|
||||||
this.piskelController.setCurrentFrameIndex(state.frameIndex);
|
this.setupState(state);
|
||||||
this.piskelController.setCurrentLayerIndex(state.layerIndex);
|
|
||||||
this.replayState(state);
|
this.replayState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastState = this.stateQueue[index];
|
||||||
|
this.setupState(lastState);
|
||||||
|
|
||||||
this.piskelController.voice();
|
this.piskelController.voice();
|
||||||
$.subscribe(Events.PISKEL_SAVE_STATE, this.saveState__b);
|
$.subscribe(Events.PISKEL_SAVE_STATE, this.saveState__b);
|
||||||
$.publish(Events.PISKEL_RESET);
|
$.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) {
|
ns.HistoryService.prototype.loadPiskel = function (piskel, callback) {
|
||||||
var descriptor = this.piskelController.piskel.getDescriptor();
|
var descriptor = this.piskelController.piskel.getDescriptor();
|
||||||
pskl.utils.serialization.Deserializer.deserialize(piskel, function (piskel) {
|
pskl.utils.serialization.Deserializer.deserialize(piskel, function (piskel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user