From aabc715086783c791f7e2e8a72991a5e79aea530 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Tue, 29 Sep 2020 19:10:50 +0200 Subject: [PATCH] Finished todo list for current contribution Fixed canvas trimming history, added proper setting management for the pixel grid. --- _ext/scripts/utilities/getSetValue.js | 1 + js/_history.js | 13 +++++++++++-- js/_pixelGrid.js | 2 +- js/_resizeCanvas.js | 18 +++++++++--------- js/_settings.js | 6 +++++- views/pixel-editor.hbs | 5 +---- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/_ext/scripts/utilities/getSetValue.js b/_ext/scripts/utilities/getSetValue.js index eed10fd..f69e489 100644 --- a/_ext/scripts/utilities/getSetValue.js +++ b/_ext/scripts/utilities/getSetValue.js @@ -2,6 +2,7 @@ function getValue(elementId) { var element = (typeof elementId == 'string' ? document.getElementById(elementId) : elementId); + console.log("setting: " + elementId + ": " + element.value); return element.value; } diff --git a/js/_history.js b/js/_history.js index 19da676..652ffc6 100644 --- a/js/_history.js +++ b/js/_history.js @@ -36,10 +36,11 @@ function HistoryStateResizeSprite(xRatio, yRatio, algo, oldData) { saveHistoryState(this); } -function HistoryStateResizeCanvas(newSize, oldSize, imageDatas) { +function HistoryStateResizeCanvas(newSize, oldSize, imageDatas, trim) { this.oldSize = oldSize; this.newSize = newSize; this.imageDatas = imageDatas; + this.trim = trim; this.undo = function() { let dataIndex = 0; @@ -58,7 +59,15 @@ function HistoryStateResizeCanvas(newSize, oldSize, imageDatas) { }; this.redo = function() { - resizeCanvas(null, newSize); + console.log("trim: " + this.trim); + if (!this.trim) { + resizeCanvas(null, newSize); + undoStates.push(this); + } + else { + trimCanvas(null, false); + } + undoStates.push(this); }; diff --git a/js/_pixelGrid.js b/js/_pixelGrid.js index 26dd600..0c36c98 100644 --- a/js/_pixelGrid.js +++ b/js/_pixelGrid.js @@ -28,7 +28,7 @@ function fillPixelGrid() { // OPTIMIZABLE, could probably be a bit more elegant // Draw horizontal lines for (let i=0; iPixel grid
- -
-
- +