From 9d9fd5b753e953e8e809829f0eacfb0b84e0a84e Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 6 Jun 2021 10:24:56 +1000 Subject: [PATCH] Allow editing of default map and tokens and add default label setting --- src/components/map/MapEditor.js | 46 ++++++++++++--------------- src/components/map/MapSettings.js | 16 +++++----- src/components/token/TokenSettings.js | 18 ++++++++--- src/components/token/TokenTiles.js | 5 +-- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/components/map/MapEditor.js b/src/components/map/MapEditor.js index b042ab0..e9d66da 100644 --- a/src/components/map/MapEditor.js +++ b/src/components/map/MapEditor.js @@ -93,8 +93,6 @@ function MapEditor({ map, onSettingsChange }) { interactionEmitter: null, }; - const canEditGrid = map.type !== "default"; - const gridChanged = map.grid.inset.topLeft.x !== defaultInset.topLeft.x || map.grid.inset.topLeft.y !== defaultInset.topLeft.y || @@ -133,7 +131,7 @@ function MapEditor({ map, onSettingsChange }) { > - {showGridControls && canEditGrid && ( + {showGridControls && ( <> @@ -159,28 +157,26 @@ function MapEditor({ map, onSettingsChange }) { )} - {canEditGrid && ( - setShowGridControls(!showGridControls)} - bg="overlay" - sx={{ - borderRadius: "50%", - position: "absolute", - bottom: 0, - right: 0, - }} - m={2} - p="6px" - > - {showGridControls ? : } - - )} + setShowGridControls(!showGridControls)} + bg="overlay" + sx={{ + borderRadius: "50%", + position: "absolute", + bottom: 0, + right: 0, + }} + m={2} + p="6px" + > + {showGridControls ? : } + diff --git a/src/components/map/MapSettings.js b/src/components/map/MapSettings.js index 02a4c95..9eca0ba 100644 --- a/src/components/map/MapSettings.js +++ b/src/components/map/MapSettings.js @@ -149,7 +149,7 @@ function MapSettings({ name="gridX" value={`${(map && map.grid.size.x) || 0}`} onChange={handleGridSizeXChange} - disabled={mapEmpty || map.type === "default"} + disabled={mapEmpty} min={1} my={1} /> @@ -161,7 +161,7 @@ function MapSettings({ name="gridY" value={`${(map && map.grid.size.y) || 0}`} onChange={handleGridSizeYChange} - disabled={mapEmpty || map.type === "default"} + disabled={mapEmpty} min={1} my={1} /> @@ -173,7 +173,7 @@ function MapSettings({ name="name" value={(map && map.name) || ""} onChange={(e) => onSettingsChange("name", e.target.value)} - disabled={mapEmpty || map.type === "default"} + disabled={mapEmpty} my={1} /> @@ -188,7 +188,7 @@ function MapSettings({ onSettingsChange("name", e.target.value)} - disabled={tokenEmpty || token.type === "default"} + disabled={tokenEmpty} my={1} /> @@ -33,7 +33,7 @@ function TokenSettings({ token, onSettingsChange }) { !tokenEmpty && categorySettings.find((s) => s.value === token.defaultCategory) } - isDisabled={tokenEmpty || token.type === "default"} + isDisabled={tokenEmpty} onChange={(option) => onSettingsChange("defaultCategory", option.value) } @@ -41,7 +41,7 @@ function TokenSettings({ token, onSettingsChange }) { /> - + onSettingsChange("defaultSize", parseFloat(e.target.value)) } - disabled={tokenEmpty || token.type === "default"} + disabled={tokenEmpty} min={1} my={1} /> + + + onSettingsChange("defaultLabel", e.target.value)} + disabled={tokenEmpty} + my={1} + /> + ); } diff --git a/src/components/token/TokenTiles.js b/src/components/token/TokenTiles.js index 3b4e817..363eeb9 100644 --- a/src/components/token/TokenTiles.js +++ b/src/components/token/TokenTiles.js @@ -23,10 +23,7 @@ function TokenTiles({ tokens, onTokenEdit, subgroup }) { const token = tokens.find((token) => token.id === group.id); const isSelected = selectedGroupIds.includes(group.id); const canEdit = - isSelected && - token.type !== "default" && - selectMode === "single" && - selectedGroupIds.length === 1; + isSelected && selectMode === "single" && selectedGroupIds.length === 1; return (