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" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<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">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ConditionKind, Entrance, LayoutState, RoomConfig } from '../types';
|
||||
import type { ConditionKind, Entrance, FurnitureConfig, LayoutState, RoomConfig } from '../types';
|
||||
|
||||
interface ControlPanelProps {
|
||||
state: LayoutState;
|
||||
@@ -37,6 +37,25 @@ export function ControlPanel({
|
||||
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 = () => {
|
||||
if (!selectedId) return;
|
||||
const updated = state.furniture.map((f) =>
|
||||
@@ -123,6 +142,9 @@ export function ControlPanel({
|
||||
<button onClick={placeEntrance} style={{ marginLeft: 8 }}>
|
||||
Place Entrance
|
||||
</button>
|
||||
<button onClick={createObject} style={{ marginLeft: 8 }}>
|
||||
Create Object
|
||||
</button>
|
||||
</div>
|
||||
{state.entrance && (
|
||||
<div style={{ marginTop: 8 }}>
|
||||
|
||||
Reference in New Issue
Block a user