feat(wired-ui): expand advanced wired editors

This commit is contained in:
Lorenzune
2026-03-21 14:27:57 +01:00
parent cb0a9242b5
commit 27cb71f0cc
90 changed files with 3529 additions and 538 deletions
@@ -2,34 +2,17 @@ import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredDirectionIcon, WIRED_DIRECTION_GRID } from '../WiredDirectionIcon';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const directionOptions: { value: number, icon: string }[] = [
{
value: 0,
icon: 'ne'
},
{
value: 2,
icon: 'se'
},
{
value: 4,
icon: 'sw'
},
{
value: 6,
icon: 'nw'
}
];
const rotationOptions: number[] = [ 0, 1, 2, 3, 4, 5, 6 ];
export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
{
const [ movement, setMovement ] = useState(-1);
const [ rotation, setRotation ] = useState(-1);
const [ blockOnUserCollision, setBlockOnUserCollision ] = useState(false);
const { trigger = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
@@ -37,7 +20,7 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ movement, rotation, furniSource ]);
const save = () => setIntParams([ movement, rotation, furniSource, blockOnUserCollision ? 1 : 0 ]);
useEffect(() =>
{
@@ -54,6 +37,8 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
if(trigger.intData.length > 2) setFurniSource(trigger.intData[2]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
setBlockOnUserCollision((trigger.intData?.length ?? 0) > 3 ? trigger.intData[3] === 1 : false);
}, [ trigger ]);
const onChangeFurniSource = (next: number) => setFurniSource(next);
@@ -68,18 +53,23 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.startdir') }</Text>
<div className="flex gap-1">
{ directionOptions.map(option =>
<div className="grid grid-cols-4 gap-2 max-w-[240px]">
{ WIRED_DIRECTION_GRID.flatMap((row, rowIndex) => row.map((direction, columnIndex) =>
{
if(direction === null)
{
return <div key={ `move-to-dir-empty-${ rowIndex }-${ columnIndex }` } />;
}
return (
<div key={ option.value } className="flex items-center gap-1">
<input checked={ (movement === option.value) } className="form-check-input" id={ `movement${ option.value }` } name="movement" type="radio" onChange={ event => setMovement(option.value) } />
<Text>
<i className={ `icon icon-${ option.icon }` } />
</Text>
</div>
<label key={ `move-to-dir-${ direction }` } className="flex items-center justify-center gap-[2px] cursor-pointer">
<input checked={ (movement === direction) } className="form-check-input" id={ `movement${ direction }` } name="movement" type="radio" onChange={ () => setMovement(direction) } />
<span className="inline-flex items-center justify-center">
<WiredDirectionIcon direction={ direction } selected={ movement === direction } />
</span>
</label>
);
}) }
})) }
</div>
</div>
<div className="flex flex-col gap-1">
@@ -94,6 +84,13 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
);
}) }
</div>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.user_collide') }</Text>
<label className="flex items-center gap-1 cursor-pointer">
<input checked={ blockOnUserCollision } className="form-check-input" type="checkbox" onChange={ event => setBlockOnUserCollision(event.target.checked) } />
<Text>{ LocalizeText('wiredfurni.params.user_collide.0') }</Text>
</label>
</div>
</WiredActionBaseView>
);
};