@antha/input 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type AnthaReadRawInputModState } from '../raw-inputs/antha-read-raw-input.mod.js';
|
|
2
2
|
import { type MenuNavModState } from './antha-menu-nav.mod.js';
|
|
3
3
|
/**
|
|
4
|
-
* Menu navigation state
|
|
4
|
+
* Menu navigation state whose return path lists parent menus from the outermost to the nearest.
|
|
5
5
|
*
|
|
6
6
|
* @category Internal
|
|
7
7
|
*/
|
|
8
8
|
export type AnthaMenuState<MenuKey extends string = string> = {
|
|
9
9
|
activeMenu: MenuKey | undefined;
|
|
10
|
-
returnTo: MenuKey
|
|
10
|
+
returnTo: MenuKey[];
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* State consumed or updated by {@link createAnthaMenuStateMod}.
|
|
@@ -18,13 +18,21 @@ export type AnthaMenuStateModState<MenuKey extends string = string> = MenuNavMod
|
|
|
18
18
|
menuState: AnthaMenuState<MenuKey> | undefined;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Returns the parent menu, or closes menu mode when
|
|
21
|
+
* Returns to the nearest parent menu and removes it from the path, or closes menu mode when the
|
|
22
|
+
* path is empty.
|
|
22
23
|
*
|
|
23
24
|
* @category Internal
|
|
24
25
|
*/
|
|
25
|
-
export declare function
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
export declare function popAnthaMenuState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined): AnthaMenuState<MenuKey>;
|
|
27
|
+
/**
|
|
28
|
+
* Opens `submenu` and appends the current menu to the return path so backing out of `submenu`
|
|
29
|
+
* returns to it. When no menu is open, `submenu` opens with an empty return path.
|
|
30
|
+
*
|
|
31
|
+
* @category Internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function pushAnthaMenuState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined, submenu: NoInfer<MenuKey>): {
|
|
34
|
+
activeMenu: MenuKey;
|
|
35
|
+
returnTo: MenuKey[];
|
|
28
36
|
};
|
|
29
37
|
/**
|
|
30
38
|
* Resolves pause and back inputs into a menu-state transition.
|
|
@@ -36,10 +44,7 @@ export declare function getAnthaMenuStateForNavigation<MenuKey extends string>({
|
|
|
36
44
|
menuState: Readonly<AnthaMenuState<MenuKey>> | undefined;
|
|
37
45
|
openPauseMenuWasTriggered: boolean;
|
|
38
46
|
pauseMenu: MenuKey;
|
|
39
|
-
}>):
|
|
40
|
-
activeMenu: MenuKey | undefined;
|
|
41
|
-
returnTo: undefined;
|
|
42
|
-
} | undefined;
|
|
47
|
+
}>): AnthaMenuState<MenuKey> | undefined;
|
|
43
48
|
/**
|
|
44
49
|
* Switches the raw-input consumer and menu-navigation state on pause/back inputs. Add this before
|
|
45
50
|
* `createAnthaMenuNavMod` so navigation sees the updated `isInMenu` value.
|
|
@@ -3,14 +3,30 @@ import { check } from '@augment-vir/assert';
|
|
|
3
3
|
import { getObjectTypedEntries } from '@augment-vir/common';
|
|
4
4
|
import { isPlayerMenuNavigationAllowed, MenuNavBinding, } from './antha-menu-nav.mod.js';
|
|
5
5
|
/**
|
|
6
|
-
* Returns the parent menu, or closes menu mode when
|
|
6
|
+
* Returns to the nearest parent menu and removes it from the path, or closes menu mode when the
|
|
7
|
+
* path is empty.
|
|
7
8
|
*
|
|
8
9
|
* @category Internal
|
|
9
10
|
*/
|
|
10
|
-
export function
|
|
11
|
+
export function popAnthaMenuState(currentState) {
|
|
11
12
|
return {
|
|
12
|
-
activeMenu: returnTo,
|
|
13
|
-
returnTo:
|
|
13
|
+
activeMenu: currentState?.returnTo.at(-1),
|
|
14
|
+
returnTo: currentState?.returnTo.slice(0, -1) || [],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Opens `submenu` and appends the current menu to the return path so backing out of `submenu`
|
|
19
|
+
* returns to it. When no menu is open, `submenu` opens with an empty return path.
|
|
20
|
+
*
|
|
21
|
+
* @category Internal
|
|
22
|
+
*/
|
|
23
|
+
export function pushAnthaMenuState(currentState, submenu) {
|
|
24
|
+
return {
|
|
25
|
+
activeMenu: submenu,
|
|
26
|
+
returnTo: [
|
|
27
|
+
...(currentState?.returnTo || []),
|
|
28
|
+
...(check.isDefined(currentState?.activeMenu) ? [currentState.activeMenu] : []),
|
|
29
|
+
],
|
|
14
30
|
};
|
|
15
31
|
}
|
|
16
32
|
/**
|
|
@@ -24,12 +40,12 @@ export function getAnthaMenuStateForNavigation({ menuExitWasTriggered, menuState
|
|
|
24
40
|
return openPauseMenuWasTriggered
|
|
25
41
|
? {
|
|
26
42
|
activeMenu: pauseMenu,
|
|
27
|
-
returnTo:
|
|
43
|
+
returnTo: [],
|
|
28
44
|
}
|
|
29
45
|
: undefined;
|
|
30
46
|
}
|
|
31
47
|
return openPauseMenuWasTriggered || menuExitWasTriggered
|
|
32
|
-
?
|
|
48
|
+
? popAnthaMenuState(menuState)
|
|
33
49
|
: undefined;
|
|
34
50
|
}
|
|
35
51
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"vira": "^32.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@antha/engine": "^0.
|
|
46
|
-
"@antha/gamepad-type": "^0.
|
|
45
|
+
"@antha/engine": "^0.20.0",
|
|
46
|
+
"@antha/gamepad-type": "^0.20.0",
|
|
47
47
|
"@augment-vir/test": "^32.3.0",
|
|
48
48
|
"@web/dev-server-esbuild": "^2.0.0",
|
|
49
49
|
"@web/test-runner": "^1.0.0",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"typedoc": "^0.28.20"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@antha/engine": "^0.
|
|
58
|
-
"@antha/gamepad-type": "^0.
|
|
57
|
+
"@antha/engine": "^0.20.0",
|
|
58
|
+
"@antha/gamepad-type": "^0.20.0",
|
|
59
59
|
"element-vir": "^27"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|