2021-06-11 23:38:16 -05: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-16 23:30:54 -05:00
|
|
|
<div
|
|
|
|
v-if="challenge.shown"
|
|
|
|
:style="style"
|
|
|
|
:class="{
|
|
|
|
feature: true,
|
|
|
|
[layer]: true,
|
|
|
|
challenge: true,
|
|
|
|
resetNotify: challenge.active,
|
|
|
|
notify: challenge.active && challenge.canComplete,
|
|
|
|
done: challenge.completed,
|
2021-09-19 11:28:44 -05:00
|
|
|
canStart: challenge.canStart,
|
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
|
|
|
maxed: challenge.maxed
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<div v-if="title"><component :is="title" /></div>
|
2021-09-19 11:28:44 -05:00
|
|
|
<button
|
|
|
|
:style="{ backgroundColor: challenge.canStart ? buttonColor : null }"
|
|
|
|
@click="toggle"
|
|
|
|
>
|
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
|
|
|
{{ buttonText }}
|
|
|
|
</button>
|
|
|
|
<component v-if="fullDisplay" :is="fullDisplay" />
|
|
|
|
<default-challenge-display v-else :id="id" />
|
|
|
|
<mark-node :mark="challenge.mark" />
|
|
|
|
<branch-node :branches="challenge.branches" :id="id" featureType="challenge" />
|
|
|
|
</div>
|
2021-06-11 23:38:16 -05: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-16 23:30:54 -05:00
|
|
|
<script lang="ts">
|
|
|
|
import { layers } from "@/game/layers";
|
|
|
|
import { Challenge } from "@/typings/features/challenge";
|
|
|
|
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
|
|
|
|
import { Component, defineComponent } from "vue";
|
2021-06-11 23:38:16 -05: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-16 23:30:54 -05:00
|
|
|
export default defineComponent({
|
|
|
|
name: "challenge",
|
|
|
|
mixins: [InjectLayerMixin],
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: [Number, String],
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
challenge(): Challenge {
|
|
|
|
return layers[this.layer].challenges!.data[this.id];
|
|
|
|
},
|
|
|
|
style(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [layers[this.layer].componentStyles?.challenge, this.challenge.style];
|
|
|
|
},
|
|
|
|
title(): Component | string | null {
|
|
|
|
if (this.challenge.titleDisplay) {
|
|
|
|
return coerceComponent(this.challenge.titleDisplay, "div");
|
|
|
|
}
|
|
|
|
if (this.challenge.name) {
|
|
|
|
return coerceComponent(this.challenge.name, "h3");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
buttonColor(): string {
|
|
|
|
return layers[this.layer].color;
|
|
|
|
},
|
|
|
|
buttonText(): string {
|
|
|
|
if (this.challenge.active) {
|
|
|
|
return this.challenge.canComplete ? "Finish" : "Exit Early";
|
|
|
|
}
|
|
|
|
if (this.challenge.maxed) {
|
|
|
|
return "Completed";
|
|
|
|
}
|
|
|
|
return "Start";
|
|
|
|
},
|
|
|
|
fullDisplay(): Component | string | null {
|
|
|
|
if (this.challenge.fullDisplay) {
|
|
|
|
return coerceComponent(this.challenge.fullDisplay, "div");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.challenge.toggle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-06-11 23:38:16 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.challenge {
|
2021-06-15 23:07:32 -05:00
|
|
|
background-color: var(--locked);
|
2021-07-02 04:50:44 -05:00
|
|
|
width: 300px;
|
|
|
|
min-height: 300px;
|
2021-06-15 23:07:32 -05: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 11:28:44 -05:00
|
|
|
.challenge.canStart button {
|
|
|
|
cursor: pointer;
|
2021-06-11 23:38:16 -05:00
|
|
|
}
|
|
|
|
</style>
|