Keep Create Object button for custom objects
This commit is contained in:
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>furniture-app</title>
|
<title>furniture-app</title>
|
||||||
<script type="module" crossorigin src="/assets/index-DK0NE8HO.js"></script>
|
<script type="module" crossorigin src="/assets/index-DtrVKW5h.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-B4HUQdL0.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-B4HUQdL0.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ConditionKind, Entrance, LayoutState, RoomConfig } from '../types';
|
import type { ConditionKind, Entrance, FurnitureConfig, LayoutState, RoomConfig } from '../types';
|
||||||
|
|
||||||
interface ControlPanelProps {
|
interface ControlPanelProps {
|
||||||
state: LayoutState;
|
state: LayoutState;
|
||||||
@@ -37,6 +37,25 @@ export function ControlPanel({
|
|||||||
onStateChange({ ...state, entrance: { x: 20, y: 20, width: 20, height: 20 } });
|
onStateChange({ ...state, entrance: { x: 20, y: 20, width: 20, height: 20 } });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const createObject = () => {
|
||||||
|
const id = 'obj_' + Date.now();
|
||||||
|
const newItem: FurnitureConfig = {
|
||||||
|
id,
|
||||||
|
name: 'Object ' + (state.furniture.length + 1),
|
||||||
|
type: 'custom',
|
||||||
|
shape: { type: 'rectangle', x: 100, y: 100, width: 50, height: 50 },
|
||||||
|
conditions: [
|
||||||
|
{ kind: 'walk_to_and_sit', weight: 1 },
|
||||||
|
{ kind: 'accessible', weight: 1 },
|
||||||
|
],
|
||||||
|
color: '#90caf9',
|
||||||
|
lockedForOptimization: false,
|
||||||
|
placed: true,
|
||||||
|
};
|
||||||
|
onStateChange({ ...state, furniture: [...state.furniture, newItem] });
|
||||||
|
onSelect(id);
|
||||||
|
};
|
||||||
|
|
||||||
const toggleLock = () => {
|
const toggleLock = () => {
|
||||||
if (!selectedId) return;
|
if (!selectedId) return;
|
||||||
const updated = state.furniture.map((f) =>
|
const updated = state.furniture.map((f) =>
|
||||||
@@ -123,6 +142,9 @@ export function ControlPanel({
|
|||||||
<button onClick={placeEntrance} style={{ marginLeft: 8 }}>
|
<button onClick={placeEntrance} style={{ marginLeft: 8 }}>
|
||||||
Place Entrance
|
Place Entrance
|
||||||
</button>
|
</button>
|
||||||
|
<button onClick={createObject} style={{ marginLeft: 8 }}>
|
||||||
|
Create Object
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{state.entrance && (
|
{state.entrance && (
|
||||||
<div style={{ marginTop: 8 }}>
|
<div style={{ marginTop: 8 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user