eraser and brush bug fixes
This commit is contained in:
parent
8835295de0
commit
0f0385f901
@ -765,16 +765,12 @@ export const mergeLayers = function (blocks = null) {
|
|||||||
|
|
||||||
if (curBlock.fg === undefined) {
|
if (curBlock.fg === undefined) {
|
||||||
curBlock.fg = store.getters.currentAsciiLayers[z].data[y][x].fg;
|
curBlock.fg = store.getters.currentAsciiLayers[z].data[y][x].fg;
|
||||||
} else {
|
|
||||||
curBlock.fg = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curBlock.char === undefined) {
|
if (curBlock.char === undefined) {
|
||||||
curBlock.char = store.getters.currentAsciiLayers[z].data[y][x].char;
|
curBlock.char = store.getters.currentAsciiLayers[z].data[y][x].char;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,13 +149,7 @@ export default {
|
|||||||
_this.canTool = true;
|
_this.canTool = true;
|
||||||
_this.isBrushing ? _this.drawBrush(false) : _this.eraser();
|
_this.isBrushing ? _this.drawBrush(false) : _this.eraser();
|
||||||
_this.canTool = false;
|
_this.canTool = false;
|
||||||
_this.dispatchBlocks();
|
_this.dispatchBlocks(true);
|
||||||
|
|
||||||
this.diffBlocks = {
|
|
||||||
l: this.selectedLayerIndex,
|
|
||||||
new: [],
|
|
||||||
old: [],
|
|
||||||
};
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,7 +446,7 @@ export default {
|
|||||||
// Save text to store when finished
|
// Save text to store when finished
|
||||||
isTextEditing(val, old) {
|
isTextEditing(val, old) {
|
||||||
if (val !== old && val === false) {
|
if (val !== old && val === false) {
|
||||||
this.dispatchBlocks();
|
this.dispatchBlocks(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textEditing(val, old) {
|
textEditing(val, old) {
|
||||||
@ -472,7 +466,7 @@ export default {
|
|||||||
this.$emit("selecting", val);
|
this.$emit("selecting", val);
|
||||||
},
|
},
|
||||||
yOffset() {
|
yOffset() {
|
||||||
this.delayRedrawCanvas();
|
this.delayRedrawCanvas(true);
|
||||||
},
|
},
|
||||||
selectedLayerIndex(val, old) {
|
selectedLayerIndex(val, old) {
|
||||||
if (val !== old) {
|
if (val !== old) {
|
||||||
@ -1053,8 +1047,8 @@ export default {
|
|||||||
this.top = y;
|
this.top = y;
|
||||||
},
|
},
|
||||||
dispatchBlocks(clearDiff = false) {
|
dispatchBlocks(clearDiff = false) {
|
||||||
this.diffBlocks.old = this.diffBlocks.old.flat();
|
this.diffBlocks.old = this.diffBlocks.old.flat().reverse();
|
||||||
this.diffBlocks.new = this.diffBlocks.new.flat();
|
this.diffBlocks.new = this.diffBlocks.new.flat().reverse();
|
||||||
|
|
||||||
this.$store.dispatch("updateAsciiBlocksAsync", {
|
this.$store.dispatch("updateAsciiBlocksAsync", {
|
||||||
blocks: this.currentAsciiLayerBlocks,
|
blocks: this.currentAsciiLayerBlocks,
|
||||||
@ -1260,13 +1254,14 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
delayRedrawCanvas() {
|
delayRedrawCanvas(force = false) {
|
||||||
|
// Force will skip hash checking and redraw everything anyway
|
||||||
if (this.redraw) {
|
if (this.redraw) {
|
||||||
this.redraw = false;
|
this.redraw = false;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
_this.redrawCanvas();
|
_this.redrawCanvas(force);
|
||||||
_this.redraw = true;
|
_this.redraw = true;
|
||||||
});
|
});
|
||||||
}, 1000 / this.options.fps);
|
}, 1000 / this.options.fps);
|
||||||
@ -1483,7 +1478,7 @@ export default {
|
|||||||
this.toolCtx.fillStyle =
|
this.toolCtx.fillStyle =
|
||||||
brushBlock.fg !== undefined
|
brushBlock.fg !== undefined
|
||||||
? this.mircColours[brushBlock.fg]
|
? this.mircColours[brushBlock.fg]
|
||||||
: "#000000";
|
: "#FFFFFF";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1494,7 +1489,7 @@ export default {
|
|||||||
|
|
||||||
this.toolCtx.fillStyle = this.canFg
|
this.toolCtx.fillStyle = this.canFg
|
||||||
? this.mircColours[brushBlock.fg]
|
? this.mircColours[brushBlock.fg]
|
||||||
: "#000000";
|
: "#FFFFFF";
|
||||||
|
|
||||||
this.toolCtx.fillText(
|
this.toolCtx.fillText(
|
||||||
brushBlock.char,
|
brushBlock.char,
|
||||||
@ -1715,6 +1710,13 @@ export default {
|
|||||||
|
|
||||||
const brushBlock = this.brushBlocks[y][x];
|
const brushBlock = this.brushBlocks[y][x];
|
||||||
|
|
||||||
|
// If we have no fg or bg, and just a space - this has to be an empty block
|
||||||
|
if (brushBlock.char !== undefined && brushBlock.char === " " &&
|
||||||
|
brushBlock.bg === undefined &&
|
||||||
|
brushBlock.fg === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const brushX = this.x * blockWidth + x * blockWidth - brushDiffX;
|
const brushX = this.x * blockWidth + x * blockWidth - brushDiffX;
|
||||||
const brushY = this.y * blockHeight + y * blockHeight - brushDiffY;
|
const brushY = this.y * blockHeight + y * blockHeight - brushDiffY;
|
||||||
|
|
||||||
@ -1795,7 +1797,7 @@ export default {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentAsciiLayerBlocks[arrayY][arrayX] === undefined) {
|
if (this.currentAsciiLayerBlocks[arrayY][arrayX] === undefined || JSON.stringify(this.brushBlocks[y][x]) === '{}') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user