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-02-27 19:49:34 +00:00
|
|
|
v-if="unref(visibility) !== Visibility.None"
|
|
|
|
:style="[
|
|
|
|
{
|
|
|
|
visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined
|
|
|
|
},
|
|
|
|
unref(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-02-27 19:49:34 +00:00
|
|
|
can: unref(canPurchase),
|
|
|
|
locked: !unref(canPurchase),
|
|
|
|
bought: unref(bought),
|
|
|
|
...unref(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-02-27 19:49:34 +00:00
|
|
|
:disabled="!unref(canPurchase)"
|
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-02-27 19:49:34 +00:00
|
|
|
<component v-if="unref(component)" :is="unref(component)" />
|
|
|
|
<MarkNode :mark="unref(mark)" />
|
2022-01-14 04:25:47 +00:00
|
|
|
<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">
|
2022-02-27 22:04:56 +00:00
|
|
|
import "@/components/common/features.css";
|
|
|
|
import LinkNode from "@/components/links/LinkNode.vue";
|
|
|
|
import MarkNode from "@/components/MarkNode.vue";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { jsx, StyleValue, Visibility } from "@/features/feature";
|
2022-02-27 22:04:56 +00:00
|
|
|
import { displayResource, Resource } from "@/features/resources/resource";
|
|
|
|
import { GenericUpgrade } from "@/features/upgrades/upgrade";
|
2022-01-25 04:25:34 +00:00
|
|
|
import { DecimalSource } from "@/lib/break_eternity";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { coerceComponent, isCoercableComponent, processedPropType, unwrapRef } from "@/util/vue";
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
defineComponent,
|
|
|
|
PropType,
|
|
|
|
shallowRef,
|
|
|
|
toRefs,
|
|
|
|
unref,
|
|
|
|
UnwrapRef,
|
|
|
|
watchEffect
|
|
|
|
} from "vue";
|
2021-06-12 04:38:16 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
display: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<UnwrapRef<GenericUpgrade["display"]>>(String, Object, Function),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
visibility: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<Visibility>(Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
style: processedPropType<StyleValue>(String, Object, Array),
|
|
|
|
classes: processedPropType<Record<string, boolean>>(Object),
|
|
|
|
resource: Object as PropType<Resource>,
|
|
|
|
cost: processedPropType<DecimalSource>(String, Object, Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
canPurchase: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
bought: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
mark: processedPropType<boolean | string>(Boolean, String),
|
2022-01-25 04:25:34 +00:00
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
purchase: {
|
|
|
|
type: Function as PropType<VoidFunction>,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
components: {
|
|
|
|
LinkNode,
|
|
|
|
MarkNode
|
|
|
|
},
|
2022-01-25 04:25:34 +00:00
|
|
|
setup(props) {
|
|
|
|
const { display, cost } = toRefs(props);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const component = shallowRef<Component | string>("");
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
const currDisplay = unwrapRef(display);
|
2022-01-25 04:25:34 +00:00
|
|
|
if (currDisplay == null) {
|
2022-02-27 19:49:34 +00:00
|
|
|
component.value = "";
|
|
|
|
return;
|
2022-01-25 04:25:34 +00:00
|
|
|
}
|
|
|
|
if (isCoercableComponent(currDisplay)) {
|
2022-02-27 19:49:34 +00:00
|
|
|
component.value = coerceComponent(currDisplay);
|
|
|
|
return;
|
2022-01-25 04:25:34 +00:00
|
|
|
}
|
2022-02-27 19:49:34 +00:00
|
|
|
const currCost = unwrapRef(cost);
|
|
|
|
const Title = coerceComponent(currDisplay.title || "", "h3");
|
|
|
|
const Description = coerceComponent(currDisplay.description, "div");
|
|
|
|
const EffectDisplay = coerceComponent(currDisplay.effectDisplay || "");
|
|
|
|
component.value = coerceComponent(
|
|
|
|
jsx(() => (
|
|
|
|
<span>
|
|
|
|
{currDisplay.title ? (
|
|
|
|
<div>
|
|
|
|
<Title />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
<Description />
|
|
|
|
{currDisplay.effectDisplay ? (
|
|
|
|
<div>
|
|
|
|
Currently: <EffectDisplay />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
{props.resource != null ? (
|
|
|
|
<>
|
|
|
|
<br />
|
|
|
|
Cost: {props.resource &&
|
|
|
|
displayResource(props.resource, currCost)}{" "}
|
|
|
|
{props.resource?.displayName}
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
</span>
|
|
|
|
))
|
2022-01-25 04:25:34 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
component,
|
2022-02-27 19:49:34 +00:00
|
|
|
unref,
|
2022-01-25 04:25:34 +00:00
|
|
|
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>
|