diff --git a/src/api/nitro/session/GetFurnitureDataForProductOffer.ts b/src/api/nitro/session/GetFurnitureDataForProductOffer.ts index 9bfd214..b037765 100644 --- a/src/api/nitro/session/GetFurnitureDataForProductOffer.ts +++ b/src/api/nitro/session/GetFurnitureDataForProductOffer.ts @@ -6,7 +6,7 @@ export function GetFurnitureDataForProductOffer(offer: CatalogPageMessageProduct let furniData: IFurnitureData = null; - switch ((offer.productType.toUpperCase()) as FurnitureType) + switch ((offer.productType) as FurnitureType) { case FurnitureType.FLOOR: furniData = GetSessionDataManager().getFloorItemData(offer.furniClassId); diff --git a/src/api/utils/ProductImageUtility.ts b/src/api/utils/ProductImageUtility.ts index b12c43d..5443513 100644 --- a/src/api/utils/ProductImageUtility.ts +++ b/src/api/utils/ProductImageUtility.ts @@ -1,18 +1,18 @@ -import { CatalogPageMessageProductData, GetRoomEngine } from '@nitrots/nitro-renderer'; +import { FurnitureType, GetRoomEngine } from '@nitrots/nitro-renderer'; import { FurniCategory } from '../inventory'; export class ProductImageUtility { - public static getProductImageUrl(productType: string, furniClassId: number, extraParam: string): string + public static getProductImageUrl(productType: FurnitureType, furniClassId: number, extraParam: string): string { let imageUrl: string = null; switch(productType) { - case CatalogPageMessageProductData.S: + case FurnitureType.FLOOR: imageUrl = GetRoomEngine().getFurnitureFloorIconUrl(furniClassId); break; - case CatalogPageMessageProductData.I: + case FurnitureType.WALL: const productCategory = this.getProductCategory(CatalogPageMessageProductData.I, furniClassId); if(productCategory === 1) @@ -32,7 +32,7 @@ export class ProductImageUtility } } break; - case CatalogPageMessageProductData.E: + case FurnitureType.EFFECT: // fx_icon_furniClassId_png break; } @@ -40,11 +40,11 @@ export class ProductImageUtility return imageUrl; } - public static getProductCategory(productType: string, furniClassId: number): number + public static getProductCategory(productType: FurnitureType, furniClassId: number): number { - if(productType === CatalogPageMessageProductData.S) return 1; + if(productType === FurnitureType.FLOOR) return 1; - if(productType === CatalogPageMessageProductData.I) + if(productType === FurnitureType.WALL) { if(furniClassId === 3001) return FurniCategory.WALL_PAPER; diff --git a/src/common/index.ts b/src/common/index.ts index 2dc9a26..10f2bf3 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -17,6 +17,5 @@ export * from './card/tabs'; export * from './draggable-window'; export * from './layout'; export * from './layout/limited-edition'; -export * from './transitions'; export * from './types'; export * from './utils'; diff --git a/src/common/layout/LayoutAvatarImageView.tsx b/src/common/layout/LayoutAvatarImageView.tsx index 316b1fd..86d589e 100644 --- a/src/common/layout/LayoutAvatarImageView.tsx +++ b/src/common/layout/LayoutAvatarImageView.tsx @@ -80,7 +80,7 @@ export const LayoutAvatarImageView: FC = props => setAvatarUrl(imageUrl); } - avatarImage.dispose(true); + avatarImage.dispose(); }; resetFigure(figure); diff --git a/src/components/room/widgets/furniture/FurnitureAreaHideView.tsx b/src/components/room/widgets/furniture/FurnitureAreaHideView.tsx new file mode 100644 index 0000000..8b7bd82 --- /dev/null +++ b/src/components/room/widgets/furniture/FurnitureAreaHideView.tsx @@ -0,0 +1,58 @@ +import { GetRoomEngine } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { LocalizeText } from '../../../../api'; +import { Button, Column, Flex, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; +import { useFurnitureAreaHideWidget } from '../../../../hooks'; + +export const FurnitureAreaHideView: FC<{}> = props => +{ + const { objectId = -1, isOn, setIsOn, wallItems, setWallItems, inverted, setInverted, invisibility, setInvisibility, onClose = null } = useFurnitureAreaHideWidget(); + + if(objectId === -1) return null; + + return ( + + + + + + { LocalizeText('wiredfurni.params.area_selection') } + { LocalizeText('wiredfurni.params.area_selection.info') } + + + + + + + + { LocalizeText('widget.areahide.options') } + + setWallItems(event.target.checked ? true : false) } /> + { LocalizeText('widget.areahide.options.wallitems') } + + + setInverted(event.target.checked ? true : false) } /> + + { LocalizeText('widget.areahide.options.invert') } + { LocalizeText('widget.areahide.options.invert.info') } + + + + setInvisibility(event.target.checked ? true : false) } /> + + { LocalizeText('widget.areahide.options.invisibility') } + { LocalizeText('widget.areahide.options.invisibility.info') } + + + + + + + ); +}; \ No newline at end of file diff --git a/src/hooks/rooms/widgets/furniture/index.ts b/src/hooks/rooms/widgets/furniture/index.ts index 37fa573..d9eccba 100644 --- a/src/hooks/rooms/widgets/furniture/index.ts +++ b/src/hooks/rooms/widgets/furniture/index.ts @@ -1,3 +1,4 @@ +export * from './useFurnitureAreaHideWidget'; export * from './useFurnitureBackgroundColorWidget'; export * from './useFurnitureBadgeDisplayWidget'; export * from './useFurnitureContextMenuWidget'; diff --git a/src/hooks/rooms/widgets/furniture/useFurnitureAreaHideWidget.ts b/src/hooks/rooms/widgets/furniture/useFurnitureAreaHideWidget.ts new file mode 100644 index 0000000..a454401 --- /dev/null +++ b/src/hooks/rooms/widgets/furniture/useFurnitureAreaHideWidget.ts @@ -0,0 +1,93 @@ +import { GetRoomEngine, RoomAreaSelectionManager, RoomEngineAreaHideStateEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable } from '@nitrots/nitro-renderer'; +import { useEffect, useState } from 'react'; +import { CanManipulateFurniture } from '../../../../api'; +import { useNitroEvent } from '../../../events'; +import { useRoom } from '../../useRoom'; + +const useFurnitureAreaHideWidgetState = () => +{ + const [ objectId, setObjectId ] = useState(-1); + const [ category, setCategory ] = useState(-1); + const [ isOn, setIsOn ] = useState(false); + const [ rootX, setRootX ] = useState(0); + const [ rootY, setRootY ] = useState(0); + const [ width, setWidth ] = useState(0); + const [ length, setLength ] = useState(0); + const [ invisibility, setInvisibility ] = useState(false); + const [ wallItems, setWallItems ] = useState(false); + const [ inverted, setInverted ] = useState(false); + const { roomSession = null } = useRoom(); + + const onClose = () => + { + setObjectId(-1); + setCategory(-1); + setIsOn(false); + setRootX(0); + setRootY(0); + setWidth(0); + setLength(0); + setInvisibility(false); + setWallItems(false); + setInverted(false); + + GetRoomEngine().areaSelectionManager.deactivate(); + }; + + useNitroEvent(RoomEngineTriggerWidgetEvent.REQUEST_AREA_HIDE, event => + { + if(!CanManipulateFurniture(roomSession, event.objectId, event.category)) return; + + setObjectId(event.objectId); + setCategory(event.category); + + const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); + + const model = roomObject.model; + + setIsOn(roomObject.getState(0) === 1); + setRootX(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_X) ?? 0); + setRootY(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_Y) ?? 0); + setWidth(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_WIDTH) ?? 0); + setLength(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_LENGTH) ?? 0); + setInvisibility(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_INVISIBILITY) === 1); + setWallItems(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_WALL_ITEMS) === 1); + setInverted(model.getValue(RoomObjectVariable.FURNITURE_AREA_HIDE_INVERT) === 1); + }); + + useNitroEvent(RoomEngineAreaHideStateEvent.UPDATE_STATE_AREA_HIDE, event => + { + setObjectId(event.objectId); + setCategory(event.category); + setIsOn(event.isOn); + }); + + useEffect(() => + { + if(objectId === -1) return; + + if(!isOn) + { + const callback = (rootX: number, rootY: number, width: number, height: number) => + { + setRootX(rootX); + setRootY(rootY); + setWidth(width); + setLength(height); + }; + + if(GetRoomEngine().areaSelectionManager.activate(callback, RoomAreaSelectionManager.HIGHLIGHT_DARKEN)) + { + GetRoomEngine().areaSelectionManager.setHighlight(rootX, rootY, width, length); + } + } + else + { + GetRoomEngine().areaSelectionManager.deactivate(); + } + }, [ objectId, isOn, rootX, rootY, width, length ]); + + return { objectId, category, isOn, setIsOn, rootX, setRootX, rootY, setRootY, width, setWidth, length, setLength, invisibility, setInvisibility, wallItems, setWallItems, inverted, setInverted, onClose }; +}; + +export const useFurnitureAreaHideWidget = useFurnitureAreaHideWidgetState; \ No newline at end of file