Moved back to always showing controls and removed option to disable map change
This commit is contained in:
parent
4b9b06395d
commit
ccaa51fe84
@ -32,7 +32,6 @@ function Map({
|
||||
allowMapDrawing,
|
||||
allowFogDrawing,
|
||||
allowTokenChange,
|
||||
allowMapChange,
|
||||
}) {
|
||||
const mapSource = useDataSource(map, defaultMapSources);
|
||||
|
||||
@ -137,15 +136,18 @@ function Map({
|
||||
}, [mapState]);
|
||||
|
||||
const disabledControls = [];
|
||||
if (!allowMapChange) {
|
||||
disabledControls.push("map");
|
||||
}
|
||||
if (!allowMapDrawing) {
|
||||
disabledControls.push("drawing");
|
||||
disabledControls.push("brush");
|
||||
disabledControls.push("shape");
|
||||
disabledControls.push("erase");
|
||||
}
|
||||
// If no actions that can be undone
|
||||
if (!allowFogDrawing && !allowMapDrawing) {
|
||||
disabledControls.push("undo");
|
||||
disabledControls.push("redo");
|
||||
}
|
||||
if (!map) {
|
||||
disabledControls.push("pan");
|
||||
disabledControls.push("brush");
|
||||
}
|
||||
if (mapShapes.length === 0) {
|
||||
disabledControls.push("erase");
|
||||
@ -270,7 +272,7 @@ function Map({
|
||||
map={map}
|
||||
aspectRatio={aspectRatio}
|
||||
isEnabled={selectedToolId === "pan"}
|
||||
controls={(allowMapChange || allowMapDrawing) && mapControls}
|
||||
controls={mapControls}
|
||||
>
|
||||
{map && mapImage}
|
||||
{map && mapDrawing}
|
||||
|
@ -68,9 +68,8 @@ function MapContols({
|
||||
};
|
||||
const tools = ["pan", "fog", "brush", "shape", "erase"];
|
||||
|
||||
const sections = [];
|
||||
if (!disabledControls.includes("map")) {
|
||||
sections.push({
|
||||
const sections = [
|
||||
{
|
||||
id: "map",
|
||||
component: (
|
||||
<SelectMapButton
|
||||
@ -79,10 +78,8 @@ function MapContols({
|
||||
currentMap={currentMap}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
if (!disabledControls.includes("drawing")) {
|
||||
sections.push({
|
||||
},
|
||||
{
|
||||
id: "drawing",
|
||||
component: tools.map((tool) => (
|
||||
<RadioIconButton
|
||||
@ -95,8 +92,8 @@ function MapContols({
|
||||
{toolsById[tool].icon}
|
||||
</RadioIconButton>
|
||||
)),
|
||||
});
|
||||
sections.push({
|
||||
},
|
||||
{
|
||||
id: "history",
|
||||
component: (
|
||||
<>
|
||||
@ -114,8 +111,8 @@ function MapContols({
|
||||
</IconButton>
|
||||
</>
|
||||
),
|
||||
});
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
let controls = null;
|
||||
if (sections.length === 1 && sections[0].id === "map") {
|
||||
|
@ -72,10 +72,10 @@ function MapSettings({
|
||||
<Label>
|
||||
<Checkbox
|
||||
checked={
|
||||
mapState !== null && mapState.editFlags.includes("drawings")
|
||||
mapState !== null && mapState.editFlags.includes("drawing")
|
||||
}
|
||||
disabled={mapState === null}
|
||||
onChange={(e) => handleFlagChange(e, "drawings")}
|
||||
onChange={(e) => handleFlagChange(e, "drawing")}
|
||||
/>
|
||||
Drawings
|
||||
</Label>
|
||||
@ -89,16 +89,6 @@ function MapSettings({
|
||||
/>
|
||||
Tokens
|
||||
</Label>
|
||||
<Label>
|
||||
<Checkbox
|
||||
checked={
|
||||
mapState !== null && mapState.editFlags.includes("map")
|
||||
}
|
||||
disabled={mapState === null}
|
||||
onChange={(e) => handleFlagChange(e, "map")}
|
||||
/>
|
||||
Map
|
||||
</Label>
|
||||
</Flex>
|
||||
</Box>
|
||||
<Box my={2} sx={{ flexGrow: 1 }}>
|
||||
|
@ -24,7 +24,7 @@ const defaultMapState = {
|
||||
fogDrawActionIndex: -1,
|
||||
fogDrawActions: [],
|
||||
// Flags to determine what other people can edit
|
||||
editFlags: ["map", "drawings", "tokens"],
|
||||
editFlags: ["drawing", "tokens"],
|
||||
};
|
||||
|
||||
const defaultMapProps = {
|
||||
|
@ -44,17 +44,10 @@ function Game() {
|
||||
const [map, setMap] = useState(null);
|
||||
const [mapState, setMapState] = useState(null);
|
||||
|
||||
// TODO: move into map, consider removing map lockdown
|
||||
const canChangeMap =
|
||||
map === null ||
|
||||
(map !== null &&
|
||||
mapState !== null &&
|
||||
(mapState.editFlags.includes("map") || map.owner === userId));
|
||||
|
||||
const canEditMapDrawings =
|
||||
const canEditMapDrawing =
|
||||
map !== null &&
|
||||
mapState !== null &&
|
||||
(mapState.editFlags.includes("drawings") || map.owner === userId);
|
||||
(mapState.editFlags.includes("drawing") || map.owner === userId);
|
||||
|
||||
const canEditFogDrawing =
|
||||
map !== null &&
|
||||
@ -422,17 +415,14 @@ function Game() {
|
||||
onMapUndo={handleMapUndo}
|
||||
onMapRedo={handleMapRedo}
|
||||
onFogDraw={handleFogDraw}
|
||||
allowMapDrawing={canEditMapDrawings}
|
||||
allowMapDrawing={canEditMapDrawing}
|
||||
allowFogDrawing={canEditFogDrawing}
|
||||
allowTokenChange={canEditTokens}
|
||||
allowMapChange={canChangeMap}
|
||||
/>
|
||||
{canEditTokens && (
|
||||
<Tokens
|
||||
tokens={tokens}
|
||||
onCreateMapTokenState={handleMapTokenStateChange}
|
||||
/>
|
||||
)}
|
||||
<Tokens
|
||||
tokens={tokens}
|
||||
onCreateMapTokenState={handleMapTokenStateChange}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Banner isOpen={!!peerError} onRequestClose={() => setPeerError(null)}>
|
||||
|
Loading…
Reference in New Issue
Block a user