mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Simplified SAVE STATE events, added wrap method to easily build decorators
This commit is contained in:
@@ -50,12 +50,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
ns.BaseTool.prototype.raiseSaveStateEvent = function (args) {
|
||||
var toolInfo = {
|
||||
toolId : this.toolId,
|
||||
args : args
|
||||
};
|
||||
$.publish(Events.PISKEL_SAVE_STATE, toolInfo);
|
||||
ns.BaseTool.prototype.raiseSaveStateEvent = function (replayData) {
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'REPLAY',
|
||||
scope : this,
|
||||
replay : replayData
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -53,13 +53,9 @@
|
||||
ns.Move.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
||||
this.moveToolAt(col, row, color, frame, overlay);
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'TOOL',
|
||||
tool : this,
|
||||
replay : {
|
||||
colDiff : col - this.startCol,
|
||||
rowDiff : row - this.startRow
|
||||
}
|
||||
this.raiseSaveStateEvent({
|
||||
colDiff : col - this.startCol,
|
||||
rowDiff : row - this.startRow
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
ns.PaintBucket.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
||||
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, col, row, color);
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'TOOL',
|
||||
tool : this,
|
||||
replay : {
|
||||
col : col,
|
||||
row : row,
|
||||
color : color
|
||||
}
|
||||
this.raiseSaveStateEvent({
|
||||
col : col,
|
||||
row : row,
|
||||
color : color
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -51,17 +51,12 @@
|
||||
this.draw_(coords.col, coords.row, color, frame);
|
||||
|
||||
$.publish(Events.DRAG_END, [col, row]);
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'TOOL',
|
||||
tool : this,
|
||||
replay : {
|
||||
col : col,
|
||||
row : row,
|
||||
startCol : this.startCol,
|
||||
startRow : this.startRow,
|
||||
color : color
|
||||
}
|
||||
this.raiseSaveStateEvent({
|
||||
col : col,
|
||||
row : row,
|
||||
startCol : this.startCol,
|
||||
startRow : this.startRow,
|
||||
color : color
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -55,13 +55,9 @@
|
||||
|
||||
|
||||
ns.SimplePen.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'TOOL',
|
||||
tool : this,
|
||||
replay : {
|
||||
pixels : this.pixels.slice(0),
|
||||
color : color
|
||||
}
|
||||
this.raiseSaveStateEvent({
|
||||
pixels : this.pixels.slice(0),
|
||||
color : color
|
||||
});
|
||||
this.pixels = [];
|
||||
};
|
||||
|
||||
@@ -73,13 +73,9 @@
|
||||
// For now, we are done with the stroke tool and don't need an overlay anymore:
|
||||
overlay.clear();
|
||||
|
||||
$.publish(Events.PISKEL_SAVE_STATE, {
|
||||
type : 'TOOL',
|
||||
tool : this,
|
||||
replay : {
|
||||
pixels : strokePoints,
|
||||
color : color
|
||||
}
|
||||
this.raiseSaveStateEvent({
|
||||
pixels : strokePoints,
|
||||
color : color
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user