From 7ff02fc0104857554b5acd6f7707b5da2bb2c75f Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 01:44:22 -0700 Subject: [PATCH 1/7] add optional pipe mode field --- server/src/types/core-types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/types/core-types.ts b/server/src/types/core-types.ts index b50c38f..0a83ae6 100644 --- a/server/src/types/core-types.ts +++ b/server/src/types/core-types.ts @@ -31,6 +31,8 @@ export interface Factory { export type PipeId = string; export type PipeMap = { [key: PipeId]: Pipe }; +export type PipeMode = 'natural' | 'spread'; + /** * Data structure representing a pipe for transferring items between two Groups */ @@ -38,6 +40,7 @@ export interface Pipe { id: PipeId, from: GroupId, to: GroupId + mode?: PipeMode, nickname?: string, filter?: string, }; From 88160cf485c7c367dadd9720d493ea42934f1d1b Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 01:47:33 -0700 Subject: [PATCH 2/7] add dropdown for mode --- client/src/components/EdgeOptions.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/components/EdgeOptions.tsx b/client/src/components/EdgeOptions.tsx index 854b664..1cdd1a8 100644 --- a/client/src/components/EdgeOptions.tsx +++ b/client/src/components/EdgeOptions.tsx @@ -77,6 +77,13 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro onInput={ e => setNickname((e.target as HTMLInputElement).value) } /> + +
+ + +
From 58ec730f98e868874c1334030a1e3f4978a8079d Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 01:58:13 -0700 Subject: [PATCH 3/7] make mode select work --- client/src/components/EdgeOptions.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/src/components/EdgeOptions.tsx b/client/src/components/EdgeOptions.tsx index 1cdd1a8..1eb9a16 100644 --- a/client/src/components/EdgeOptions.tsx +++ b/client/src/components/EdgeOptions.tsx @@ -1,4 +1,4 @@ -import { Pipe } from "@server/types/core-types"; +import { Pipe, PipeMode } from "@server/types/core-types"; import { useState } from "react"; import { SendMessage } from "react-use-websocket"; import { Edge, useOnSelectionChange, useStoreApi } from "reactflow"; @@ -17,12 +17,14 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro const [ nickname, setNickname ] = useState(""); const [ filter, setFilter ] = useState(""); + const [ mode, setMode ] = useState(undefined as string | undefined); useOnSelectionChange({ onChange: ({ edges }) => { setSelectedEdges(edges); setFilter(edges.length === 1 ? (pipes[edges[0].id].filter || "") : "..."); setNickname(edges.length === 1 ? (pipes[edges[0].id].nickname || "") : "..."); + setMode(edges.length === 1 ? pipes[edges[0].id].mode : "..."); } }); @@ -40,6 +42,11 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro changes = true; } + if (mode && mode !== "...") { + edits.mode = mode as PipeMode; + changes = true; + } + if (changes) { for (let edge of selectedEdges) { GraphUpdateCallbacks.onPipeUpdate(edge.id, edits, sendMessage) @@ -80,8 +87,11 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro
- setMode((e.target as HTMLInputElement).value) } + > +
From ee14b092669d89f0ddb5b80b1233cd20c45ae776 Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 02:09:29 -0700 Subject: [PATCH 4/7] fix option persistence bug --- client/src/components/EdgeOptions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/components/EdgeOptions.tsx b/client/src/components/EdgeOptions.tsx index 1eb9a16..316ed33 100644 --- a/client/src/components/EdgeOptions.tsx +++ b/client/src/components/EdgeOptions.tsx @@ -88,8 +88,8 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro
From 3d2a164f8b83bea07876326c46e41feec6e939e9 Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 02:11:28 -0700 Subject: [PATCH 5/7] add comments for pipe mode devs --- computercraft/sigils/pipe.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/computercraft/sigils/pipe.lua b/computercraft/sigils/pipe.lua index 8985568..7688614 100644 --- a/computercraft/sigils/pipe.lua +++ b/computercraft/sigils/pipe.lua @@ -47,7 +47,11 @@ local function processPipe (pipe, groupMap, missingPeriphs) local ok, transferOrders = pcall( function () - return PipeModeNatural.getTransferOrders(groupMap[pipe.from], groupMap[pipe.to], missingPeriphs, filter) + if pipe.mode == "natural" then -- you can add more item pipe modes with more if/else statements + return PipeModeNatural.getTransferOrders(groupMap[pipe.from], groupMap[pipe.to], missingPeriphs, filter) + else -- natural is the default + return PipeModeNatural.getTransferOrders(groupMap[pipe.from], groupMap[pipe.to], missingPeriphs, filter) + end end ) From f4345a6a9f3d0b513d52911081cb582f3c8c5845 Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 02:24:44 -0700 Subject: [PATCH 6/7] update selector and button styles --- client/src/components/EdgeOptions.tsx | 5 +++-- client/src/index.css | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/components/EdgeOptions.tsx b/client/src/components/EdgeOptions.tsx index 316ed33..4a53a58 100644 --- a/client/src/components/EdgeOptions.tsx +++ b/client/src/components/EdgeOptions.tsx @@ -85,11 +85,12 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro />
-
- +
+ diff --git a/client/src/index.css b/client/src/index.css index 4d07d67..4404551 100644 --- a/client/src/index.css +++ b/client/src/index.css @@ -30,6 +30,7 @@ .mcui-button { @apply bg-neutral-500; @apply text-white; + @apply outline-white; @apply border-2; @apply border-t-mcgui-slot-border-light; @apply border-s-mcgui-slot-border-light; @@ -42,10 +43,10 @@ @apply disabled:bg-stone-800; @apply hover:border-white; - @apply hover:border-4; + @apply hover:outline; @apply active:border-white; - @apply active:border-4; + @apply active:outline-2; @apply active:bg-stone-700; text-shadow: 1.5px 1.5px 0px #373737; From 515c049536bb446d94bd711d115ffc62721ec7d1 Mon Sep 17 00:00:00 2001 From: fechan Date: Sun, 27 Oct 2024 02:34:06 -0700 Subject: [PATCH 7/7] hide pipe mode if it is fluid type --- client/src/components/EdgeOptions.tsx | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/client/src/components/EdgeOptions.tsx b/client/src/components/EdgeOptions.tsx index 4a53a58..9f7611d 100644 --- a/client/src/components/EdgeOptions.tsx +++ b/client/src/components/EdgeOptions.tsx @@ -14,9 +14,11 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro const [ selectedEdges, setSelectedEdges ] = useState([] as Edge[]); const pipes = useFactoryStore(state => state.factory.pipes); + const groups = useFactoryStore(state => state.factory.groups); const [ nickname, setNickname ] = useState(""); const [ filter, setFilter ] = useState(""); + const [ isFluid, setIsFluid ] = useState(false); const [ mode, setMode ] = useState(undefined as string | undefined); useOnSelectionChange({ @@ -25,6 +27,7 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro setFilter(edges.length === 1 ? (pipes[edges[0].id].filter || "") : "..."); setNickname(edges.length === 1 ? (pipes[edges[0].id].nickname || "") : "..."); setMode(edges.length === 1 ? pipes[edges[0].id].mode : "..."); + setIsFluid(edges.length > 0 && groups[pipes[edges[0].id].from].fluid === true); } }); @@ -84,19 +87,8 @@ export function EdgeOptions({ sendMessage, addReqNeedingLayout }: EdgeOptionsPro onInput={ e => setNickname((e.target as HTMLInputElement).value) } />
- -
- - -
-
+
+ { !isFluid && +
+ + +
+ } + +