Change map state drawShapes and fogShapes name
This commit is contained in:
parent
d1e62e850a
commit
b300418d78
@ -104,8 +104,8 @@ function Map({
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawShapes = Object.values(mapState?.drawShapes || {});
|
const drawShapes = Object.values(mapState?.drawings || {});
|
||||||
const fogShapes = Object.values(mapState?.fogShapes || {});
|
const fogShapes = Object.values(mapState?.fogs || {});
|
||||||
|
|
||||||
function handleToolAction(action: string) {
|
function handleToolAction(action: string) {
|
||||||
if (action === "eraseAll") {
|
if (action === "eraseAll") {
|
||||||
|
@ -113,7 +113,7 @@ function MapContols({
|
|||||||
const disabledSettings: Partial<Record<keyof Settings, string[]>> = {
|
const disabledSettings: Partial<Record<keyof Settings, string[]>> = {
|
||||||
drawing: [],
|
drawing: [],
|
||||||
};
|
};
|
||||||
if (mapState && isEmpty(mapState.drawShapes)) {
|
if (mapState && isEmpty(mapState.drawings)) {
|
||||||
disabledSettings.drawing?.push("erase");
|
disabledSettings.drawing?.push("erase");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ function MapEditBar({
|
|||||||
for (let state of selectedMapStates) {
|
for (let state of selectedMapStates) {
|
||||||
if (
|
if (
|
||||||
Object.values(state.tokens).length > 0 ||
|
Object.values(state.tokens).length > 0 ||
|
||||||
Object.values(state.drawShapes).length > 0 ||
|
Object.values(state.drawings).length > 0 ||
|
||||||
Object.values(state.fogShapes).length > 0 ||
|
Object.values(state.fogs).length > 0 ||
|
||||||
Object.values(state.notes).length > 0
|
Object.values(state.notes).length > 0
|
||||||
) {
|
) {
|
||||||
_hasMapState = true;
|
_hasMapState = true;
|
||||||
|
@ -252,9 +252,9 @@ function SelectionMenu({
|
|||||||
data: {
|
data: {
|
||||||
tokens: {},
|
tokens: {},
|
||||||
notes: {},
|
notes: {},
|
||||||
drawShapes: {},
|
drawings: {},
|
||||||
editFlags: [],
|
editFlags: [],
|
||||||
fogShapes: {},
|
fogs: {},
|
||||||
mapId: mapState.mapId,
|
mapId: mapState.mapId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -55,8 +55,8 @@ const MapDataContext =
|
|||||||
|
|
||||||
const defaultMapState: Omit<MapState, "mapId"> = {
|
const defaultMapState: Omit<MapState, "mapId"> = {
|
||||||
tokens: {},
|
tokens: {},
|
||||||
drawShapes: {},
|
drawings: {},
|
||||||
fogShapes: {},
|
fogs: {},
|
||||||
// Flags to determine what other people can edit
|
// Flags to determine what other people can edit
|
||||||
editFlags: ["drawing", "tokens", "notes", "fog"],
|
editFlags: ["drawing", "tokens", "notes", "fog"],
|
||||||
notes: {},
|
notes: {},
|
||||||
|
@ -50,9 +50,9 @@ function useMapActions(
|
|||||||
): MapState {
|
): MapState {
|
||||||
for (let mapAction of actions) {
|
for (let mapAction of actions) {
|
||||||
if (mapAction.type === "drawings") {
|
if (mapAction.type === "drawings") {
|
||||||
mapState.drawShapes = mapAction.action.execute(mapState.drawShapes);
|
mapState.drawings = mapAction.action.execute(mapState.drawings);
|
||||||
} else if (mapAction.type === "fogs") {
|
} else if (mapAction.type === "fogs") {
|
||||||
mapState.fogShapes = mapAction.action.execute(mapState.fogShapes);
|
mapState.fogs = mapAction.action.execute(mapState.fogs);
|
||||||
} else if (mapAction.type === "tokens") {
|
} else if (mapAction.type === "tokens") {
|
||||||
mapState.tokens = mapAction.action.execute(mapState.tokens);
|
mapState.tokens = mapAction.action.execute(mapState.tokens);
|
||||||
} else if (mapAction.type === "notes") {
|
} else if (mapAction.type === "notes") {
|
||||||
@ -68,9 +68,9 @@ function useMapActions(
|
|||||||
): MapState {
|
): MapState {
|
||||||
for (let mapAction of actions) {
|
for (let mapAction of actions) {
|
||||||
if (mapAction.type === "drawings") {
|
if (mapAction.type === "drawings") {
|
||||||
mapState.drawShapes = mapAction.action.undo(mapState.drawShapes);
|
mapState.drawings = mapAction.action.undo(mapState.drawings);
|
||||||
} else if (mapAction.type === "fogs") {
|
} else if (mapAction.type === "fogs") {
|
||||||
mapState.fogShapes = mapAction.action.undo(mapState.fogShapes);
|
mapState.fogs = mapAction.action.undo(mapState.fogs);
|
||||||
} else if (mapAction.type === "tokens") {
|
} else if (mapAction.type === "tokens") {
|
||||||
mapState.tokens = mapAction.action.undo(mapState.tokens);
|
mapState.tokens = mapAction.action.undo(mapState.tokens);
|
||||||
} else if (mapAction.type === "notes") {
|
} else if (mapAction.type === "notes") {
|
||||||
|
@ -55,8 +55,8 @@ export function getDefaultMaps(userId: string): {
|
|||||||
const state: MapState = {
|
const state: MapState = {
|
||||||
mapId: id,
|
mapId: id,
|
||||||
tokens: {},
|
tokens: {},
|
||||||
drawShapes: {},
|
drawings: {},
|
||||||
fogShapes: {},
|
fogs: {},
|
||||||
editFlags: ["drawing", "tokens", "notes"],
|
editFlags: ["drawing", "tokens", "notes"],
|
||||||
notes: {},
|
notes: {},
|
||||||
};
|
};
|
||||||
|
@ -7,8 +7,8 @@ export type EditFlag = "drawing" | "tokens" | "notes" | "fog";
|
|||||||
|
|
||||||
export type MapState = {
|
export type MapState = {
|
||||||
tokens: TokenStates;
|
tokens: TokenStates;
|
||||||
drawShapes: DrawingState;
|
drawings: DrawingState;
|
||||||
fogShapes: FogState;
|
fogs: FogState;
|
||||||
editFlags: Array<EditFlag>;
|
editFlags: Array<EditFlag>;
|
||||||
notes: Notes;
|
notes: Notes;
|
||||||
mapId: string;
|
mapId: string;
|
||||||
|
@ -847,9 +847,40 @@ export const versions: Record<number, VersionCallback> = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// v1.10.0 - Delete groups again
|
||||||
|
38(v, onUpgrade) {
|
||||||
|
v.stores({}).upgrade((tx) => {
|
||||||
|
onUpgrade?.(38);
|
||||||
|
tx.table("maps")
|
||||||
|
.toCollection()
|
||||||
|
.modify((map) => {
|
||||||
|
delete map.group;
|
||||||
|
});
|
||||||
|
tx.table("tokens")
|
||||||
|
.toCollection()
|
||||||
|
.modify((token) => {
|
||||||
|
delete token.group;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// v1.10.0 - Rename drawShapes and fogShapes in state
|
||||||
|
39(v, onUpgrade) {
|
||||||
|
v.stores({}).upgrade((tx) => {
|
||||||
|
onUpgrade?.(39);
|
||||||
|
tx.table("states")
|
||||||
|
.toCollection()
|
||||||
|
.modify((state) => {
|
||||||
|
state.drawings = state.drawShapes;
|
||||||
|
state.fogs = state.fogShapes;
|
||||||
|
|
||||||
|
delete state.drawShapes;
|
||||||
|
delete state.fogShapes;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const latestVersion = 37;
|
export const latestVersion = 39;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load versions onto a database up to a specific version number
|
* Load versions onto a database up to a specific version number
|
||||||
|
@ -15,10 +15,10 @@ export const MapStateSchema: any = {
|
|||||||
tokens: {
|
tokens: {
|
||||||
$ref: "#/definitions/TokenStates",
|
$ref: "#/definitions/TokenStates",
|
||||||
},
|
},
|
||||||
drawShapes: {
|
drawings: {
|
||||||
$ref: "#/definitions/DrawingState",
|
$ref: "#/definitions/DrawingState",
|
||||||
},
|
},
|
||||||
fogShapes: {
|
fogs: {
|
||||||
$ref: "#/definitions/FogState",
|
$ref: "#/definitions/FogState",
|
||||||
},
|
},
|
||||||
editFlags: {
|
editFlags: {
|
||||||
@ -35,14 +35,7 @@ export const MapStateSchema: any = {
|
|||||||
type: "string",
|
type: "string",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
required: [
|
required: ["drawings", "editFlags", "fogs", "mapId", "notes", "tokens"],
|
||||||
"drawShapes",
|
|
||||||
"editFlags",
|
|
||||||
"fogShapes",
|
|
||||||
"mapId",
|
|
||||||
"notes",
|
|
||||||
"tokens",
|
|
||||||
],
|
|
||||||
type: "object",
|
type: "object",
|
||||||
definitions: {
|
definitions: {
|
||||||
TokenStates: {
|
TokenStates: {
|
||||||
|
Loading…
Reference in New Issue
Block a user