mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
d6fbd19ee0
Redesign the floor plan editor with side-by-side layout featuring: - Real-time isometric 3D preview that updates as tiles are drawn - Vertical height gradient selector with COLORMAP colors - Area counter showing total and walkable tile counts - Zoom controls (+/-) on the 2D canvas - Simplified single-row toolbar - Wall height control in the preview panel Co-Authored-By: medievalshell <medievalshell@users.noreply.github.com>
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import { FC } from 'react';
|
|
import { COLORMAP, FloorAction, HEIGHT_SCHEME } from '@nitrots/nitro-renderer';
|
|
import { FloorplanEditor } from '@nitrots/nitro-renderer';
|
|
import { Column, Text } from '../../../common';
|
|
import { useFloorplanEditorContext } from '../FloorplanEditorContext';
|
|
|
|
const colormap = COLORMAP as Record<string, string>;
|
|
|
|
export const FloorplanHeightSelector: FC<{}> = () =>
|
|
{
|
|
const { floorHeight, setFloorHeight, setFloorAction } = useFloorplanEditorContext();
|
|
|
|
const onSelectHeight = (height: number) =>
|
|
{
|
|
setFloorHeight(height);
|
|
setFloorAction(FloorAction.SET);
|
|
|
|
FloorplanEditor.instance.actionSettings.currentAction = FloorAction.SET;
|
|
FloorplanEditor.instance.actionSettings.currentHeight = height.toString(36);
|
|
};
|
|
|
|
const heights: number[] = [];
|
|
|
|
for(let i = 26; i >= 0; i--) heights.push(i);
|
|
|
|
return (
|
|
<Column className="h-full w-[30px] min-w-[30px] select-none">
|
|
<Text bold small center>{ floorHeight }</Text>
|
|
<div className="flex flex-col flex-1 rounded overflow-hidden border-2 border-muted">
|
|
{ heights.map(h =>
|
|
{
|
|
const char = HEIGHT_SCHEME[h + 1];
|
|
const color = colormap[char] || '101010';
|
|
const isActive = (floorHeight === h);
|
|
|
|
return (
|
|
<div
|
|
key={ h }
|
|
className="flex-1 cursor-pointer relative flex items-center justify-center"
|
|
style={ {
|
|
backgroundColor: `#${ color }`,
|
|
outline: isActive ? '2px solid #fff' : 'none',
|
|
outlineOffset: '-2px',
|
|
zIndex: isActive ? 1 : 0
|
|
} }
|
|
onClick={ () => onSelectHeight(h) }
|
|
title={ `${ h }` }
|
|
/>
|
|
);
|
|
}) }
|
|
</div>
|
|
</Column>
|
|
);
|
|
};
|