Add basic selection movement

This commit is contained in:
Mitchell McCaffrey
2021-07-21 18:56:18 +10:00
parent 20f48f173e
commit 4cee11d5ea
9 changed files with 311 additions and 60 deletions
+23
View File
@@ -308,6 +308,28 @@ function NetworkedMapAndTokens({ session }: { session: Session }) {
addActions([{ type: "tokens", action }]);
}
function handleSelectionItemsChange(
tokenChanges: Record<string, Partial<TokenState>>,
noteChanges: Record<string, Partial<Note>>
) {
let tokenEdits: Partial<TokenState>[] = [];
for (let id in tokenChanges) {
tokenEdits.push({ ...tokenChanges[id], id });
}
const tokenAction = new EditStatesAction(tokenEdits);
let noteEdits: Partial<Note>[] = [];
for (let id in noteChanges) {
noteEdits.push({ ...noteChanges[id], id });
}
const noteAction = new EditStatesAction(noteEdits);
addActions([
{ type: "tokens", action: tokenAction },
{ type: "notes", action: noteAction },
]);
}
useEffect(() => {
async function handlePeerData({ id, data, reply }: PeerDataEvent) {
if (id === "assetRequest") {
@@ -371,6 +393,7 @@ function NetworkedMapAndTokens({ session }: { session: Session }) {
mapActions={mapActions}
onMapTokenStateChange={handleMapTokenStateChange}
onMapTokenStateRemove={handleMapTokenStateRemove}
onSelectionItemsChange={handleSelectionItemsChange}
onMapChange={handleMapChange}
onMapReset={handleMapReset}
onMapDraw={handleMapDraw}