Skip to content

Commit

Permalink
Polished previous bug fix
Browse files Browse the repository at this point in the history
Now it's possible to use all non-resizable tool and even copy a locked layer to paste it on an unlocked one.
  • Loading branch information
unsettledgames committed Dec 12, 2021
1 parent 1d9ef0f commit 62130ae
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/ToolManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ToolManager = (() => {
else if (Input.isAltPressed()) {
tools["eyedropper"].onStart(mousePos, mouseEvent.target);
}
else if (!currFile.currentLayer.isLocked){
else if (!currFile.currentLayer.isLocked || !((Object.getPrototypeOf(currTool) instanceof DrawingTool))) {
currTool.onStart(mousePos, mouseEvent.target);
}
break;
Expand Down Expand Up @@ -91,7 +91,7 @@ const ToolManager = (() => {
else if (Input.isAltPressed()) {
tools["eyedropper"].onDrag(mousePos, mouseEvent.target);
}
else if (!currFile.currentLayer.isLocked){
else if (!currFile.currentLayer.isLocked || !((Object.getPrototypeOf(currTool) instanceof DrawingTool))){
currTool.onDrag(mousePos, mouseEvent.target);
}
break;
Expand Down Expand Up @@ -122,7 +122,7 @@ const ToolManager = (() => {
else if (Input.isAltPressed()) {
tools["eyedropper"].onEnd(mousePos, mouseEvent.target);
}
else if (!currFile.currentLayer.isLocked){
else if (!currFile.currentLayer.isLocked || !((Object.getPrototypeOf(currTool) instanceof DrawingTool))) {
currTool.onEnd(mousePos);
}
break;
Expand Down
1 change: 1 addition & 0 deletions js/pixel-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
//=include layers/PixelGrid.js

/** TOOLS **/
//=include tools/DrawingTool.js
//=include tools/ResizableTool.js
//=include tools/SelectionTool.js

Expand Down
5 changes: 5 additions & 0 deletions js/tools/DrawingTool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DrawingTool extends Tool {
constructor (name, options) {
super(name, options);
}
}
2 changes: 1 addition & 1 deletion js/tools/FillTool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class FillTool extends Tool {
class FillTool extends DrawingTool {
constructor(name, options, switchFunction) {
super(name, options);

Expand Down
6 changes: 5 additions & 1 deletion js/tools/MoveSelectionTool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class MoveSelectionTool extends Tool {
class MoveSelectionTool extends DrawingTool {
currSelection = undefined;
selectionTool = undefined;
endTool = undefined;
Expand All @@ -25,6 +25,8 @@ class MoveSelectionTool extends Tool {
}

cutSelection() {
if (currFile.currentLayer.isLocked)
return;
this.cutting = true;
this.lastCopiedSelection = this.currSelection;
this.endSelection();
Expand All @@ -35,6 +37,8 @@ class MoveSelectionTool extends Tool {
}

pasteSelection() {
if (currFile.currentLayer.isLocked)
return;
if (this.lastCopiedSelection === undefined)
return;
// Finish the current selection and start a new one with the same data
Expand Down
2 changes: 1 addition & 1 deletion js/tools/ResizableTool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ResizableTool extends Tool {
class ResizableTool extends DrawingTool {
startResizePos = undefined;
currSize = 1;
prevSize = 1;
Expand Down

0 comments on commit 62130ae

Please sign in to comment.