First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
<template>
|
|
|
|
<button
|
2021-09-04 00:37:45 -05:00
|
|
|
v-if="gridCell.unlocked"
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
:class="{ feature: true, tile: true, can: canClick, locked: !canClick }"
|
|
|
|
:style="style"
|
2021-09-04 00:37:45 -05:00
|
|
|
@click="gridCell.click"
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
@mousedown="start"
|
|
|
|
@mouseleave="stop"
|
|
|
|
@mouseup="stop"
|
|
|
|
@touchstart="start"
|
|
|
|
@touchend="stop"
|
|
|
|
@touchcancel="stop"
|
|
|
|
:disabled="!canClick"
|
|
|
|
>
|
|
|
|
<div v-if="title"><component :is="title" /></div>
|
|
|
|
<component :is="display" style="white-space: pre-line;" />
|
2021-09-04 00:37:45 -05:00
|
|
|
<branch-node :branches="gridCell.branches" :id="id" featureType="gridCell" />
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { layers } from "@/game/layers";
|
|
|
|
import { GridCell } from "@/typings/features/grid";
|
|
|
|
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
|
|
|
|
import { Component, defineComponent } from "vue";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: "grid-cell",
|
|
|
|
mixins: [InjectLayerMixin],
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: [Number, String],
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
cell: {
|
|
|
|
type: [Number, String],
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
size: [Number, String]
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
interval: null,
|
|
|
|
time: 0
|
|
|
|
} as {
|
|
|
|
interval: number | null;
|
|
|
|
time: number;
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
gridCell(): GridCell {
|
|
|
|
return layers[this.layer].grids!.data[this.id][this.cell] as GridCell;
|
|
|
|
},
|
|
|
|
canClick(): boolean {
|
|
|
|
return this.gridCell.canClick;
|
|
|
|
},
|
|
|
|
style(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [
|
|
|
|
this.canClick ? { backgroundColor: layers[this.layer].color } : {},
|
|
|
|
layers[this.layer].componentStyles?.["grid-cell"],
|
|
|
|
this.gridCell.style
|
|
|
|
];
|
|
|
|
},
|
|
|
|
title(): Component | string | null {
|
|
|
|
if (this.gridCell.title) {
|
|
|
|
return coerceComponent(this.gridCell.title, "h3");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
display(): Component | string {
|
|
|
|
return coerceComponent(this.gridCell.display, "div");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
start() {
|
|
|
|
if (!this.interval && this.gridCell.click) {
|
|
|
|
this.interval = setInterval(this.gridCell.click, 250);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
stop() {
|
|
|
|
if (this.interval) {
|
|
|
|
clearInterval(this.interval);
|
|
|
|
this.interval = null;
|
|
|
|
this.time = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.tile {
|
|
|
|
min-height: 80px;
|
|
|
|
width: 80px;
|
|
|
|
font-size: 10px;
|
|
|
|
}
|
|
|
|
</style>
|