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 v-if="bar.unlocked" :style="style" :class="{ [layer]: true, bar: true }">
|
|
|
|
<div class="overlayTextContainer border" :style="borderStyle">
|
|
|
|
<component class="overlayText" :style="textStyle" :is="display" />
|
|
|
|
</div>
|
|
|
|
<div class="border" :style="backgroundStyle">
|
|
|
|
<div class="fill" :style="fillStyle" />
|
|
|
|
</div>
|
|
|
|
<branch-node :branches="bar.branches" :id="id" featureType="bar" />
|
|
|
|
</div>
|
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
|
|
|
<script lang="ts">
|
|
|
|
import { Direction } from "@/game/enums";
|
|
|
|
import { layers } from "@/game/layers";
|
|
|
|
import { Bar } from "@/typings/features/bar";
|
|
|
|
import Decimal from "@/util/bignum";
|
|
|
|
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
|
|
|
|
import { Component, defineComponent } from "vue";
|
2021-06-12 04:38:16 +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
|
|
|
export default defineComponent({
|
|
|
|
name: "bar",
|
|
|
|
mixins: [InjectLayerMixin],
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: [Number, String],
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
bar(): Bar {
|
|
|
|
return layers[this.layer].bars!.data[this.id];
|
|
|
|
},
|
|
|
|
progress(): number {
|
|
|
|
let progress =
|
|
|
|
this.bar.progress instanceof Decimal
|
|
|
|
? this.bar.progress.toNumber()
|
|
|
|
: (this.bar.progress as number);
|
|
|
|
return (1 - Math.min(Math.max(progress, 0), 1)) * 100;
|
|
|
|
},
|
|
|
|
style(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [
|
|
|
|
{ width: this.bar.width + "px", height: this.bar.height + "px" },
|
|
|
|
layers[this.layer].componentStyles?.bar,
|
|
|
|
this.bar.style
|
|
|
|
];
|
|
|
|
},
|
|
|
|
borderStyle(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [
|
|
|
|
{ width: this.bar.width + "px", height: this.bar.height + "px" },
|
|
|
|
this.bar.borderStyle
|
|
|
|
];
|
|
|
|
},
|
|
|
|
textStyle(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [this.bar.style, this.bar.textStyle];
|
|
|
|
},
|
|
|
|
backgroundStyle(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
return [
|
|
|
|
{ width: this.bar.width + "px", height: this.bar.height + "px" },
|
|
|
|
this.bar.style,
|
|
|
|
this.bar.baseStyle,
|
|
|
|
this.bar.borderStyle
|
|
|
|
];
|
|
|
|
},
|
|
|
|
fillStyle(): Array<Partial<CSSStyleDeclaration> | undefined> {
|
|
|
|
const fillStyle: Partial<CSSStyleDeclaration> = {
|
|
|
|
width: this.bar.width + 0.5 + "px",
|
|
|
|
height: this.bar.height + 0.5 + "px"
|
|
|
|
};
|
|
|
|
switch (this.bar.direction) {
|
|
|
|
case Direction.Up:
|
|
|
|
fillStyle.clipPath = `inset(${this.progress}% 0% 0% 0%)`;
|
|
|
|
fillStyle.width = this.bar.width + 1 + "px";
|
|
|
|
break;
|
|
|
|
case Direction.Down:
|
|
|
|
fillStyle.clipPath = `inset(0% 0% ${this.progress}% 0%)`;
|
|
|
|
fillStyle.width = this.bar.width + 1 + "px";
|
|
|
|
break;
|
|
|
|
case Direction.Right:
|
|
|
|
fillStyle.clipPath = `inset(0% ${this.progress}% 0% 0%)`;
|
|
|
|
break;
|
|
|
|
case Direction.Left:
|
|
|
|
fillStyle.clipPath = `inset(0% 0% 0% ${this.progress} + '%)`;
|
|
|
|
break;
|
|
|
|
case Direction.Default:
|
|
|
|
fillStyle.clipPath = "inset(0% 50% 0% 0%)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return [fillStyle, this.bar.style, this.bar.fillStyle];
|
|
|
|
},
|
|
|
|
display(): Component | string {
|
|
|
|
return coerceComponent(this.bar.display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-06-12 04:38:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.bar {
|
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
|
|
|
position: relative;
|
|
|
|
display: table;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.overlayTextContainer {
|
|
|
|
position: absolute;
|
|
|
|
border-radius: 10px;
|
|
|
|
vertical-align: middle;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
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
|
|
|
z-index: 3;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.overlayText {
|
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
|
|
|
z-index: 6;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.border {
|
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
|
|
|
border: 2px solid;
|
2021-06-12 04:38:16 +00:00
|
|
|
border-radius: 10px;
|
|
|
|
border-color: var(--color);
|
|
|
|
overflow: hidden;
|
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
|
|
|
mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
|
2021-06-12 04:38:16 +00:00
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fill {
|
|
|
|
position: absolute;
|
|
|
|
background-color: var(--color);
|
|
|
|
overflow: hidden;
|
|
|
|
margin-left: -0.5px;
|
|
|
|
transition-duration: 0.2s;
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
</style>
|