mIRC import sorta okay, fuckin editor parse shit still fucked
This commit is contained in:
parent
559170b15a
commit
6a424f8126
|
@ -163,10 +163,11 @@ export default {
|
|||
// The proper X and Y value of the block inside the ASCII
|
||||
let asciiX = 0;
|
||||
let asciiY = 0;
|
||||
let firstColor = true;
|
||||
|
||||
for (
|
||||
let charPos = 0;
|
||||
charPos < this.asciiImport.length - 1;
|
||||
charPos <= this.asciiImport.length - 1;
|
||||
charPos++
|
||||
) {
|
||||
let curChar = asciiStringArray[charPos];
|
||||
|
@ -176,7 +177,11 @@ export default {
|
|||
switch (curChar) {
|
||||
case "\n":
|
||||
// Reset the colours here on a new line
|
||||
curBlock = Object.assign(curBlock, emptyCurBlock);
|
||||
curBlock = {
|
||||
fg: null,
|
||||
bg: null,
|
||||
char: null,
|
||||
};
|
||||
asciiY++;
|
||||
|
||||
// We can determine the width at the end of the first line
|
||||
|
@ -184,13 +189,20 @@ export default {
|
|||
this.finalAscii.width = asciiX - 1; // minus \n for the proper width
|
||||
}
|
||||
|
||||
|
||||
|
||||
asciiX = 0;
|
||||
break;
|
||||
|
||||
case "\u0003":
|
||||
curBlock = Object.assign(curBlock, emptyCurBlock);
|
||||
let firstColor = true;
|
||||
|
||||
curBlock = {
|
||||
fg: null,
|
||||
bg: null,
|
||||
char: null,
|
||||
};
|
||||
firstColor = true;
|
||||
curBlock.fg = ""
|
||||
curBlock.bg = ""
|
||||
// Pick up the colour here, then set it
|
||||
charPos++;
|
||||
|
||||
|
@ -224,13 +236,15 @@ export default {
|
|||
curBlock.bg = `${asciiStringArray[k]}`;
|
||||
}
|
||||
|
||||
curBlock.char = `${asciiStringArray[k + 1]}`;
|
||||
// curBlock.char = `${asciiStringArray[k + 1]}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check colours
|
||||
// Given how we have the code above we may not need this
|
||||
//asciiX--;
|
||||
|
||||
if (
|
||||
!isNaN(curBlock.fg) &&
|
||||
curBlock.fg >= 0 &&
|
||||
|
@ -244,25 +258,32 @@ export default {
|
|||
|
||||
// Minus X value if all good
|
||||
asciiX--;
|
||||
|
||||
// this.finalAscii.blocks[asciiY][asciiX] = curBlock;
|
||||
} else {
|
||||
console.log(`curBlock BAD`, curBlock);
|
||||
console.log(`curBlock BAD`, JSON.stringify(curBlock));
|
||||
}
|
||||
|
||||
charPos++;
|
||||
break;
|
||||
|
||||
default:
|
||||
asciiX++;
|
||||
curBlock.char = curChar
|
||||
asciiX++;
|
||||
|
||||
// The console log shows the correct curBlock
|
||||
console.log(JSON.stringify({asciiY, asciiX, curBlock}))
|
||||
|
||||
// Fk this js shit, serialising the curBlock works much better. Lost hours on this bs, fk.
|
||||
this.finalAscii.blocks[asciiY][asciiX] = JSON.parse(JSON.stringify(curBlock));
|
||||
|
||||
break;
|
||||
} // End Switch
|
||||
|
||||
// curBlock.fg = this.mircColors[curBlock.fg - 1];
|
||||
// curBlock.bg = this.mircColors[curBlock.bg - 1];
|
||||
|
||||
this.finalAscii.blocks[asciiY][asciiX] = curBlock;
|
||||
// break;
|
||||
} // End loop charPos
|
||||
|
||||
// Presume if we get this far we have a colour state set
|
||||
console.log(JSON.stringify(this.finalAscii.blocks))
|
||||
this.$store.commit("newAsciibirdMeta", this.finalAscii);
|
||||
|
||||
// End file upload
|
||||
|
@ -297,12 +318,8 @@ export default {
|
|||
for (let x = 0; x < payload.width; x++) {
|
||||
for (let y = 0; y < payload.height; y++) {
|
||||
payload.blocks[y].push({
|
||||
bg: this.mircColors[
|
||||
Math.floor(Math.random() * this.mircColors.length)
|
||||
],
|
||||
fg: this.mircColors[
|
||||
Math.floor(Math.random() * this.mircColors.length)
|
||||
],
|
||||
bg: Math.floor(Math.random() * this.mircColors.length),
|
||||
fg: Math.floor(Math.random() * this.mircColors.length),
|
||||
char: this.charCodes[
|
||||
Math.floor(Math.random() * this.charCodes.length)
|
||||
],
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
5_
|
||||
5_/-\_
|
||||
5.-`-:-:-`-.
|
||||
5/-:-:-:-:-:-\
|
||||
5\:-:-:-:-:-:/
|
||||
14|5` `14|
|
||||
14| |
|
||||
14`\ /'
|
||||
14`-._.-'
|
||||
14`
|
|
@ -0,0 +1 @@
|
|||
3,3XXX1,3ALBINOS3,3XXXXX3,3X
|
|
@ -0,0 +1,8 @@
|
|||
3,3XXX1,3ALBINOS3,3XXXXX3,3X
|
||||
11,11XXX5,5XXXXX11,11XXX0,0X11,11XXX
|
||||
11,11XXX5,5XXX1,5M5,5X11,11XX4,0^_^11,11XX
|
||||
11,11XXX5,5XXX1,5U5,5X11,11X0,0XXXXX11,11X
|
||||
11,11XXX5,5XXX1,5S5,5X11,11XX0,0XXX11,11XX
|
||||
11,11XXX5,5XXX1,5T5,5X11,11XX0,0X11,11X0,0X11,11XX
|
||||
11,11XXX5,5XXXXX11,11XXXXXXX
|
||||
3,3XXXXX1,3HANG3,3XXXXXX
|
|
@ -66,6 +66,7 @@ export default {
|
|||
components: { Block },
|
||||
mounted() {
|
||||
this.currentAsciibirdMeta = this.$store.getters.currentAscii;
|
||||
this.mircColors = this.$store.getters.mircColors;
|
||||
},
|
||||
created() {},
|
||||
data: () => ({
|
||||
|
@ -79,6 +80,7 @@ export default {
|
|||
message: "Hello Vue!",
|
||||
vueCanvas: null,
|
||||
},
|
||||
mircColors: null,
|
||||
ctx: null,
|
||||
selectionMode: false,
|
||||
startPosition: {
|
||||
|
@ -135,6 +137,9 @@ export default {
|
|||
// },
|
||||
},
|
||||
methods: {
|
||||
getMircColor(index) {
|
||||
return this.$store.getters.mircColors[index]
|
||||
},
|
||||
onChangeTab() {
|
||||
// Get the asciimeta index from the route URL
|
||||
this.currentAsciibirdMeta = this.$store.getters.currentAscii;
|
||||
|
@ -174,64 +179,39 @@ export default {
|
|||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
if (this.currentAsciibirdMeta.blocks.length) {
|
||||
const blockWidth = this.currentAsciibirdMeta.blockWidth;
|
||||
const blockHeight = this.currentAsciibirdMeta.blockHeight;
|
||||
const BLOCK_WIDTH = this.currentAsciibirdMeta.blockWidth;
|
||||
const BLOCK_HEIGHT = this.currentAsciibirdMeta.blockHeight;
|
||||
|
||||
// Position of the meta array
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
// Try get better loop
|
||||
let theX = 0;
|
||||
|
||||
// Draws the actual rectangle
|
||||
let blockX = 0;
|
||||
let blockY = 0;
|
||||
let canvasX = 0;
|
||||
let canvasY = 0;
|
||||
let curBlock = {};
|
||||
|
||||
this.ctx.font = "16px Mono";
|
||||
|
||||
for (y = 0; y < this.currentAsciibirdMeta.width; y++) {
|
||||
blockY = this.currentAsciibirdMeta.blockHeight * y;
|
||||
for (y = 0; y < this.currentAsciibirdMeta.height; y++) {
|
||||
canvasY = BLOCK_HEIGHT * y;
|
||||
|
||||
for (x = 0; x < this.currentAsciibirdMeta.blocks[y].length; x++) {
|
||||
if (!this.currentAsciibirdMeta.blocks[y][x]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (this.currentAsciibirdMeta.blocks[y][x] !== undefined) {
|
||||
// console.log({
|
||||
// block: this.currentAsciibirdMeta.blocks[y][x],
|
||||
// x: x,
|
||||
// y: y,
|
||||
// theX,
|
||||
// blockY,
|
||||
// blockX,
|
||||
// blockWidth,
|
||||
// blockHeight,
|
||||
// });
|
||||
|
||||
curBlock = this.currentAsciibirdMeta.blocks[y][x];
|
||||
blockX = blockWidth * theX;
|
||||
|
||||
// Background block
|
||||
this.ctx.fillStyle = curBlock.fg;
|
||||
this.ctx.fillRect(blockX, blockY, this.currentAsciibirdMeta.blockWidth, this.currentAsciibirdMeta.blockHeight);
|
||||
|
||||
let tempChar = "";
|
||||
for (x = 0; x < this.currentAsciibirdMeta.width; x++) {
|
||||
curBlock = JSON.parse(JSON.stringify(this.currentAsciibirdMeta.blocks[y][x]));
|
||||
canvasX = BLOCK_WIDTH * x;
|
||||
|
||||
if (curBlock.char) {
|
||||
tempChar = curBlock.char;
|
||||
this.ctx.fillStyle = curBlock.fg;
|
||||
|
||||
this.ctx.fillText(tempChar, blockX, blockY - 3);
|
||||
this.ctx.fillStyle = this.mircColors[curBlock.fg];
|
||||
this.ctx.fillText(curBlock.char, canvasX + 3, canvasY - 3);
|
||||
}
|
||||
|
||||
theX++;
|
||||
// Background block
|
||||
this.ctx.fillStyle = this.mircColors[curBlock.bg];
|
||||
this.ctx.fillRect(canvasX, canvasY, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
|
||||
// break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
this.ctx.stroke();
|
||||
|
|
Loading…
Reference in New Issue