Implemented class selection window controller/keyboard compatibility. Added selection passthrough for disabled/grayed out items. Change hover fade-in for toggleable buttons. Release Build 6988.
This commit is contained in:
@@ -44,6 +44,7 @@ All rights reserved.
|
||||
#include "ScrollableWindowComponent.h"
|
||||
#include "RowInventoryScrollableWindowComponent.h"
|
||||
#include "MenuItemItemButton.h"
|
||||
#include <variant>
|
||||
|
||||
INCLUDE_ITEM_CATEGORIES
|
||||
INCLUDE_DATA
|
||||
@@ -294,6 +295,7 @@ void Menu::OpenMenu(MenuType menu,bool cover){
|
||||
if(menus[menu]->onOpenFunc){
|
||||
Data returnData;
|
||||
menus[menu]->onOpenFunc(menu,returnData);
|
||||
menus[menu]->defaultButton=returnData;
|
||||
if(std::holds_alternative<ButtonName>(returnData)&&std::get<ButtonName>(returnData).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(returnData))menus[menu]->SetSelection(returnData,true);
|
||||
}
|
||||
stack.push_back(menus[menu]);
|
||||
@@ -335,57 +337,59 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!selection.expired()){
|
||||
std::string selectionButtonName=selection.lock()->GetName();
|
||||
if(!selection.lock()->parentComponent.expired()){ //If a component has a parent, then we use the parent as the identifier for what should happen next.
|
||||
selectionButtonName=selection.lock()->parentComponent.lock()->GetName();
|
||||
}
|
||||
|
||||
if(navigationGroups.count(selectionButtonName)){
|
||||
Navigation nav=navigationGroups[selectionButtonName];
|
||||
|
||||
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS()<-0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.up)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.up)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
}
|
||||
do{
|
||||
if(navigationGroups.size()==0)break; //We don't do anything here when there are no navigation groups.
|
||||
std::string selectionButtonName=selection.lock()->GetName();
|
||||
if(!selection.lock()->parentComponent.expired()){ //If a component has a parent, then we use the parent as the identifier for what should happen next.
|
||||
selectionButtonName=selection.lock()->parentComponent.lock()->GetName();
|
||||
}
|
||||
if(game->KEY_DOWN.PressedDAS()||game->KEY_SCROLLDOWN.AnalogDAS()>0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.down)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.down)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
if(navigationGroups.count(selectionButtonName)){
|
||||
Navigation nav=navigationGroups[selectionButtonName];
|
||||
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS()<-0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.up)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.up)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(game->KEY_LEFT.PressedDAS()||game->KEY_SCROLLLEFT.AnalogDAS()<-0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.left)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.left)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
if(game->KEY_DOWN.PressedDAS()||game->KEY_SCROLLDOWN.AnalogDAS()>0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.down)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.down)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(game->KEY_RIGHT.PressedDAS()||game->KEY_SCROLLRIGHT.AnalogDAS()>0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.right)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.right)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
if(game->KEY_LEFT.PressedDAS()||game->KEY_SCROLLLEFT.AnalogDAS()<-0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.left)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.left)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
}
|
||||
}
|
||||
if(game->KEY_RIGHT.PressedDAS()||game->KEY_SCROLLRIGHT.AnalogDAS()>0.2f){
|
||||
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
|
||||
if(std::holds_alternative<MenuDataFunc>(nav.right)){
|
||||
Data returnData;
|
||||
std::get<MenuDataFunc>(nav.right)(type,returnData);
|
||||
SetSelection(returnData);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(std::holds_alternative<ButtonName>(defaultButton)&&std::get<ButtonName>(defaultButton).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(defaultButton))SetSelection(defaultButton,true);
|
||||
}
|
||||
}
|
||||
}while(selection.lock()->disabled||selection.lock()->grayedOut);
|
||||
}
|
||||
|
||||
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
|
||||
|
||||
Reference in New Issue
Block a user