2021-06-12 04:38:16 +00:00
|
|
|
<template>
|
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-17 04:30:54 +00:00
|
|
|
<button
|
2022-01-14 04:25:47 +00:00
|
|
|
v-if="visibility !== Visibility.None"
|
|
|
|
v-show="visibility === Visibility.Visible"
|
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-17 04:30:54 +00:00
|
|
|
:style="style"
|
2022-01-14 04:25:47 +00:00
|
|
|
@click="purchase"
|
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-17 04:30:54 +00:00
|
|
|
:class="{
|
|
|
|
feature: true,
|
|
|
|
upgrade: true,
|
2022-01-14 04:25:47 +00:00
|
|
|
can: canPurchase && !bought,
|
|
|
|
locked: !canPurchase && !bought,
|
|
|
|
bought,
|
|
|
|
...classes
|
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-17 04:30:54 +00:00
|
|
|
}"
|
2022-01-14 04:25:47 +00:00
|
|
|
:disabled="!canPurchase && !bought"
|
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-17 04:30:54 +00:00
|
|
|
>
|
2022-01-14 04:25:47 +00:00
|
|
|
<component v-if="component" :is="component" />
|
|
|
|
<MarkNode :mark="mark" />
|
|
|
|
<LinkNode :id="id" />
|
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-17 04:30:54 +00:00
|
|
|
</button>
|
2021-06-12 04:38:16 +00:00
|
|
|
</template>
|
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
<script lang="tsx">
|
|
|
|
import { StyleValue, Visibility } from "@/features/feature";
|
|
|
|
import { displayResource, Resource } from "@/features/resource";
|
2022-01-14 04:25:47 +00:00
|
|
|
import { GenericUpgrade } from "@/features/upgrade";
|
2022-01-25 04:25:34 +00:00
|
|
|
import { DecimalSource } from "@/lib/break_eternity";
|
2022-01-14 04:25:47 +00:00
|
|
|
import { coerceComponent, isCoercableComponent } from "@/util/vue";
|
2022-01-25 04:25:34 +00:00
|
|
|
import { computed, defineComponent, PropType, Ref, toRef, toRefs, unref, UnwrapRef } from "vue";
|
2022-01-14 04:25:47 +00:00
|
|
|
import LinkNode from "../system/LinkNode.vue";
|
|
|
|
import MarkNode from "./MarkNode.vue";
|
2021-06-12 04:38:16 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
display: {
|
|
|
|
type: Object as PropType<UnwrapRef<GenericUpgrade["display"]>>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
visibility: {
|
|
|
|
type: Object as PropType<Visibility>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
style: Object as PropType<StyleValue>,
|
|
|
|
classes: Object as PropType<Record<string, boolean>>,
|
|
|
|
resource: {
|
|
|
|
type: Object as PropType<Resource>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
cost: {
|
|
|
|
type: Object as PropType<DecimalSource>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
canPurchase: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
bought: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
mark: [Boolean, String],
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
purchase: {
|
|
|
|
type: Function as PropType<VoidFunction>,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setup(props) {
|
|
|
|
const { display, cost } = toRefs(props);
|
|
|
|
const resource = toRef(props, "resource") as unknown as Ref<Resource>;
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
const component = computed(() => {
|
|
|
|
const currDisplay = display.value;
|
|
|
|
if (currDisplay == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (isCoercableComponent(currDisplay)) {
|
|
|
|
return coerceComponent(currDisplay);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<div v-if={currDisplay.title}>
|
|
|
|
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
|
|
|
<component v-is={coerceComponent(currDisplay.title!, "h2")} />
|
|
|
|
</div>
|
|
|
|
<component v-is={coerceComponent(currDisplay.description, "div")} />
|
|
|
|
<div v-if={currDisplay.effectDisplay}>
|
|
|
|
<br />
|
|
|
|
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
|
|
|
Currently: <component v-is={coerceComponent(currDisplay.effectDisplay!)} />
|
|
|
|
</div>
|
|
|
|
<template v-if={resource.value != null && cost.value != null}>
|
|
|
|
<br />
|
|
|
|
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
|
|
|
Cost: {displayResource(resource.value, cost.value)}{" "}
|
|
|
|
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
|
|
|
|
{resource.value.displayName}
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
component,
|
|
|
|
LinkNode,
|
|
|
|
MarkNode,
|
|
|
|
Visibility
|
|
|
|
};
|
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-17 04:30:54 +00:00
|
|
|
}
|
|
|
|
});
|
2021-06-12 04:38:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.upgrade {
|
|
|
|
min-height: 120px;
|
|
|
|
width: 120px;
|
|
|
|
font-size: 10px;
|
|
|
|
}
|
|
|
|
</style>
|