MCPcopy
hub / github.com/KilledByAPixel/LittleJS / getNavigableObjects

Method getNavigableObjects

plugins/uiSystem.js:524–550  ·  view source on GitHub ↗

Get all navigable UI objects sorted by navigationIndex * @return {Array }

()

Source from the content-addressed store, hash-verified

522 /** Get all navigable UI objects sorted by navigationIndex
523 * @return {Array<UIObject>} */
524 getNavigableObjects()
525 {
526 function getNavigableRecursive(o)
527 {
528 if (!o.visible || o.disabled)
529 return; // skip children if parent is invisible or disabled
530
531 if (o.isInteractive() && o.navigationIndex !== undefined)
532 objects.push(o);
533 for (let i=o.children.length; i--;)
534 getNavigableRecursive(o.children[i]);
535 }
536
537 // get all the valid navigable objects recursively
538 let objects = [];
539 for (let i = uiSystem.uiObjects.length; i--;)
540 {
541 const o = uiSystem.uiObjects[i];
542 if (uiSystem.confirmDialog && o !== uiSystem.confirmDialog)
543 continue;
544 o.parent || getNavigableRecursive(o);
545 }
546
547 // sort by navigationIndex (lower numbers first)
548 objects.sort((a, b)=> a.navigationIndex - b.navigationIndex);
549 return objects;
550 }
551
552 /** Get navigation direction from gamepad or keyboard
553 * @return {number} */

Callers 1

uiUpdateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected