mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
feat(wired-ui): expand advanced wired editors
This commit is contained in:
@@ -1,28 +1,41 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredConditionBaseView } from './WiredConditionBaseView';
|
||||
import { WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
|
||||
export const WiredConditionFurniHasAvatarOnView: FC<{}> = props =>
|
||||
interface WiredConditionFurniHasAvatarOnViewProps
|
||||
{
|
||||
negative?: boolean;
|
||||
}
|
||||
|
||||
export const WiredConditionFurniHasAvatarOnView: FC<WiredConditionFurniHasAvatarOnViewProps> = ({ negative = false }) =>
|
||||
{
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
const [ requireAll, setRequireAll ] = useState(0);
|
||||
const [ furniSource, setFurniSource ] = useState<number>(() =>
|
||||
{
|
||||
if(trigger?.intData?.length >= 1) return trigger.intData[0];
|
||||
if(trigger?.intData?.length > 1) return trigger.intData[1];
|
||||
if(trigger?.intData?.length >= 1 && trigger.intData[0] > 1) return trigger.intData[0];
|
||||
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
|
||||
});
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(!trigger) return;
|
||||
if(trigger.intData.length >= 1) setFurniSource(trigger.intData[0]);
|
||||
|
||||
if(trigger.intData.length >= 1) setRequireAll(trigger.intData[0] === 1 ? 1 : 0);
|
||||
else setRequireAll(0);
|
||||
|
||||
if(trigger.intData.length > 1) setFurniSource(trigger.intData[1]);
|
||||
else if(trigger.intData.length >= 1 && trigger.intData[0] > 1) setFurniSource(trigger.intData[0]);
|
||||
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
|
||||
}, [ trigger ]);
|
||||
|
||||
const onChangeFurniSource = (next: number) => setFurniSource(next);
|
||||
|
||||
const save = () => setIntParams([ furniSource ]);
|
||||
const save = () => setIntParams([ requireAll, furniSource ]);
|
||||
|
||||
const requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_BY_ID;
|
||||
|
||||
@@ -31,6 +44,16 @@ export const WiredConditionFurniHasAvatarOnView: FC<{}> = props =>
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ requiresFurni }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.requireall') }</Text>
|
||||
{ [ 0, 1 ].map(value => (
|
||||
<label key={ value } className="flex items-center gap-1">
|
||||
<input checked={ (requireAll === value) } className="form-check-input" name="furniHasAvatarRequireAll" type="radio" onChange={ () => setRequireAll(value) } />
|
||||
<Text>{ LocalizeText(`wiredfurni.params.${ negative ? 'not_requireall' : 'requireall' }.${ value + 2 }`) }</Text>
|
||||
</label>
|
||||
)) }
|
||||
</div>
|
||||
</WiredConditionBaseView>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user