diff --git a/src/views/inventory/InventoryView.tsx b/src/views/inventory/InventoryView.tsx index cca52d96..5d6d1b22 100644 --- a/src/views/inventory/InventoryView.tsx +++ b/src/views/inventory/InventoryView.tsx @@ -59,7 +59,7 @@ export const InventoryView: FC = props => setObjectMoverRequested(false); - if(!event._Str_4057) setIsVisible(true); + if(!event.placedInRoom) setIsVisible(true); }, []); useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent); diff --git a/src/views/room/widgets/furniture/FurnitureWidgets.scss b/src/views/room/widgets/furniture/FurnitureWidgets.scss index 270dd3ec..2bf505ba 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgets.scss +++ b/src/views/room/widgets/furniture/FurnitureWidgets.scss @@ -1,4 +1,5 @@ @import './engraving-lock/FurnitureEngravingLockView'; +@import './dimmer/FurnitureDimmerView'; @import './exchange-credit/FurnitureExchangeCreditView'; @import './manipulation-menu/FurnitureManipulationMenuView'; @import './mannequin/FurnitureMannequinView'; diff --git a/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx b/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx index 651c04a1..39e0a655 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx +++ b/src/views/room/widgets/furniture/FurnitureWidgetsView.tsx @@ -1,3 +1,4 @@ +import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView'; import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView'; import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView'; import { FurnitureWidgetsViewProps } from './FurnitureWidgetsView.types'; @@ -14,6 +15,7 @@ export function FurnitureWidgetsView(props: FurnitureWidgetsViewProps): JSX.Elem return (
+ diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerData.ts b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerData.ts new file mode 100644 index 00000000..3076cea2 --- /dev/null +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerData.ts @@ -0,0 +1,7 @@ +export class FurnitureDimmerData +{ + constructor( + public objectId: number, + public category: number, + public active: boolean) {} +} diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss new file mode 100644 index 00000000..cbea044c --- /dev/null +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss @@ -0,0 +1,3 @@ +.nitro-dimmer { + width: 300px; +} diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx new file mode 100644 index 00000000..cc146908 --- /dev/null +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx @@ -0,0 +1,91 @@ +import { RoomEngineTriggerWidgetEvent } from 'nitro-renderer/src/nitro/room/events/RoomEngineTriggerWidgetEvent'; +import { RoomObjectVariable } from 'nitro-renderer/src/nitro/room/object/RoomObjectVariable'; +import { FC, useCallback, useState } from 'react'; +import { NitroEvent } from '../../../../../../../nitro-renderer/src/core/events/NitroEvent'; +import { GetRoomEngine } from '../../../../../api/nitro/room/GetRoomEngine'; +import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; +import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event'; +import { NitroCardContentView } from '../../../../../layout/card/content/NitroCardContentView'; +import { NitroCardHeaderView } from '../../../../../layout/card/header/NitroCardHeaderView'; +import { NitroCardView } from '../../../../../layout/card/NitroCardView'; +import { LocalizeText } from '../../../../../utils/LocalizeText'; +import { RoomWidgetDimmerStateUpdateEvent } from '../../events/RoomWidgetDimmerStateUpdateEvent'; +import { RoomWidgetDimmerUpdateEvent } from '../../events/RoomWidgetDimmerUpdateEvent'; +import { RoomWidgetRoomObjectUpdateEvent } from '../../events/RoomWidgetRoomObjectUpdateEvent'; +import { FurnitureDimmerData } from './FurnitureDimmerData'; +import { FurnitureDimmerViewProps } from './FurnitureDimmerView.types'; + +export const FurnitureDimmerView: FC = props => +{ + const [ dimmerData, setDimmerData ] = useState(null); + + const onNitroEvent = useCallback((event: NitroEvent) => + { + switch(event.type) + { + case RoomEngineTriggerWidgetEvent.REQUEST_DIMMER: { + const widgetEvent = (event as RoomEngineTriggerWidgetEvent); + + const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category); + + if(!roomObject) return; + + const data = roomObject.model.getValue(RoomObjectVariable.FURNITURE_DATA); + + console.log('data', data); + + setDimmerData(new FurnitureDimmerData(widgetEvent.objectId, widgetEvent.category, false)); + return; + } + case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: { + const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent); + + setDimmerData(prevState => + { + if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState; + + return null; + }); + return; + } + case RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS: { + const widgetEvent = (event as RoomWidgetDimmerUpdateEvent); + + console.log(widgetEvent); + return; + } + case RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE: { + const widgetEvent = (event as RoomWidgetDimmerStateUpdateEvent); + + console.log(widgetEvent); + return; + } + } + }, []); + + useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_DIMMER, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetDimmerUpdateEvent.RWDUE_PRESETS, props.events, onNitroEvent); + CreateEventDispatcherHook(RoomWidgetDimmerStateUpdateEvent.RWDSUE_DIMMER_STATE, props.events, onNitroEvent); + + const processAction = useCallback((type: string, value: string = null) => + { + switch(type) + { + case 'close': + setDimmerData(null); + return; + } + }, []); + + if(!dimmerData) return null; + + return ( + + processAction('close') } /> + + + + + ); +} diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.types.ts b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.types.ts new file mode 100644 index 00000000..6c267da7 --- /dev/null +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.types.ts @@ -0,0 +1,4 @@ +import { FurnitureWidgetProps } from '../FurnitureWidget.types'; + +export interface FurnitureDimmerViewProps extends FurnitureWidgetProps +{} diff --git a/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx b/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx index ad6eda9b..1a991a3b 100644 --- a/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx +++ b/src/views/room/widgets/furniture/engraving-lock/FurnitureEngravingLockView.tsx @@ -32,7 +32,7 @@ export const FurnitureEngravingLockView: FC = p if(!roomObject) return; const data = roomObject.model.getValue(RoomObjectVariable.FURNITURE_DATA); - const type = roomObject.model.getValue(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING) + const type = roomObject.model.getValue(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING); if(data[0] === '1') { diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx index 45ff3cad..37a945e8 100644 --- a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx +++ b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx @@ -83,7 +83,7 @@ export const FurnitureMannequinView: FC = props => { for(const item of figureContainer.getPartTypeIds()) { - if(parts.indexOf(item) == -1) + if(parts.indexOf(item) === -1) { figureContainer.removePart(item); }