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.

pull/35/head
sigonasr2 1 year ago
parent 6db0aa3641
commit 5d315ada93
  1. 3
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 83
      Adventures in Lestoria/BuyItemWindow.cpp
  4. 1
      Adventures in Lestoria/Key.cpp
  5. 2
      Adventures in Lestoria/Menu.cpp
  6. 4
      Adventures in Lestoria/MenuComponent.cpp
  7. 1
      Adventures in Lestoria/MenuComponent.h
  8. 2
      Adventures in Lestoria/MenuType.h
  9. 2
      Adventures in Lestoria/Version.h
  10. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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){
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){
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,7 +316,6 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
buttonHoldTime=0;
}
if(!Menu::UsingMouseNavigation()){
for(auto&[input,data]:inputGroups){
bool activated=false;
switch(input.GetEngageType()){
@ -348,7 +347,6 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
}
}
}
}
if(!selection.expired()){
const int MAX_ITERATIONS=10; //Skip a maximum amount of items in case everything gets disabled somehow, prevents an infinite loop.
int iterationCount=0;

@ -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

Loading…
Cancel
Save