Disabled map select when loading a map

This commit is contained in:
Mitchell McCaffrey 2020-07-17 15:57:52 +10:00
parent f25261d70b
commit 61a2e1ac8d
4 changed files with 16 additions and 3 deletions

View File

@ -32,6 +32,7 @@ function Map({
onFogDrawRedo, onFogDrawRedo,
allowMapDrawing, allowMapDrawing,
allowFogDrawing, allowFogDrawing,
allowMapChange,
disabledTokens, disabledTokens,
}) { }) {
const { tokensById } = useContext(TokenDataContext); const { tokensById } = useContext(TokenDataContext);
@ -141,6 +142,9 @@ function Map({
if (!allowFogDrawing) { if (!allowFogDrawing) {
disabledControls.push("fog"); disabledControls.push("fog");
} }
if (!allowMapChange) {
disabledControls.push("map");
}
const disabledSettings = { fog: [], drawing: [] }; const disabledSettings = { fog: [], drawing: [] };
if (mapShapes.length === 0) { if (mapShapes.length === 0) {

View File

@ -67,6 +67,7 @@ function MapContols({
onMapStateChange={onMapStateChange} onMapStateChange={onMapStateChange}
currentMap={currentMap} currentMap={currentMap}
currentMapState={currentMapState} currentMapState={currentMapState}
disabled={disabledControls.includes("map")}
/> />
), ),
}, },

View File

@ -11,6 +11,7 @@ function SelectMapButton({
onMapStateChange, onMapStateChange,
currentMap, currentMap,
currentMapState, currentMapState,
disabled,
}) { }) {
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
@ -30,6 +31,7 @@ function SelectMapButton({
aria-label="Select Map" aria-label="Select Map"
title="Select Map" title="Select Map"
onClick={openModal} onClick={openModal}
disabled={disabled}
> >
<SelectMapIcon /> <SelectMapIcon />
</IconButton> </IconButton>

View File

@ -25,9 +25,12 @@ import Tokens from "../components/token/Tokens";
*/ */
function NetworkedMapAndTokens({ session }) { function NetworkedMapAndTokens({ session }) {
const { userId } = useContext(AuthContext); const { userId } = useContext(AuthContext);
const { assetLoadStart, assetLoadFinish, assetProgressUpdate } = useContext( const {
MapLoadingContext assetLoadStart,
); assetLoadFinish,
assetProgressUpdate,
isLoading,
} = useContext(MapLoadingContext);
const { putToken, getToken } = useContext(TokenDataContext); const { putToken, getToken } = useContext(TokenDataContext);
const { putMap, getMap, updateMap } = useContext(MapDataContext); const { putMap, getMap, updateMap } = useContext(MapDataContext);
@ -363,6 +366,8 @@ function NetworkedMapAndTokens({ session }) {
}; };
}); });
const canChangeMap = !isLoading;
const canEditMapDrawing = const canEditMapDrawing =
currentMap !== null && currentMap !== null &&
currentMapState !== null && currentMapState !== null &&
@ -407,6 +412,7 @@ function NetworkedMapAndTokens({ session }) {
onFogDrawRedo={handleFogDrawRedo} onFogDrawRedo={handleFogDrawRedo}
allowMapDrawing={canEditMapDrawing} allowMapDrawing={canEditMapDrawing}
allowFogDrawing={canEditFogDrawing} allowFogDrawing={canEditFogDrawing}
allowMapChange={canChangeMap}
disabledTokens={disabledMapTokens} disabledTokens={disabledMapTokens}
/> />
<Tokens onMapTokenStateCreate={handleMapTokenStateCreate} /> <Tokens onMapTokenStateCreate={handleMapTokenStateCreate} />