mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Added undo/redo feature
* new file : HistoryManager.js * can undo (ctrl-z) and redo (ctrl-y) changes performed through the tools * history states are recorded per frame * a new state is recorder each time a tool is released (introduced TOOL_RELEASED event for this purpose) * a duplicated frame doesn't inherit the history states of the original frame * there is no limit to the number of states that can be stored per frame * actions such as creating/duplicating/deleting a frame are not concerned by this update
This commit is contained in:
15
js/piskel.js
15
js/piskel.js
@@ -79,7 +79,8 @@ $.namespace("pskl");
|
||||
|
||||
this.animationController.init();
|
||||
this.previewsController.init();
|
||||
|
||||
|
||||
pskl.HistoryManager.init();
|
||||
pskl.NotificationService.init();
|
||||
pskl.LocalStorageService.init(frameSheet);
|
||||
|
||||
@@ -154,7 +155,7 @@ $.namespace("pskl");
|
||||
|
||||
setActiveFrame: function(index) {
|
||||
activeFrameIndex = index;
|
||||
this.drawingController.frame = frameSheet.getFrameByIndex(index);
|
||||
this.drawingController.frame = this.getCurrentFrame();
|
||||
},
|
||||
|
||||
setActiveFrameAndRedraw: function(index) {
|
||||
@@ -176,6 +177,10 @@ $.namespace("pskl");
|
||||
return activeFrameIndex;
|
||||
},
|
||||
|
||||
getCurrentFrame : function () {
|
||||
return frameSheet.getFrameByIndex(activeFrameIndex);
|
||||
},
|
||||
|
||||
initDrawingArea : function() {
|
||||
drawingAreaContainer = $('#drawing-canvas-container')[0];
|
||||
document.body.addEventListener('mouseup', this.onMouseup.bind(this));
|
||||
@@ -261,6 +266,8 @@ $.namespace("pskl");
|
||||
if(isRightClicked) {
|
||||
$.publish(Events.CANVAS_RIGHT_CLICK_RELEASED);
|
||||
}
|
||||
|
||||
|
||||
isClicked = false;
|
||||
isRightClicked = false;
|
||||
var spriteCoordinate = this.getSpriteCoordinate(event);
|
||||
@@ -271,11 +278,11 @@ $.namespace("pskl");
|
||||
this.drawingController
|
||||
);
|
||||
|
||||
|
||||
$.publish(Events.TOOL_RELEASED);
|
||||
// TODO: Remove that when we have the centralized redraw loop
|
||||
this.previewsController.createPreviews();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
onCanvasContextMenu : function (event) {
|
||||
|
||||
Reference in New Issue
Block a user