import { FC, useState } from 'react'; import { FaCaretLeft, FaCaretRight } from 'react-icons/fa'; import ReactSlider from 'react-slider'; import { LocalizeText } from '../../../api'; import { Column, Flex, LayoutGridItem, Text } from '../../../common'; import { COLORMAP, FloorAction } from '@nitrots/nitro-renderer'; import { FloorplanEditor } from '@nitrots/nitro-renderer'; import { useFloorplanEditorContext } from '../FloorplanEditorContext'; const MIN_WALL_HEIGHT: number = 0; const MAX_WALL_HEIGHT: number = 16; const MIN_FLOOR_HEIGHT: number = 0; const MAX_FLOOR_HEIGHT: number = 26; export const FloorplanOptionsView: FC<{}> = props => { const { visualizationSettings = null, setVisualizationSettings = null } = useFloorplanEditorContext(); const [ floorAction, setFloorAction ] = useState(FloorAction.SET); const [ floorHeight, setFloorHeight ] = useState(0); const [ isSquareSelectMode, setSquareSelectMode ] = useState(false); const selectAction = (action: number) => { setFloorAction(action); FloorplanEditor.instance.actionSettings.currentAction = action; } const toggleSquareSelectMode = () => { const nextValue = FloorplanEditor.instance.toggleSquareSelectMode(); setSquareSelectMode(nextValue); } const changeDoorDirection = () => { setVisualizationSettings(prevValue => { const newValue = { ...prevValue }; if(newValue.entryPointDir < 7) { ++newValue.entryPointDir; } else { newValue.entryPointDir = 0; } return newValue; }); } const onFloorHeightChange = (value: number) => { if(isNaN(value) || (value <= 0)) value = 0; if(value > 26) value = 26; setFloorHeight(value); FloorplanEditor.instance.actionSettings.currentHeight = value.toString(36); } const onFloorThicknessChange = (value: number) => { setVisualizationSettings(prevValue => { const newValue = { ...prevValue }; newValue.thicknessFloor = value; return newValue; }); } const onWallThicknessChange = (value: number) => { setVisualizationSettings(prevValue => { const newValue = { ...prevValue }; newValue.thicknessWall = value; return newValue; }); } const onWallHeightChange = (value: number) => { if(isNaN(value) || (value <= 0)) value = MIN_WALL_HEIGHT; if(value > MAX_WALL_HEIGHT) value = MAX_WALL_HEIGHT; setVisualizationSettings(prevValue => { const newValue = { ...prevValue }; newValue.wallHeight = value; return newValue; }); } const increaseWallHeight = () => { let height = (visualizationSettings.wallHeight + 1); if(height > MAX_WALL_HEIGHT) height = MAX_WALL_HEIGHT; onWallHeightChange(height); } const decreaseWallHeight = () => { let height = (visualizationSettings.wallHeight - 1); if(height <= 0) height = MIN_WALL_HEIGHT; onWallHeightChange(height); } return ( { LocalizeText('floor.plan.editor.draw.mode') } selectAction(FloorAction.SET) }> selectAction(FloorAction.UNSET) }> selectAction(FloorAction.UP) }> selectAction(FloorAction.DOWN) }> selectAction(FloorAction.DOOR) }> FloorplanEditor.instance.toggleSelectAll() }> { LocalizeText('floor.plan.editor.enter.direction') } { LocalizeText('floor.editor.wall.height') } onWallHeightChange(event.target.valueAsNumber) } /> { LocalizeText('floor.plan.editor.tile.height') }: { floorHeight } onFloorHeightChange(event) } renderThumb={ (props, state) => { const { key, style, ...rest } = (props as Record); return
{ state.valueNow }
; } } />
{ LocalizeText('floor.plan.editor.room.options') }
); }