import { FC, useEffect, useState } from 'react'; import { LocalizeText, WiredFurniType } from '../../../../api'; import { Text } from '../../../../common'; import { useWired } from '../../../../hooks'; import { WiredActionBaseView } from './WiredActionBaseView'; import { WiredSourcesSelector } from '../WiredSourcesSelector'; const directionOptions: { value: number, icon: string }[] = [ { value: 4, icon: 'ne' }, { value: 5, icon: 'se' }, { value: 6, icon: 'sw' }, { value: 7, icon: 'nw' }, { value: 2, icon: 'mv-2' }, { value: 3, icon: 'mv-3' }, { value: 1, icon: 'mv-1' } ]; const rotationOptions: number[] = [ 0, 1, 2, 3 ]; export const WiredActionMoveFurniView: FC<{}> = props => { const [ movement, setMovement ] = useState(-1); const [ rotation, setRotation ] = useState(-1); const { trigger = null, setIntParams = null } = useWired(); const [ furniSource, setFurniSource ] = useState(() => { if(trigger?.intData?.length > 2) return trigger.intData[2]; return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0; }); const save = () => setIntParams([ movement, rotation, furniSource ]); useEffect(() => { if(trigger.intData.length >= 2) { setMovement(trigger.intData[0]); setRotation(trigger.intData[1]); } else { setMovement(-1); setRotation(-1); } if(trigger.intData.length > 2) setFurniSource(trigger.intData[2]); else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0); }, [ trigger ]); const onChangeFurniSource = (next: number) => setFurniSource(next); const requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT; return ( }>
{ LocalizeText('wiredfurni.params.movefurni') }
setMovement(0) } /> { LocalizeText('wiredfurni.params.movefurni.0') }
{ directionOptions.map(option => { return (
setMovement(option.value) } />
); }) }
{ LocalizeText('wiredfurni.params.rotatefurni') } { rotationOptions.map(option => { return (
setRotation(option) } /> { [ 1, 2 ].includes(option) && } { LocalizeText(`wiredfurni.params.rotatefurni.${ option }`) }
); }) }
); };