2020-12-27 02:42:26 +00:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<t-modal
|
|
|
|
name="create-ascii-modal"
|
|
|
|
header="Create new ASCII"
|
2021-01-16 03:03:14 +00:00
|
|
|
:clickToClose="false"
|
|
|
|
:escToClose="false"
|
2020-12-27 02:42:26 +00:00
|
|
|
@before-closed="closeNewASCII"
|
|
|
|
>
|
2021-01-16 03:03:14 +00:00
|
|
|
<!-- Main Menu -->
|
2021-01-30 02:33:11 +00:00
|
|
|
Width
|
2021-01-16 03:03:14 +00:00
|
|
|
<t-input
|
|
|
|
type="number"
|
|
|
|
name="width"
|
|
|
|
v-model="forms.createAscii.width"
|
|
|
|
max="3"
|
|
|
|
/>
|
2021-01-30 02:33:11 +00:00
|
|
|
|
|
|
|
Height
|
2021-01-16 03:03:14 +00:00
|
|
|
<t-input
|
|
|
|
type="number"
|
|
|
|
name="height"
|
|
|
|
v-model="forms.createAscii.height"
|
|
|
|
max="4"
|
|
|
|
/>
|
2021-01-30 02:33:11 +00:00
|
|
|
|
|
|
|
Title
|
2021-01-16 03:03:14 +00:00
|
|
|
<t-input
|
|
|
|
type="text"
|
|
|
|
name="title"
|
|
|
|
v-model="forms.createAscii.title"
|
|
|
|
max="128"
|
|
|
|
/>
|
2020-12-27 02:42:26 +00:00
|
|
|
|
|
|
|
<template v-slot:footer>
|
2021-01-16 03:03:14 +00:00
|
|
|
<div
|
|
|
|
class="flex justify-between"
|
|
|
|
@click="$modal.hide('create-ascii-modal')"
|
|
|
|
>
|
|
|
|
<t-button type="button"> Cancel </t-button>
|
|
|
|
<t-button type="button" @click="createNewASCII()"> Ok </t-button>
|
2020-12-27 02:42:26 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</t-modal>
|
|
|
|
|
2021-01-09 01:57:48 +00:00
|
|
|
<div>
|
2021-03-14 07:36:14 +00:00
|
|
|
<t-button @click="createClick()" class="ml-1">New ASCII</t-button>
|
2021-01-30 02:33:11 +00:00
|
|
|
<t-button @click="clearCache()" class="ml-1">Clear and Refresh</t-button>
|
2021-03-14 07:36:14 +00:00
|
|
|
<t-button @click="startImport('mirc')" class="ml-1">Import mIRC</t-button>
|
|
|
|
<t-button @click="startImport('ansi')" class="ml-1">Import ANSI</t-button>
|
2021-01-16 03:03:14 +00:00
|
|
|
<input
|
|
|
|
type="file"
|
|
|
|
style="display: none"
|
|
|
|
ref="asciiInput"
|
2021-03-14 07:36:14 +00:00
|
|
|
@change="onImport()"
|
2021-01-16 03:03:14 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<t-button
|
|
|
|
v-for="(value, key) in asciibirdMeta"
|
|
|
|
v-bind:key="key"
|
|
|
|
class="ml-1"
|
|
|
|
@click="changeTab(key, value)"
|
2021-01-30 02:33:11 +00:00
|
|
|
:disabled="false"
|
2021-01-16 03:03:14 +00:00
|
|
|
>
|
2021-01-09 01:57:48 +00:00
|
|
|
{{ value.title }} ({{ value.width }} / {{ value.height }})
|
|
|
|
</t-button>
|
|
|
|
|
2021-02-06 01:22:16 +00:00
|
|
|
<Toolbar v-if="asciibirdMeta.length" />
|
2021-02-20 02:16:45 +00:00
|
|
|
<DebugPanel v-if="asciibirdMeta.length" />
|
2021-02-13 01:51:01 +00:00
|
|
|
|
2021-02-06 01:22:16 +00:00
|
|
|
<div class="border-gray-600">
|
2021-02-20 03:18:32 +00:00
|
|
|
<!-- <router-view /> -->
|
2021-03-14 07:36:14 +00:00
|
|
|
<Editor v-if="asciibirdMeta.length" />
|
2021-01-09 01:57:48 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-12-27 02:42:26 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-02-06 01:22:16 +00:00
|
|
|
import Toolbar from "./components/Toolbar.vue";
|
2021-02-13 01:51:01 +00:00
|
|
|
import DebugPanel from "./components/DebugPanel.vue";
|
2021-02-20 03:18:32 +00:00
|
|
|
import Editor from "./views/Editor.vue";
|
2021-03-14 07:36:14 +00:00
|
|
|
import * as Anser from "anser";
|
|
|
|
|
2020-12-27 02:42:26 +00:00
|
|
|
export default {
|
2021-03-14 07:36:14 +00:00
|
|
|
async created() {
|
2021-02-20 03:18:32 +00:00
|
|
|
this.mircColors = this.$store.getters.mircColors;
|
|
|
|
this.charCodes = this.$store.getters.charCodes;
|
|
|
|
this.asciibirdMeta = this.$store.getters.asciibirdMeta;
|
2021-03-14 07:36:14 +00:00
|
|
|
|
|
|
|
let asciiUrl = new URL(location.href).searchParams.get("ircwatch");
|
|
|
|
if (asciiUrl) {
|
|
|
|
let res = await fetch(`https://irc.watch/ascii/txt/${asciiUrl}`);
|
|
|
|
console.log({ asciiData, asciiUrl });
|
|
|
|
let asciiData = await res.text();
|
|
|
|
this.mircAsciiImport(asciiData, asciiUrl);
|
|
|
|
window.location.href = "/";
|
|
|
|
}
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
2021-02-20 03:18:32 +00:00
|
|
|
components: { Toolbar, DebugPanel, Editor },
|
2021-02-13 01:17:07 +00:00
|
|
|
name: "Dashboard",
|
2020-12-27 02:42:26 +00:00
|
|
|
data: () => ({
|
|
|
|
forms: {
|
|
|
|
createAscii: {
|
|
|
|
width: 5,
|
|
|
|
height: 5,
|
2021-02-13 01:17:07 +00:00
|
|
|
title: "ascii",
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
formsDefault: null,
|
|
|
|
status: {
|
|
|
|
createNew: false,
|
|
|
|
},
|
2021-02-13 01:17:07 +00:00
|
|
|
text: "ASCII",
|
2020-12-27 02:42:26 +00:00
|
|
|
currentTab: 1,
|
|
|
|
asciibirdMeta: [],
|
2021-02-06 01:22:16 +00:00
|
|
|
mircColors: null,
|
|
|
|
charCodes: null,
|
2021-02-20 08:05:31 +00:00
|
|
|
refresh: false,
|
2021-02-13 01:17:07 +00:00
|
|
|
asciiImport: "",
|
2021-01-16 03:03:14 +00:00
|
|
|
finalAscii: null,
|
|
|
|
asciiArray: [],
|
|
|
|
imageUrl: null,
|
2021-01-23 02:50:32 +00:00
|
|
|
parseColor: false,
|
2021-01-16 03:03:14 +00:00
|
|
|
colorCode: false,
|
|
|
|
importBlocks: null,
|
2021-03-14 07:36:14 +00:00
|
|
|
importFormat: null,
|
2020-12-27 02:42:26 +00:00
|
|
|
}),
|
|
|
|
methods: {
|
2021-03-14 07:36:14 +00:00
|
|
|
onImport() {
|
2021-01-23 02:50:32 +00:00
|
|
|
const { files } = this.$refs.asciiInput;
|
|
|
|
const filename = files[0].name;
|
2021-01-16 03:03:14 +00:00
|
|
|
const fileReader = new FileReader();
|
|
|
|
this.asciiImport = fileReader.readAsText(files[0]);
|
|
|
|
|
2021-02-13 01:17:07 +00:00
|
|
|
fileReader.addEventListener("load", () => {
|
2021-03-14 07:36:14 +00:00
|
|
|
switch (this.importFormat) {
|
|
|
|
case "ansi":
|
|
|
|
this.asniImport(fileReader.result, filename);
|
|
|
|
break;
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
case "mirc":
|
|
|
|
this.mircAsciiImport(fileReader.result, filename);
|
|
|
|
break;
|
|
|
|
}
|
2021-02-20 04:12:09 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
this.importFormat = null;
|
|
|
|
});
|
2021-02-20 04:12:09 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
this.asciiImportFile = files[0];
|
|
|
|
},
|
|
|
|
startImport(type) {
|
|
|
|
this.importFormat = type;
|
|
|
|
this.$refs.asciiInput.click();
|
|
|
|
},
|
|
|
|
asniImport(contents, filename) {
|
|
|
|
let ansiArray = contents.split("\n");
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
let ansiWidth = 0;
|
2021-02-13 01:17:07 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
this.finalAscii = {
|
|
|
|
width: false, // defined in: switch (curChar) case "\n":
|
|
|
|
height: contents.split("\r\n").length,
|
|
|
|
title: filename,
|
|
|
|
key: this.$store.getters.nextTabValue,
|
|
|
|
blockWidth: 8 * this.$store.getters.blockSizeMultiplier,
|
|
|
|
blockHeight: 13 * this.$store.getters.blockSizeMultiplier,
|
|
|
|
blocks: this.create2DArray(contents.split("\r\n").length),
|
|
|
|
};
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
for (let i = 0; i <= ansiArray.length - 1; i++) {
|
|
|
|
if (ansiWidth > 0 && this.finalAscii.width === false) {
|
|
|
|
this.finalAscii.width = ansiWidth;
|
|
|
|
}
|
2021-02-20 08:35:04 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
ansiWidth = 0;
|
2021-02-20 02:16:45 +00:00
|
|
|
|
2021-03-15 05:49:02 +00:00
|
|
|
for (let j = 0; j <= ansiArray[i].length - 1; j++) {
|
2021-03-14 07:36:14 +00:00
|
|
|
let ansiParse = Anser.ansiToJson(ansiArray[i]);
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-15 05:49:02 +00:00
|
|
|
for (let l = 0; l <= ansiParse.length - 1; l++) {
|
2021-03-14 07:36:14 +00:00
|
|
|
var contentArray = ansiParse[l].content.split("");
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
var curBlock = {
|
2021-03-15 05:49:02 +00:00
|
|
|
fg: this.mircColors.indexOf(`rgb(${ansiParse[l].fg})`),
|
|
|
|
bg: this.mircColors.indexOf(`rgb(${ansiParse[l].bg})`),
|
2021-03-14 07:36:14 +00:00
|
|
|
char: null,
|
|
|
|
};
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-15 05:49:02 +00:00
|
|
|
// If we had no matches in our mIRC RGB lookup, then we have to try match
|
|
|
|
// the ASNI colours to the best mIRC colour
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-15 05:49:02 +00:00
|
|
|
if (curBlock.fg === -1) {
|
|
|
|
switch (ansiParse[l].fg) {
|
|
|
|
case "187, 187, 0": // orangeish yellow
|
|
|
|
curBlock.fg = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "187, 0, 0": // red
|
|
|
|
curBlock.fg = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curBlock.bg === -1) {
|
|
|
|
switch (ansiParse[l].bg) {
|
|
|
|
case "187, 187, 0": // orangeish yellow
|
|
|
|
curBlock.bg = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "187, 0, 0": // red
|
|
|
|
curBlock.bg = 4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let k = 0; k <= contentArray.length - 1; k++) {
|
2021-03-14 07:36:14 +00:00
|
|
|
if (contentArray[k] === "\r") {
|
2021-03-15 05:49:02 +00:00
|
|
|
continue;
|
2021-03-13 03:30:58 +00:00
|
|
|
}
|
2021-01-30 02:33:11 +00:00
|
|
|
|
2021-03-15 05:49:02 +00:00
|
|
|
this.mircColors.indexOf(`rgb(${ansiParse[l].fg})`);
|
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
curBlock.char = contentArray[k];
|
2021-03-13 03:30:58 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
this.finalAscii.blocks[i][ansiWidth] = JSON.parse(
|
2021-03-13 03:30:58 +00:00
|
|
|
JSON.stringify(curBlock)
|
|
|
|
);
|
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
ansiWidth++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-20 05:39:35 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
this.$store.commit("newAsciibirdMeta", this.finalAscii);
|
|
|
|
},
|
|
|
|
mircAsciiImport(contents, filename) {
|
|
|
|
const MIRC_MAX_COLORS = this.mircColors.length;
|
|
|
|
|
|
|
|
// The current state of the colors
|
|
|
|
let curBlock = {
|
|
|
|
fg: null,
|
|
|
|
bg: null,
|
|
|
|
char: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Object clone this to reset the block state
|
|
|
|
let emptyCurBlock = {
|
|
|
|
fg: null,
|
|
|
|
bg: null,
|
|
|
|
char: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
// set asciiImport as the entire file contents as a string
|
2021-03-20 08:35:54 +00:00
|
|
|
this.asciiImport = contents.split("\u0003\u0003").join("\u0003");
|
2021-03-14 07:36:14 +00:00
|
|
|
|
|
|
|
// This will end up in the asciibirdMeta
|
|
|
|
this.finalAscii = {
|
|
|
|
width: false, // defined in: switch (curChar) case "\n":
|
|
|
|
height: this.asciiImport.split("\n").length,
|
|
|
|
title: filename,
|
|
|
|
key: this.$store.getters.nextTabValue,
|
|
|
|
blockWidth: 8 * this.$store.getters.blockSizeMultiplier,
|
|
|
|
blockHeight: 13 * this.$store.getters.blockSizeMultiplier,
|
|
|
|
blocks: this.create2DArray(this.asciiImport.split("\n").length),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Turn the entire ascii string into an array
|
|
|
|
let asciiStringArray = this.asciiImport.split("");
|
|
|
|
|
|
|
|
// The proper X and Y value of the block inside the ASCII
|
|
|
|
let asciiX = 0;
|
|
|
|
let asciiY = 0;
|
|
|
|
let firstColor = false;
|
|
|
|
let secondColor = false;
|
|
|
|
|
|
|
|
let colorChar1 = null;
|
|
|
|
let colorChar2 = null;
|
|
|
|
var parsedColor = null;
|
|
|
|
|
|
|
|
var theWidth = 0;
|
|
|
|
|
2021-03-20 00:39:17 +00:00
|
|
|
// for (let charPos = 0; charPos <= this.asciiImport.length - 1; charPos++) {
|
|
|
|
while (asciiStringArray.length) {
|
2021-03-14 07:36:14 +00:00
|
|
|
let curChar = asciiStringArray[0];
|
|
|
|
|
|
|
|
// Defining a small finite state machine
|
|
|
|
// to detect the colour code
|
|
|
|
switch (curChar) {
|
|
|
|
case "\n":
|
|
|
|
// Reset the colours here on a new line
|
|
|
|
curBlock = {
|
|
|
|
fg: null,
|
|
|
|
bg: null,
|
|
|
|
char: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
asciiY++;
|
|
|
|
|
|
|
|
// We can determine the width at the end of the first line
|
|
|
|
if (!this.finalAscii.width) {
|
|
|
|
this.finalAscii.width =
|
|
|
|
this.asciiImport.split("\n")[0].length - 1 - theWidth; // minus \n for the proper width
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resets the X value
|
|
|
|
asciiX = 0;
|
|
|
|
|
|
|
|
asciiStringArray.shift();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "\u0003":
|
|
|
|
firstColor = false;
|
|
|
|
secondColor = false;
|
|
|
|
|
|
|
|
// CC
|
2021-03-20 09:33:16 +00:00
|
|
|
// if (
|
|
|
|
// asciiStringArray[0] === "\u0003" &&
|
|
|
|
// asciiStringArray[1] === "\u0003"
|
|
|
|
// ) {
|
|
|
|
// curBlock = {
|
|
|
|
// fg: null,
|
|
|
|
// bg: null,
|
|
|
|
// char: null,
|
|
|
|
// };
|
|
|
|
|
|
|
|
// console.log("Got CC");
|
|
|
|
// continue;
|
|
|
|
// }
|
2021-03-14 07:36:14 +00:00
|
|
|
|
|
|
|
asciiStringArray.shift();
|
|
|
|
theWidth++;
|
|
|
|
|
|
|
|
if (!firstColor) {
|
|
|
|
colorChar1 = `${asciiStringArray[0]}`;
|
|
|
|
colorChar2 = `${asciiStringArray[1]}`;
|
|
|
|
parsedColor = parseInt(`${colorChar1}${colorChar2}`);
|
|
|
|
|
2021-03-20 09:33:16 +00:00
|
|
|
if (isNaN(parsedColor)) {
|
|
|
|
curBlock.bg = parseInt(colorChar1);
|
|
|
|
theWidth += 1;
|
|
|
|
asciiStringArray.shift();
|
|
|
|
} else if (parsedColor <= MIRC_MAX_COLORS && parsedColor >= 0) {
|
2021-03-14 07:36:14 +00:00
|
|
|
curBlock.fg = parseInt(parsedColor);
|
|
|
|
firstColor = true;
|
|
|
|
theWidth += parsedColor.toString().length;
|
|
|
|
|
|
|
|
asciiStringArray = asciiStringArray.slice(
|
|
|
|
parsedColor.toString().length,
|
|
|
|
asciiStringArray.length
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
colorChar1 = null;
|
|
|
|
colorChar2 = null;
|
|
|
|
parsedColor = null;
|
|
|
|
|
|
|
|
// No background colour
|
|
|
|
if (asciiStringArray[0] !== ",") {
|
|
|
|
secondColor = true;
|
2021-02-20 03:18:32 +00:00
|
|
|
break;
|
2021-03-14 07:36:14 +00:00
|
|
|
} else {
|
2021-03-20 09:59:32 +00:00
|
|
|
// Remove , from array
|
2021-03-14 07:36:14 +00:00
|
|
|
asciiStringArray.shift();
|
|
|
|
}
|
2021-02-20 02:16:45 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
if (!secondColor) {
|
|
|
|
colorChar1 = `${asciiStringArray[0]}`;
|
|
|
|
colorChar2 = `${asciiStringArray[1]}`;
|
|
|
|
parsedColor = parseInt(`${colorChar1}${colorChar2}`);
|
2021-02-20 02:16:45 +00:00
|
|
|
|
2021-03-20 09:59:32 +00:00
|
|
|
// Work out the 01, 02
|
|
|
|
if ( (!isNaN(colorChar1)) && (!isNaN(colorChar2)) && parseInt(colorChar2) > parseInt(colorChar1)) {
|
|
|
|
parsedColor = parseInt(colorChar2)
|
|
|
|
asciiStringArray.shift();
|
|
|
|
}
|
|
|
|
|
2021-03-20 09:33:16 +00:00
|
|
|
if (isNaN(parsedColor)) {
|
|
|
|
curBlock.bg = parseInt(colorChar1);
|
|
|
|
theWidth += 1;
|
|
|
|
asciiStringArray.shift();
|
|
|
|
} else if (parsedColor <= MIRC_MAX_COLORS && parsedColor >= 0) {
|
2021-03-14 07:36:14 +00:00
|
|
|
curBlock.bg = parseInt(parsedColor);
|
|
|
|
theWidth += parsedColor.toString().length;
|
2021-02-20 02:16:45 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
asciiStringArray = asciiStringArray.slice(
|
|
|
|
parsedColor.toString().length,
|
|
|
|
asciiStringArray.length
|
|
|
|
);
|
2021-02-20 02:16:45 +00:00
|
|
|
|
2021-03-14 07:36:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
curBlock.char = curChar;
|
|
|
|
asciiStringArray.shift();
|
|
|
|
asciiX++;
|
|
|
|
// Fk this js shit, serialising the curBlock works much better. Lost hours on this bs, fk.
|
|
|
|
|
|
|
|
this.finalAscii.blocks[asciiY][asciiX - 1] = JSON.parse(
|
|
|
|
JSON.stringify(curBlock)
|
|
|
|
);
|
|
|
|
|
|
|
|
break;
|
|
|
|
} // End Switch
|
|
|
|
|
|
|
|
// break;
|
|
|
|
} // End loop charPos
|
|
|
|
|
|
|
|
this.$store.commit("newAsciibirdMeta", this.finalAscii);
|
2021-01-16 03:03:14 +00:00
|
|
|
},
|
2020-12-27 02:42:26 +00:00
|
|
|
createClick() {
|
2021-01-08 00:51:41 +00:00
|
|
|
this.forms.createAscii.title = `New ASCII ${this.asciibirdMeta.length}`;
|
2021-02-13 01:17:07 +00:00
|
|
|
this.$modal.show("create-ascii-modal");
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
|
|
|
changeTab(key, value) {
|
|
|
|
// Update the tab index in vuex store
|
2021-03-13 03:30:58 +00:00
|
|
|
this.currentTab = key;
|
|
|
|
this.refresh = !this.refresh;
|
2021-02-13 01:17:07 +00:00
|
|
|
this.$store.commit("changeTab", key);
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
2021-01-30 02:33:11 +00:00
|
|
|
clearCache() {
|
|
|
|
localStorage.clear();
|
2021-02-13 01:17:07 +00:00
|
|
|
window.location.href = "/";
|
2021-01-30 02:33:11 +00:00
|
|
|
},
|
2020-12-27 02:42:26 +00:00
|
|
|
createNewASCII() {
|
|
|
|
const payload = {
|
|
|
|
title: this.forms.createAscii.title,
|
2021-01-08 00:47:08 +00:00
|
|
|
key: this.asciibirdMeta.length,
|
2020-12-27 02:42:26 +00:00
|
|
|
width: this.forms.createAscii.width,
|
|
|
|
height: this.forms.createAscii.height,
|
2021-01-30 02:33:11 +00:00
|
|
|
blockWidth: 16,
|
|
|
|
blockHeight: 26,
|
2020-12-27 02:42:26 +00:00
|
|
|
blocks: this.create2DArray(this.forms.createAscii.height),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Push all the default ASCII blocks
|
2021-01-30 02:33:11 +00:00
|
|
|
for (let x = 0; x < payload.width; x++) {
|
|
|
|
for (let y = 0; y < payload.height; y++) {
|
|
|
|
payload.blocks[y].push({
|
2021-02-20 05:39:35 +00:00
|
|
|
bg: Math.floor(Math.random() * this.mircColors.length),
|
|
|
|
fg: Math.floor(Math.random() * this.mircColors.length),
|
2021-01-16 03:03:14 +00:00
|
|
|
char: this.charCodes[
|
|
|
|
Math.floor(Math.random() * this.charCodes.length)
|
|
|
|
],
|
2020-12-27 02:42:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-06 01:22:16 +00:00
|
|
|
// console.log('payload', payload);
|
2021-01-30 02:33:11 +00:00
|
|
|
|
2021-02-13 01:17:07 +00:00
|
|
|
this.$store.commit("newAsciibirdMeta", payload);
|
|
|
|
this.$modal.hide("create-ascii-modal");
|
2021-03-13 03:30:58 +00:00
|
|
|
this.refresh = !this.refresh;
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
|
|
|
closeNewASCII({ params, cancel }) {
|
|
|
|
this.forms.createAscii.width = 5;
|
|
|
|
this.forms.createAscii.height = 5;
|
2021-02-13 01:17:07 +00:00
|
|
|
this.forms.createAscii.title = "New ASCII";
|
2020-12-27 02:42:26 +00:00
|
|
|
},
|
|
|
|
create2DArray(rows) {
|
|
|
|
const arr = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < rows; i++) {
|
|
|
|
arr[i] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|