mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
More wired changes
This commit is contained in:
parent
93274670ce
commit
f172442cbc
@ -11,7 +11,7 @@ export const WiredView: FC<{}> = props =>
|
||||
const [ intParams, setIntParams ] = useState<number[]>([]);
|
||||
const [ stringParam, setStringParam ] = useState<string>('');
|
||||
const [ furniIds, setFurniIds ] = useState<number[]>([]);
|
||||
const [ actionDelay, setActionDelay ] = useState<number>(null);
|
||||
const [ actionDelay, setActionDelay ] = useState<number>(0);
|
||||
|
||||
const saveWired = () =>
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { WiredActionDefinition } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { FC, useEffect } from 'react';
|
||||
import ReactSlider from 'react-slider';
|
||||
import { GetWiredTimeLocale, LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Column, Text } from '../../../../common';
|
||||
@ -16,33 +16,25 @@ export interface WiredActionBaseViewProps
|
||||
export const WiredActionBaseView: FC<WiredActionBaseViewProps> = props =>
|
||||
{
|
||||
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, hasSpecialInput = false, children = null } = props;
|
||||
const [ delay, setDelay ] = useState(-1);
|
||||
const { trigger = null, setActionDelay = null } = useWiredContext();
|
||||
const { trigger = null, actionDelay = 0, setActionDelay = null } = useWiredContext();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setDelay((trigger as WiredActionDefinition).delayInPulses);
|
||||
}, [ trigger ]);
|
||||
|
||||
const onSave = useCallback(() =>
|
||||
{
|
||||
if(save) save();
|
||||
|
||||
setActionDelay(delay);
|
||||
}, [ delay, save, setActionDelay ]);
|
||||
setActionDelay((trigger as WiredActionDefinition).delayInPulses);
|
||||
}, [ trigger, setActionDelay ]);
|
||||
|
||||
return (
|
||||
<WiredBaseView wiredType="action" requiresFurni={ requiresFurni } save={ onSave } hasSpecialInput={ hasSpecialInput }>
|
||||
<WiredBaseView wiredType="action" requiresFurni={ requiresFurni } save={ save } hasSpecialInput={ hasSpecialInput }>
|
||||
{ children }
|
||||
{ !!children && <hr className="m-0 bg-dark" /> }
|
||||
<Column>
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.delay', [ 'seconds' ], [ GetWiredTimeLocale(delay) ]) }</Text>
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.delay', [ 'seconds' ], [ GetWiredTimeLocale(actionDelay) ]) }</Text>
|
||||
<ReactSlider
|
||||
className={ 'nitro-slider' }
|
||||
min={ 0 }
|
||||
max={ 20 }
|
||||
value={ delay }
|
||||
onChange={ event => setDelay(event) } />
|
||||
value={ actionDelay }
|
||||
onChange={ event => setActionDelay(event) } />
|
||||
</Column>
|
||||
</WiredBaseView>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user