mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Room Widget: dimmer
This commit is contained in:
parent
976f70ed5b
commit
bd9c7e001e
@ -59,7 +59,7 @@ export const InventoryView: FC<InventoryViewProps> = props =>
|
|||||||
|
|
||||||
setObjectMoverRequested(false);
|
setObjectMoverRequested(false);
|
||||||
|
|
||||||
if(!event._Str_4057) setIsVisible(true);
|
if(!event.placedInRoom) setIsVisible(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent);
|
useRoomEngineEvent(RoomEngineObjectEvent.PLACED, onRoomEngineObjectPlacedEvent);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@import './engraving-lock/FurnitureEngravingLockView';
|
@import './engraving-lock/FurnitureEngravingLockView';
|
||||||
|
@import './dimmer/FurnitureDimmerView';
|
||||||
@import './exchange-credit/FurnitureExchangeCreditView';
|
@import './exchange-credit/FurnitureExchangeCreditView';
|
||||||
@import './manipulation-menu/FurnitureManipulationMenuView';
|
@import './manipulation-menu/FurnitureManipulationMenuView';
|
||||||
@import './mannequin/FurnitureMannequinView';
|
@import './mannequin/FurnitureMannequinView';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView';
|
||||||
import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView';
|
import { FurnitureEngravingLockView } from './engraving-lock/FurnitureEngravingLockView';
|
||||||
import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView';
|
import { FurnitureExchangeCreditView } from './exchange-credit/FurnitureExchangeCreditView';
|
||||||
import { FurnitureWidgetsViewProps } from './FurnitureWidgetsView.types';
|
import { FurnitureWidgetsViewProps } from './FurnitureWidgetsView.types';
|
||||||
@ -14,6 +15,7 @@ export function FurnitureWidgetsView(props: FurnitureWidgetsViewProps): JSX.Elem
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="position-absolute nitro-room-widgets t-0 l-0">
|
<div className="position-absolute nitro-room-widgets t-0 l-0">
|
||||||
|
<FurnitureDimmerView events={ events } />
|
||||||
<FurnitureEngravingLockView events={ events } />
|
<FurnitureEngravingLockView events={ events } />
|
||||||
<FurnitureExchangeCreditView events={ events } />
|
<FurnitureExchangeCreditView events={ events } />
|
||||||
<FurnitureHighScoreView events={ events } />
|
<FurnitureHighScoreView events={ events } />
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
export class FurnitureDimmerData
|
||||||
|
{
|
||||||
|
constructor(
|
||||||
|
public objectId: number,
|
||||||
|
public category: number,
|
||||||
|
public active: boolean) {}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
.nitro-dimmer {
|
||||||
|
width: 300px;
|
||||||
|
}
|
@ -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<FurnitureDimmerViewProps> = props =>
|
||||||
|
{
|
||||||
|
const [ dimmerData, setDimmerData ] = useState<FurnitureDimmerData>(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<string[]>(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 (
|
||||||
|
<NitroCardView className="nitro-dimmer">
|
||||||
|
<NitroCardHeaderView headerText={ LocalizeText('widget.dimmer.title') } onCloseClick={ event => processAction('close') } />
|
||||||
|
<NitroCardContentView>
|
||||||
|
|
||||||
|
</NitroCardContentView>
|
||||||
|
</NitroCardView>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
import { FurnitureWidgetProps } from '../FurnitureWidget.types';
|
||||||
|
|
||||||
|
export interface FurnitureDimmerViewProps extends FurnitureWidgetProps
|
||||||
|
{}
|
@ -32,7 +32,7 @@ export const FurnitureEngravingLockView: FC<FurnitureEngravingLockViewProps> = p
|
|||||||
if(!roomObject) return;
|
if(!roomObject) return;
|
||||||
|
|
||||||
const data = roomObject.model.getValue<string[]>(RoomObjectVariable.FURNITURE_DATA);
|
const data = roomObject.model.getValue<string[]>(RoomObjectVariable.FURNITURE_DATA);
|
||||||
const type = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING)
|
const type = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_FRIENDFURNI_ENGRAVING);
|
||||||
|
|
||||||
if(data[0] === '1')
|
if(data[0] === '1')
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
|
|||||||
{
|
{
|
||||||
for(const item of figureContainer.getPartTypeIds())
|
for(const item of figureContainer.getPartTypeIds())
|
||||||
{
|
{
|
||||||
if(parts.indexOf(item) == -1)
|
if(parts.indexOf(item) === -1)
|
||||||
{
|
{
|
||||||
figureContainer.removePart(item);
|
figureContainer.removePart(item);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user