wired ui: add source selector support

This commit is contained in:
Lorenzune
2026-03-15 19:02:34 +01:00
parent bdae069003
commit ba0208c654
37 changed files with 1095 additions and 104 deletions
+14 -3
View File
@@ -1,5 +1,5 @@
import { GetSessionDataManager } from '@nitrots/nitro-renderer';
import { CSSProperties, FC, PropsWithChildren, useEffect, useState } from 'react';
import { CSSProperties, FC, PropsWithChildren, ReactNode, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../api';
import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common';
import { useWired } from '../../../hooks';
@@ -13,11 +13,12 @@ export interface WiredBaseViewProps
save: () => void;
validate?: () => boolean;
cardStyle?: CSSProperties;
footer?: ReactNode;
}
export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
{
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false, cardStyle = undefined } = props;
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false, cardStyle = undefined, footer = null } = props;
const [ wiredName, setWiredName ] = useState<string>(null);
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
const [ needsSave, setNeedsSave ] = useState<boolean>(false);
@@ -83,9 +84,14 @@ export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
return [];
});
}
}, [ trigger, hasSpecialInput, setIntParams, setStringParam, setFurniIds ]);
useEffect(() =>
{
if(!trigger) return;
setAllowsFurni(requiresFurni);
}, [ trigger, hasSpecialInput, requiresFurni, setIntParams, setStringParam, setFurniIds, setAllowsFurni ]);
}, [ trigger, requiresFurni, setAllowsFurni ]);
return (
<NitroCardView className="nitro-wired" theme="primary-slim" uniqueKey="nitro-wired" style={ cardStyle }>
@@ -105,6 +111,11 @@ export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
<hr className="m-0 bg-dark" />
<WiredFurniSelectorView />
</> }
{ footer &&
<>
<hr className="m-0 bg-dark" />
{ footer }
</> }
<div className="flex items-center gap-1">
<Button fullWidth variant="success" onClick={ onSave }>{ LocalizeText('wiredfurni.ready') }</Button>
<Button fullWidth variant="secondary" onClick={ onClose }>{ LocalizeText('cancel') }</Button>
@@ -0,0 +1,92 @@
import { FC } from 'react';
import { FaChevronLeft, FaChevronRight } from 'react-icons/fa';
import { LocalizeText } from '../../../api';
import { Button, Text } from '../../../common';
export const FURNI_SOURCES = [
{ value: 0, label: 'wiredfurni.params.sources.furni.0' },
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
{ value: 200, label: 'wiredfurni.params.sources.furni.200' },
{ value: 201, label: 'wiredfurni.params.sources.furni.201' }
];
export const USER_SOURCES = [
{ value: 0, label: 'wiredfurni.params.sources.users.0' },
{ value: 200, label: 'wiredfurni.params.sources.users.200' },
{ value: 201, label: 'wiredfurni.params.sources.users.201' }
];
interface WiredSourcesSelectorProps
{
showFurni?: boolean;
showUsers?: boolean;
furniSource?: number;
userSource?: number;
onChangeFurni?: (source: number) => void;
onChangeUsers?: (source: number) => void;
}
export const WiredSourcesSelector: FC<WiredSourcesSelectorProps> = props =>
{
const { showFurni = false, showUsers = false, furniSource = 0, userSource = 0, onChangeFurni = null, onChangeUsers = null } = props;
const furniIndex = Math.max(0, FURNI_SOURCES.findIndex(s => s.value === furniSource));
const userIndex = Math.max(0, USER_SOURCES.findIndex(s => s.value === userSource));
const prevFurni = () =>
{
const next = (furniIndex - 1 + FURNI_SOURCES.length) % FURNI_SOURCES.length;
onChangeFurni && onChangeFurni(FURNI_SOURCES[next].value);
};
const nextFurni = () =>
{
const next = (furniIndex + 1) % FURNI_SOURCES.length;
onChangeFurni && onChangeFurni(FURNI_SOURCES[next].value);
};
const prevUsers = () =>
{
const next = (userIndex - 1 + USER_SOURCES.length) % USER_SOURCES.length;
onChangeUsers && onChangeUsers(USER_SOURCES[next].value);
};
const nextUsers = () =>
{
const next = (userIndex + 1) % USER_SOURCES.length;
onChangeUsers && onChangeUsers(USER_SOURCES[next].value);
};
if(!showFurni && !showUsers) return null;
return (
<div className="flex flex-col gap-2">
{ showFurni &&
<>
<Text bold>{ LocalizeText('wiredfurni.params.sources.furni.title') }</Text>
<div className="flex items-center gap-2">
<Button variant="primary" className="px-2 py-1" onClick={ prevFurni }><FaChevronLeft /></Button>
<div className="flex flex-1 items-center justify-center">
<Text small>{ LocalizeText(FURNI_SOURCES[furniIndex].label) }</Text>
</div>
<Button variant="primary" className="px-2 py-1" onClick={ nextFurni }><FaChevronRight /></Button>
</div>
</> }
{ showFurni && showUsers && <hr className="m-0 bg-dark" /> }
{ showUsers &&
<>
<Text bold>{ LocalizeText('wiredfurni.params.sources.users.title') }</Text>
<div className="flex items-center gap-2">
<Button variant="primary" className="px-2 py-1" onClick={ prevUsers }><FaChevronLeft /></Button>
<div className="flex flex-1 items-center justify-center">
<Text small>{ LocalizeText(USER_SOURCES[userIndex].label) }</Text>
</div>
<Button variant="primary" className="px-2 py-1" onClick={ nextUsers }><FaChevronRight /></Button>
</div>
</> }
</div>
);
};
@@ -1,5 +1,5 @@
import { WiredActionDefinition } from '@nitrots/nitro-renderer';
import { CSSProperties, FC, PropsWithChildren, useEffect } from 'react';
import { CSSProperties, FC, PropsWithChildren, ReactNode, useEffect } from 'react';
import { GetWiredTimeLocale, LocalizeText, WiredFurniType } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
@@ -13,11 +13,12 @@ export interface WiredActionBaseViewProps
validate?: () => boolean;
cardStyle?: CSSProperties;
hideDelay?: boolean;
footer?: ReactNode;
}
export const WiredActionBaseView: FC<PropsWithChildren<WiredActionBaseViewProps>> = props =>
{
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, hasSpecialInput = false, children = null, cardStyle = undefined, hideDelay = false } = props;
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, hasSpecialInput = false, children = null, cardStyle = undefined, hideDelay = false, footer = null } = props;
const { trigger = null, actionDelay = 0, setActionDelay = null } = useWired();
useEffect(() =>
@@ -26,7 +27,7 @@ export const WiredActionBaseView: FC<PropsWithChildren<WiredActionBaseViewProps>
}, [ trigger, setActionDelay ]);
return (
<WiredBaseView hasSpecialInput={ hasSpecialInput } requiresFurni={ requiresFurni } save={ save } validate={ validate } wiredType="action" cardStyle={ cardStyle }>
<WiredBaseView hasSpecialInput={ hasSpecialInput } requiresFurni={ requiresFurni } save={ save } validate={ validate } wiredType="action" cardStyle={ cardStyle } footer={ footer }>
{ children }
{ !hideDelay && !!children && <hr className="m-0 bg-dark" /> }
{ !hideDelay && <div className="flex flex-col">
@@ -4,27 +4,38 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionBotFollowAvatarView: FC<{}> = props =>
{
const [ botName, setBotName ] = useState('');
const [ followMode, setFollowMode ] = useState(-1);
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () =>
{
setStringParam(botName);
setIntParams([ followMode ]);
setIntParams([ followMode, userSource ]);
};
useEffect(() =>
{
setBotName(trigger.stringData);
setFollowMode((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
@@ -4,6 +4,7 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const ALLOWED_HAND_ITEM_IDS: number[] = [ 2, 5, 7, 8, 9, 10, 27 ];
@@ -12,21 +13,31 @@ export const WiredActionBotGiveHandItemView: FC<{}> = props =>
const [ botName, setBotName ] = useState('');
const [ handItemId, setHandItemId ] = useState(-1);
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () =>
{
setStringParam(botName);
setIntParams([ handItemId ]);
setIntParams([ handItemId, userSource ]);
};
useEffect(() =>
{
setBotName(trigger.stringData);
setHandItemId((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
@@ -1,24 +1,62 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionBotMoveView: FC<{}> = props =>
{
const [ botName, setBotName ] = useState('');
const { trigger = null, setStringParam = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setStringParam = null, setIntParams = null } = useWired();
const save = () => setStringParam(botName);
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () =>
{
setStringParam(botName);
setIntParams([ furniSource ]);
};
useEffect(() =>
{
if(!trigger) return;
setBotName(trigger.stringData);
if(trigger.intData.length >= 1) setFurniSource(trigger.intData[0]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
@@ -4,6 +4,7 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionBotTalkToAvatarView: FC<{}> = props =>
{
@@ -11,11 +12,16 @@ export const WiredActionBotTalkToAvatarView: FC<{}> = props =>
const [ message, setMessage ] = useState('');
const [ talkMode, setTalkMode ] = useState(-1);
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () =>
{
setStringParam(botName + WIRED_STRING_DELIMETER + message);
setIntParams([ talkMode ]);
setIntParams([ talkMode, userSource ]);
};
useEffect(() =>
@@ -26,10 +32,15 @@ export const WiredActionBotTalkToAvatarView: FC<{}> = props =>
if(data.length > 1) setMessage(data[1].length > 0 ? data[1] : '');
setTalkMode((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
@@ -1,24 +1,62 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionBotTeleportView: FC<{}> = props =>
{
const [ botName, setBotName ] = useState('');
const { trigger = null, setStringParam = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setStringParam = null, setIntParams = null } = useWired();
const save = () => setStringParam(botName);
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () =>
{
setStringParam(botName);
setIntParams([ furniSource ]);
};
useEffect(() =>
{
if(!trigger) return;
setBotName(trigger.stringData);
if(trigger.intData.length >= 1) setFurniSource(trigger.intData[0]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.bot.name') }</Text>
<NitroInput maxLength={ 32 } type="text" value={ botName } onChange={ event => setBotName(event.target.value) } />
@@ -1,8 +1,51 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionCallAnotherStackView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -1,8 +1,51 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionChaseView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -4,21 +4,37 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionChatView: FC<{}> = props =>
{
const [ message, setMessage ] = useState('');
const { trigger = null, setStringParam = null } = useWired();
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return 0;
});
const save = () => setStringParam(message);
const save = () =>
{
setStringParam(message);
setIntParams([ userSource ]);
};
useEffect(() =>
{
setMessage(trigger.stringData);
if(trigger.intData.length >= 1) setUserSource(trigger.intData[0]);
else setUserSource(0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.message') }</Text>
<NitroInput maxLength={ GetConfigurationValue<number>('wired.action.chat.max.length', 100) } type="text" value={ message } onChange={ event => setMessage(event.target.value) } />
@@ -1,8 +1,51 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionFleeView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -5,6 +5,7 @@ import { Button, Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionGiveRewardView: FC<{}> = props =>
{
@@ -15,6 +16,11 @@ export const WiredActionGiveRewardView: FC<{}> = props =>
const [ limitationInterval, setLimitationInterval ] = useState(1);
const [ rewards, setRewards ] = useState<{ isBadge: boolean, itemCode: string, probability: number }[]>([]);
const { trigger = null, setIntParams = null, setStringParam = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 4) return trigger.intData[4];
return 0;
});
const addReward = () => setRewards(rewards => [ ...rewards, { isBadge: false, itemCode: '', probability: null } ]);
@@ -59,7 +65,7 @@ export const WiredActionGiveRewardView: FC<{}> = props =>
if(stringRewards.length > 0)
{
setStringParam(stringRewards.join(';'));
setIntParams([ rewardTime, uniqueRewards ? 1 : 0, rewardsLimit, limitationInterval ]);
setIntParams([ rewardTime, uniqueRewards ? 1 : 0, rewardsLimit, limitationInterval, userSource ]);
}
};
@@ -88,11 +94,16 @@ export const WiredActionGiveRewardView: FC<{}> = props =>
setRewardsLimit((trigger.intData.length > 2) ? trigger.intData[2] : 0);
setLimitationInterval((trigger.intData.length > 3) ? trigger.intData[3] : 0);
setLimitEnabled((trigger.intData.length > 3) ? trigger.intData[3] > 0 : false);
setUserSource((trigger.intData.length > 4) ? trigger.intData[4] : 0);
setRewards(readRewards);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex items-center gap-1">
<input className="form-check-input" id="limitEnabled" type="checkbox" onChange={ event => setLimitEnabled(event.target.checked) } />
<Text>{ LocalizeText('wiredfurni.params.prizelimit', [ 'amount' ], [ limitEnabled ? rewardsLimit.toString() : '' ]) }</Text>
@@ -3,14 +3,20 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionGiveScoreView: FC<{}> = props =>
{
const [ points, setPoints ] = useState(1);
const [ time, setTime ] = useState(1);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 2) return trigger.intData[2];
return 0;
});
const save = () => setIntParams([ points, time ]);
const save = () => setIntParams([ points, time, userSource ]);
useEffect(() =>
{
@@ -24,10 +30,16 @@ export const WiredActionGiveScoreView: FC<{}> = props =>
setPoints(1);
setTime(1);
}
setUserSource((trigger.intData.length > 2) ? trigger.intData[2] : 0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.setpoints', [ 'points' ], [ points.toString() ]) }</Text>
<Slider
@@ -3,21 +3,32 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionJoinTeamView: FC<{}> = props =>
{
const [ selectedTeam, setSelectedTeam ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () => setIntParams([ selectedTeam ]);
const save = () => setIntParams([ selectedTeam, userSource ]);
useEffect(() =>
{
setSelectedTeam((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.team') }</Text>
{ [ 1, 2, 3, 4 ].map(team =>
@@ -4,21 +4,37 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionKickFromRoomView: FC<{}> = props =>
{
const [ message, setMessage ] = useState('');
const { trigger = null, setStringParam = null } = useWired();
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return 0;
});
const save = () => setStringParam(message);
const save = () =>
{
setStringParam(message);
setIntParams([ userSource ]);
};
useEffect(() =>
{
setMessage(trigger.stringData);
if(trigger.intData.length >= 1) setUserSource(trigger.intData[0]);
else setUserSource(0);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.message') }</Text>
<NitroInput maxLength={ GetConfigurationValue<number>('wired.action.kick.from.room.max.length', 100) } type="text" value={ message } onChange={ event => setMessage(event.target.value) } />
@@ -1,8 +1,32 @@
import { FC } from 'react';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionLeaveTeamView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ null } />;
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return 0;
});
useEffect(() =>
{
if(!trigger) return;
if(trigger.intData.length >= 1) setUserSource(trigger.intData[0]);
else setUserSource(0);
}, [ trigger ]);
const save = () => setIntParams([ userSource ]);
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> } />
);
};
@@ -1,8 +1,9 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const directionOptions: { value: number, icon: string }[] = [
{
@@ -29,9 +30,14 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
{
const [ movement, setMovement ] = useState(-1);
const [ rotation, setRotation ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 2) return trigger.intData[2];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ movement, rotation ]);
const save = () => setIntParams([ movement, rotation, furniSource ]);
useEffect(() =>
{
@@ -45,10 +51,35 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props =>
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) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
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">
@@ -1,8 +1,9 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const directionOptions: { value: number, icon: string }[] = [
{
@@ -27,9 +28,14 @@ export const WiredActionMoveFurniToView: FC<{}> = props =>
{
const [ spacing, setSpacing ] = useState(-1);
const [ movement, setMovement ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 2) return trigger.intData[2];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ movement, spacing ]);
const save = () => setIntParams([ movement, spacing, furniSource ]);
useEffect(() =>
{
@@ -43,10 +49,35 @@ export const WiredActionMoveFurniToView: FC<{}> = props =>
setSpacing(-1);
setMovement(-1);
}
if(trigger.intData.length > 2) setFurniSource(trigger.intData[2]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.emptytiles', [ 'tiles' ], [ spacing.toString() ]) }</Text>
<Slider
@@ -1,8 +1,9 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const directionOptions: { value: number, icon: string }[] = [
{
@@ -41,9 +42,14 @@ export const WiredActionMoveFurniView: FC<{}> = props =>
{
const [ movement, setMovement ] = useState(-1);
const [ rotation, setRotation ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 2) return trigger.intData[2];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ movement, rotation ]);
const save = () => setIntParams([ movement, rotation, furniSource ]);
useEffect(() =>
{
@@ -57,10 +63,35 @@ export const WiredActionMoveFurniView: FC<{}> = props =>
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) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.movefurni') }</Text>
<div className="flex items-center gap-1">
@@ -4,27 +4,38 @@ import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionMuteUserView: FC<{}> = props =>
{
const [ time, setTime ] = useState(-1);
const [ message, setMessage ] = useState('');
const { trigger = null, setIntParams = null, setStringParam = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () =>
{
setIntParams([ time ]);
setIntParams([ time, userSource ]);
setStringParam(message);
};
useEffect(() =>
{
setTime((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
setMessage(trigger.stringData);
}, [ trigger ]);
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.length.minutes', [ 'minutes' ], [ time.toString() ]) }</Text>
<Slider
@@ -1,27 +1,58 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionSetFurniStateToView: FC<{}> = props =>
{
const [ stateFlag, setStateFlag ] = useState(0);
const [ directionFlag, setDirectionFlag ] = useState(0);
const [ positionFlag, setPositionFlag ] = useState(0);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 3) return trigger.intData[3];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]);
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag, furniSource ]);
useEffect(() =>
{
setStateFlag(trigger.getBoolean(0) ? 1 : 0);
setDirectionFlag(trigger.getBoolean(1) ? 1 : 0);
setPositionFlag(trigger.getBoolean(2) ? 1 : 0);
if(trigger.intData.length > 3) setFurniSource(trigger.intData[3]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text>
<div className="flex items-center gap-1">
@@ -1,8 +1,69 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredActionTeleportView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 2) return trigger.intData[1];
return 0;
});
useEffect(() =>
{
if(!trigger) return;
if(trigger.intData.length >= 1) setFurniSource(trigger.intData[0]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
if(trigger.intData.length >= 2) setUserSource(trigger.intData[1]);
else setUserSource(0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource, userSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={
<WiredSourcesSelector
showFurni={ true }
showUsers={ true }
furniSource={ furniSource }
userSource={ userSource }
onChangeFurni={ onChangeFurniSource }
onChangeUsers={ setUserSource } />
} />
);
};
@@ -1,8 +1,51 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { WiredActionBaseView } from './WiredActionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
import { useWired } from '../../../../hooks';
export const WiredActionToggleFurniStateView: FC<{}> = props =>
{
return <WiredActionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredActionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -3,6 +3,7 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const ALLOWED_HAND_ITEM_IDS: number[] = [ 2, 5, 7, 8, 9, 10, 27 ];
@@ -10,16 +11,26 @@ export const WiredConditionActorHasHandItemView: FC<{}> = props =>
{
const [ handItemId, setHandItemId ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () => setIntParams([ handItemId ]);
const save = () => setIntParams([ handItemId, userSource ]);
useEffect(() =>
{
setHandItemId((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.handitem') }</Text>
<select className="form-select form-select-sm" value={ handItemId } onChange={ event => setHandItemId(parseInt(event.target.value)) }>
@@ -1,8 +1,32 @@
import { FC } from 'react';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionActorIsGroupMemberView: FC<{}> = props =>
{
return <WiredConditionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ null } />;
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return 0;
});
useEffect(() =>
{
if(!trigger) return;
if(trigger.intData.length >= 1) setUserSource(trigger.intData[0]);
else setUserSource(0);
}, [ trigger ]);
const save = () => setIntParams([ userSource ]);
return (
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> } />
);
};
@@ -1,8 +1,67 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionActorIsOnFurniView: FC<{}> = props =>
{
return <WiredConditionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 0) return trigger.intData[0];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
useEffect(() =>
{
if(!trigger) return;
if(trigger.intData.length > 0) setFurniSource(trigger.intData[0]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
if(trigger.intData.length > 1) setUserSource(trigger.intData[1]);
else setUserSource(0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource, userSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ (
<WiredSourcesSelector
showFurni={ true }
showUsers={ true }
furniSource={ furniSource }
userSource={ userSource }
onChangeFurni={ onChangeFurniSource }
onChangeUsers={ setUserSource } />
) } />
);
};
@@ -3,6 +3,7 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
const teamIds: number[] = [ 1, 2, 3, 4 ];
@@ -10,16 +11,26 @@ export const WiredConditionActorIsTeamMemberView: FC<{}> = props =>
{
const [ selectedTeam, setSelectedTeam ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () => setIntParams([ selectedTeam ]);
const save = () => setIntParams([ selectedTeam, userSource ]);
useEffect(() =>
{
setSelectedTeam((trigger.intData.length > 0) ? trigger.intData[0] : 0);
setUserSource((trigger.intData.length > 1) ? trigger.intData[1] : 0);
}, [ trigger ]);
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.team') }</Text>
{ teamIds.map(value =>
@@ -4,21 +4,37 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionActorIsWearingBadgeView: FC<{}> = props =>
{
const [ badge, setBadge ] = useState('');
const { trigger = null, setStringParam = null } = useWired();
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 1) return trigger.intData[0];
return 0;
});
const save = () => setStringParam(badge);
const save = () =>
{
setStringParam(badge);
setIntParams([ userSource ]);
};
useEffect(() =>
{
setBadge(trigger.stringData);
if(trigger.intData.length >= 1) setUserSource(trigger.intData[0]);
else setUserSource(0);
}, [ trigger ]);
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.badgecode') }</Text>
<NitroInput type="text" value={ badge } onChange={ event => setBadge(event.target.value) } />
@@ -4,21 +4,33 @@ import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { NitroInput } from '../../../../layout';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionActorIsWearingEffectView: FC<{}> = props =>
{
const [ effect, setEffect ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return 0;
});
const save = () => setIntParams([ effect ]);
const save = () => setIntParams([ effect, userSource ]);
useEffect(() =>
{
setEffect(trigger?.intData[0] ?? 0);
if(trigger?.intData?.length > 1) setUserSource(trigger.intData[1]);
else setUserSource(0);
}, [ trigger ]);
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.tooltip.effectid') }</Text>
<NitroInput type="number" value={ effect } onChange={ event => setEffect(parseInt(event.target.value)) } />
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren } from 'react';
import { FC, PropsWithChildren, ReactNode } from 'react';
import { WiredFurniType } from '../../../../api';
import { WiredBaseView } from '../WiredBaseView';
@@ -7,16 +7,17 @@ export interface WiredConditionBaseViewProps
hasSpecialInput: boolean;
requiresFurni: number;
save: () => void;
footer?: ReactNode;
}
export const WiredConditionBaseView: FC<PropsWithChildren<WiredConditionBaseViewProps>> = props =>
{
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, hasSpecialInput = false, children = null } = props;
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, hasSpecialInput = false, children = null, footer = null } = props;
const onSave = () => (save && save());
return (
<WiredBaseView hasSpecialInput={ hasSpecialInput } requiresFurni={ requiresFurni } save={ onSave } wiredType="condition">
<WiredBaseView hasSpecialInput={ hasSpecialInput } requiresFurni={ requiresFurni } save={ onSave } wiredType="condition" footer={ footer }>
{ children }
</WiredBaseView>
);
@@ -1,8 +1,50 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionFurniHasAvatarOnView: FC<{}> = props =>
{
return <WiredConditionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -1,23 +1,53 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionFurniHasFurniOnView: FC<{}> = props =>
{
const [ requireAll, setRequireAll ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ requireAll ]);
const save = () => setIntParams([ requireAll, furniSource ]);
useEffect(() =>
{
setRequireAll((trigger.intData.length > 0) ? trigger.intData[0] : 0);
if(trigger.intData.length > 1) setFurniSource(trigger.intData[1]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
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 =>
@@ -1,23 +1,53 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionFurniHasNotFurniOnView: FC<{}> = props =>
{
const [ requireAll, setRequireAll ] = useState(-1);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 1) return trigger.intData[1];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ requireAll ]);
const save = () => setIntParams([ requireAll, furniSource ]);
useEffect(() =>
{
setRequireAll((trigger.intData.length > 0) ? trigger.intData[0] : 0);
if(trigger.intData.length > 1) setFurniSource(trigger.intData[1]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.not_requireall') }</Text>
{ [ 0, 1 ].map(value =>
@@ -1,8 +1,50 @@
import { FC } from 'react';
import { WiredFurniType } from '../../../../api';
import { FC, useEffect, useState } from 'react';
import { WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionFurniIsOfTypeView: FC<{}> = props =>
{
return <WiredConditionBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ null } />;
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length >= 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]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const save = () => setIntParams([ furniSource ]);
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> } />
);
};
@@ -1,27 +1,57 @@
import { FC, useEffect, useState } from 'react';
import { LocalizeText, WiredFurniType } from '../../../../api';
import { LocalizeText, WiredFurniType, WiredSelectionVisualizer } from '../../../../api';
import { Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionFurniMatchesSnapshotView: FC<{}> = props =>
{
const [ stateFlag, setStateFlag ] = useState(0);
const [ directionFlag, setDirectionFlag ] = useState(0);
const [ positionFlag, setPositionFlag ] = useState(0);
const { trigger = null, setIntParams = null } = useWired();
const { trigger = null, furniIds = [], setFurniIds = null, setIntParams = null } = useWired();
const [ furniSource, setFurniSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 3) return trigger.intData[3];
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
});
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag ]);
const save = () => setIntParams([ stateFlag, directionFlag, positionFlag, furniSource ]);
useEffect(() =>
{
setStateFlag(trigger.getBoolean(0) ? 1 : 0);
setDirectionFlag(trigger.getBoolean(1) ? 1 : 0);
setPositionFlag(trigger.getBoolean(2) ? 1 : 0);
if(trigger.intData.length > 3) setFurniSource(trigger.intData[3]);
else setFurniSource((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0);
}, [ trigger ]);
const onChangeFurniSource = (next: number) =>
{
if(furniIds.length && setFurniIds)
{
setFurniIds(prev =>
{
if(prev && prev.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prev);
return [];
});
}
setFurniSource(next);
};
const requiresFurni = (furniSource === 100)
? WiredFurniType.STUFF_SELECTION_OPTION_BY_ID
: WiredFurniType.STUFF_SELECTION_OPTION_NONE;
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ requiresFurni }
save={ save }
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } onChangeFurni={ onChangeFurniSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.conditions') }</Text>
<div className="flex items-center gap-1">
@@ -3,14 +3,20 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
import { Slider, Text } from '../../../../common';
import { useWired } from '../../../../hooks';
import { WiredConditionBaseView } from './WiredConditionBaseView';
import { WiredSourcesSelector } from '../WiredSourcesSelector';
export const WiredConditionUserCountInRoomView: FC<{}> = props =>
{
const [ min, setMin ] = useState(1);
const [ max, setMax ] = useState(0);
const { trigger = null, setIntParams = null } = useWired();
const [ userSource, setUserSource ] = useState<number>(() =>
{
if(trigger?.intData?.length > 2) return trigger.intData[2];
return 0;
});
const save = () => setIntParams([ min, max ]);
const save = () => setIntParams([ min, max, userSource ]);
useEffect(() =>
{
@@ -24,10 +30,16 @@ export const WiredConditionUserCountInRoomView: FC<{}> = props =>
setMin(1);
setMax(0);
}
if(trigger.intData.length > 2) setUserSource(trigger.intData[2]);
else setUserSource(0);
}, [ trigger ]);
return (
<WiredConditionBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
<WiredConditionBaseView
hasSpecialInput={ true }
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
save={ save }
footer={ <WiredSourcesSelector showUsers={ true } userSource={ userSource } onChangeUsers={ setUserSource } /> }>
<div className="flex flex-col gap-1">
<Text bold>{ LocalizeText('wiredfurni.params.usercountmin', [ 'value' ], [ min.toString() ]) }</Text>
<Slider