From 1bac62be4c4fb9f831b72fb2c6e6451160b20a56 Mon Sep 17 00:00:00 2001 From: Nicola <47360416+unsettledgames@users.noreply.github.com> Date: Sat, 11 Dec 2021 12:48:12 +0100 Subject: [PATCH] Fixed #45, #44, #40, #38 --- js/History.js | 12 ------------ js/LayerList.js | 2 +- js/PaletteBlock.js | 3 +++ js/Settings.js | 2 +- js/layers/Layer.js | 25 +++++++++---------------- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/js/History.js b/js/History.js index 89f505c..f619b3e 100644 --- a/js/History.js +++ b/js/History.js @@ -1,15 +1,3 @@ -/** BUG: - * - Create a new pixel - * - Open a png file - * - Draw with the pencil - * - Hit CTRL+Z - * - RESULT: undo doesn't work, the app can't find the current layer - * - * - RELATED: when opening an LPE file, the app draws on a layer that is below the one in which the - * file is loaded. This is because the data is loaded on new layers, but the first one - * isn't removed and sometimes it could have the same ID of a recently added layer. - */ - /** How the history works * - undoStates stores the states that can be undone * - redoStates stores the states that can be redone diff --git a/js/LayerList.js b/js/LayerList.js index c0a2107..9c52c47 100644 --- a/js/LayerList.js +++ b/js/LayerList.js @@ -382,7 +382,7 @@ const LayerList = (() => { Layer.layerOptions.style.top = "0"; Layer.layerOptions.style.marginTop = "" + (event.clientY - 25) + "px"; - getLayerByID(selectedId).selectLayer(); + getLayerByID(selectedId).selectLayer(false); } } diff --git a/js/PaletteBlock.js b/js/PaletteBlock.js index b884076..c62e7be 100644 --- a/js/PaletteBlock.js +++ b/js/PaletteBlock.js @@ -131,6 +131,9 @@ const PaletteBlock = (() => { currentSelection.startCoords = getColourCoordinates(index); currentSelection.endCoords = getColourCoordinates(index); } + else if (mouseEvent.which == 1) { + endRampSelection(mouseEvent); + } } /** Updates the outline for the current selection. diff --git a/js/Settings.js b/js/Settings.js index d152280..bb9e63d 100644 --- a/js/Settings.js +++ b/js/Settings.js @@ -21,7 +21,7 @@ const Settings = (() => { enableDynamicCursorOutline: true, //unused - performance enableBrushPreview: true, //unused - performance enableEyedropperPreview: true, //unused - performance - numberOfHistoryStates: 20, + numberOfHistoryStates: 256, maxColorsOnImportedImage: 128, pixelGridColour: '#000000' }; diff --git a/js/layers/Layer.js b/js/layers/Layer.js index 3d6a7a7..466086c 100644 --- a/js/layers/Layer.js +++ b/js/layers/Layer.js @@ -186,23 +186,16 @@ class Layer { this.canvas.style.top = otherLayer.canvas.style.top; } - selectLayer(layer) { - if (layer == null) { - // Deselecting the old layer - currFile.currentLayer.deselectLayer(); + selectLayer(hideOptions = true) { + if (hideOptions) + LayerList.closeOptionsMenu(); + // Deselecting the old layer + currFile.currentLayer.deselectLayer(); - // Selecting the current layer - this.isSelected = true; - this.menuEntry.classList.add("selected-layer"); - currFile.currentLayer = LayerList.getLayerByName(this.menuEntry.getElementsByTagName("p")[0].innerHTML); - } - else { - currFile.currentLayer.deselectLayer(); - - layer.isSelected = true; - layer.menuEntry.classList.add("selected-layer"); - currFile.currentLayer = layer; - } + // Selecting the current layer + this.isSelected = true; + this.menuEntry.classList.add("selected-layer"); + currFile.currentLayer = this; } toggleLock() {