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
|
|
|
<div
|
2022-02-27 19:49:34 +00:00
|
|
|
v-if="unref(visibility) !== Visibility.None"
|
|
|
|
:style="[
|
|
|
|
{
|
|
|
|
visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined
|
|
|
|
},
|
|
|
|
notifyStyle,
|
|
|
|
unref(style) ?? {}
|
|
|
|
]"
|
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,
|
|
|
|
challenge: true,
|
2022-02-27 19:49:34 +00:00
|
|
|
done: unref(completed),
|
2022-03-23 04:04:49 +00:00
|
|
|
canStart: unref(canStart) && !unref(maxed),
|
2022-02-27 19:49:34 +00:00
|
|
|
maxed: unref(maxed),
|
|
|
|
...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-03-23 04:04:49 +00:00
|
|
|
<button
|
|
|
|
class="toggleChallenge"
|
|
|
|
@click="toggle"
|
|
|
|
:disabled="!unref(canStart) || unref(maxed)"
|
|
|
|
>
|
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
|
|
|
{{ buttonText }}
|
|
|
|
</button>
|
2022-02-27 19:49:34 +00:00
|
|
|
<component v-if="unref(comp)" :is="unref(comp)" />
|
|
|
|
<MarkNode :mark="unref(mark)" />
|
2022-03-20 18:57:45 +00:00
|
|
|
<Node :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
|
|
|
</div>
|
2021-06-12 04:38:16 +00:00
|
|
|
</template>
|
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
<script lang="tsx">
|
2022-03-04 03:39:48 +00:00
|
|
|
import "components/common/features.css";
|
2022-06-27 00:17:22 +00:00
|
|
|
import MarkNode from "components/MarkNode.vue";
|
|
|
|
import Node from "components/Node.vue";
|
|
|
|
import type { GenericChallenge } from "features/challenges/challenge";
|
|
|
|
import type { StyleValue } from "features/feature";
|
|
|
|
import { jsx, Visibility } from "features/feature";
|
2022-03-04 03:39:48 +00:00
|
|
|
import { getHighNotifyStyle, getNotifyStyle } from "game/notifications";
|
|
|
|
import { coerceComponent, isCoercableComponent, processedPropType, unwrapRef } from "util/vue";
|
2022-06-27 00:17:22 +00:00
|
|
|
import type { Component, PropType, UnwrapRef } from "vue";
|
|
|
|
import { computed, defineComponent, shallowRef, toRefs, unref, watchEffect } from "vue";
|
2021-06-12 04:38:16 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
active: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
maxed: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
canComplete: {
|
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
|
|
|
display: processedPropType<UnwrapRef<GenericChallenge["display"]>>(
|
|
|
|
String,
|
|
|
|
Object,
|
|
|
|
Function
|
|
|
|
),
|
2022-01-25 04:25:34 +00:00
|
|
|
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),
|
2022-01-25 04:25:34 +00:00
|
|
|
completed: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
canStart: {
|
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
|
|
|
|
},
|
|
|
|
toggle: {
|
|
|
|
type: Function as PropType<VoidFunction>,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
components: {
|
|
|
|
MarkNode,
|
2022-03-20 18:57:45 +00:00
|
|
|
Node
|
2022-02-27 19:49:34 +00:00
|
|
|
},
|
2022-01-25 04:25:34 +00:00
|
|
|
setup(props) {
|
|
|
|
const { active, maxed, canComplete, display } = toRefs(props);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
const buttonText = computed(() => {
|
|
|
|
if (active.value) {
|
|
|
|
return canComplete.value ? "Finish" : "Exit Early";
|
|
|
|
}
|
|
|
|
if (maxed.value) {
|
|
|
|
return "Completed";
|
|
|
|
}
|
|
|
|
return "Start";
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const comp = shallowRef<Component | string>("");
|
|
|
|
|
|
|
|
const notifyStyle = computed(() => {
|
|
|
|
const currActive = unwrapRef(active);
|
|
|
|
const currCanComplete = unwrapRef(canComplete);
|
|
|
|
if (currActive) {
|
|
|
|
if (currCanComplete) {
|
|
|
|
return getHighNotifyStyle();
|
|
|
|
}
|
|
|
|
return getNotifyStyle();
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
const currDisplay = unwrapRef(display);
|
2022-01-25 04:25:34 +00:00
|
|
|
if (currDisplay == null) {
|
2022-02-27 19:49:34 +00:00
|
|
|
comp.value = "";
|
|
|
|
return;
|
2022-01-25 04:25:34 +00:00
|
|
|
}
|
|
|
|
if (isCoercableComponent(currDisplay)) {
|
2022-02-27 19:49:34 +00:00
|
|
|
comp.value = coerceComponent(currDisplay);
|
|
|
|
return;
|
2022-01-25 04:25:34 +00:00
|
|
|
}
|
2022-02-27 19:49:34 +00:00
|
|
|
const Title = coerceComponent(currDisplay.title || "", "h3");
|
|
|
|
const Description = coerceComponent(currDisplay.description, "div");
|
|
|
|
const Goal = coerceComponent(currDisplay.goal || "");
|
|
|
|
const Reward = coerceComponent(currDisplay.reward || "");
|
|
|
|
const EffectDisplay = coerceComponent(currDisplay.effectDisplay || "");
|
|
|
|
comp.value = coerceComponent(
|
|
|
|
jsx(() => (
|
|
|
|
<span>
|
|
|
|
{currDisplay.title ? (
|
|
|
|
<div>
|
|
|
|
<Title />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
<Description />
|
|
|
|
{currDisplay.goal ? (
|
|
|
|
<div>
|
|
|
|
<br />
|
|
|
|
Goal: <Goal />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
{currDisplay.reward ? (
|
|
|
|
<div>
|
|
|
|
<br />
|
|
|
|
Reward: <Reward />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
{currDisplay.effectDisplay ? (
|
|
|
|
<div>
|
|
|
|
Currently: <EffectDisplay />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</span>
|
|
|
|
))
|
2022-01-25 04:25:34 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
buttonText,
|
2022-02-27 19:49:34 +00:00
|
|
|
notifyStyle,
|
|
|
|
comp,
|
|
|
|
Visibility,
|
|
|
|
unref
|
2022-01-25 04:25:34 +00:00
|
|
|
};
|
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>
|
|
|
|
.challenge {
|
2021-06-16 04:07:32 +00:00
|
|
|
background-color: var(--locked);
|
2021-07-02 09:50:44 +00:00
|
|
|
width: 300px;
|
|
|
|
min-height: 300px;
|
2021-06-16 04:07:32 +00:00
|
|
|
color: black;
|
|
|
|
font-size: 15px;
|
|
|
|
display: flex;
|
|
|
|
flex-flow: column;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.challenge.done {
|
|
|
|
background-color: var(--bought);
|
|
|
|
}
|
|
|
|
|
|
|
|
.challenge button {
|
|
|
|
min-height: 50px;
|
|
|
|
width: 120px;
|
|
|
|
border-radius: var(--border-radius);
|
|
|
|
box-shadow: none !important;
|
|
|
|
background: transparent;
|
|
|
|
}
|
|
|
|
|
2021-09-19 16:28:44 +00:00
|
|
|
.challenge.canStart button {
|
|
|
|
cursor: pointer;
|
2022-01-14 04:25:47 +00:00
|
|
|
background-color: var(--layer-color);
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
</style>
|