forked from profectus/Profectus
Added diamond shaped nodes
This commit is contained in:
parent
0ced1d7cd7
commit
b43f3003b5
5 changed files with 124 additions and 25 deletions
|
@ -7,6 +7,7 @@
|
||||||
@mouseleave="mouseLeave"
|
@mouseleave="mouseLeave"
|
||||||
@mousedown="e => $emit('startDragging', e, node.id)"
|
@mousedown="e => $emit('startDragging', e, node.id)"
|
||||||
>
|
>
|
||||||
|
<g v-if="shape === Shape.Circle">
|
||||||
<circle
|
<circle
|
||||||
v-if="canAccept"
|
v-if="canAccept"
|
||||||
:r="size + 8"
|
:r="size + 8"
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
<circle
|
<circle
|
||||||
v-if="progressDisplay === ProgressDisplay.Fill"
|
v-if="progressDisplay === ProgressDisplay.Fill"
|
||||||
:r="size * progress"
|
:r="Math.max(size * progress - 2, 0)"
|
||||||
:fill="progressColor"
|
:fill="progressColor"
|
||||||
/>
|
/>
|
||||||
<circle
|
<circle
|
||||||
|
@ -29,9 +30,56 @@
|
||||||
fill="transparent"
|
fill="transparent"
|
||||||
:stroke-dasharray="(size + 4.5) * 2 * Math.PI"
|
:stroke-dasharray="(size + 4.5) * 2 * Math.PI"
|
||||||
:stroke-width="5"
|
:stroke-width="5"
|
||||||
:stroke-dashoffset="(size + 4.5) * 2 * Math.PI - progress * (size + 4.5) * 2 * Math.PI"
|
:stroke-dashoffset="
|
||||||
|
(size + 4.5) * 2 * Math.PI - progress * (size + 4.5) * 2 * Math.PI
|
||||||
|
"
|
||||||
:stroke="progressColor"
|
:stroke="progressColor"
|
||||||
/>
|
/>
|
||||||
|
</g>
|
||||||
|
<g v-else-if="shape === Shape.Diamond" transform="rotate(45, 0, 0)">
|
||||||
|
<rect
|
||||||
|
v-if="canAccept"
|
||||||
|
:width="size + 16"
|
||||||
|
:height="size + 16"
|
||||||
|
:transform="`translate(${-(size + 16) / 2}, ${-(size + 16) / 2})`"
|
||||||
|
:fill="backgroundColor"
|
||||||
|
:stroke="receivingNode ? '#0F0' : '#0F03'"
|
||||||
|
:stroke-width="2"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<rect
|
||||||
|
:width="size"
|
||||||
|
:height="size"
|
||||||
|
:transform="`translate(${-size / 2}, ${-size / 2})`"
|
||||||
|
:fill="fillColor"
|
||||||
|
:stroke="outlineColor"
|
||||||
|
:stroke-width="4"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<rect
|
||||||
|
v-if="progressDisplay === ProgressDisplay.Fill"
|
||||||
|
:width="Math.max(size * progress - 2, 0)"
|
||||||
|
:height="Math.max(size * progress - 2, 0)"
|
||||||
|
:transform="
|
||||||
|
`translate(${-Math.max(size * progress - 2, 0) / 2}, ${-Math.max(
|
||||||
|
size * progress - 2,
|
||||||
|
0
|
||||||
|
) / 2})`
|
||||||
|
"
|
||||||
|
:fill="progressColor"
|
||||||
|
/>
|
||||||
|
<rect
|
||||||
|
v-else
|
||||||
|
:width="size + 9"
|
||||||
|
:height="size + 9"
|
||||||
|
:transform="`translate(${-(size + 9) / 2}, ${-(size + 9) / 2})`"
|
||||||
|
fill="transparent"
|
||||||
|
:stroke-dasharray="(size + 9) * 4"
|
||||||
|
:stroke-width="5"
|
||||||
|
:stroke-dashoffset="(size + 9) * 4 - progress * (size + 9) * 4"
|
||||||
|
:stroke="progressColor"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
|
||||||
<text :fill="titleColor" class="node-title">{{ title }}</text>
|
<text :fill="titleColor" class="node-title">{{ title }}</text>
|
||||||
</g>
|
</g>
|
||||||
|
@ -39,7 +87,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import themes from "@/data/themes";
|
import themes from "@/data/themes";
|
||||||
import { ProgressDisplay } from "@/game/enums";
|
import { ProgressDisplay, Shape } from "@/game/enums";
|
||||||
import player from "@/game/player";
|
import player from "@/game/player";
|
||||||
import { BoardNode, NodeType } from "@/typings/features/board";
|
import { BoardNode, NodeType } from "@/typings/features/board";
|
||||||
import { getNodeTypeProperty } from "@/util/features";
|
import { getNodeTypeProperty } from "@/util/features";
|
||||||
|
@ -52,6 +100,7 @@ export default defineComponent({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
ProgressDisplay,
|
ProgressDisplay,
|
||||||
|
Shape,
|
||||||
lastMousePosition: { x: 0, y: 0 },
|
lastMousePosition: { x: 0, y: 0 },
|
||||||
hovering: false
|
hovering: false
|
||||||
};
|
};
|
||||||
|
@ -90,6 +139,9 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
: this.node.position;
|
: this.node.position;
|
||||||
},
|
},
|
||||||
|
shape(): Shape {
|
||||||
|
return getNodeTypeProperty(this.nodeType, this.node, "shape");
|
||||||
|
},
|
||||||
size(): number {
|
size(): number {
|
||||||
let size: number = getNodeTypeProperty(this.nodeType, this.node, "size");
|
let size: number = getNodeTypeProperty(this.nodeType, this.node, "size");
|
||||||
if (this.receivingNode) {
|
if (this.receivingNode) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import { ProgressDisplay, Shape } from "@/game/enums";
|
||||||
import player from "@/game/player";
|
import player from "@/game/player";
|
||||||
import Decimal, { DecimalSource } from "@/lib/break_eternity";
|
import Decimal, { DecimalSource } from "@/lib/break_eternity";
|
||||||
import { RawLayer } from "@/typings/layer";
|
import { RawLayer } from "@/typings/layer";
|
||||||
|
import { camelToTitle } from "@/util/common";
|
||||||
import themes from "../themes";
|
import themes from "../themes";
|
||||||
|
|
||||||
type ResourceNodeData = {
|
type ResourceNodeData = {
|
||||||
|
@ -14,6 +16,10 @@ type ItemNodeData = {
|
||||||
amount: DecimalSource;
|
amount: DecimalSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ActionNodeData = {
|
||||||
|
actionType: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
id: "main",
|
id: "main",
|
||||||
display: `
|
display: `
|
||||||
|
@ -21,7 +27,15 @@ export default {
|
||||||
<div v-else-if="player.devSpeed && player.devSpeed !== 1">Dev Speed: {{ format(player.devSpeed) }}x</div>
|
<div v-else-if="player.devSpeed && player.devSpeed !== 1">Dev Speed: {{ format(player.devSpeed) }}x</div>
|
||||||
<div>TODO: Board</div>
|
<div>TODO: Board</div>
|
||||||
<Board id="main" />
|
<Board id="main" />
|
||||||
|
|
||||||
`,
|
`,
|
||||||
|
startData() {
|
||||||
|
return {
|
||||||
|
openNode: null
|
||||||
|
} as {
|
||||||
|
openNode: string | null;
|
||||||
|
};
|
||||||
|
},
|
||||||
minimizable: false,
|
minimizable: false,
|
||||||
componentStyles: {
|
componentStyles: {
|
||||||
board: {
|
board: {
|
||||||
|
@ -52,6 +66,13 @@ export default {
|
||||||
itemType: "speed",
|
itemType: "speed",
|
||||||
amount: new Decimal(5 * 60 * 60)
|
amount: new Decimal(5 * 60 * 60)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
position: { x: -150, y: 150 },
|
||||||
|
type: "action",
|
||||||
|
data: {
|
||||||
|
actionType: "browse"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
@ -92,6 +113,24 @@ export default {
|
||||||
return (node.data as ItemNodeData).itemType;
|
return (node.data as ItemNodeData).itemType;
|
||||||
},
|
},
|
||||||
draggable: true
|
draggable: true
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
title(node) {
|
||||||
|
return camelToTitle((node.data as ActionNodeData).actionType);
|
||||||
|
},
|
||||||
|
tooltip(node) {
|
||||||
|
switch ((node.data as ActionNodeData).actionType) {
|
||||||
|
default:
|
||||||
|
return camelToTitle((node.data as ActionNodeData).actionType);
|
||||||
|
case "browse":
|
||||||
|
return "Browse the internet";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
draggable: false,
|
||||||
|
shape: Shape.Diamond,
|
||||||
|
size: 100,
|
||||||
|
progressColor: "#0FF3",
|
||||||
|
progressDisplay: ProgressDisplay.Outline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,3 +33,8 @@ export enum ProgressDisplay {
|
||||||
Outline = "Outline",
|
Outline = "Outline",
|
||||||
Fill = "Fill"
|
Fill = "Fill"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Shape {
|
||||||
|
Circle = "Circle",
|
||||||
|
Diamond = "Triangle"
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import { createGridProxy, createLayerProxy } from "@/util/proxies";
|
||||||
import { applyPlayerData } from "@/util/save";
|
import { applyPlayerData } from "@/util/save";
|
||||||
import clone from "lodash.clonedeep";
|
import clone from "lodash.clonedeep";
|
||||||
import { isRef } from "vue";
|
import { isRef } from "vue";
|
||||||
import { ProgressDisplay } from "./enums";
|
import { ProgressDisplay, Shape } from "./enums";
|
||||||
import { default as playerProxy } from "./player";
|
import { default as playerProxy } from "./player";
|
||||||
|
|
||||||
export const layers: Record<string, Readonly<Layer>> = {};
|
export const layers: Record<string, Readonly<Layer>> = {};
|
||||||
|
@ -438,6 +438,7 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
layer.boards.data[id].types[nodeType].type = nodeType;
|
layer.boards.data[id].types[nodeType].type = nodeType;
|
||||||
setDefault(layer.boards.data[id].types[nodeType], "size", 50);
|
setDefault(layer.boards.data[id].types[nodeType], "size", 50);
|
||||||
setDefault(layer.boards.data[id].types[nodeType], "draggable", false);
|
setDefault(layer.boards.data[id].types[nodeType], "draggable", false);
|
||||||
|
setDefault(layer.boards.data[id].types[nodeType], "shape", Shape.Circle);
|
||||||
setDefault(layer.boards.data[id].types[nodeType], "canAccept", false);
|
setDefault(layer.boards.data[id].types[nodeType], "canAccept", false);
|
||||||
setDefault(
|
setDefault(
|
||||||
layer.boards.data[id].types[nodeType],
|
layer.boards.data[id].types[nodeType],
|
||||||
|
|
2
src/typings/features/board.d.ts
vendored
2
src/typings/features/board.d.ts
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
import { Shape } from "@/game/enums";
|
||||||
import { DecimalSource } from "@/lib/break_eternity";
|
import { DecimalSource } from "@/lib/break_eternity";
|
||||||
import { State } from "../state";
|
import { State } from "../state";
|
||||||
import { Feature, RawFeature } from "./feature";
|
import { Feature, RawFeature } from "./feature";
|
||||||
|
@ -35,6 +36,7 @@ export interface NodeType extends Feature {
|
||||||
title: string | ((node: BoardNode) => string);
|
title: string | ((node: BoardNode) => string);
|
||||||
size: number | ((node: BoardNode) => number);
|
size: number | ((node: BoardNode) => number);
|
||||||
draggable: boolean | ((node: BoardNode) => boolean);
|
draggable: boolean | ((node: BoardNode) => boolean);
|
||||||
|
shape: Shape | ((node: BoardNode) => Shape);
|
||||||
canAccept: boolean | ((node: BoardNode, otherNode: BoardNode) => boolean);
|
canAccept: boolean | ((node: BoardNode, otherNode: BoardNode) => boolean);
|
||||||
progress?: number | ((node: BoardNode) => number);
|
progress?: number | ((node: BoardNode) => number);
|
||||||
progressDisplay: ProgressDisplay | ((node: BoardNode) => ProgressDisplay);
|
progressDisplay: ProgressDisplay | ((node: BoardNode) => ProgressDisplay);
|
||||||
|
|
Loading…
Reference in a new issue