From 9c77ee70b2e83f8c715ad4d3a1d03c06505f23be Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 12 Jan 2022 23:54:46 -0500 Subject: [PATCH] Wired layout changes --- src/components/wired/WiredView.scss | 1 - src/components/wired/WiredView.tsx | 6 ++- src/components/wired/views/WiredBaseView.tsx | 52 +++++++++---------- .../wired/views/WiredFurniSelectorView.tsx | 10 ++-- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/components/wired/WiredView.scss b/src/components/wired/WiredView.scss index eba870c2..11232733 100644 --- a/src/components/wired/WiredView.scss +++ b/src/components/wired/WiredView.scss @@ -1,6 +1,5 @@ .nitro-wired { width: 300px; - padding:7px; .icon { background-repeat: no-repeat; diff --git a/src/components/wired/WiredView.tsx b/src/components/wired/WiredView.tsx index 2a95a5b1..51bad7c7 100644 --- a/src/components/wired/WiredView.tsx +++ b/src/components/wired/WiredView.tsx @@ -1,5 +1,6 @@ import { ConditionDefinition, Triggerable, TriggerDefinition, UpdateActionMessageComposer, UpdateConditionMessageComposer, UpdateTriggerMessageComposer, WiredActionDefinition } from '@nitrots/nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; +import { IsOwnerOfFloorFurniture } from '../../api'; import { WiredEvent } from '../../events'; import { useUiEvent } from '../../hooks/events'; import { SendMessageHook } from '../../hooks/messages'; @@ -22,7 +23,10 @@ export const WiredView: FC<{}> = props => const onWiredEvent = useCallback((event: WiredEvent) => { - // check if owner & warn with confirm + if(!IsOwnerOfFloorFurniture(trigger.id)) + { + + } if(trigger instanceof WiredActionDefinition) { diff --git a/src/components/wired/views/WiredBaseView.tsx b/src/components/wired/views/WiredBaseView.tsx index f807fc25..e04181ca 100644 --- a/src/components/wired/views/WiredBaseView.tsx +++ b/src/components/wired/views/WiredBaseView.tsx @@ -1,8 +1,12 @@ 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 { WiredEvent } from '../../../events'; import { dispatchUiEvent } from '../../../hooks/events'; -import { NitroCardContentView, NitroCardView } from '../../../layout'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../layout'; import { WiredFurniType } from '../common/WiredFurniType'; import { WiredSelectionVisualizer } from '../common/WiredSelectionVisualizer'; import { useWiredContext } from '../context/WiredContext'; @@ -13,11 +17,12 @@ export interface WiredBaseViewProps wiredType: string; requiresFurni: number; save: () => void; + validate?: () => boolean; } export const WiredBaseView: FC = props => { - const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, children = null } = props; + const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null } = props; const [ wiredName, setWiredName ] = useState(null); const [ wiredDescription, setWiredDescription ] = useState(null); const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null } = useWiredContext(); @@ -60,10 +65,12 @@ export const WiredBaseView: FC = props => const onSave = useCallback(() => { + if(validate && !validate()) return; + if(save) save(); setTimeout(() => dispatchUiEvent(new WiredEvent(WiredEvent.SAVE_WIRED)), 1); - }, [ save ]); + }, [ save, validate ]); const close = useCallback(() => { @@ -71,34 +78,27 @@ export const WiredBaseView: FC = props => }, [ setTrigger ]); return ( - -
-
{ LocalizeText('wiredfurni.title') }
-
- -
-
+ + -
- -
{ wiredName }
-
-
{ wiredDescription }
-
- { !children ? null : <> -
- { children } - } -
+ + + + { wiredName } + + { wiredDescription } + + { (children !== null) &&
} + { children } { (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) && <> -
+
} -
- - -
+ + + +
); diff --git a/src/components/wired/views/WiredFurniSelectorView.tsx b/src/components/wired/views/WiredFurniSelectorView.tsx index 129f1b8a..2bda2a08 100644 --- a/src/components/wired/views/WiredFurniSelectorView.tsx +++ b/src/components/wired/views/WiredFurniSelectorView.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useEffect } from 'react'; import { LocalizeText } from '../../../api'; +import { Column } from '../../../common/Column'; +import { Text } from '../../../common/Text'; import { WiredSelectObjectEvent } from '../../../events'; import { useUiEvent } from '../../../hooks/events'; import { WiredSelectionVisualizer } from '../common/WiredSelectionVisualizer'; @@ -75,9 +77,9 @@ export const WiredFurniSelectorView: FC<{}> = props => }, [ trigger, setFurniIds ]); return ( -
-
{ LocalizeText('wiredfurni.pickfurnis.caption', ['count', 'limit'], [ furniIds.length.toString(), trigger.maximumItemSelectionCount.toString() ]) }
- { LocalizeText('wiredfurni.pickfurnis.desc') } -
+ + { LocalizeText('wiredfurni.pickfurnis.caption', ['count', 'limit'], [ furniIds.length.toString(), trigger.maximumItemSelectionCount.toString() ]) } + { LocalizeText('wiredfurni.pickfurnis.desc') } + ); }