2021-06-11 23:38:16 -05:00
|
|
|
<template>
|
2022-01-13 22:25:47 -06:00
|
|
|
<div
|
2023-02-15 20:00:36 -06:00
|
|
|
v-if="isVisible(visibility)"
|
2022-02-27 13:49:34 -06:00
|
|
|
:style="{
|
2023-02-15 20:00:36 -06:00
|
|
|
visibility: isHidden(visibility) ? 'hidden' : undefined
|
2022-02-27 13:49:34 -06:00
|
|
|
}"
|
2022-12-10 19:33:24 +01:00
|
|
|
class="table-grid"
|
2022-01-13 22:25:47 -06:00
|
|
|
>
|
2022-12-10 19:33:24 +01:00
|
|
|
<div v-for="row in unref(rows)" class="row-grid" :class="{ mergeAdjacent }" :key="row">
|
2022-02-27 13:49:34 -06:00
|
|
|
<GridCell
|
|
|
|
v-for="col in unref(cols)"
|
|
|
|
:key="col"
|
|
|
|
v-bind="gatherCellProps(unref(cells)[row * 100 + col])"
|
|
|
|
/>
|
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
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-11 23:38:16 -05:00
|
|
|
</template>
|
|
|
|
|
2022-01-24 22:23:30 -06:00
|
|
|
<script lang="ts">
|
2022-03-03 21:39:48 -06:00
|
|
|
import "components/common/table.css";
|
|
|
|
import themes from "data/themes";
|
2023-02-15 20:00:36 -06:00
|
|
|
import { isHidden, isVisible, Visibility } from "features/feature";
|
2022-06-26 19:17:22 -05:00
|
|
|
import type { GridCell } from "features/grids/grid";
|
2022-03-03 21:39:48 -06:00
|
|
|
import settings from "game/settings";
|
|
|
|
import { processedPropType } from "util/vue";
|
2022-02-27 13:49:34 -06:00
|
|
|
import { computed, defineComponent, unref } from "vue";
|
2022-01-24 22:25:34 -06:00
|
|
|
import GridCellVue from "./GridCell.vue";
|
2021-06-11 23:38:16 -05:00
|
|
|
|
2022-01-24 22:25:34 -06:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
visibility: {
|
2023-02-15 20:00:36 -06:00
|
|
|
type: processedPropType<Visibility | boolean>(Number, Boolean),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
rows: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<number>(Number),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
cols: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<number>(Number),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
cells: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<Record<string, GridCell>>(Object),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 13:49:34 -06:00
|
|
|
components: { GridCell: GridCellVue },
|
2022-01-24 22:25:34 -06:00
|
|
|
setup() {
|
2022-02-27 13:49:34 -06:00
|
|
|
const mergeAdjacent = computed(() => themes[settings.theme].mergeAdjacent);
|
|
|
|
|
|
|
|
function gatherCellProps(cell: GridCell) {
|
|
|
|
const { visibility, onClick, onHold, display, title, style, canClick, id } = cell;
|
|
|
|
return { visibility, onClick, onHold, display, title, style, canClick, id };
|
|
|
|
}
|
|
|
|
|
2023-02-15 20:00:36 -06:00
|
|
|
return { unref, gatherCellProps, Visibility, mergeAdjacent, isVisible, isHidden };
|
2022-01-24 22:25:34 -06:00
|
|
|
}
|
2022-01-24 22:23:30 -06:00
|
|
|
});
|
2021-06-11 23:38:16 -05:00
|
|
|
</script>
|