asciibird/src/components/DebugPanel.vue

212 lines
5.1 KiB
Vue
Raw Normal View History

2021-02-13 01:51:01 +00:00
<template>
<div>
<vue-draggable-resizable
@dragstop="onDragStop"
2021-08-14 06:41:42 +00:00
:grid="[blockWidth, blockHeight]"
:min-width="blockWidth * 40"
:max-width="blockWidth * 40"
:min-height="blockHeight * 20"
:max-height="blockHeight * 20"
2021-04-24 00:20:11 +00:00
:w="debugPanelState.w"
:h="debugPanelState.h"
:x="debugPanelState.x"
:y="debugPanelState.y"
2021-02-13 01:51:01 +00:00
>
2021-08-06 04:00:21 +00:00
<t-card class="h-full">
2021-08-04 03:21:06 +00:00
<span
class="ml-5"
v-html="`Tool: ${getToolName}`"
/> <br>
<span
class="ml-5"
v-html="`FgColour: ${currentFg}`"
/> <br>
<span
class="ml-5"
v-html="`BgColor: ${currentBg}`"
/> <br>
<span
class="ml-5"
v-html="`Char: ${currentChar}`"
/> <br>
2021-03-29 05:10:31 +00:00
2021-08-04 03:21:06 +00:00
<span
class="ml-5"
v-html="`canvasX: ${canvasX}`"
/> <br>
<span
class="ml-5"
v-html="`canvasY: ${canvasY}`"
/> <br>
2021-08-04 03:21:06 +00:00
<span
class="ml-5"
v-html="`mirrorX: ${mirrorX}`"
/> <br>
<span
class="ml-5"
v-html="`mirrorY: ${mirrorY}`"
2021-08-17 00:24:41 +00:00
/>
<br>
2021-12-17 11:54:57 +00:00
<span class="ml-5">State Internal Size: {{ asciiStats.stateSize }} </span> <br>
2021-11-06 01:19:15 +00:00
<div class="mb-4 border-t-2">
<div class="mt-1 p-2 bg-red-300 rounded-md cursor-pointer" @click="copyUriToClipboard()">Copy URI Encoded String</div>
</div>
2021-08-04 03:21:06 +00:00
</t-card>
2021-02-13 01:51:01 +00:00
</vue-draggable-resizable>
</div>
</template>
<script>
2021-12-24 04:06:55 +00:00
import { toolbarIcons, mircColours99, blockWidth, blockHeight, exportMirc, mergeLayers } from '../ascii';
2021-11-06 01:19:15 +00:00
import LZString from "lz-string";
2021-04-24 00:20:11 +00:00
2021-02-13 01:51:01 +00:00
export default {
2021-04-24 00:20:11 +00:00
created() {
2021-08-04 03:21:06 +00:00
this.panel.x = this.debugPanelState.x;
this.panel.y = this.debugPanelState.y;
this.panel.w = this.debugPanelState.w;
this.panel.h = this.debugPanelState.h;
2021-04-24 00:20:11 +00:00
},
2021-08-04 03:21:06 +00:00
name: 'DebugPanel',
props: ['canvasX', 'canvasY'],
2021-02-13 01:51:01 +00:00
data: () => ({
2021-04-24 00:20:11 +00:00
panel: {
w: 0,
h: 0,
2021-02-13 01:51:01 +00:00
x: 100,
y: 100,
visible: true,
2021-02-13 01:51:01 +00:00
},
throttle: true,
2021-02-13 01:51:01 +00:00
}),
2021-04-02 02:07:49 +00:00
computed: {
blockWidth() {
2021-08-14 06:41:42 +00:00
return blockWidth * this.blockSizeMultiplier;
},
blockHeight() {
2021-08-14 06:41:42 +00:00
return blockHeight * this.blockSizeMultiplier;
},
blockSizeMultiplier() {
return this.$store.getters.blockSizeMultiplier
},
2021-04-02 02:07:49 +00:00
getToolName() {
2021-08-04 03:21:06 +00:00
return toolbarIcons[this.$store.getters.currentTool] ? toolbarIcons[this.$store.getters.currentTool].name : 'none';
2021-04-24 00:20:11 +00:00
},
debugPanelState() {
2021-08-04 03:21:06 +00:00
return this.$store.getters.debugPanel;
2021-04-24 00:20:11 +00:00
},
currentAscii() {
return this.$store.getters.currentAscii;
},
asciiStats() {
2021-12-17 08:47:38 +00:00
// const compressed = ( JSON.stringify(this.currentAscii) / 1024).toFixed(2);
2021-12-17 11:54:57 +00:00
// const uncompressed = (JSON.stringify(this.currentAscii).length / 1024).toFixed(2);
const byteSize = str => new Blob([str]).size;
const stateSize = (byteSize(JSON.stringify(this.state)) / 1024).toFixed(2);
2021-08-04 03:21:06 +00:00
return {
2021-12-17 11:54:57 +00:00
stateSize: `${stateSize}kb`,
2021-08-04 03:21:06 +00:00
};
},
currentTool() {
return toolbarIcons[
this.$store.getters.currentTool
];
},
mircColours() {
return mircColours99;
},
canFg() {
return this.$store.getters.isTargettingFg;
},
canBg() {
return this.$store.getters.isTargettingBg;
},
canText() {
return this.$store.getters.isTargettingChar;
},
currentFg() {
return this.$store.getters.currentFg;
},
currentBg() {
return this.$store.getters.currentBg;
},
currentChar() {
2021-08-06 01:51:58 +00:00
return this.$store.getters.currentChar;
},
isTextEditing() {
2021-08-04 03:21:06 +00:00
return this.currentTool.name === 'text';
},
isSelecting() {
2021-08-04 03:21:06 +00:00
return this.currentTool.name === 'select';
},
isSelected() {
return (
2021-08-04 03:21:06 +00:00
this.selecting.startX
&& this.selecting.startY
&& this.selecting.endX
&& this.selecting.endY
);
},
brushBlocks() {
return this.$store.getters.brushBlocks;
},
toolbarState() {
return this.$store.getters.toolbarState;
},
mirrorX() {
return this.toolbarState.mirrorX;
},
mirrorY() {
return this.toolbarState.mirrorY;
},
state() {
return this.$store.getters.state;
2021-08-04 03:21:06 +00:00
},
2021-04-02 02:07:49 +00:00
},
watch: {},
2021-02-13 01:51:01 +00:00
methods: {
2021-11-06 01:19:15 +00:00
copyUriToClipboard() {
2021-12-24 04:06:55 +00:00
let ascii = LZString.compressToEncodedURIComponent(JSON.stringify(mergeLayers()));
2021-11-06 01:19:15 +00:00
this.$copyText(ascii).then(
(e) => {
this.$toasted.show("Copied URI encoded ASCII for Splash Ascii!", {
type: "success",
});
},
(e) => {
this.$toasted.show("Error when copying URI encoded ASCII!", {
type: "error",
});
}
);
},
2021-04-24 00:20:11 +00:00
onResize(x, y, w, h) {
this.panel.x = x;
this.panel.y = y;
this.panel.w = w;
this.panel.h = h;
2021-08-04 03:21:06 +00:00
this.$store.commit('changeDebugPanelState', this.panel);
2021-02-13 01:51:01 +00:00
},
onDragStop(x, y) {
2021-04-24 00:20:11 +00:00
this.panel.x = x;
this.panel.y = y;
2021-08-04 03:21:06 +00:00
this.$store.commit('changeDebugPanelState', this.panel);
2021-02-13 01:51:01 +00:00
},
2021-12-17 11:54:57 +00:00
exportMirc() {
return exportMirc()
}
2021-02-13 01:51:01 +00:00
},
};
</script>