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
|
|
|
<line
|
|
|
|
:stroke="stroke"
|
|
|
|
:stroke-width="strokeWidth"
|
|
|
|
v-bind="typeof options === 'string' ? [] : options"
|
|
|
|
:x1="startPosition.x"
|
|
|
|
:y1="startPosition.y"
|
|
|
|
:x2="endPosition.x"
|
|
|
|
:y2="endPosition.y"
|
|
|
|
/>
|
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 { BranchNode, BranchOptions, Position } from "@/typings/branches";
|
|
|
|
import { defineComponent, PropType } from "vue";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: "branch-line",
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: [String, Object] as PropType<string | BranchOptions>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
startNode: {
|
|
|
|
type: Object as PropType<BranchNode>,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
endNode: {
|
|
|
|
type: Object as PropType<BranchNode>,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
stroke(): string {
|
|
|
|
if (typeof this.options === "string" || !("stroke" in this.options)) {
|
|
|
|
return "white";
|
|
|
|
}
|
|
|
|
return this.options.stroke!;
|
|
|
|
},
|
2021-08-22 22:57:59 -05:00
|
|
|
strokeWidth(): number | string {
|
|
|
|
if (typeof this.options === "string" || !("strokeWidth" in this.options)) {
|
|
|
|
return "15";
|
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
|
|
|
}
|
2021-08-22 22:57:59 -05:00
|
|
|
return this.options["strokeWidth"]!;
|
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
|
|
|
},
|
|
|
|
startPosition(): Position {
|
|
|
|
const position = { x: this.startNode.x || 0, y: this.startNode.y || 0 };
|
|
|
|
if (typeof this.options !== "string" && "startOffset" in this.options) {
|
|
|
|
position.x += this.options.startOffset?.x || 0;
|
|
|
|
position.y += this.options.startOffset?.y || 0;
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
},
|
|
|
|
endPosition(): Position {
|
|
|
|
const position = { x: this.endNode.x || 0, y: this.endNode.y || 0 };
|
|
|
|
if (typeof this.options !== "string" && "endOffset" in this.options) {
|
|
|
|
position.x += this.options.endOffset?.x || 0;
|
|
|
|
position.y += this.options.endOffset?.y || 0;
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-06-11 23:38:16 -05:00
|
|
|
</script>
|
|
|
|
|
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
|
|
|
<style scoped></style>
|