Implemented equipment menu navigation (partially).
This commit is contained in:
@@ -45,6 +45,7 @@ All rights reserved.
|
||||
#include "RowInventoryScrollableWindowComponent.h"
|
||||
#include "MenuItemItemButton.h"
|
||||
#include <variant>
|
||||
#include "SoundEffect.h"
|
||||
|
||||
INCLUDE_ITEM_CATEGORIES
|
||||
INCLUDE_DATA
|
||||
@@ -64,6 +65,7 @@ MenuType Menu::lastMenuTypeCreated;
|
||||
std::string Menu::lastRegisteredComponent;
|
||||
bool Menu::alreadyClicked=false;
|
||||
bool Menu::scrolling=false;
|
||||
std::weak_ptr<MenuComponent>Menu::lastHover;
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_GFX
|
||||
@@ -152,6 +154,7 @@ void Menu::MenuSelect(AiL*game){
|
||||
if(buttonStillValid){
|
||||
if(selection.lock()->menuDest!=MenuType::ENUM_END){
|
||||
if(stack.size()<MAX_MENUS){
|
||||
SoundEffect::PlaySFX("Menu Select",SoundEffect::CENTERED);
|
||||
Menu::OpenMenu(selection.lock()->menuDest); //Navigate to the next menu.
|
||||
}else{
|
||||
ERR("WARNING! Exceeded menu stack size limit!")
|
||||
@@ -188,6 +191,8 @@ void Menu::Update(AiL*game){
|
||||
if(component->selectable){
|
||||
if(!component->disable&&!component->disableOutsideWindow&&!component->grayedOut){
|
||||
if(component->GetHoverState(game)){
|
||||
if(!Menu::lastHover.expired()&&&*component!=&*Menu::lastHover.lock())SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
Menu::lastHover=component;
|
||||
component->hovered=true;
|
||||
itemHovered=true;
|
||||
SetSelection(std::weak_ptr<MenuComponent>(component));
|
||||
@@ -356,6 +361,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
if(navigationGroups.count(selectionButtonName)){
|
||||
Navigation nav=navigationGroups[selectionButtonName];
|
||||
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS(0.5f)<-0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.up)&&std::get<std::string>(nav.up).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.up)));
|
||||
else
|
||||
@@ -366,6 +372,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_DOWN.PressedDAS()||game->KEY_SCROLLDOWN.AnalogDAS(0.5f)>0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.down)&&std::get<std::string>(nav.down).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.down)));
|
||||
else
|
||||
@@ -376,6 +383,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_LEFT.PressedDAS()||game->KEY_SCROLLLEFT.AnalogDAS(0.5f)<-0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.left)&&std::get<std::string>(nav.left).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.left)));
|
||||
else
|
||||
@@ -386,6 +394,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
if(game->KEY_RIGHT.PressedDAS()||game->KEY_SCROLLRIGHT.AnalogDAS(0.5f)>0.5f){
|
||||
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
|
||||
SetMouseNavigation(false);
|
||||
if(std::holds_alternative<std::string>(nav.right)&&std::get<std::string>(nav.right).length()>0)SetSelection(std::string_view(std::get<std::string>(nav.right)));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user