@antha/input 0.2.0 → 0.3.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.
|
@@ -58,6 +58,13 @@ export type MenuNavOptions = Readonly<Partial<{
|
|
|
58
58
|
* @default {milliseconds: 60}
|
|
59
59
|
*/
|
|
60
60
|
repeatInterval: Readonly<AnyDuration>;
|
|
61
|
+
/**
|
|
62
|
+
* The minimum input value required to trigger directional menu navigation. Helps prevent
|
|
63
|
+
* unintentional perpendicular navigation with joysticks in 2D menus.
|
|
64
|
+
*
|
|
65
|
+
* @default 0.8
|
|
66
|
+
*/
|
|
67
|
+
minimumDirectionalInputValue: number;
|
|
61
68
|
/**
|
|
62
69
|
* Allow wrapping when navigating menu items.
|
|
63
70
|
*
|
|
@@ -40,6 +40,12 @@ export var MenuNavBinding;
|
|
|
40
40
|
MenuNavBinding["MenuSectionPrevious"] = "menu-section-previous";
|
|
41
41
|
MenuNavBinding["OpenPauseMenu"] = "open-pause-menu";
|
|
42
42
|
})(MenuNavBinding || (MenuNavBinding = {}));
|
|
43
|
+
const directionalMenuNavBindings = [
|
|
44
|
+
MenuNavBinding.MenuUp,
|
|
45
|
+
MenuNavBinding.MenuDown,
|
|
46
|
+
MenuNavBinding.MenuLeft,
|
|
47
|
+
MenuNavBinding.MenuRight,
|
|
48
|
+
];
|
|
43
49
|
/**
|
|
44
50
|
* Default menu nav bindings for {@link AnthaMenuNavMod}.
|
|
45
51
|
*
|
|
@@ -223,6 +229,7 @@ export const defaultMenuNavOptions = {
|
|
|
223
229
|
repeatInterval: {
|
|
224
230
|
milliseconds: 60,
|
|
225
231
|
},
|
|
232
|
+
minimumDirectionalInputValue: 0.8,
|
|
226
233
|
allowWrapping: true,
|
|
227
234
|
blockPerpendicularNavigation: false,
|
|
228
235
|
};
|
|
@@ -258,6 +265,7 @@ export function createAnthaMenuNavMod(options = {}) {
|
|
|
258
265
|
const repeatInterval = convertDuration(state.menuNavOptions.repeatInterval, {
|
|
259
266
|
milliseconds: true,
|
|
260
267
|
}).milliseconds;
|
|
268
|
+
const minimumDirectionalInputValue = state.menuNavOptions.minimumDirectionalInputValue;
|
|
261
269
|
const bindingsToAct = {};
|
|
262
270
|
const activeMenuBindings = {};
|
|
263
271
|
getObjectTypedValues(state.activeBindings).forEach((playerActiveBindings) => {
|
|
@@ -266,11 +274,13 @@ export function createAnthaMenuNavMod(options = {}) {
|
|
|
266
274
|
return;
|
|
267
275
|
}
|
|
268
276
|
activeMenuBindings[bindingName] = true;
|
|
269
|
-
if (!
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
277
|
+
if ((!directionalMenuNavBindings.includes(bindingName) ||
|
|
278
|
+
activeBinding.value >= minimumDirectionalInputValue) &&
|
|
279
|
+
(!activeBinding.actCount ||
|
|
280
|
+
(activeBinding.holdDuration.milliseconds >= repeatThreshold &&
|
|
281
|
+
activeBinding.holdDuration.milliseconds -
|
|
282
|
+
activeBinding.lastActDuration.milliseconds >
|
|
283
|
+
repeatInterval))) {
|
|
274
284
|
bindingsToAct[bindingName] = true;
|
|
275
285
|
activeBinding.actCount++;
|
|
276
286
|
activeBinding.lastActDuration = activeBinding.holdDuration;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:docs": "virmator docs check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@antha/gamepad-type": "^0.
|
|
36
|
+
"@antha/gamepad-type": "^0.3.0",
|
|
37
37
|
"@augment-vir/assert": "^32.2.3",
|
|
38
38
|
"@augment-vir/common": "^32.2.3",
|
|
39
39
|
"date-vir": "^9.1.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"istanbul-smart-text-reporter": "^1.1.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@antha/engine": "^0.
|
|
54
|
+
"@antha/engine": "^0.3.0",
|
|
55
55
|
"element-vir": ">=26"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|