2020-12-27 02:42:26 +00:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<t-modal
|
|
|
|
name="create-ascii-modal"
|
|
|
|
header="Create new ASCII"
|
|
|
|
:clickToClose=false
|
|
|
|
:escToClose=false
|
|
|
|
@before-closed="closeNewASCII"
|
|
|
|
>
|
|
|
|
|
|
|
|
<!-- Main Menu -->
|
|
|
|
<t-input type="number" name="width" v-model="forms.createAscii.width" max="3" />
|
|
|
|
<t-input type="number" name="height" v-model="forms.createAscii.height" max="4" />
|
|
|
|
<t-input type="text" name="title" v-model="forms.createAscii.title" max="128" />
|
|
|
|
|
|
|
|
<template v-slot:footer>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</t-modal>
|
|
|
|
|
|
|
|
|
2021-01-09 01:57:48 +00:00
|
|
|
<div>
|
|
|
|
<t-button @click="createClick()" class="ml-1">Add new ASCII</t-button>
|
2020-12-27 02:42:26 +00:00
|
|
|
|
2021-01-09 01:57:48 +00:00
|
|
|
<t-button v-for="(value, key) in asciibirdMeta" v-bind:key="key" class="ml-1" @click="changeTab(key, value)">
|
|
|
|
{{ value.title }} ({{ value.width }} / {{ value.height }})
|
|
|
|
</t-button>
|
|
|
|
|
|
|
|
<div class="border-gray-600">
|
|
|
|
<router-view/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2020-12-27 02:42:26 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
created() {
|
|
|
|
this.asciibirdMeta = this.$store.state.asciibirdMeta;
|
|
|
|
},
|
|
|
|
name: 'Dashboard',
|
|
|
|
data: () => ({
|
|
|
|
forms: {
|
|
|
|
createAscii: {
|
|
|
|
width: 5,
|
|
|
|
height: 5,
|
|
|
|
title: 'ascii',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
formsDefault: null,
|
|
|
|
status: {
|
|
|
|
createNew: false,
|
|
|
|
},
|
|
|
|
text: 'ASCII',
|
|
|
|
currentTab: 1,
|
|
|
|
asciibirdMeta: [],
|
2021-01-09 01:57:48 +00:00
|
|
|
mircColors: [
|
|
|
|
'rgb(255,255,255)', 'rgb(0,0,0)', 'rgb(0,0,127)', 'rgb(0,147,0)', 'rgb(255,0,0)',
|
|
|
|
'rgb(127,0,0)', 'rgb(156,0,156)', 'rgb(252,127,0)', 'rgb(255,255,0)', 'rgb(0,252,0)',
|
|
|
|
'rgb(0,147,147)', 'rgb(0,255,255)', 'rgb(0,0,252)', 'rgb(255,0,255)',
|
|
|
|
'rgb(127,127,127)', 'rgb(210,210,210)'
|
|
|
|
],
|
|
|
|
charCodes: [
|
|
|
|
'*','-','=','+','^','#'
|
|
|
|
]
|
2020-12-27 02:42:26 +00:00
|
|
|
|
|
|
|
}),
|
|
|
|
// computed: {
|
|
|
|
// returnAsciiMetaIndex() {
|
|
|
|
// return this.$store.state.asciibirdMeta[this.currentTab];
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
methods: {
|
|
|
|
createClick() {
|
2021-01-08 00:51:41 +00:00
|
|
|
this.forms.createAscii.title = `New ASCII ${this.asciibirdMeta.length}`;
|
2020-12-27 02:42:26 +00:00
|
|
|
this.$modal.show('create-ascii-modal');
|
|
|
|
},
|
|
|
|
changeTab(key, value) {
|
|
|
|
// Update the router title
|
|
|
|
// if (this.$router.params.ascii !== key) {
|
2021-01-10 03:06:46 +00:00
|
|
|
this.$router.push({ name: 'editor', params: { ascii: `/${key}` } });
|
2020-12-27 02:42:26 +00:00
|
|
|
// }
|
|
|
|
|
|
|
|
// Update the tab index in vuex store
|
|
|
|
this.$store.commit('changeTab', key);
|
|
|
|
},
|
|
|
|
createNewASCII() {
|
2021-01-09 01:57:48 +00:00
|
|
|
|
2020-12-27 02:42:26 +00:00
|
|
|
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-10 03:06:46 +00:00
|
|
|
blockWidth: 8 + 0.5,
|
|
|
|
blockHeight: 13 + 0.5,
|
2020-12-27 02:42:26 +00:00
|
|
|
blocks: this.create2DArray(this.forms.createAscii.height),
|
|
|
|
};
|
|
|
|
|
|
|
|
// Push all the default ASCII blocks
|
|
|
|
for (let i = 0; i <= payload.width - 1; i++) {
|
|
|
|
for (let j = 0; j <= payload.height - 1; j++) {
|
|
|
|
payload.blocks[i].push({
|
|
|
|
x: j,
|
|
|
|
y: i,
|
2021-01-09 01:57:48 +00:00
|
|
|
bg: this.mircColors[Math.floor(Math.random() * this.mircColors.length)],
|
|
|
|
fg: this.mircColors[Math.floor(Math.random() * this.mircColors.length)],
|
|
|
|
char: this.charCodes[Math.floor(Math.random() * this.charCodes.length)],
|
2020-12-27 02:42:26 +00:00
|
|
|
bold: false,
|
|
|
|
blinking: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$store.commit('newAsciibirdMeta', payload);
|
|
|
|
this.$modal.hide('create-ascii-modal');
|
|
|
|
},
|
|
|
|
closeNewASCII({ params, cancel }) {
|
|
|
|
this.forms.createAscii.width = 5;
|
|
|
|
this.forms.createAscii.height = 5;
|
|
|
|
this.forms.createAscii.title = 'New ASCII';
|
|
|
|
},
|
|
|
|
create2DArray(rows) {
|
|
|
|
const arr = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < rows; i++) {
|
|
|
|
arr[i] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|