mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
History service gets core piskelController from public piskelController
This commit is contained in:
parent
8806c41892
commit
94b1a1df4a
@ -36,6 +36,8 @@
|
|||||||
this.piskelController.init();
|
this.piskelController.init();
|
||||||
|
|
||||||
this.paletteImportService = new pskl.service.palette.PaletteImportService();
|
this.paletteImportService = new pskl.service.palette.PaletteImportService();
|
||||||
|
this.paletteImportService.init();
|
||||||
|
|
||||||
this.paletteService = new pskl.service.palette.PaletteService();
|
this.paletteService = new pskl.service.palette.PaletteService();
|
||||||
this.paletteService.addDynamicPalette(new pskl.service.palette.CurrentColorsPalette());
|
this.paletteService.addDynamicPalette(new pskl.service.palette.CurrentColorsPalette());
|
||||||
|
|
||||||
@ -95,7 +97,7 @@
|
|||||||
this.selectionManager = new pskl.selection.SelectionManager(this.piskelController);
|
this.selectionManager = new pskl.selection.SelectionManager(this.piskelController);
|
||||||
this.selectionManager.init();
|
this.selectionManager.init();
|
||||||
|
|
||||||
this.historyService = new pskl.service.HistoryService(this.corePiskelController);
|
this.historyService = new pskl.service.HistoryService(this.piskelController);
|
||||||
this.historyService.init();
|
this.historyService.init();
|
||||||
|
|
||||||
this.notificationController = new pskl.controller.NotificationController();
|
this.notificationController = new pskl.controller.NotificationController();
|
||||||
@ -131,7 +133,9 @@
|
|||||||
this.imageUploadService = new pskl.service.ImageUploadService();
|
this.imageUploadService = new pskl.service.ImageUploadService();
|
||||||
this.imageUploadService.init();
|
this.imageUploadService.init();
|
||||||
|
|
||||||
this.savedStatusService = new pskl.service.SavedStatusService(this.piskelController, this.historyService);
|
this.savedStatusService = new pskl.service.SavedStatusService(
|
||||||
|
this.piskelController,
|
||||||
|
this.historyService);
|
||||||
this.savedStatusService.init();
|
this.savedStatusService.init();
|
||||||
|
|
||||||
this.backupService = new pskl.service.BackupService(this.piskelController);
|
this.backupService = new pskl.service.BackupService(this.piskelController);
|
||||||
@ -140,7 +144,9 @@
|
|||||||
this.beforeUnloadService = new pskl.service.BeforeUnloadService(this.piskelController);
|
this.beforeUnloadService = new pskl.service.BeforeUnloadService(this.piskelController);
|
||||||
this.beforeUnloadService.init();
|
this.beforeUnloadService.init();
|
||||||
|
|
||||||
this.headerController = new pskl.controller.HeaderController(this.piskelController, this.savedStatusService);
|
this.headerController = new pskl.controller.HeaderController(
|
||||||
|
this.piskelController,
|
||||||
|
this.savedStatusService);
|
||||||
this.headerController.init();
|
this.headerController.init();
|
||||||
|
|
||||||
this.penSizeService = new pskl.service.pensize.PenSizeService();
|
this.penSizeService = new pskl.service.pensize.PenSizeService();
|
||||||
@ -156,7 +162,8 @@
|
|||||||
this.userWarningController.init();
|
this.userWarningController.init();
|
||||||
|
|
||||||
this.performanceReportService = new pskl.service.performance.PerformanceReportService(
|
this.performanceReportService = new pskl.service.performance.PerformanceReportService(
|
||||||
this.piskelController, this.currentColorsService);
|
this.piskelController,
|
||||||
|
this.currentColorsService);
|
||||||
this.performanceReportService.init();
|
this.performanceReportService.init();
|
||||||
|
|
||||||
this.drawingLoop = new pskl.rendering.DrawingLoop();
|
this.drawingLoop = new pskl.rendering.DrawingLoop();
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var ns = $.namespace('pskl.controller.piskel');
|
var ns = $.namespace('pskl.controller.piskel');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PublicPiskelController is a decorator on PiskelController, provides the same API
|
||||||
|
* but will fire RESET/SAVE events when appropriate so that other objects get notified
|
||||||
|
* when important changes are made on the current Piskel.
|
||||||
|
* @param {PiskelController} piskelController the wrapped PiskelController
|
||||||
|
*/
|
||||||
ns.PublicPiskelController = function (piskelController) {
|
ns.PublicPiskelController = function (piskelController) {
|
||||||
this.piskelController = piskelController;
|
this.piskelController = piskelController;
|
||||||
pskl.utils.wrap(this, this.piskelController);
|
pskl.utils.wrap(this, this.piskelController);
|
||||||
@ -38,6 +44,10 @@
|
|||||||
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DUPLICATE_FRAME, this.duplicateCurrentFrame.bind(this));
|
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DUPLICATE_FRAME, this.duplicateCurrentFrame.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.PublicPiskelController.prototype.getWrappedPiskelController = function () {
|
||||||
|
return this.piskelController;
|
||||||
|
};
|
||||||
|
|
||||||
ns.PublicPiskelController.prototype.setPiskel = function (piskel, preserveState) {
|
ns.PublicPiskelController.prototype.setPiskel = function (piskel, preserveState) {
|
||||||
this.piskelController.setPiskel(piskel, preserveState);
|
this.piskelController.setPiskel(piskel, preserveState);
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
var ns = $.namespace('pskl.service');
|
var ns = $.namespace('pskl.service');
|
||||||
|
|
||||||
ns.HistoryService = function (piskelController, shortcutService, deserializer, serializer) {
|
ns.HistoryService = function (piskelController, shortcutService, deserializer, serializer) {
|
||||||
this.piskelController = piskelController || pskl.app.piskelController;
|
// Use the real piskel controller that will not fire events when calling setters
|
||||||
|
this.piskelController = piskelController.getWrappedPiskelController();
|
||||||
|
|
||||||
this.shortcutService = shortcutService || pskl.app.shortcutService;
|
this.shortcutService = shortcutService || pskl.app.shortcutService;
|
||||||
this.deserializer = deserializer || pskl.utils.serialization.arraybuffer.ArrayBufferDeserializer;
|
this.deserializer = deserializer || pskl.utils.serialization.arraybuffer.ArrayBufferDeserializer;
|
||||||
this.serializer = serializer || pskl.utils.serialization.arraybuffer.ArrayBufferSerializer;
|
this.serializer = serializer || pskl.utils.serialization.arraybuffer.ArrayBufferSerializer;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.PaletteImportService = function () {};
|
ns.PaletteImportService = function () {};
|
||||||
|
ns.PaletteImportService.prototype.init = function () {};
|
||||||
|
|
||||||
ns.PaletteImportService.prototype.read = function (file, onSuccess, onError) {
|
ns.PaletteImportService.prototype.read = function (file, onSuccess, onError) {
|
||||||
var reader = this.getReader_(file, onSuccess, onError);
|
var reader = this.getReader_(file, onSuccess, onError);
|
||||||
|
@ -22,7 +22,16 @@ describe("History Service suite", function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var createMockHistoryService = function () {
|
var createMockHistoryService = function () {
|
||||||
var mockPiskelController = { getPiskel : function () {}, getFPS : function () { return 12; } };
|
var mockPiskelController = {
|
||||||
|
getWrappedPiskelController: function () {
|
||||||
|
return {
|
||||||
|
getPiskel : function () {},
|
||||||
|
getFPS : function () {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
var mockShortcutService = {
|
var mockShortcutService = {
|
||||||
registerShortcuts : function () {},
|
registerShortcuts : function () {},
|
||||||
registerShortcut : function () {}
|
registerShortcut : function () {}
|
||||||
|
Loading…
Reference in New Issue
Block a user