Polish wired extra and trigger editors

This commit is contained in:
Lorenzune
2026-03-24 02:11:54 +01:00
parent 3e20f65f3a
commit bf05948e86
8 changed files with 109 additions and 16 deletions
@@ -1,5 +1,5 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { WiredFurniType } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredExtraBaseView } from './WiredExtraBaseView';
@@ -37,9 +37,7 @@ export const WiredExtraAnimationTimeView: FC<{}> = () =>
return (
<WiredExtraBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save } cardStyle={ { width: 380 } }>
<div className="flex flex-col gap-2">
<Text bold>{ LocalizeText('wiredfurni.params.anim_time.title') }</Text>
<Text>{ LocalizeText('wiredfurni.params.anim_time.description') }</Text>
<Text bold>{ LocalizeText('wiredfurni.params.anim_time.value', [ 'ms' ], [ duration.toString() ]) }</Text>
<Text bold>{ duration } ms</Text>
<Slider min={ MIN_DURATION } max={ MAX_DURATION } step={ STEP_DURATION } value={ duration } onChange={ value => setDuration(normalizeDuration(Array.isArray(value) ? value[0] : Number(value))) } />
</div>
</WiredExtraBaseView>
@@ -1,6 +1,5 @@
import { FC } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { Text } from '../../../../common';
import { WiredFurniType } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredExtraBaseView } from './WiredExtraBaseView';
@@ -14,12 +13,5 @@ export const WiredExtraMoveNoAnimationView: FC<{}> = () =>
setStringParam('');
};
return (
<WiredExtraBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save } cardStyle={ { width: 360 } }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.mov_no_animation.title') }</Text>
<Text>{ LocalizeText('wiredfurni.params.mov_no_animation.description') }</Text>
</div>
</WiredExtraBaseView>
);
return <WiredExtraBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save } cardStyle={ { width: 320 } } />;
};
@@ -0,0 +1,71 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredExtraBaseView } from './WiredExtraBaseView';
const MIN_PICK_AMOUNT = 1;
const MIN_SKIP_EXECUTIONS = 0;
const MAX_RANDOM_VALUE = 1000;
const normalizePickAmount = (value: number) =>
{
if(isNaN(value)) return MIN_PICK_AMOUNT;
return Math.max(MIN_PICK_AMOUNT, Math.min(MAX_RANDOM_VALUE, Math.floor(value)));
};
const normalizeSkipExecutions = (value: number) =>
{
if(isNaN(value)) return MIN_SKIP_EXECUTIONS;
return Math.max(MIN_SKIP_EXECUTIONS, Math.min(MAX_RANDOM_VALUE, Math.floor(value)));
};
export const WiredExtraRandomView: FC<{}> = () =>
{
const { trigger = null, setIntParams = null, setStringParam = null } = useWired();
const [ pickAmount, setPickAmount ] = useState(MIN_PICK_AMOUNT);
const [ skipExecutions, setSkipExecutions ] = useState(MIN_SKIP_EXECUTIONS);
useEffect(() =>
{
if(!trigger) return;
setPickAmount(normalizePickAmount((trigger.intData.length > 0) ? trigger.intData[0] : MIN_PICK_AMOUNT));
setSkipExecutions(normalizeSkipExecutions((trigger.intData.length > 1) ? trigger.intData[1] : MIN_SKIP_EXECUTIONS));
}, [ trigger ]);
const save = () =>
{
setIntParams([ normalizePickAmount(pickAmount), normalizeSkipExecutions(skipExecutions) ]);
setStringParam('');
};
return (
<WiredExtraBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save } cardStyle={ { width: 380 } }>
<div className="flex flex-col gap-2">
<div className="flex flex-col gap-1">
<Text>{ LocalizeText('wiredfurni.params.pickamount', [ 'picks' ], [ pickAmount.toString() ]) }</Text>
<Slider
max={ MAX_RANDOM_VALUE }
min={ MIN_PICK_AMOUNT }
step={ 1 }
value={ pickAmount }
onChange={ value => setPickAmount(normalizePickAmount(Array.isArray(value) ? value[0] : Number(value))) } />
<Text small>{ pickAmount }</Text>
</div>
<div className="flex flex-col gap-1">
<Text>{ LocalizeText('wiredfurni.params.skipactions', [ 'skips' ], [ skipExecutions.toString() ]) }</Text>
<Slider
max={ MAX_RANDOM_VALUE }
min={ MIN_SKIP_EXECUTIONS }
step={ 1 }
value={ skipExecutions }
onChange={ value => setSkipExecutions(normalizeSkipExecutions(Array.isArray(value) ? value[0] : Number(value))) } />
<Text small>{ skipExecutions }</Text>
</div>
</div>
</WiredExtraBaseView>
);
};
@@ -0,0 +1,17 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredExtraBaseView } from './WiredExtraBaseView';
export const WiredExtraUnseenView: FC<{}> = () =>
{
const { setIntParams = null, setStringParam = null } = useWired();
const save = () =>
{
setIntParams([]);
setStringParam('');
};
return <WiredExtraBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save } cardStyle={ { width: 320 } } />;
};