Called each vblank while the menu is on
| 572 | |
| 573 | // Called each vblank while the menu is on |
| 574 | void updateMenu() { |
| 575 | if (subMenuUpdateFunc != 0) { |
| 576 | subMenuUpdateFunc(); |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | bool redraw = false; |
| 581 | // Get input |
| 582 | if (keyPressedAutoRepeat(KEY_UP)) { |
| 583 | option--; |
| 584 | if (option < -1) |
| 585 | option = menuList[menu].numOptions-1; |
| 586 | redraw = true; |
| 587 | } |
| 588 | else if (keyPressedAutoRepeat(KEY_DOWN)) { |
| 589 | option++; |
| 590 | if (option >= menuList[menu].numOptions) |
| 591 | option = -1; |
| 592 | redraw = true; |
| 593 | } |
| 594 | else if (keyPressedAutoRepeat(KEY_LEFT)) { |
| 595 | if (option == -1) { |
| 596 | menu--; |
| 597 | if (menu < 0) |
| 598 | menu = numMenus-1; |
| 599 | } |
| 600 | else if (menuList[menu].options[option].numValues != 0 && menuList[menu].options[option].enabled) { |
| 601 | int selection = menuList[menu].options[option].selection-1; |
| 602 | if (selection < 0) |
| 603 | selection = menuList[menu].options[option].numValues-1; |
| 604 | menuList[menu].options[option].selection = selection; |
| 605 | menuList[menu].options[option].function(selection); |
| 606 | } |
| 607 | redraw = true; |
| 608 | } |
| 609 | else if (keyPressedAutoRepeat(KEY_RIGHT)) { |
| 610 | if (option == -1) { |
| 611 | menu++; |
| 612 | if (menu >= numMenus) |
| 613 | menu = 0; |
| 614 | } |
| 615 | else if (menuList[menu].options[option].numValues != 0 && menuList[menu].options[option].enabled) { |
| 616 | int selection = menuList[menu].options[option].selection+1; |
| 617 | if (selection >= menuList[menu].options[option].numValues) |
| 618 | selection = 0; |
| 619 | menuList[menu].options[option].selection = selection; |
| 620 | menuList[menu].options[option].function(selection); |
| 621 | } |
| 622 | redraw = true; |
| 623 | } |
| 624 | else if (keyJustPressed(KEY_A)) { |
| 625 | forceReleaseKey(KEY_A); |
| 626 | if (option >= 0 && menuList[menu].options[option].numValues == 0 && menuList[menu].options[option].enabled) { |
| 627 | menuList[menu].options[option].function(menuList[menu].options[option].selection); |
| 628 | } |
| 629 | redraw = true; |
| 630 | } |
| 631 | else if (keyJustPressed(KEY_B)) { |
no test coverage detected