mirror of
https://github.com/duckietm/Nitro-Cool-UI.git
synced 2025-06-21 22:36:58 +00:00
🆙 Added the Area Hide in Nitro
This commit is contained in:
parent
96806c33ba
commit
bcbbaf5944
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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';
|
||||
|
@ -80,7 +80,7 @@ export const LayoutAvatarImageView: FC<LayoutAvatarImageViewProps> = props =>
|
||||
setAvatarUrl(imageUrl);
|
||||
}
|
||||
|
||||
avatarImage.dispose(true);
|
||||
avatarImage.dispose();
|
||||
};
|
||||
|
||||
resetFigure(figure);
|
||||
|
@ -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 (
|
||||
<NitroCardView theme="primary-slim" className="nitro-room-widget-area-hide" style={ { maxWidth: '400px' }}>
|
||||
<NitroCardHeaderView headerText={ LocalizeText('widget.areahide.title') } onCloseClick={ onClose } />
|
||||
<NitroCardContentView overflow="hidden" justifyContent="between">
|
||||
<Column gap={ 2 }>
|
||||
<Column gap={ 1 }>
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.area_selection') }</Text>
|
||||
<Text bold>{ LocalizeText('wiredfurni.params.area_selection.info') }</Text>
|
||||
</Column>
|
||||
<Flex gap={ 1 }>
|
||||
<Button fullWidth variant="primary" onClick={ event => GetRoomEngine().areaSelectionManager.startSelecting() }>
|
||||
{ LocalizeText('wiredfurni.params.area_selection.select') }
|
||||
</Button>
|
||||
<Button fullWidth variant="primary" onClick={ event => GetRoomEngine().areaSelectionManager.clearHighlight() }>
|
||||
{ LocalizeText('wiredfurni.params.area_selection.clear') }
|
||||
</Button>
|
||||
</Flex>
|
||||
</Column>
|
||||
<Column gap={ 1 }>
|
||||
<Text bold>{ LocalizeText('widget.areahide.options') }</Text>
|
||||
<Flex gap={ 1 }>
|
||||
<input className="form-check-input" type="checkbox" id="setWallItems" checked={ wallItems } onChange={ event => setWallItems(event.target.checked ? true : false) } />
|
||||
<Text>{ LocalizeText('widget.areahide.options.wallitems') }</Text>
|
||||
</Flex>
|
||||
<Flex gap={ 1 }>
|
||||
<input className="form-check-input" type="checkbox" id="setInverted" checked={ inverted } onChange={ event => setInverted(event.target.checked ? true : false) } />
|
||||
<Column gap={ 1 }>
|
||||
<Text>{ LocalizeText('widget.areahide.options.invert') }</Text>
|
||||
<Text>{ LocalizeText('widget.areahide.options.invert.info') }</Text>
|
||||
</Column>
|
||||
</Flex>
|
||||
<Flex gap={ 1 }>
|
||||
<input className="form-check-input" type="checkbox" id="setInvisibility" checked={ invisibility } onChange={ event => setInvisibility(event.target.checked ? true : false) } />
|
||||
<Column gap={ 1 }>
|
||||
<Text>{ LocalizeText('widget.areahide.options.invisibility') }</Text>
|
||||
<Text>{ LocalizeText('widget.areahide.options.invisibility.info') }</Text>
|
||||
</Column>
|
||||
</Flex>
|
||||
</Column>
|
||||
<Button fullWidth variant="primary">
|
||||
{ LocalizeText(isOn ? 'widget.dimmer.button.off' : 'widget.dimmer.button.on') }
|
||||
</Button>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
};
|
@ -1,3 +1,4 @@
|
||||
export * from './useFurnitureAreaHideWidget';
|
||||
export * from './useFurnitureBackgroundColorWidget';
|
||||
export * from './useFurnitureBadgeDisplayWidget';
|
||||
export * from './useFurnitureContextMenuWidget';
|
||||
|
@ -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<number>(-1);
|
||||
const [ category, setCategory ] = useState<number>(-1);
|
||||
const [ isOn, setIsOn ] = useState<boolean>(false);
|
||||
const [ rootX, setRootX ] = useState<number>(0);
|
||||
const [ rootY, setRootY ] = useState<number>(0);
|
||||
const [ width, setWidth ] = useState<number>(0);
|
||||
const [ length, setLength ] = useState<number>(0);
|
||||
const [ invisibility, setInvisibility ] = useState<boolean>(false);
|
||||
const [ wallItems, setWallItems ] = useState<boolean>(false);
|
||||
const [ inverted, setInverted ] = useState<boolean>(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>(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<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_X) ?? 0);
|
||||
setRootY(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_Y) ?? 0);
|
||||
setWidth(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_WIDTH) ?? 0);
|
||||
setLength(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_LENGTH) ?? 0);
|
||||
setInvisibility(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_INVISIBILITY) === 1);
|
||||
setWallItems(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_WALL_ITEMS) === 1);
|
||||
setInverted(model.getValue<number>(RoomObjectVariable.FURNITURE_AREA_HIDE_INVERT) === 1);
|
||||
});
|
||||
|
||||
useNitroEvent<RoomEngineAreaHideStateEvent>(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;
|
Loading…
x
Reference in New Issue
Block a user