From 5e9e3e1e4c9d4dc276ca89ac52c312984d253163 Mon Sep 17 00:00:00 2001 From: Lorenzune Date: Wed, 8 Apr 2026 16:18:16 +0200 Subject: [PATCH] Polish wired editor UI and variable handling --- src/api/wired/WiredActionLayoutCode.ts | 2 + src/assets/images/wired/source_furni.png | Bin 0 -> 236 bytes src/assets/images/wired/source_user.png | Bin 0 -> 218 bytes src/assets/images/wired/wired_bg_left.png | Bin 0 -> 737 bytes src/assets/images/wired/wired_bg_right.png | Bin 0 -> 1208 bytes src/components/wired/WiredView.tsx | 17 +- src/components/wired/views/WiredBaseView.tsx | 92 ++-- .../views/WiredFurniSelectionSourceRow.tsx | 6 +- .../wired/views/WiredSourcesSelector.tsx | 11 +- .../views/actions/WiredActionLayoutView.tsx | 5 + ...iredActionNegativeCallAnotherStackView.tsx | 36 ++ .../extras/WiredExtraContextVariableView.tsx | 23 +- .../extras/WiredExtraRoomVariableView.tsx | 23 +- .../extras/WiredExtraUserVariableView.tsx | 23 +- .../extras/WiredExtraVariableEchoView.tsx | 23 +- .../WiredExtraVariableReferenceView.tsx | 23 +- .../WiredExtraVariableTextConnectorView.tsx | 31 +- .../WiredNeighborhoodSelectorView.tsx | 456 ++++++++++++++++++ .../WiredSelectorFurniNeighborhoodView.tsx | 455 +---------------- .../WiredSelectorUsersNeighborhoodView.tsx | 456 +----------------- src/css/index.css | 270 +++++++++-- src/hooks/wired/useWired.ts | 3 + 22 files changed, 926 insertions(+), 1029 deletions(-) create mode 100644 src/assets/images/wired/source_furni.png create mode 100644 src/assets/images/wired/source_user.png create mode 100644 src/assets/images/wired/wired_bg_left.png create mode 100644 src/assets/images/wired/wired_bg_right.png create mode 100644 src/components/wired/views/actions/WiredActionNegativeCallAnotherStackView.tsx create mode 100644 src/components/wired/views/selectors/WiredNeighborhoodSelectorView.tsx diff --git a/src/api/wired/WiredActionLayoutCode.ts b/src/api/wired/WiredActionLayoutCode.ts index 088818b..f3aa61a 100644 --- a/src/api/wired/WiredActionLayoutCode.ts +++ b/src/api/wired/WiredActionLayoutCode.ts @@ -84,4 +84,6 @@ export class WiredActionLayoutCode public static VARIABLE_ECHO_EXTRA: number = 83; public static CONTEXT_VARIABLE_EXTRA: number = 84; public static TEXT_INPUT_VARIABLE_EXTRA: number = 85; + public static NEG_CALL_ANOTHER_STACK: number = 86; + public static NEG_SEND_SIGNAL: number = 87; } diff --git a/src/assets/images/wired/source_furni.png b/src/assets/images/wired/source_furni.png new file mode 100644 index 0000000000000000000000000000000000000000..ed7fe4dff23cd297f57a7ebf2b8196fe0844fac4 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^oIuRY!3HGPMlP2IQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjK*2^&7sn8d;L`q$ye$Siu5UXsH8S#iH5M#% z6ESC$zF-`nG_&S7=kf{FXSdH?eqtG0Qe?q2$&dGhjh%IhbTtK>IW$6ZyiE09?mic0 zTQbdI-Did8H(dNKd;IhKmU`&WEuQ&u%4_QVM%xNb!1@J z*w6hZkrl|72=EDU1=7EN|Nism4K`BS&*7?O{-CY= z>h+n+N7N26XTPwkdvdpSYNu;rqGwf92-8XK+O=FGKg*B(50@Y=O&KttBBYfJ=E5+y-?!T+%XhO@$Y zuYhVe3p^r=85sBufiR<}hF1g7q5nKx978JNj$ZQ2b1@V+eBu7*86|0V|1WbqS+0=% z^lmd}?(J>4FW;8!zFYP7`|rP1vV84_t7Q9+KdzeVxBPO|-1E;rSHtS7lbK!T)6c5p=bKL6v;Vr!r>d(ypFRc}pL`A!jE^^+TvHDe z{2Xk2@_qhUmHK+q&2>L&uC0mKoOHI!R2z+9p&}nPqu+rmvHS4nna!SdYYgNYMGlFz zKR0HdToaLK$E4Y!%XdDVPwnT1Lp3Zx9MLlK&dd0GN^Jefu|!~-h0T1+8BY##eHQdk z%qgs}D>gXUF8WM)g42yhA8MW@Oybu*uC2)FBIa3o;q`uVxBER zB@Ik%-KZuSZg?tc2Fz>rO%|=BE~RYK>e4|=r<{kxp8fH8-mlN|e%2zwfS~8goR_<>B9UwNALTQ=c-swd3YZY2>fXg?&qkJ3a^LOv zGZPo>%Un;Qij%VsVxi#XthCyxgYb>az-SE9f~JZSv;EWAX!QaQav%?Wq^;n4w&G1! zN(gO?bTyIzIqs(f(^i76Vt1PwN@6Z$yZ68D^@K-h#wIp>uzeZReG|SK_8w4qd#OqzU`c$D2dFT(^b^0ki}BVrtS-{xXXdd z5=YGPBNXAyH|*jDhPS$8Xt+t4(DrxqF6bU2=!7Xs0#hj|pn8W)mNsL%YvIP7OSr6y z@w17c3QTj6ZLyx=wPfbLXbMm0dfu}Ox`oWeaVQJBD@(5(qjm;KENX1`w)tk#Dy~ds z){ciNwzO0&Iw%XC!+p~S6syuIwyS9B(2}}W+V7DdoW%%a_1@$ZK{6Ca&n zRtdKYUetCtibvyWMKUuq_o?3Rl76>k;qOKbA)cMmI@ zpwNJ){k2H1P%=P!e}ZTn4jCPhUU-CCZqI)VZTkWqJo<6r5TkyRoMUbg*$8rrxdjGM zZEoqxd)xHf7|FThUVGkv<93mke_DHzkk;lgS_LXsZ# zI(US4TL;JTIe_?)fCMXgctkJ&T45O=VYD9J_-f%CvRQ9(k@|>wT=7wxb6n|#fvR|! zA*0|FL9W-RS;TRE2oUEV01;^g;^nN$e;uC%q5a$Phh;V>-c?O7)LvHlKZ>&WGdH3)& zP`^D6YU7xTw9?fYBQxalj5_$GDBoRL>Bq&=--tD6Y2{w)+=s2I(pz~HYC;tFJy5jd Kv?LXURr?<+b3OF{ literal 0 HcmV?d00001 diff --git a/src/components/wired/WiredView.tsx b/src/components/wired/WiredView.tsx index 0f073ab..73d81e2 100644 --- a/src/components/wired/WiredView.tsx +++ b/src/components/wired/WiredView.tsx @@ -1,5 +1,5 @@ import { ConditionDefinition, TriggerDefinition, WiredActionDefinition } from '@nitrots/nitro-renderer'; -import { FC } from 'react'; +import { FC, Fragment } from 'react'; import { useWired } from '../../hooks'; import { WiredActionLayoutView } from './views/actions/WiredActionLayoutView'; import { WiredConditionLayoutView } from './views/conditions/WiredConditionLayoutView'; @@ -11,11 +11,20 @@ export const WiredView: FC<{}> = props => if(!trigger) return null; - if(trigger instanceof WiredActionDefinition) return WiredActionLayoutView(trigger.code); + if(trigger instanceof WiredActionDefinition) + { + return { WiredActionLayoutView(trigger.code) }; + } - if(trigger instanceof TriggerDefinition) return WiredTriggerLayoutView(trigger.code); + if(trigger instanceof TriggerDefinition) + { + return { WiredTriggerLayoutView(trigger.code) }; + } - if(trigger instanceof ConditionDefinition) return WiredConditionLayoutView(trigger.code); + if(trigger instanceof ConditionDefinition) + { + return { WiredConditionLayoutView(trigger.code) }; + } return null; }; diff --git a/src/components/wired/views/WiredBaseView.tsx b/src/components/wired/views/WiredBaseView.tsx index 681cb4b..0858b71 100644 --- a/src/components/wired/views/WiredBaseView.tsx +++ b/src/components/wired/views/WiredBaseView.tsx @@ -1,6 +1,8 @@ import { GetRoomEngine, GetSessionDataManager } from '@nitrots/nitro-renderer'; import { CSSProperties, FC, PropsWithChildren, ReactNode, useEffect, useState } from 'react'; import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../api'; +import wiredBgLeft from '../../../assets/images/wired/wired_bg_left.png'; +import wiredBgRight from '../../../assets/images/wired/wired_bg_right.png'; import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common'; import { useWired, useWiredTools } from '../../../hooks'; import { WiredFurniSelectorView } from './WiredFurniSelectorView'; @@ -20,6 +22,7 @@ export interface WiredBaseViewProps export const WiredBaseView: FC> = props => { + const WIRED_CARD_WIDTH = 244; const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false, cardStyle = undefined, footer = null, footerCollapsible = true, selectionPreview = null } = props; const [ wiredName, setWiredName ] = useState(null); const [ needsSave, setNeedsSave ] = useState(false); @@ -122,64 +125,53 @@ export const WiredBaseView: FC> = props => const resolvedCardStyle: CSSProperties = { ...cardStyle }; - if(resolvedCardStyle.width !== undefined) - { - if(typeof resolvedCardStyle.width === 'number') - { - resolvedCardStyle.maxWidth = Math.min(resolvedCardStyle.width, 324); - } - else if(typeof resolvedCardStyle.width === 'string') - { - const match = resolvedCardStyle.width.trim().match(/^(\d+(?:\.\d+)?)px$/i); - - resolvedCardStyle.maxWidth = match ? `${ Math.min(parseFloat(match[1]), 324) }px` : resolvedCardStyle.width; - } - - delete resolvedCardStyle.width; - } - - if(resolvedCardStyle.minWidth === undefined) resolvedCardStyle.minWidth = 216; - if(resolvedCardStyle.maxWidth === undefined) resolvedCardStyle.maxWidth = 'min(90vw, 324px)'; + resolvedCardStyle.width = WIRED_CARD_WIDTH; + resolvedCardStyle.minWidth = WIRED_CARD_WIDTH; + resolvedCardStyle.maxWidth = WIRED_CARD_WIDTH; + resolvedCardStyle.resize = 'none'; return ( - +
-
- + + +
{ wiredName }
- { !!children &&
} - { !!children &&
{ children }
} - { (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) && - <> -
-
- { selectionPreview || } -
- } - { footer && - <> -
-
- { footerCollapsible - ? ( - <> - - { showFooter &&
{ footer }
} - - ) - : footer } -
- } -
-
- - +
+ { !!children &&
} + { !!children &&
{ children }
} + { (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) && + <> +
+
+ { selectionPreview || } +
+ } + { footer && + <> +
+
+ { footerCollapsible + ? ( + <> + + { showFooter &&
{ footer }
} + + ) + : footer } +
+ } +
+
+ + +
diff --git a/src/components/wired/views/WiredFurniSelectionSourceRow.tsx b/src/components/wired/views/WiredFurniSelectionSourceRow.tsx index b064d80..3037205 100644 --- a/src/components/wired/views/WiredFurniSelectionSourceRow.tsx +++ b/src/components/wired/views/WiredFurniSelectionSourceRow.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react'; +import { FC, ReactNode } from 'react'; import { FaChevronLeft, FaChevronRight, FaMousePointer } from 'react-icons/fa'; import { LocalizeText } from '../../../api'; import { Button, Text } from '../../../common'; @@ -16,13 +16,14 @@ interface WiredFurniSelectionSourceRowProps selectionLimit: number; selectionEnabledValues: number[]; showSelectionToggle?: boolean; + headerContent?: ReactNode; onChange: (value: number) => void; onSelectionActivate?: () => void; } export const WiredFurniSelectionSourceRow: FC = props => { - const { title = '', titleIsLiteral = false, options = [], value = 0, selectionKind = 'primary', selectionActive = false, selectionCount = 0, selectionLimit = 0, selectionEnabledValues = [], showSelectionToggle = true, onChange = null, onSelectionActivate = null } = props; + const { title = '', titleIsLiteral = false, options = [], value = 0, selectionKind = 'primary', selectionActive = false, selectionCount = 0, selectionLimit = 0, selectionEnabledValues = [], showSelectionToggle = true, headerContent = null, onChange = null, onSelectionActivate = null } = props; const currentIndex = Math.max(0, options.findIndex(option => (option.value === value))); const currentOption = options[currentIndex] ?? options[0]; const canActivateSelection = !!onSelectionActivate && selectionEnabledValues.includes(currentOption?.value); @@ -45,6 +46,7 @@ export const WiredFurniSelectionSourceRow: FC
{ resolvedTitle } + { headerContent } { showSelectionToggle &&