Added controller compatibility for buy item menu. Removed restriction on mouse navigation not handling inputs defined in input engage groups of menus. Release Build 7242.
This commit is contained in:
parent
6db0aa3641
commit
5d315ada93
@ -132,6 +132,7 @@ InputGroup AiL::KEY_SCROLLVERT_L;
|
||||
InputGroup AiL::KEY_SCROLL;
|
||||
InputGroup AiL::KEY_SHOULDER;
|
||||
InputGroup AiL::KEY_CHANGE_LOADOUT;
|
||||
InputGroup AiL::KEY_MOUSE_HOLDDOWN;
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
::discord::Core*Discord{};
|
||||
@ -2555,6 +2556,8 @@ void AiL::InitializeDefaultKeybinds(){
|
||||
KEY_UNEQUIP.AddKeybind({KEY,R});
|
||||
KEY_UNEQUIP.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::FACE_U)});
|
||||
|
||||
KEY_MOUSE_HOLDDOWN.AddKeybind({MOUSE,Mouse::LEFT});
|
||||
|
||||
#define TieMenuNameToMenuInputGroup(KEY_NAME) \
|
||||
InputGroup::menuNamesToInputGroups[DATA["Inputs"][#KEY_NAME].GetString()]=&KEY_NAME; \
|
||||
InputGroup::menuInputGroups.push_back(DATA["Inputs"][#KEY_NAME].GetString());
|
||||
|
@ -105,6 +105,7 @@ public:
|
||||
static InputGroup KEY_SCROLL;
|
||||
static InputGroup KEY_SHOULDER;
|
||||
static InputGroup KEY_CHANGE_LOADOUT;
|
||||
static InputGroup KEY_MOUSE_HOLDDOWN;
|
||||
|
||||
static float SIZE_CHANGE_SPEED;
|
||||
double levelTime;
|
||||
|
@ -43,6 +43,7 @@ All rights reserved.
|
||||
using A=Attribute;
|
||||
|
||||
void Menu::InitializeBuyItemWindow(){
|
||||
static bool incrementButtonDisabled=false;
|
||||
Menu*buyItemWindow=CreateMenu(BUY_ITEM,CENTERED,{192,72});
|
||||
static auto GetQuantity=[&](){
|
||||
return std::stoi(Component<MenuLabel>(BUY_ITEM,"Amount to buy Amount Label")->GetLabel());
|
||||
@ -72,11 +73,17 @@ void Menu::InitializeBuyItemWindow(){
|
||||
buyItemWindow->ADD("Amount to buy Amount Label",MenuLabel)(geom2d::rect<float>{{buyItemWindow->size.x/2+48,34},{32,12}},"0",1.0f,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::FIT_TO_LABEL)END;
|
||||
|
||||
buyItemWindow->ADD("Increase buy amount Button",MenuComponent)(geom2d::rect<float>{{buyItemWindow->size.x/2+80+2,34},{12,12}},"+",[&](MenuFuncData data){
|
||||
UpdateMenu(GetQuantity()+1);
|
||||
if(!incrementButtonDisabled){
|
||||
UpdateMenu(GetQuantity()+1);
|
||||
}
|
||||
incrementButtonDisabled=false;
|
||||
return true;
|
||||
})END;
|
||||
buyItemWindow->ADD("Decrease buy amount Button",MenuComponent)(geom2d::rect<float>{{buyItemWindow->size.x/2+48-14,34},{12,12}},"-",[](MenuFuncData data){
|
||||
UpdateMenu(GetQuantity()-1);
|
||||
if(!incrementButtonDisabled){
|
||||
UpdateMenu(GetQuantity()-1);
|
||||
}
|
||||
incrementButtonDisabled=false;
|
||||
return true;
|
||||
})END;
|
||||
|
||||
@ -94,4 +101,80 @@ void Menu::InitializeBuyItemWindow(){
|
||||
Menu::CloseMenu();
|
||||
return true;
|
||||
})END;
|
||||
|
||||
buyItemWindow->SetupKeyboardNavigation(
|
||||
[](MenuType type,Data&returnData){ //On Open
|
||||
if(Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
|
||||
returnData="Cancel Button";
|
||||
}else{
|
||||
returnData="Purchase Button";
|
||||
}
|
||||
},
|
||||
{ //Button Key
|
||||
{game->KEY_START,{[](MenuFuncData data){
|
||||
if(Component<MenuComponent>(data.menu.GetType(),"Purchase Button")->IsGreyedOut()){
|
||||
return "";
|
||||
}else{
|
||||
return "Purchase";
|
||||
}
|
||||
},[](MenuType type){
|
||||
Component<MenuComponent>(type,"Purchase Button")->Click();
|
||||
}}},
|
||||
{{game->KEY_SHOULDER},{"Qty Up/Down",[](MenuType type){}}},
|
||||
{{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[](MenuType type){
|
||||
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
|
||||
if(Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
|
||||
Component<MenuComponent>(type,"Decrease buy amount Button")->Click();
|
||||
}
|
||||
}}},
|
||||
{{game->KEY_FASTSCROLLUP,PressedDAS},{"",[](MenuType type){
|
||||
bool foundValidAmt=!Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut();
|
||||
Component<MenuComponent>(type,"Decrease buy amount Button")->Click();
|
||||
if(foundValidAmt&&Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
|
||||
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
|
||||
}
|
||||
}}},
|
||||
{game->KEY_BACK,{"Back",[](MenuType type){}}},
|
||||
{{game->KEY_CONFIRM,PressedDAS},{"",[](MenuType type){
|
||||
if(Menu::menus[type]->GetSelection().expired())return;
|
||||
incrementButtonDisabled=false;
|
||||
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Increase buy amount Button"){
|
||||
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
|
||||
if(Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
|
||||
Component<MenuComponent>(type,"Decrease buy amount Button")->Click();
|
||||
}
|
||||
}else
|
||||
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Decrease buy amount Button"){
|
||||
bool foundValidAmt=!Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut();
|
||||
Component<MenuComponent>(type,"Decrease buy amount Button")->Click();
|
||||
if(foundValidAmt&&Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
|
||||
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
|
||||
}
|
||||
}
|
||||
incrementButtonDisabled=true; //We handled the clicks ourselves, we don't want it to cause another click on release.
|
||||
}}},
|
||||
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
|
||||
}
|
||||
,{ //Button Navigation Rules
|
||||
{"Cancel Button",{
|
||||
.up="Decrease buy amount Button",
|
||||
.down="Decrease buy amount Button",
|
||||
.left="Purchase Button",
|
||||
.right="Purchase Button",}},
|
||||
{"Purchase Button",{
|
||||
.up="Increase buy amount Button",
|
||||
.down="Increase buy amount Button",
|
||||
.left="Cancel Button",
|
||||
.right="Cancel Button",}},
|
||||
{"Increase buy amount Button",{
|
||||
.up="Purchase Button",
|
||||
.down="Purchase Button",
|
||||
.left="Decrease buy amount Button",
|
||||
.right="Decrease buy amount Button",}},
|
||||
{"Decrease buy amount Button",{
|
||||
.up="Cancel Button",
|
||||
.down="Cancel Button",
|
||||
.left="Increase buy amount Button",
|
||||
.right="Increase buy amount Button",}},
|
||||
});
|
||||
}
|
@ -625,7 +625,6 @@ const InputEngageGroup InputEngageGroup::operator=(const InputEngageGroup&rhs){
|
||||
return InputEngageGroup{rhs.group,rhs.type};
|
||||
}
|
||||
|
||||
|
||||
void InputGroup::RemovePrimaryKeybind(InputType type){
|
||||
auto primaryInputIt=std::find_if(keyOrder.begin(),keyOrder.end(),[&](Input&input){return input.GetType()==type;});
|
||||
|
||||
|
@ -316,36 +316,34 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
|
||||
buttonHoldTime=0;
|
||||
}
|
||||
|
||||
if(!Menu::UsingMouseNavigation()){
|
||||
for(auto&[input,data]:inputGroups){
|
||||
bool activated=false;
|
||||
switch(input.GetEngageType()){
|
||||
case Released:{
|
||||
activated=input.GetGroup().Released();
|
||||
}break;
|
||||
case Pressed:{
|
||||
activated=input.GetGroup().Pressed();
|
||||
}break;
|
||||
case PressedDAS:{
|
||||
activated=input.GetGroup().PressedDAS();
|
||||
}break;
|
||||
case Held:{
|
||||
activated=input.GetGroup().Held();
|
||||
}break;
|
||||
case Analog:{
|
||||
activated=input.GetGroup().Analog()!=0.f;
|
||||
}break;
|
||||
[[unlikely]]default:ERR(std::format("WARNING! Unhandled input engage type {}! THIS SHOULD NOT BE HAPPENING!",int(input.GetEngageType())));
|
||||
}
|
||||
for(auto&[input,data]:inputGroups){
|
||||
bool activated=false;
|
||||
switch(input.GetEngageType()){
|
||||
case Released:{
|
||||
activated=input.GetGroup().Released();
|
||||
}break;
|
||||
case Pressed:{
|
||||
activated=input.GetGroup().Pressed();
|
||||
}break;
|
||||
case PressedDAS:{
|
||||
activated=input.GetGroup().PressedDAS();
|
||||
}break;
|
||||
case Held:{
|
||||
activated=input.GetGroup().Held();
|
||||
}break;
|
||||
case Analog:{
|
||||
activated=input.GetGroup().Analog()!=0.f;
|
||||
}break;
|
||||
[[unlikely]]default:ERR(std::format("WARNING! Unhandled input engage type {}! THIS SHOULD NOT BE HAPPENING!",int(input.GetEngageType())));
|
||||
}
|
||||
|
||||
if(activated){
|
||||
auto&action=data.second;
|
||||
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
|
||||
else
|
||||
if(std::holds_alternative<std::function<void(MenuType)>>(action))std::get<std::function<void(MenuType)>>(action)(type);
|
||||
else{
|
||||
ERR("WARNING! Navigation data has an unrecognized type or is empty! This should not be happening!")
|
||||
}
|
||||
if(activated){
|
||||
auto&action=data.second;
|
||||
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
|
||||
else
|
||||
if(std::holds_alternative<std::function<void(MenuType)>>(action))std::get<std::function<void(MenuType)>>(action)(type);
|
||||
else{
|
||||
ERR("WARNING! Navigation data has an unrecognized type or is empty! This should not be happening!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -255,6 +255,10 @@ void MenuComponent::SetGrayedOut(bool grayedOut){
|
||||
this->grayedOut=grayedOut;
|
||||
}
|
||||
|
||||
const bool MenuComponent::IsGreyedOut()const{
|
||||
return grayedOut;
|
||||
}
|
||||
|
||||
void MenuComponent::OnPlayerMoneyUpdate(uint32_t newMoney){}
|
||||
|
||||
void MenuComponent::OnChapterUpdate(uint8_t newChapter){}
|
||||
|
@ -159,6 +159,7 @@ public:
|
||||
virtual void Disable();
|
||||
const bool IsEnabled()const;
|
||||
const bool IsDisabled()const;
|
||||
const bool IsGreyedOut()const;
|
||||
virtual void Cleanup();
|
||||
virtual void SetHoverFunc(std::function<bool(MenuFuncData)>func);
|
||||
virtual void SetMouseOutFunc(std::function<bool(MenuFuncData)>func);
|
||||
|
@ -53,7 +53,7 @@ enum MenuType{
|
||||
CHARACTER_MENU, //100% Controller Compatibility
|
||||
INVENTORY, //100% Controller Compatibility
|
||||
MERCHANT, //100% Controller Compatibility
|
||||
BUY_ITEM, //0% Controller Compatibility
|
||||
BUY_ITEM, //100% Controller Compatibility
|
||||
SELL_ITEM, //0% Controller Compatibility
|
||||
BLACKSMITH, //0% Controller Compatibility
|
||||
CRAFT_ITEM, //0% Controller Compatibility
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 7211
|
||||
#define VERSION_BUILD 7242
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user