mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 07:26:19 +00:00
feat(wired-ui): expand advanced wired editors
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { GetSessionDataManager } from '@nitrots/nitro-renderer';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
@@ -6,22 +5,34 @@ import { useWired } from '../../../../hooks';
|
||||
import { NitroInput } from '../../../../layout';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
export const WiredTriggerAvatarSaysSomethingView: FC<{}> = props =>
|
||||
const MATCH_CONTAINS = 0;
|
||||
const MATCH_EXACT = 1;
|
||||
const MATCH_ALL = 2;
|
||||
|
||||
export const WiredTriggerAvatarSaysSomethingView: FC<{}> = () =>
|
||||
{
|
||||
const [ message, setMessage ] = useState('');
|
||||
const [ triggererAvatar, setTriggererAvatar ] = useState(-1);
|
||||
const [ matchMode, setMatchMode ] = useState(MATCH_CONTAINS);
|
||||
const [ hideMessage, setHideMessage ] = useState(false);
|
||||
const [ ownerOnly, setOwnerOnly ] = useState(false);
|
||||
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () =>
|
||||
{
|
||||
setStringParam(message);
|
||||
setIntParams([ triggererAvatar ]);
|
||||
setIntParams([
|
||||
matchMode,
|
||||
hideMessage ? 1 : 0,
|
||||
ownerOnly ? 1 : 0
|
||||
]);
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setMessage(trigger.stringData);
|
||||
setTriggererAvatar((trigger.intData.length > 0) ? trigger.intData[0] : 0);
|
||||
setMessage(trigger?.stringData ?? '');
|
||||
setMatchMode((trigger?.intData?.length > 0) ? trigger.intData[0] : MATCH_CONTAINS);
|
||||
setHideMessage((trigger?.intData?.length > 1) ? (trigger.intData[1] === 1) : false);
|
||||
setOwnerOnly((trigger?.intData?.length > 2) ? (trigger.intData[2] === 1) : false);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
@@ -31,14 +42,27 @@ export const WiredTriggerAvatarSaysSomethingView: FC<{}> = props =>
|
||||
<NitroInput type="text" value={ message } onChange={ event => setMessage(event.target.value) } />
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.picktriggerer') }</Text>
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ (triggererAvatar === 0) } className="form-check-input" id="triggererAvatar0" name="triggererAvatar" type="radio" onChange={ event => setTriggererAvatar(0) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.anyavatar') }</Text>
|
||||
<input checked={ (matchMode === MATCH_CONTAINS) } className="form-check-input" id="sayMatchContains" name="sayMatchMode" type="radio" onChange={ () => setMatchMode(MATCH_CONTAINS) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.chatcontains') }</Text>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ (triggererAvatar === 1) } className="form-check-input" id="triggererAvatar1" name="triggererAvatar" type="radio" onChange={ event => setTriggererAvatar(1) } />
|
||||
<Text>{ GetSessionDataManager().userName }</Text>
|
||||
<input checked={ (matchMode === MATCH_EXACT) } className="form-check-input" id="sayMatchExact" name="sayMatchMode" type="radio" onChange={ () => setMatchMode(MATCH_EXACT) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.exactmatch') }</Text>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ (matchMode === MATCH_ALL) } className="form-check-input" id="sayMatchAll" name="sayMatchMode" type="radio" onChange={ () => setMatchMode(MATCH_ALL) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.allmatch') }</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ hideMessage } className="form-check-input" id="sayHideMessage" type="checkbox" onChange={ event => setHideMessage(event.target.checked) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.chat.hide') }</Text>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ ownerOnly } className="form-check-input" id="sayOwnerOnly" type="checkbox" onChange={ event => setOwnerOnly(event.target.checked) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.chat.onlyowner') }</Text>
|
||||
</div>
|
||||
</div>
|
||||
</WiredTriggerBaseView>
|
||||
|
||||
@@ -1,8 +1,33 @@
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
export const WiredTriggerAvatarWalksOffFurniView: FC<{}> = props =>
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerAvatarWalksOffFurniView: FC<{}> = () =>
|
||||
{
|
||||
return <WiredTriggerBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ null } />;
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
|
||||
const save = () => setIntParams([ furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setFurniSource((trigger?.intData?.length > 0) ? normalizeFurniSource(trigger.intData[0]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ false }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> } />
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,33 @@
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
export const WiredTriggerAvatarWalksOnFurniView: FC<{}> = props =>
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerAvatarWalksOnFurniView: FC<{}> = () =>
|
||||
{
|
||||
return <WiredTriggerBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ null } />;
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
|
||||
const save = () => setIntParams([ furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setFurniSource((trigger?.intData?.length > 0) ? normalizeFurniSource(trigger.intData[0]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ false }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> } />
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,26 +3,52 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { NitroInput } from '../../../../layout';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const BOT_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.users.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.users.200' }
|
||||
];
|
||||
|
||||
const normalizeBotSource = (value: number) => (BOT_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerBotReachedAvatarView: FC<{}> = props =>
|
||||
{
|
||||
const [ botName, setBotName ] = useState('');
|
||||
const { trigger = null, setStringParam = null } = useWired();
|
||||
const [ botSource, setBotSource ] = useState(100);
|
||||
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () => setStringParam(botName);
|
||||
const save = () =>
|
||||
{
|
||||
setStringParam((botSource === 100) ? botName : '');
|
||||
setIntParams([ botSource ]);
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setBotName(trigger.stringData);
|
||||
setBotSource((trigger?.intData?.length > 0) ? normalizeBotSource(trigger.intData[0]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
|
||||
<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) } />
|
||||
</div>
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE }
|
||||
save={ save }
|
||||
footer={
|
||||
<WiredSourcesSelector
|
||||
showUsers={ true }
|
||||
userSource={ botSource }
|
||||
userSources={ BOT_SOURCE_OPTIONS }
|
||||
usersTitle="wiredfurni.params.sources.users.title.bots"
|
||||
onChangeUsers={ setBotSource } />
|
||||
}>
|
||||
{ (botSource === 100) &&
|
||||
<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) } />
|
||||
</div> }
|
||||
</WiredTriggerBaseView>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,26 +3,64 @@ import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { NitroInput } from '../../../../layout';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const BOT_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.users.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.users.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
const normalizeBotSource = (value: number) => (BOT_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerBotReachedStuffView: FC<{}> = props =>
|
||||
{
|
||||
const [ botName, setBotName ] = useState('');
|
||||
const { trigger = null, setStringParam = null } = useWired();
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
const [ botSource, setBotSource ] = useState(100);
|
||||
const { trigger = null, setStringParam = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () => setStringParam(botName);
|
||||
const save = () =>
|
||||
{
|
||||
setStringParam((botSource === 100) ? botName : '');
|
||||
setIntParams([ furniSource, botSource ]);
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setBotName(trigger.stringData);
|
||||
setFurniSource((trigger?.intData?.length > 0) ? normalizeFurniSource(trigger.intData[0]) : 100);
|
||||
setBotSource((trigger?.intData?.length > 1) ? normalizeBotSource(trigger.intData[1]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ save }>
|
||||
<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) } />
|
||||
</div>
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={
|
||||
<WiredSourcesSelector
|
||||
showFurni={ true }
|
||||
showUsers={ true }
|
||||
furniSource={ furniSource }
|
||||
userSource={ botSource }
|
||||
furniSources={ FURNI_SOURCE_OPTIONS }
|
||||
userSources={ BOT_SOURCE_OPTIONS }
|
||||
usersTitle="wiredfurni.params.sources.users.title.bots"
|
||||
onChangeFurni={ setFurniSource }
|
||||
onChangeUsers={ setBotSource } />
|
||||
}>
|
||||
{ (botSource === 100) &&
|
||||
<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) } />
|
||||
</div> }
|
||||
</WiredTriggerBaseView>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,33 @@
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerClickFurniView: FC<{}> = () =>
|
||||
{
|
||||
return <WiredTriggerBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ null } />;
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
|
||||
const save = () => setIntParams([ furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setFurniSource((trigger?.intData?.length > 0) ? normalizeFurniSource(trigger.intData[0]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ false }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> } />
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,20 +1,46 @@
|
||||
import { FC, useEffect } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const CLICK_TILE_INTERACTION_TYPES = [ 'room_invisible_click_tile' ];
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerClickTileView: FC<{}> = () =>
|
||||
{
|
||||
const { setAllowedInteractionTypes } = useWired();
|
||||
const { trigger = null, setIntParams = null, setAllowedInteractionTypes = null, setAllowedInteractionErrorKey = null } = useWired();
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
|
||||
const save = () => setIntParams([ furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setFurniSource((trigger?.intData?.length > 0) ? normalizeFurniSource(trigger.intData[0]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setAllowedInteractionTypes(CLICK_TILE_INTERACTION_TYPES);
|
||||
setAllowedInteractionErrorKey('wiredfurni.error.require_click_tiles');
|
||||
|
||||
return () => setAllowedInteractionTypes(null);
|
||||
}, [ setAllowedInteractionTypes ]);
|
||||
return () =>
|
||||
{
|
||||
setAllowedInteractionTypes(null);
|
||||
setAllowedInteractionErrorKey(null);
|
||||
};
|
||||
}, [ setAllowedInteractionErrorKey, setAllowedInteractionTypes ]);
|
||||
|
||||
return <WiredTriggerBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_OR_BY_TYPE } save={ null } />;
|
||||
return (
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ false }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> } />
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
import { FC } from 'react';
|
||||
import { WiredFurniType } from '../../../../api';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
export const WiredTriggerClickUserView: FC<{}> = () =>
|
||||
{
|
||||
return <WiredTriggerBaseView hasSpecialInput={ false } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ null } />;
|
||||
const [ blockMenuOpen, setBlockMenuOpen ] = useState(false);
|
||||
const [ doNotRotate, setDoNotRotate ] = useState(false);
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () => setIntParams([
|
||||
blockMenuOpen ? 1 : 0,
|
||||
doNotRotate ? 1 : 0
|
||||
]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setBlockMenuOpen((trigger?.intData?.length > 0) ? (trigger.intData[0] === 1) : false);
|
||||
setDoNotRotate((trigger?.intData?.length > 1) ? (trigger.intData[1] === 1) : false);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_NONE } save={ save }>
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ blockMenuOpen } className="form-check-input" id="clickUserBlockMenuOpen" type="checkbox" onChange={ event => setBlockMenuOpen(event.target.checked) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.click_user.block_menu_open') }</Text>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<input checked={ doNotRotate } className="form-check-input" id="clickUserDoNotRotate" type="checkbox" onChange={ event => setDoNotRotate(event.target.checked) } />
|
||||
<Text>{ LocalizeText('wiredfurni.params.click_user.do_not_rotate') }</Text>
|
||||
</div>
|
||||
</div>
|
||||
</WiredTriggerBaseView>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,13 +11,13 @@ const MINUTES_MAX = 99;
|
||||
const HALF_SECONDS_MIN = 0;
|
||||
const HALF_SECONDS_MAX = 119;
|
||||
const TRIGGER_FURNI_SOURCES: WiredSourceOption[] = [
|
||||
{ value: 0, label: 'wiredfurni.params.sources.furni.0' },
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' }
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeMinutes = (value: number) => Math.max(MINUTES_MIN, Math.min(MINUTES_MAX, value));
|
||||
const normalizeHalfSeconds = (value: number) => Math.max(HALF_SECONDS_MIN, Math.min(HALF_SECONDS_MAX, value));
|
||||
const normalizeFurniSource = (value: number) => (value === 100 ? 100 : 0);
|
||||
const normalizeFurniSource = (value: number) => (TRIGGER_FURNI_SOURCES.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
const formatSeconds = (halfSeconds: number) =>
|
||||
{
|
||||
@@ -33,7 +33,7 @@ export const WiredTriggerClockCounterView: FC<{}> = () =>
|
||||
const [ furniSource, setFurniSource ] = useState<number>(() =>
|
||||
{
|
||||
if(trigger?.intData?.length > 2) return normalizeFurniSource(trigger.intData[2]);
|
||||
return (trigger?.selectedItems?.length ?? 0) > 0 ? 100 : 0;
|
||||
return 100;
|
||||
});
|
||||
const [ minutes, setMinutes ] = useState(0);
|
||||
const [ halfSeconds, setHalfSeconds ] = useState(0);
|
||||
@@ -55,7 +55,7 @@ export const WiredTriggerClockCounterView: FC<{}> = () =>
|
||||
|
||||
setMinutes((trigger.intData.length > 0) ? normalizeMinutes(trigger.intData[0]) : 0);
|
||||
setHalfSeconds((trigger.intData.length > 1) ? normalizeHalfSeconds(trigger.intData[1]) : 0);
|
||||
setFurniSource((trigger.intData.length > 2) ? normalizeFurniSource(trigger.intData[2]) : ((trigger.selectedItems?.length ?? 0) > 0 ? 100 : 0));
|
||||
setFurniSource((trigger.intData.length > 2) ? normalizeFurniSource(trigger.intData[2]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
useEffect(() =>
|
||||
|
||||
@@ -2,35 +2,59 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const ANTENNA_INTERACTION_TYPES = [ 'antenna' ];
|
||||
const ANTENNA_ERROR_MESSAGE = 'Puoi selezionare solo furni antenna.';
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerReceiveSignalView: FC<{}> = () =>
|
||||
{
|
||||
const [ senderCount, setSenderCount ] = useState(0);
|
||||
const [ maxSenders, setMaxSenders ] = useState(5);
|
||||
const [ channel, setChannel ] = useState(0);
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
|
||||
const { trigger = null, setAllowedInteractionTypes } = useWired();
|
||||
const { trigger = null, setIntParams = null, setAllowedInteractionTypes = null, setAllowedInteractionErrorKey = null } = useWired();
|
||||
|
||||
const save = () => setIntParams([ channel, furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(!trigger) return;
|
||||
|
||||
const p = trigger.intData;
|
||||
if(p.length >= 1) setChannel(p[0]);
|
||||
if(p.length >= 2) setSenderCount(p[1]);
|
||||
if(p.length >= 3) setMaxSenders(p[2]);
|
||||
if(p.length >= 4) setFurniSource(normalizeFurniSource(p[3]));
|
||||
else setFurniSource(100);
|
||||
}, [ trigger ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setAllowedInteractionTypes(ANTENNA_INTERACTION_TYPES);
|
||||
setAllowedInteractionErrorKey(ANTENNA_ERROR_MESSAGE);
|
||||
|
||||
return () => setAllowedInteractionTypes(null);
|
||||
}, [ setAllowedInteractionTypes ]);
|
||||
return () =>
|
||||
{
|
||||
setAllowedInteractionTypes(null);
|
||||
setAllowedInteractionErrorKey(null);
|
||||
};
|
||||
}, [ setAllowedInteractionErrorKey, setAllowedInteractionTypes ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ null }>
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> }>
|
||||
<div className="flex items-center justify-between">
|
||||
<Text small>{ LocalizeText('wiredfurni.params.signal.senders_connected') }</Text>
|
||||
<Text bold small>{ senderCount }/{ maxSenders }</Text>
|
||||
|
||||
@@ -4,16 +4,20 @@ import { Slider, Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const TEAM_TYPES = [ 0, 1, 2, 3, 4 ];
|
||||
|
||||
export const WiredTriggeScoreAchievedView: FC<{}> = props =>
|
||||
{
|
||||
const [ points, setPoints ] = useState(1);
|
||||
const [ teamType, setTeamType ] = useState(0);
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () => setIntParams([ points ]);
|
||||
const save = () => setIntParams([ points, teamType ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setPoints((trigger.intData.length > 0) ? trigger.intData[0] : 0);
|
||||
setTeamType((trigger.intData.length > 1) ? trigger.intData[1] : 0);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
@@ -25,6 +29,14 @@ export const WiredTriggeScoreAchievedView: FC<{}> = props =>
|
||||
min={ 1 }
|
||||
value={ points }
|
||||
onChange={ event => setPoints(event) } />
|
||||
<hr className="m-0 bg-dark" />
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.team') }</Text>
|
||||
{ TEAM_TYPES.map(value => (
|
||||
<label key={ value } className="flex items-center gap-1">
|
||||
<input checked={ (teamType === value) } className="form-check-input" name="scoreAchievedTeamType" type="radio" onChange={ () => setTeamType(value) } />
|
||||
<Text>{ LocalizeText((value === 0) ? 'wiredfurni.params.team.any' : `wiredfurni.params.team.${ value }`) }</Text>
|
||||
</label>
|
||||
)) }
|
||||
</div>
|
||||
</WiredTriggerBaseView>
|
||||
);
|
||||
|
||||
@@ -2,22 +2,36 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { LocalizeText, WiredFurniType } from '../../../../api';
|
||||
import { Text } from '../../../../common';
|
||||
import { useWired } from '../../../../hooks';
|
||||
import { WiredSourceOption, WiredSourcesSelector } from '../WiredSourcesSelector';
|
||||
import { WiredTriggerBaseView } from './WiredTriggerBaseView';
|
||||
|
||||
const FURNI_SOURCE_OPTIONS: WiredSourceOption[] = [
|
||||
{ value: 100, label: 'wiredfurni.params.sources.furni.100' },
|
||||
{ value: 200, label: 'wiredfurni.params.sources.furni.200' }
|
||||
];
|
||||
|
||||
const normalizeFurniSource = (value: number) => (FURNI_SOURCE_OPTIONS.some(option => (option.value === value)) ? value : 100);
|
||||
|
||||
export const WiredTriggerToggleFurniView: FC<{}> = () =>
|
||||
{
|
||||
const [ triggerMode, setTriggerMode ] = useState(0);
|
||||
const [ furniSource, setFurniSource ] = useState(100);
|
||||
const { trigger = null, setIntParams = null } = useWired();
|
||||
|
||||
const save = () => setIntParams([ triggerMode ]);
|
||||
const save = () => setIntParams([ triggerMode, furniSource ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setTriggerMode((trigger?.intData?.length > 0) ? trigger.intData[0] : 0);
|
||||
setFurniSource((trigger?.intData?.length > 1) ? normalizeFurniSource(trigger.intData[1]) : 100);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredTriggerBaseView hasSpecialInput={ true } requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } save={ save }>
|
||||
<WiredTriggerBaseView
|
||||
hasSpecialInput={ true }
|
||||
requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID_BY_TYPE_OR_FROM_CONTEXT }
|
||||
save={ save }
|
||||
footer={ <WiredSourcesSelector showFurni={ true } furniSource={ furniSource } furniSources={ FURNI_SOURCE_OPTIONS } onChangeFurni={ setFurniSource } /> }>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.condition.state') }</Text>
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
Reference in New Issue
Block a user