Skip to content

Commit

Permalink
Add ability to select all scenes with Ctrl/Cmd + A from Game World view
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaltby committed Sep 15, 2024
1 parent aecabd1 commit f7594f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add ability to define constant values, compared to variables these don't take any extra memory when used in game
- Add ability to select all scenes with Ctrl/Cmd + A from Game World view

### Changed

Expand Down
10 changes: 9 additions & 1 deletion src/components/world/WorldView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const WorldView = () => {
const scenesLookup = useAppSelector((state) =>
sceneSelectors.selectEntities(state)
);
const allSceneIds = useAppSelector(sceneSelectors.selectIds);

const showConnections = useAppSelector(
(state) =>
Expand Down Expand Up @@ -210,6 +211,10 @@ const WorldView = () => {

//#region Keyboard handling

const onSelectAllScenes = useCallback(() => {
dispatch(editorActions.setSceneSelectionIds(allSceneIds));
}, [allSceneIds, dispatch]);

const onKeyDown = useCallback(
(e: KeyboardEvent) => {
if (e.shiftKey && tool === "select") {
Expand All @@ -221,6 +226,9 @@ const WorldView = () => {
if (e.target.nodeName !== "BODY") {
return;
}
if ((e.ctrlKey || e.metaKey) && e.code === "KeyA") {
return onSelectAllScenes();
}
if (e.ctrlKey || e.metaKey) {
return;
}
Expand All @@ -232,7 +240,7 @@ const WorldView = () => {
dispatch(entitiesActions.removeSelectedEntity());
}
},
[dispatch, focus, tool]
[dispatch, focus, onSelectAllScenes, tool]
);

const onKeyUp = useCallback(
Expand Down

0 comments on commit f7594f5

Please sign in to comment.