Added erase all back in

This commit is contained in:
Mitchell McCaffrey
2020-04-29 20:55:52 +10:00
parent 5357b79e70
commit aeb33058bb
3 changed files with 20 additions and 10 deletions

View File

@@ -63,6 +63,7 @@ function Map({
useBlending: true,
},
});
function handleToolSettingChange(tool, change) {
setToolSettings((prevSettings) => ({
...prevSettings,
@@ -73,6 +74,16 @@ function Map({
}));
}
function handleToolAction(action) {
if (action === "eraseAll") {
onMapDraw({
type: "remove",
shapeIds: mapShapes.map((s) => s.id),
timestamp: Date.now(),
});
}
}
const [mapShapes, setMapShapes] = useState([]);
function handleMapShapeAdd(shape) {
onMapDraw({ type: "add", shapes: [shape], timestamp: Date.now() });
@@ -82,14 +93,6 @@ function Map({
onMapDraw({ type: "remove", shapeIds: [shapeId], timestamp: Date.now() });
}
function handleShapeRemoveAll() {
onMapDraw({
type: "remove",
shapeIds: mapShapes.map((s) => s.id),
timestamp: Date.now(),
});
}
const [fogShapes, setFogShapes] = useState([]);
function handleFogShapeAdd(shape) {
onFogDraw({ type: "add", shapes: [shape], timestamp: Date.now() });
@@ -251,6 +254,7 @@ function Map({
selectedToolId={selectedToolId}
toolSettings={toolSettings}
onToolSettingChange={handleToolSettingChange}
onToolAction={handleToolAction}
disabledControls={disabledControls}
onUndo={onMapUndo}
onRedo={onMapRedo}