diff --git a/src/components/wired/common/GetWiredActionLayout.tsx b/src/components/wired/common/GetWiredActionLayout.tsx index 9a0b1c09..a5072141 100644 --- a/src/components/wired/common/GetWiredActionLayout.tsx +++ b/src/components/wired/common/GetWiredActionLayout.tsx @@ -25,7 +25,7 @@ import { WiredActionTeleportView } from '../views/actions/WiredActionTeleportVie import { WiredActionToggleFurniStateView } from '../views/actions/WiredActionToggleFurniStateView'; import { WiredActionLayout } from './WiredActionLayoutCode'; -export function GetWiredActionLayout(code: number): JSX.Element +export const GetWiredActionLayout = (code: number) => { switch(code) { diff --git a/src/components/wired/common/GetWiredConditionLayout.tsx b/src/components/wired/common/GetWiredConditionLayout.tsx index c3f79007..71dcd62c 100644 --- a/src/components/wired/common/GetWiredConditionLayout.tsx +++ b/src/components/wired/common/GetWiredConditionLayout.tsx @@ -15,7 +15,7 @@ import { WiredConditionTimeElapsedMoreView } from '../views/conditions/WiredCond import { WiredConditionUserCountInRoomView } from '../views/conditions/WiredConditionUserCountInRoomView'; import { WiredConditionlayout } from './WiredConditionLayoutCode'; -export function GetWiredConditionLayout(code: number): JSX.Element +export const GetWiredConditionLayout = (code: number) => { switch(code) { diff --git a/src/components/wired/common/GetWiredLayout.tsx b/src/components/wired/common/GetWiredLayout.tsx index f4730eb7..5b5a6bed 100644 --- a/src/components/wired/common/GetWiredLayout.tsx +++ b/src/components/wired/common/GetWiredLayout.tsx @@ -3,7 +3,7 @@ import { GetWiredActionLayout } from './GetWiredActionLayout'; import { GetWiredConditionLayout } from './GetWiredConditionLayout'; import { GetWiredTriggerLayout } from './GetWiredTriggerLayout'; -export function GetWiredLayout(trigger: Triggerable): JSX.Element +export const GetWiredLayout = (trigger: Triggerable) => { if(trigger instanceof WiredActionDefinition) return GetWiredActionLayout(trigger.code); diff --git a/src/components/wired/common/GetWiredTimeLocale.ts b/src/components/wired/common/GetWiredTimeLocale.ts index 02aa3b4e..49025fe4 100644 --- a/src/components/wired/common/GetWiredTimeLocale.ts +++ b/src/components/wired/common/GetWiredTimeLocale.ts @@ -1,4 +1,4 @@ -export function GetWiredTimeLocale(value: number): string +export const GetWiredTimeLocale = (value: number) => { const time = Math.floor((value / 2)); diff --git a/src/components/wired/common/GetWiredTriggerLayout.tsx b/src/components/wired/common/GetWiredTriggerLayout.tsx index 592b30dd..c6c9b452 100644 --- a/src/components/wired/common/GetWiredTriggerLayout.tsx +++ b/src/components/wired/common/GetWiredTriggerLayout.tsx @@ -14,7 +14,7 @@ import { WiredTriggeScoreAchievedView } from '../views/triggers/WiredTriggerScor import { WiredTriggerToggleFurniView } from '../views/triggers/WiredTriggerToggleFurniView'; import { WiredTriggerLayout } from './WiredTriggerLayoutCode'; -export function GetWiredTriggerLayout(code: number): JSX.Element +export const GetWiredTriggerLayout = (code: number) => { switch(code) { diff --git a/src/components/wired/views/WiredBaseView.tsx b/src/components/wired/views/WiredBaseView.tsx index e04181ca..81e83e6d 100644 --- a/src/components/wired/views/WiredBaseView.tsx +++ b/src/components/wired/views/WiredBaseView.tsx @@ -5,6 +5,7 @@ import { Column } from '../../../common/Column'; import { Flex } from '../../../common/Flex'; import { Text } from '../../../common/Text'; import { WiredEvent } from '../../../events'; +import { BatchUpdates } from '../../../hooks'; import { dispatchUiEvent } from '../../../hooks/events'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../layout'; import { WiredFurniType } from '../common/WiredFurniType'; @@ -27,42 +28,6 @@ export const WiredBaseView: FC = props => const [ wiredDescription, setWiredDescription ] = useState(null); const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null } = useWiredContext(); - useEffect(() => - { - if(!trigger) return; - - const spriteId = (trigger.spriteId || -1); - - const furniData = GetSessionDataManager().getFloorItemData(spriteId); - - if(!furniData) - { - setWiredName(('NAME: ' + spriteId)); - setWiredDescription(('NAME: ' + spriteId)); - } - else - { - setWiredName(furniData.name); - setWiredDescription(furniData.description); - } - - setIntParams(trigger.intData); - setStringParam(trigger.stringData); - setFurniIds(prevValue => - { - if(prevValue && prevValue.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prevValue); - - if(trigger.selectedItems && trigger.selectedItems.length) - { - WiredSelectionVisualizer.applySelectionShaderToFurni(trigger.selectedItems); - - return trigger.selectedItems; - } - - return []; - }); - }, [ trigger, setIntParams, setStringParam, setFurniIds ]); - const onSave = useCallback(() => { if(validate && !validate()) return; @@ -77,6 +42,44 @@ export const WiredBaseView: FC = props => setTrigger(null); }, [ setTrigger ]); + useEffect(() => + { + if(!trigger) return; + + const spriteId = (trigger.spriteId || -1); + const furniData = GetSessionDataManager().getFloorItemData(spriteId); + + BatchUpdates(() => + { + if(!furniData) + { + setWiredName(('NAME: ' + spriteId)); + setWiredDescription(('NAME: ' + spriteId)); + } + else + { + setWiredName(furniData.name); + setWiredDescription(furniData.description); + } + + setIntParams(trigger.intData); + setStringParam(trigger.stringData); + setFurniIds(prevValue => + { + if(prevValue && prevValue.length) WiredSelectionVisualizer.clearSelectionShaderFromFurni(prevValue); + + if(trigger.selectedItems && trigger.selectedItems.length) + { + WiredSelectionVisualizer.applySelectionShaderToFurni(trigger.selectedItems); + + return trigger.selectedItems; + } + + return []; + }); + }); + }, [ trigger, setIntParams, setStringParam, setFurniIds ]); + return ( @@ -88,14 +91,14 @@ export const WiredBaseView: FC = props => { wiredDescription } - { (children !== null) &&
} + { !!children &&
} { children } { (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) && <>
} - + diff --git a/src/components/wired/views/actions/WiredActionBaseView.tsx b/src/components/wired/views/actions/WiredActionBaseView.tsx index 76548401..0d3a6076 100644 --- a/src/components/wired/views/actions/WiredActionBaseView.tsx +++ b/src/components/wired/views/actions/WiredActionBaseView.tsx @@ -2,6 +2,8 @@ import { WiredActionDefinition } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; import { GetWiredTimeLocale } from '../../common/GetWiredTimeLocale'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; @@ -33,19 +35,17 @@ export const WiredActionBaseView: FC = props => return ( - { !children ? null : <> - { children } -
- } -
- + { children } + { !!children &&
} + + { LocalizeText('wiredfurni.params.delay', [ 'seconds' ], [ GetWiredTimeLocale(delay) ]) } setDelay(event) } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionBotChangeFigureView.tsx b/src/components/wired/views/actions/WiredActionBotChangeFigureView.tsx index 8f913ffc..6a3cd9fc 100644 --- a/src/components/wired/views/actions/WiredActionBotChangeFigureView.tsx +++ b/src/components/wired/views/actions/WiredActionBotChangeFigureView.tsx @@ -1,5 +1,10 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../../../api'; +import { Button } from '../../../../common/Button'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { AvatarImageView } from '../../../../views/shared/avatar-image/AvatarImageView'; import { WiredFurniType } from '../../common/WiredFurniType'; import { WIRED_STRING_DELIMETER } from '../../common/WiredStringDelimeter'; @@ -14,14 +19,6 @@ export const WiredActionBotChangeFigureView: FC<{}> = props => const [ figure, setFigure ] = useState(''); const { trigger = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - const data = trigger.stringData.split(WIRED_STRING_DELIMETER); - - if(data.length > 0) setBotName(data[0]); - if(data.length > 1) setFigure(data[1].length > 0 ? data[1] : DEFAULT_FIGURE); - }, [ trigger ]); - const copyLooks = useCallback(() => { setFigure(GetSessionDataManager().figure); @@ -32,16 +29,27 @@ export const WiredActionBotChangeFigureView: FC<{}> = props => setStringParam((botName + WIRED_STRING_DELIMETER + figure)); }, [ botName, figure, setStringParam ]); + useEffect(() => + { + const data = trigger.stringData.split(WIRED_STRING_DELIMETER); + + BatchUpdates(() => + { + if(data.length > 0) setBotName(data[0]); + if(data.length > 1) setFigure(data[1].length > 0 ? data[1] : DEFAULT_FIGURE); + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
-
+ + - -
+ +
); } diff --git a/src/components/wired/views/actions/WiredActionBotFollowAvatarView.tsx b/src/components/wired/views/actions/WiredActionBotFollowAvatarView.tsx index 3351288c..db19a24f 100644 --- a/src/components/wired/views/actions/WiredActionBotFollowAvatarView.tsx +++ b/src/components/wired/views/actions/WiredActionBotFollowAvatarView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -10,38 +14,40 @@ export const WiredActionBotFollowAvatarView: FC<{}> = props => const [ followMode, setFollowMode ] = useState(-1); const { trigger = null, setStringParam = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - setBotName(trigger.stringData); - setFollowMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); - }, [ trigger ]); - const save = useCallback(() => { - setStringParam(botName); - setIntParams([followMode]); + BatchUpdates(() => + { + setStringParam(botName); + setIntParams([followMode]); + }); }, [ followMode, botName, setStringParam, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + setBotName(trigger.stringData); + setFollowMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }); + }, [ trigger ]); + return ( -
+ setBotName(event.target.value) } /> -
-
-
+ + + setFollowMode(1) } /> - -
-
+ { LocalizeText('wiredfurni.params.start.following') } + + setFollowMode(0) } /> - -
-
+ { LocalizeText('wiredfurni.params.stop.following') } + +
); } diff --git a/src/components/wired/views/actions/WiredActionBotGiveHandItemView.tsx b/src/components/wired/views/actions/WiredActionBotGiveHandItemView.tsx index 1c998c9a..3a36ae75 100644 --- a/src/components/wired/views/actions/WiredActionBotGiveHandItemView.tsx +++ b/src/components/wired/views/actions/WiredActionBotGiveHandItemView.tsx @@ -1,10 +1,13 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; -const allowedHanditemIds: number[] = [2, 5, 7, 8, 9, 10, 27]; +const ALLOWED_HAND_ITEM_IDS: number[] = [ 2, 5, 7, 8, 9, 10, 27 ]; export const WiredActionBotGiveHandItemView: FC<{}> = props => { @@ -12,34 +15,40 @@ export const WiredActionBotGiveHandItemView: FC<{}> = props => const [ handItemId, setHandItemId ] = useState(-1); const { trigger = null, setStringParam = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - setBotName(trigger.stringData); - setHandItemId((trigger.intData.length > 0) ? trigger.intData[0] : 0); - }, [ trigger ]); - const save = useCallback(() => { - setStringParam(botName); - setIntParams([ handItemId ]); + BatchUpdates(() => + { + setStringParam(botName); + setIntParams([ handItemId ]); + }); }, [ handItemId, botName, setStringParam, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + setBotName(trigger.stringData); + setHandItemId((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
-
- + + + { LocalizeText('wiredfurni.params.handitem') } -
+
); } diff --git a/src/components/wired/views/actions/WiredActionBotMoveView.tsx b/src/components/wired/views/actions/WiredActionBotMoveView.tsx index 0ba69ae6..d03b42ea 100644 --- a/src/components/wired/views/actions/WiredActionBotMoveView.tsx +++ b/src/components/wired/views/actions/WiredActionBotMoveView.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -9,22 +11,22 @@ export const WiredActionBotMoveView: FC<{}> = props => const [ botName, setBotName ] = useState(''); const { trigger = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setBotName(trigger.stringData); - }, [ trigger ]); - const save = useCallback(() => { setStringParam(botName); }, [ botName, setStringParam ]); + useEffect(() => + { + setBotName(trigger.stringData); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionBotTalkToAvatarView.tsx b/src/components/wired/views/actions/WiredActionBotTalkToAvatarView.tsx index 118a2e85..55cb3d31 100644 --- a/src/components/wired/views/actions/WiredActionBotTalkToAvatarView.tsx +++ b/src/components/wired/views/actions/WiredActionBotTalkToAvatarView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { WIRED_STRING_DELIMETER } from '../../common/WiredStringDelimeter'; import { useWiredContext } from '../../context/WiredContext'; @@ -12,42 +16,48 @@ export const WiredActionBotTalkToAvatarView: FC<{}> = props => const [ talkMode, setTalkMode ] = useState(-1); const { trigger = null, setStringParam = null, setIntParams = null } = useWiredContext(); + const save = useCallback(() => + { + BatchUpdates(() => + { + setStringParam(botName + WIRED_STRING_DELIMETER + message); + setIntParams([ talkMode ]); + }); + }, [ botName, message, talkMode, setStringParam, setIntParams ]); + useEffect(() => { const data = trigger.stringData.split(WIRED_STRING_DELIMETER); - if(data.length > 0) setBotName(data[0]); - if(data.length > 1) setMessage(data[1].length > 0 ? data[1] : ''); - - setTalkMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); + BatchUpdates(() => + { + if(data.length > 0) setBotName(data[0]); + if(data.length > 1) setMessage(data[1].length > 0 ? data[1] : ''); + + setTalkMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }); }, [ trigger ]); - const save = useCallback(() => - { - setStringParam(botName + WIRED_STRING_DELIMETER + message); - setIntParams([ talkMode ]); - }, [ botName, message, talkMode, setStringParam, setIntParams ]); - return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
-
- + + + { LocalizeText('wiredfurni.params.message') } setMessage(event.target.value) } /> -
-
-
+ + + setTalkMode(0) } /> - -
-
+ { LocalizeText('wiredfurni.params.talk') } + + setTalkMode(1) } /> - -
-
+ { LocalizeText('wiredfurni.params.whisper') } + +
); } diff --git a/src/components/wired/views/actions/WiredActionBotTalkView.tsx b/src/components/wired/views/actions/WiredActionBotTalkView.tsx index bf92e915..86c83fb9 100644 --- a/src/components/wired/views/actions/WiredActionBotTalkView.tsx +++ b/src/components/wired/views/actions/WiredActionBotTalkView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { WIRED_STRING_DELIMETER } from '../../common/WiredStringDelimeter'; import { useWiredContext } from '../../context/WiredContext'; @@ -12,42 +16,48 @@ export const WiredActionBotTalkView: FC<{}> = props => const [ talkMode, setTalkMode ] = useState(-1); const { trigger = null, setStringParam = null, setIntParams = null } = useWiredContext(); + const save = useCallback(() => + { + BatchUpdates(() => + { + setStringParam(botName + WIRED_STRING_DELIMETER + message); + setIntParams([ talkMode ]); + }); + }, [ botName, message, talkMode, setStringParam, setIntParams ]); + useEffect(() => { const data = trigger.stringData.split(WIRED_STRING_DELIMETER); - if(data.length > 0) setBotName(data[0]); - if(data.length > 1) setMessage(data[1].length > 0 ? data[1] : ''); - - setTalkMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); + BatchUpdates(() => + { + if(data.length > 0) setBotName(data[0]); + if(data.length > 1) setMessage(data[1].length > 0 ? data[1] : ''); + + setTalkMode((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }); }, [ trigger ]); - const save = useCallback(() => - { - setStringParam(botName + WIRED_STRING_DELIMETER + message); - setIntParams([ talkMode ]); - }, [ botName, message, talkMode, setStringParam, setIntParams ]); - return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
-
- + + + { LocalizeText('wiredfurni.params.message') } setMessage(event.target.value) } /> -
-
-
+ + + setTalkMode(0) } /> - -
-
+ { LocalizeText('wiredfurni.params.talk') } + + setTalkMode(1) } /> - -
-
+ { LocalizeText('wiredfurni.params.shout') } + +
); } diff --git a/src/components/wired/views/actions/WiredActionBotTeleportView.tsx b/src/components/wired/views/actions/WiredActionBotTeleportView.tsx index e9170f68..bf929e98 100644 --- a/src/components/wired/views/actions/WiredActionBotTeleportView.tsx +++ b/src/components/wired/views/actions/WiredActionBotTeleportView.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -9,22 +11,22 @@ export const WiredActionBotTeleportView: FC<{}> = props => const [ botName, setBotName ] = useState(''); const { trigger = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setBotName(trigger.stringData); - }, [ trigger ]); - const save = useCallback(() => { setStringParam(botName); }, [ botName, setStringParam ]); + useEffect(() => + { + setBotName(trigger.stringData); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.bot.name') } setBotName(event.target.value) } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionChatView.tsx b/src/components/wired/views/actions/WiredActionChatView.tsx index b0dad715..a67ec482 100644 --- a/src/components/wired/views/actions/WiredActionChatView.tsx +++ b/src/components/wired/views/actions/WiredActionChatView.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -9,22 +11,22 @@ export const WiredActionChatView: FC<{}> = props => const [ message, setMessage ] = useState(''); const { trigger = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setMessage(trigger.stringData); - }, [ trigger ]); - const save = useCallback(() => { setStringParam(message); }, [ message, setStringParam ]); + useEffect(() => + { + setMessage(trigger.stringData); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.message') } setMessage(event.target.value) } maxLength={ 100 } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionGiveRewardView.tsx b/src/components/wired/views/actions/WiredActionGiveRewardView.tsx index a956d4bc..5da167d7 100644 --- a/src/components/wired/views/actions/WiredActionGiveRewardView.tsx +++ b/src/components/wired/views/actions/WiredActionGiveRewardView.tsx @@ -1,6 +1,12 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Button } from '../../../../common/Button'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -13,41 +19,8 @@ export const WiredActionGiveRewardView: FC<{}> = props => const [ rewardsLimit, setRewardsLimit ] = useState(1); const [ limitationInterval, setLimitationInterval ] = useState(1); const [ rewards, setRewards ] = useState<{ isBadge: boolean, itemCode: string, probability: number }[]>([]); - const { trigger = null, setIntParams = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setRewardTime(trigger.intData.length > 0 ? trigger.intData[0] : 0); - setUniqueRewards(trigger.intData.length > 1 ? trigger.intData[1] === 1 : false); - 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); - - const readRewards: { isBadge: boolean, itemCode: string, probability: number }[] = []; - - if(trigger.stringData.length > 0 && trigger.stringData.includes(';')) - { - const splittedRewards = trigger.stringData.split(';'); - - for(const rawReward of splittedRewards) - { - const reward = rawReward.split(','); - - if(reward.length !== 3) continue; - - readRewards.push({ isBadge: reward[0] === '0', itemCode: reward[1], probability: Number(reward[2]) }); - } - } - - if(readRewards.length === 0) - { - readRewards.push({ isBadge: false, itemCode: '', probability: null }); - } - - setRewards(readRewards); - }, [ trigger ]); - const addReward = useCallback(() => { setRewards(rewards => [...rewards, { isBadge: false, itemCode: '', probability: null }]); @@ -55,11 +28,15 @@ export const WiredActionGiveRewardView: FC<{}> = props => const removeReward = useCallback((index: number) => { - const rewardsClone = Array.from(rewards); - rewardsClone.splice(index, 1); + setRewards(prevValue => + { + const newValues = Array.from(prevValue); - setRewards(rewardsClone); - }, [ rewards, setRewards ]); + newValues.splice(index, 1); + + return newValues; + }); + }, [ setRewards ]); const updateReward = useCallback((index: number, isBadge: boolean, itemCode: string, probability: number) => { @@ -89,84 +66,109 @@ export const WiredActionGiveRewardView: FC<{}> = props => if(stringRewards.length > 0) { - setStringParam(stringRewards.join(';')); - setIntParams([rewardTime, uniqueRewards ? 1 : 0, rewardsLimit, limitationInterval]); + BatchUpdates(() => + { + setStringParam(stringRewards.join(';')); + setIntParams([rewardTime, uniqueRewards ? 1 : 0, rewardsLimit, limitationInterval]); + }); } }, [ rewardTime, uniqueRewards, rewardsLimit, limitationInterval, rewards, setIntParams, setStringParam ]); + useEffect(() => + { + const readRewards: { isBadge: boolean, itemCode: string, probability: number }[] = []; + + if(trigger.stringData.length > 0 && trigger.stringData.includes(';')) + { + const splittedRewards = trigger.stringData.split(';'); + + for(const rawReward of splittedRewards) + { + const reward = rawReward.split(','); + + if(reward.length !== 3) continue; + + readRewards.push({ isBadge: reward[0] === '0', itemCode: reward[1], probability: Number(reward[2]) }); + } + } + + if(readRewards.length === 0) readRewards.push({ isBadge: false, itemCode: '', probability: null }); + + BatchUpdates(() => + { + setRewardTime((trigger.intData.length > 0) ? trigger.intData[0] : 0); + setUniqueRewards((trigger.intData.length > 1) ? (trigger.intData[1] === 1) : false); + 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); + setRewards(readRewards); + }); + }, [ trigger ]); + return ( -
- setLimitEnabled(e.target.checked)} /> - -
- { !limitEnabled &&
+ + setLimitEnabled(event.target.checked)} /> + { LocalizeText('wiredfurni.params.prizelimit', ['amount'], [limitEnabled ? rewardsLimit.toString() : '']) } + + { !limitEnabled && + Reward limit not set. Make sure rewards are badges or non-tradeable items. -
} - { limitEnabled && + } + { limitEnabled && setRewardsLimit(event) } /> } -
-
How ofter can a user be rewarded?
-
- - { rewardTime > 0 && setLimitationInterval(Number(event.target.value)) } /> } -
-
-
+
+ + How often can a user be rewarded? + + + { (rewardTime > 0) && setLimitationInterval(Number(event.target.value)) } /> } + + +
+ setUniqueRewards(e.target.checked)} /> - -
-
If checked each reward will be given once to each user. This will disable the probabilities option.
-
-
-
Rewards
-
-
- - - - - - - - - - - { rewards && rewards.map((reward, index) => - { - return ( - - - - - - - ) - }) } - -
Badge?Item CodeProbability
- updateReward(index, e.target.checked, reward.itemCode, reward.probability)} /> - - updateReward(index, reward.isBadge, e.target.value, reward.probability) } /> - - updateReward(index, reward.isBadge, reward.itemCode, Number(e.target.value)) } /> - - { index > 0 && } -
+ Unique rewards + + + If checked each reward will be given once to each user. This will disable the probabilities option. + +
+ + Rewards + + + + { rewards && rewards.map((reward, index) => + { + return ( + + + updateReward(index, e.target.checked, reward.itemCode, reward.probability)} /> + Badge? + + updateReward(index, reward.isBadge, e.target.value, reward.probability) } placeholder="Item Code" /> + updateReward(index, reward.isBadge, reward.itemCode, Number(e.target.value)) } placeholder="Probability" /> + { (index > 0) && + } + + ) + }) } +
); } diff --git a/src/components/wired/views/actions/WiredActionGiveScoreToPredefinedTeamView.tsx b/src/components/wired/views/actions/WiredActionGiveScoreToPredefinedTeamView.tsx index 7895f4d3..1e5c2d38 100644 --- a/src/components/wired/views/actions/WiredActionGiveScoreToPredefinedTeamView.tsx +++ b/src/components/wired/views/actions/WiredActionGiveScoreToPredefinedTeamView.tsx @@ -1,6 +1,10 @@ import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -12,61 +16,62 @@ export const WiredActionGiveScoreToPredefinedTeamView: FC<{}> = props => const [ selectedTeam, setSelectedTeam ] = useState(1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - if(trigger.intData.length >= 2) - { - setPoints(trigger.intData[0]); - setTime(trigger.intData[1]); - setSelectedTeam(trigger.intData[2]); - } - else - { - setPoints(1); - setTime(1); - setSelectedTeam(1); - } - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ points, time, selectedTeam ]); }, [ points, time, selectedTeam, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + if(trigger.intData.length >= 2) + { + setPoints(trigger.intData[0]); + setTime(trigger.intData[1]); + setSelectedTeam(trigger.intData[2]); + } + else + { + setPoints(1); + setTime(1); + setSelectedTeam(1); + } + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.setpoints', [ 'points' ], [ points.toString() ]) } setPoints(event) } /> -
-
- + + + { LocalizeText('wiredfurni.params.settimesingame', [ 'times' ], [ time.toString() ]) } setTime(event) } /> -
-
- + + + { LocalizeText('wiredfurni.params.team') } { [1, 2, 3, 4].map(value => { return ( -
+ setSelectedTeam(value) } /> - -
+ { LocalizeText('wiredfurni.params.team.' + value) } + ); }) } -
+
); } diff --git a/src/components/wired/views/actions/WiredActionGiveScoreView.tsx b/src/components/wired/views/actions/WiredActionGiveScoreView.tsx index a73b1e87..b82f2d0c 100644 --- a/src/components/wired/views/actions/WiredActionGiveScoreView.tsx +++ b/src/components/wired/views/actions/WiredActionGiveScoreView.tsx @@ -1,6 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -11,45 +14,48 @@ export const WiredActionGiveScoreView: FC<{}> = props => const [ time, setTime ] = useState(1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - if(trigger.intData.length >= 2) - { - setPoints(trigger.intData[0]); - setTime(trigger.intData[1]); - } - else - { - setPoints(1); - setTime(1); - } - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ points, time ]); }, [ points, time, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + if(trigger.intData.length >= 2) + { + setPoints(trigger.intData[0]); + setTime(trigger.intData[1]); + } + else + { + setPoints(1); + setTime(1); + } + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.setpoints', [ 'points' ], [ points.toString() ]) } setPoints(event) } /> -
-
- + + + { LocalizeText('wiredfurni.params.settimesingame', [ 'times' ], [ time.toString() ]) } setTime(event) } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionJoinTeamView.tsx b/src/components/wired/views/actions/WiredActionJoinTeamView.tsx index a6c75127..bd3fae76 100644 --- a/src/components/wired/views/actions/WiredActionJoinTeamView.tsx +++ b/src/components/wired/views/actions/WiredActionJoinTeamView.tsx @@ -1,5 +1,8 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -9,32 +12,30 @@ export const WiredActionJoinTeamView: FC<{}> = props => const [ selectedTeam, setSelectedTeam ] = useState(-1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - setSelectedTeam((trigger.intData.length > 0) ? trigger.intData[0] : 0); - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ selectedTeam ]); }, [ selectedTeam, setIntParams ]); + useEffect(() => + { + setSelectedTeam((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.team') } { [1, 2, 3, 4].map(team => { return ( -
+ setSelectedTeam(team) } /> - -
+ { LocalizeText(`wiredfurni.params.team.${ team }`) } + ) }) } -
+
); } diff --git a/src/components/wired/views/actions/WiredActionKickFromRoomView.tsx b/src/components/wired/views/actions/WiredActionKickFromRoomView.tsx index 3e37ad35..25dc5b82 100644 --- a/src/components/wired/views/actions/WiredActionKickFromRoomView.tsx +++ b/src/components/wired/views/actions/WiredActionKickFromRoomView.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -9,22 +11,22 @@ export const WiredActionKickFromRoomView: FC<{}> = props => const [ message, setMessage ] = useState(''); const { trigger = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setMessage(trigger.stringData); - }, [ trigger ]); - const save = useCallback(() => { setStringParam(message); }, [ message, setStringParam ]); + useEffect(() => + { + setMessage(trigger.stringData); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.message') } setMessage(event.target.value) } maxLength={ 100 } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionMoveAndRotateFurniView.tsx b/src/components/wired/views/actions/WiredActionMoveAndRotateFurniView.tsx index ed1d33d3..4b322d03 100644 --- a/src/components/wired/views/actions/WiredActionMoveAndRotateFurniView.tsx +++ b/src/components/wired/views/actions/WiredActionMoveAndRotateFurniView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -31,59 +35,58 @@ export const WiredActionMoveAndRotateFurniView: FC<{}> = props => const [ rotation, setRotation ] = useState(-1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - if(trigger.intData.length >= 2) - { - setMovement(trigger.intData[0]); - setRotation(trigger.intData[1]); - } - else - { - setMovement(-1); - setRotation(-1); - } - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ movement, rotation ]); }, [ movement, rotation, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + if(trigger.intData.length >= 2) + { + setMovement(trigger.intData[0]); + setRotation(trigger.intData[1]); + } + else + { + setMovement(-1); + setRotation(-1); + } + }); + }, [ trigger ]); + return ( -
- -
+ + { LocalizeText('wiredfurni.params.startdir') } + { directionOptions.map(option => { return ( -
-
- setMovement(option.value) } /> - -
-
+ + setMovement(option.value) } /> + + + + ) }) } -
-
-
- + + + + { LocalizeText('wiredfurni.params.turn') } { rotationOptions.map(option => { return ( -
+ setRotation(option) } /> - -
+ { LocalizeText(`wiredfurni.params.turn.${ option }`) } + ) }) } -
+
); } diff --git a/src/components/wired/views/actions/WiredActionMoveFurniToView.tsx b/src/components/wired/views/actions/WiredActionMoveFurniToView.tsx index abf69e40..bea80976 100644 --- a/src/components/wired/views/actions/WiredActionMoveFurniToView.tsx +++ b/src/components/wired/views/actions/WiredActionMoveFurniToView.tsx @@ -1,6 +1,10 @@ import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -30,54 +34,53 @@ export const WiredActionMoveFurniToView: FC<{}> = props => const [ movement, setMovement ] = useState(-1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - if(trigger.intData.length >= 2) - { - setSpacing(trigger.intData[1]); - setMovement(trigger.intData[0]); - } - else - { - setSpacing(-1); - setMovement(-1); - } - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ movement, spacing ]); }, [ movement, spacing, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + if(trigger.intData.length >= 2) + { + setSpacing(trigger.intData[1]); + setMovement(trigger.intData[0]); + } + else + { + setSpacing(-1); + setMovement(-1); + } + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.emptytiles', [ 'tiles' ], [ spacing.toString() ]) } setSpacing(event) } /> -
-
- -
+ + + { LocalizeText('wiredfurni.params.startdir') } + { directionOptions.map(value => { return ( -
-
- setMovement(value.value) } /> - -
-
+ + setMovement(value.value) } /> + + ) }) } -
-
+ +
); } diff --git a/src/components/wired/views/actions/WiredActionMoveFurniView.tsx b/src/components/wired/views/actions/WiredActionMoveFurniView.tsx index a494a58d..8919d5f5 100644 --- a/src/components/wired/views/actions/WiredActionMoveFurniView.tsx +++ b/src/components/wired/views/actions/WiredActionMoveFurniView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -43,67 +47,64 @@ export const WiredActionMoveFurniView: FC<{}> = props => const [ rotation, setRotation ] = useState(-1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - if(trigger.intData.length >= 2) - { - setMovement(trigger.intData[0]); - setRotation(trigger.intData[1]); - } - else - { - setMovement(-1); - setRotation(-1); - } - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ movement, rotation ]); }, [ movement, rotation, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + if(trigger.intData.length >= 2) + { + setMovement(trigger.intData[0]); + setRotation(trigger.intData[1]); + } + else + { + setMovement(-1); + setRotation(-1); + } + }); + }, [ trigger ]); + return ( -
- -
+ + { LocalizeText('wiredfurni.params.movefurni') } + setMovement(0) } /> - -
-
+ { LocalizeText('wiredfurni.params.movefurni.0') } + + { directionOptions.map(option => { return ( -
-
- setMovement(option.value) } /> - -
-
+ + setMovement(option.value) } /> + + ) }) }
-
-
-
- + + + + { LocalizeText('wiredfurni.params.rotatefurni') } { rotationOptions.map(option => { return ( -
+ setRotation(option) } /> - -
+ + ) }) } -
+ ); } diff --git a/src/components/wired/views/actions/WiredActionMuteUserView.tsx b/src/components/wired/views/actions/WiredActionMuteUserView.tsx index 6eec99f6..ed087d7d 100644 --- a/src/components/wired/views/actions/WiredActionMuteUserView.tsx +++ b/src/components/wired/views/actions/WiredActionMuteUserView.tsx @@ -1,6 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -11,33 +14,39 @@ export const WiredActionMuteUserView: FC<{}> = props => const [ message, setMessage ] = useState(''); const { trigger = null, setIntParams = null, setStringParam = null } = useWiredContext(); - useEffect(() => - { - setTime((trigger.intData.length > 0) ? trigger.intData[0] : 0); - setMessage(trigger.stringData); - }, [ trigger ]); - const save = useCallback(() => { - setIntParams([ time ]); - setStringParam(message); + BatchUpdates(() => + { + setIntParams([ time ]); + setStringParam(message); + }); }, [ time, message, setIntParams, setStringParam ]); + useEffect(() => + { + BatchUpdates(() => + { + setTime((trigger.intData.length > 0) ? trigger.intData[0] : 0); + setMessage(trigger.stringData); + }); + }, [ trigger ]); + return ( -
- + + { LocalizeText('wiredfurni.params.length.minutes', ['minutes'], [ time.toString() ]) } setTime(event) } /> -
-
- + + + { LocalizeText('wiredfurni.params.message') } setMessage(event.target.value) } maxLength={ 100 } /> -
+
); } diff --git a/src/components/wired/views/actions/WiredActionSetFurniStateToView.tsx b/src/components/wired/views/actions/WiredActionSetFurniStateToView.tsx index 30df7087..3b334784 100644 --- a/src/components/wired/views/actions/WiredActionSetFurniStateToView.tsx +++ b/src/components/wired/views/actions/WiredActionSetFurniStateToView.tsx @@ -1,5 +1,9 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredActionBaseView } from './WiredActionBaseView'; @@ -11,41 +15,38 @@ export const WiredActionSetFurniStateToView: FC<{}> = props => const [ positionFlag, setPositionFlag ] = useState(-1); const { trigger = null, setIntParams = null } = useWiredContext(); - useEffect(() => - { - setStateFlag(trigger.getBoolean(0) ? 1 : 0); - setDirectionFlag(trigger.getBoolean(1) ? 1 : 0); - setPositionFlag(trigger.getBoolean(2) ? 1 : 0); - }, [ trigger ]); - const save = useCallback(() => { setIntParams([ stateFlag, directionFlag, positionFlag ]); }, [ directionFlag, positionFlag, stateFlag, setIntParams ]); + useEffect(() => + { + BatchUpdates(() => + { + setStateFlag(trigger.getBoolean(0) ? 1 : 0); + setDirectionFlag(trigger.getBoolean(1) ? 1 : 0); + setPositionFlag(trigger.getBoolean(2) ? 1 : 0); + }); + }, [ trigger ]); + return ( -
- -
+ + { LocalizeText('wiredfurni.params.conditions') } + setStateFlag(event.target.checked ? 1 : 0) } /> - -
-
+ { LocalizeText('wiredfurni.params.condition.state') } + + setDirectionFlag(event.target.checked ? 1 : 0) } /> - -
-
+ { LocalizeText('wiredfurni.params.condition.direction') } + + setPositionFlag(event.target.checked ? 1 : 0) } /> - -
-
+ { LocalizeText('wiredfurni.params.condition.position') } + +
); } diff --git a/src/components/wired/views/conditions/WiredConditionFurniHasFurniOnView.tsx b/src/components/wired/views/conditions/WiredConditionFurniHasFurniOnView.tsx index 79f8df23..5fab235a 100644 --- a/src/components/wired/views/conditions/WiredConditionFurniHasFurniOnView.tsx +++ b/src/components/wired/views/conditions/WiredConditionFurniHasFurniOnView.tsx @@ -29,7 +29,7 @@ export const WiredConditionFurniHasFurniOnView: FC<{}> = props => { [0, 1].map(value => { return ( - + setRequireAll(value) } /> { LocalizeText('wiredfurni.params.requireall.' + value) } diff --git a/src/components/wired/views/conditions/WiredConditionFurniHasNotFurniOnView.tsx b/src/components/wired/views/conditions/WiredConditionFurniHasNotFurniOnView.tsx index 71cf5464..1e9d8efe 100644 --- a/src/components/wired/views/conditions/WiredConditionFurniHasNotFurniOnView.tsx +++ b/src/components/wired/views/conditions/WiredConditionFurniHasNotFurniOnView.tsx @@ -29,7 +29,7 @@ export const WiredConditionFurniHasNotFurniOnView: FC<{}> = props => { [0, 1].map(value => { return ( - + setRequireAll(value) } /> { LocalizeText(`wiredfurni.params.not_requireall.${ value }`) } diff --git a/src/components/wired/views/conditions/WiredConditionFurniMatchesSnapshotView.tsx b/src/components/wired/views/conditions/WiredConditionFurniMatchesSnapshotView.tsx index c7aa6509..2924cc60 100644 --- a/src/components/wired/views/conditions/WiredConditionFurniMatchesSnapshotView.tsx +++ b/src/components/wired/views/conditions/WiredConditionFurniMatchesSnapshotView.tsx @@ -3,6 +3,7 @@ import { LocalizeText } from '../../../../api'; import { Column } from '../../../../common/Column'; import { Flex } from '../../../../common/Flex'; import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredConditionBaseView } from './WiredConditionBaseView'; @@ -21,24 +22,27 @@ export const WiredConditionFurniMatchesSnapshotView: FC<{}> = props => useEffect(() => { - setStateFlag(trigger.getBoolean(0) ? 1 : 0); - setDirectionFlag(trigger.getBoolean(1) ? 1 : 0); - setPositionFlag(trigger.getBoolean(2) ? 1 : 0); + BatchUpdates(() => + { + setStateFlag(trigger.getBoolean(0) ? 1 : 0); + setDirectionFlag(trigger.getBoolean(1) ? 1 : 0); + setPositionFlag(trigger.getBoolean(2) ? 1 : 0); + }); }, [ trigger ]); return ( { LocalizeText('wiredfurni.params.conditions') } - + setStateFlag(event.target.checked ? 1 : 0) } /> { LocalizeText('wiredfurni.params.condition.state') } - + setDirectionFlag(event.target.checked ? 1 : 0) } /> { LocalizeText('wiredfurni.params.condition.direction') } - + setPositionFlag(event.target.checked ? 1 : 0) } /> { LocalizeText('wiredfurni.params.condition.position') } diff --git a/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx b/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx index 897a7881..da62af2e 100644 --- a/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx +++ b/src/components/wired/views/conditions/WiredConditionUserCountInRoomView.tsx @@ -3,6 +3,7 @@ import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../../api'; import { Column } from '../../../../common/Column'; import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredConditionBaseView } from './WiredConditionBaseView'; @@ -20,16 +21,19 @@ export const WiredConditionUserCountInRoomView: FC<{}> = props => useEffect(() => { - if(trigger.intData.length >= 2) + BatchUpdates(() => { - setMin(trigger.intData[0]); - setMax(trigger.intData[1]); - } - else - { - setMin(1); - setMax(1); - } + if(trigger.intData.length >= 2) + { + setMin(trigger.intData[0]); + setMax(trigger.intData[1]); + } + else + { + setMin(1); + setMax(1); + } + }); }, [ trigger ]); return ( diff --git a/src/components/wired/views/triggers/WiredTriggerAvatarEnterRoomView.tsx b/src/components/wired/views/triggers/WiredTriggerAvatarEnterRoomView.tsx index c8cd6cc2..ae1c2890 100644 --- a/src/components/wired/views/triggers/WiredTriggerAvatarEnterRoomView.tsx +++ b/src/components/wired/views/triggers/WiredTriggerAvatarEnterRoomView.tsx @@ -3,6 +3,7 @@ import { LocalizeText } from '../../../../api'; import { Column } from '../../../../common/Column'; import { Flex } from '../../../../common/Flex'; import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredTriggerBaseView } from './WiredTriggerBaseView'; @@ -21,8 +22,11 @@ export const WiredTriggerAvatarEnterRoomView: FC<{}> = props => useEffect(() => { - setUsername(trigger.stringData); - setAvatarMode(trigger.stringData ? 1 : 0) + BatchUpdates(() => + { + setUsername(trigger.stringData); + setAvatarMode(trigger.stringData ? 1 : 0); + }); }, [ trigger ]); return ( diff --git a/src/components/wired/views/triggers/WiredTriggerAvatarSaysSomethingView.tsx b/src/components/wired/views/triggers/WiredTriggerAvatarSaysSomethingView.tsx index 7a9f3596..edc55a50 100644 --- a/src/components/wired/views/triggers/WiredTriggerAvatarSaysSomethingView.tsx +++ b/src/components/wired/views/triggers/WiredTriggerAvatarSaysSomethingView.tsx @@ -3,6 +3,7 @@ import { GetSessionDataManager, LocalizeText } from '../../../../api'; import { Column } from '../../../../common/Column'; import { Flex } from '../../../../common/Flex'; import { Text } from '../../../../common/Text'; +import { BatchUpdates } from '../../../../hooks'; import { WiredFurniType } from '../../common/WiredFurniType'; import { useWiredContext } from '../../context/WiredContext'; import { WiredTriggerBaseView } from './WiredTriggerBaseView'; @@ -15,14 +16,20 @@ export const WiredTriggerAvatarSaysSomethingView: FC<{}> = props => const save = useCallback(() => { - setStringParam(message); - setIntParams([ triggererAvatar ]); + BatchUpdates(() => + { + setStringParam(message); + setIntParams([ triggererAvatar ]); + }); }, [ message, triggererAvatar, setStringParam, setIntParams ]); useEffect(() => { - setMessage(trigger.stringData); - setTriggererAvatar((trigger.intData.length > 0) ? trigger.intData[0] : 0); + BatchUpdates(() => + { + setMessage(trigger.stringData); + setTriggererAvatar((trigger.intData.length > 0) ? trigger.intData[0] : 0); + }); }, [ trigger ]); return (