Fix : fix classes extending simplePen

This commit is contained in:
jdescottes 2014-07-02 07:34:07 +02:00
parent d126023c4a
commit 8a70943b09
4 changed files with 33 additions and 15 deletions

View File

@ -42,18 +42,25 @@
evt.stopPropagation();
var name = this.getName();
var description = this.getDescription();
var isPublic = !!this.isPublicCheckbox.prop('checked');
var descriptor = new pskl.model.piskel.Descriptor(name, description, isPublic);
this.piskelController.getPiskel().setDescriptor(descriptor);
if (!name) {
name = window.prompt('Please specify a name', 'New piskel');
}
this.beforeSaving_();
pskl.app.storageService.store({
success : this.onSaveSuccess_.bind(this),
error : this.onSaveError_.bind(this),
after : this.afterSaving_.bind(this)
});
if (name) {
var description = this.getDescription();
var isPublic = !!this.isPublicCheckbox.prop('checked');
var descriptor = new pskl.model.piskel.Descriptor(name, description, isPublic);
this.piskelController.getPiskel().setDescriptor(descriptor);
this.beforeSaving_();
pskl.app.storageService.store({
success : this.onSaveSuccess_.bind(this),
error : this.onSaveError_.bind(this),
after : this.afterSaving_.bind(this)
});
}
};
ns.SaveController.prototype.onSaveLocalClick_ = function (evt) {

View File

@ -27,7 +27,9 @@
* @override
*/
ns.Lighten.prototype.applyToolAt = function(col, row, color, frame, overlay, event, mouseButton) {
var pixelColor = frame.getPixel(col, row);
var overlayColor = overlay.getPixel(col, row);
var frameColor = frame.getPixel(col, row);
var pixelColor = overlayColor === Constants.TRANSPARENT_COLOR ? frameColor : overlayColor;
var isDarken = event.ctrlKey || event.cmdKey;
var isSinglePass = event.shiftKey;
@ -55,7 +57,11 @@
};
ns.Lighten.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
// apply on real frame
this.setPixelsToFrame_(frame, this.pixels);
this.resetUsedPixels_();
$.publish(Events.PISKEL_SAVE_STATE, {
type : pskl.service.HistoryService.SNAPSHOT
});

View File

@ -23,11 +23,16 @@
*/
ns.SimplePen.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
overlay.setPixel(col, row, color);
if (color === Constants.TRANSPARENT_COLOR) {
frame.setPixel(col, row, color);
}
this.previousCol = col;
this.previousRow = row;
this.pixels.push({
col : col,
row : row
row : row,
color : color
});
};
@ -56,7 +61,7 @@
ns.SimplePen.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
// apply on real frame
this.setPixelsToFrame_(frame, this.pixels, color);
this.setPixelsToFrame_(frame, this.pixels);
// save state
this.raiseSaveStateEvent({
@ -74,7 +79,7 @@
ns.SimplePen.prototype.setPixelsToFrame_ = function (frame, pixels, color) {
pixels.forEach(function (pixel) {
frame.setPixel(pixel.col, pixel.row, color);
frame.setPixel(pixel.col, pixel.row, pixel.color);
});
};
})();

View File

@ -1,6 +1,6 @@
(function () {
var ns = $.namespace('pskl.service');
var BACKUP_INTERVAL = 1000 * 30;
var BACKUP_INTERVAL = 1000 * 60;
ns.BackupService = function (piskelController) {
this.piskelController = piskelController;