diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 4950fdc1..49e43183 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -110,6 +110,7 @@ InputGroup AiL::KEY_CONFIRM; InputGroup AiL::KEY_MENU; InputGroup AiL::KEY_BACK; InputGroup AiL::KEY_START; +InputGroup AiL::KEY_CONTROLLER_START; InputGroup AiL::KEY_SELECT; InputGroup AiL::KEY_UNEQUIP; @@ -2522,6 +2523,7 @@ void AiL::InitializeDefaultKeybinds(){ KEY_START.AddKeybind({KEY,SPACE}); KEY_START.AddKeybind({CONTROLLER,static_cast(GPButtons::START)}); + KEY_CONTROLLER_START.AddKeybind({CONTROLLER,static_cast(GPButtons::START)}); KEY_SELECT.AddKeybind({KEY,ESCAPE}); KEY_SELECT.AddKeybind({CONTROLLER,static_cast(GPButtons::SELECT)}); diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 18c7ce47..2827377d 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -84,6 +84,7 @@ public: static InputGroup KEY_UNEQUIP; static InputGroup KEY_START; + static InputGroup KEY_CONTROLLER_START; static InputGroup KEY_SELECT; static InputGroup KEY_FACEUP; diff --git a/Adventures in Lestoria/BlacksmithCraftingWindow.cpp b/Adventures in Lestoria/BlacksmithCraftingWindow.cpp index 37f50801..ebff5cc1 100644 --- a/Adventures in Lestoria/BlacksmithCraftingWindow.cpp +++ b/Adventures in Lestoria/BlacksmithCraftingWindow.cpp @@ -197,7 +197,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){ #pragma region Inventory Description float inventoryDescriptionWidth=blacksmithWindow->pos.x+blacksmithWindow->size.x-26-224; blacksmithWindow->ADD("Item Description Outline",MenuLabel)(geom2d::rect{{224,28},{inventoryDescriptionWidth,blacksmithWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END; - blacksmithWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; + blacksmithWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; blacksmithWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; blacksmithWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect{{226,94},{inventoryDescriptionWidth-6,blacksmithWindow->size.y-44-66}},"",0.5f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; #pragma endregion @@ -212,7 +212,7 @@ void Menu::InitializeBlacksmithCraftingWindow(){ Player::AddMoneyListener(moneyDisplay); #pragma endregion - blacksmithWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{blacksmithWindow->size.x/2-48,28+blacksmithWindow->size.y-44+6},{96,24}},"Leave",MenuType::ENUM_END, + blacksmithWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{blacksmithWindow->size.x/2-48,28+blacksmithWindow->size.y-44+6},{96,24}},"Leave", [](MenuFuncData data){ Menu::CloseMenu(); return true; diff --git a/Adventures in Lestoria/CharacterMenuWindow.cpp b/Adventures in Lestoria/CharacterMenuWindow.cpp index 106a0eb1..d2742276 100644 --- a/Adventures in Lestoria/CharacterMenuWindow.cpp +++ b/Adventures in Lestoria/CharacterMenuWindow.cpp @@ -124,7 +124,7 @@ void Menu::InitializeCharacterMenuWindow(){ labelY-=8; } EquipSlot slot=EquipSlot(equipSlot); - auto equipmentSlot=characterMenuWindow->ADD("Equip Slot "+slotNames[i],EquipSlotButton)(geom2d::rect{{x,y+28},{24,24}},slot,MenuType::ENUM_END, + auto equipmentSlot=characterMenuWindow->ADD("Equip Slot "+slotNames[i],EquipSlotButton)(geom2d::rect{{x,y+28},{24,24}},slot, [&](MenuFuncData data){ EquipSlot slot=EquipSlot(data.component.lock()->I(Attribute::EQUIP_TYPE)); data.menu.I(A::EQUIP_TYPE)=int(slot); diff --git a/Adventures in Lestoria/ClassSelectionWindow.cpp b/Adventures in Lestoria/ClassSelectionWindow.cpp index 8f7e18e1..935e5faa 100644 --- a/Adventures in Lestoria/ClassSelectionWindow.cpp +++ b/Adventures in Lestoria/ClassSelectionWindow.cpp @@ -135,11 +135,12 @@ void Menu::InitializeClassSelectionWindow(){ auto classLabel=classSelectionWindow->ADD(className+" Background",MenuLabel)(geom2d::rect{backgroundOffsetPos,backgroundSize},"",1,ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END; - auto classButton=classSelectionWindow->ADD(className+" Button",MenuComponent)(geom2d::rect{offsetPos,buttonSize},"Info",CLASS_INFO, + auto classButton=classSelectionWindow->ADD(className+" Button",MenuComponent)(geom2d::rect{offsetPos,buttonSize},"Info", [](MenuFuncData data){ data.menu.S(A::CLASS_SELECTION)=data.component.lock()->S(A::CLASS_SELECTION); delete Menu::menus[CLASS_INFO]; Menu::InitializeClassInfoWindow(); + Menu::OpenMenu(CLASS_INFO); return true; })END; classButton->S(A::CLASS_SELECTION)=className; @@ -189,7 +190,13 @@ void Menu::InitializeClassSelectionWindow(){ {game->KEY_BACK,{"Back",[](MenuType type){ Component(type,"Back")->Click(); }}}, - {game->KEY_START,{"Confirm",[](MenuType type){ + {game->KEY_START,{[](MenuFuncData data){ + if(Component(data.menu.GetType(),"Confirm")->IsEnabled()){ + return "Confirm"; + }else{ + return ""; + } + },[](MenuType type){ Component(type,"Confirm")->Click(); }}}, {game->KEY_FACEUP,{"Change Player Name",[](MenuType type){ diff --git a/Adventures in Lestoria/ConsumableCraftingWindow.cpp b/Adventures in Lestoria/ConsumableCraftingWindow.cpp index 390af7dc..fc21ad3a 100644 --- a/Adventures in Lestoria/ConsumableCraftingWindow.cpp +++ b/Adventures in Lestoria/ConsumableCraftingWindow.cpp @@ -120,7 +120,7 @@ void Menu::InitializeConsumableCraftingWindow(){ #pragma region Inventory Description float inventoryDescriptionWidth=consumableCraftingWindow->pos.x+consumableCraftingWindow->size.x-26-224; consumableCraftingWindow->ADD("Item Description Outline",MenuLabel)(geom2d::rect{{224,28},{inventoryDescriptionWidth,consumableCraftingWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END; - consumableCraftingWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END + consumableCraftingWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END ->SetShowQuantity(false); consumableCraftingWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; consumableCraftingWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect{{226,94},{inventoryDescriptionWidth-6,consumableCraftingWindow->size.y-44-66}},"",0.5f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; @@ -136,7 +136,7 @@ void Menu::InitializeConsumableCraftingWindow(){ Player::AddMoneyListener(moneyDisplay); #pragma endregion - consumableCraftingWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{consumableCraftingWindow->size.x/2-48,28+consumableCraftingWindow->size.y-44+6},{96,24}},"Back",MenuType::ENUM_END, + consumableCraftingWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{consumableCraftingWindow->size.x/2-48,28+consumableCraftingWindow->size.y-44+6},{96,24}},"Back", [](MenuFuncData data){ Menu::CloseMenu(); return true; diff --git a/Adventures in Lestoria/EquipSlotButton.h b/Adventures in Lestoria/EquipSlotButton.h index a83a10df..1753d925 100644 --- a/Adventures in Lestoria/EquipSlotButton.h +++ b/Adventures in Lestoria/EquipSlotButton.h @@ -47,8 +47,8 @@ class EquipSlotButton:public MenuItemItemButton{ private: EquipSlot slot; public: - inline EquipSlotButton(geom2d::rectrect,EquipSlot slot,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="") - :MenuItemItemButton(rect,Item::BLANK,menuDest,onClick,onHover,onMouseOut,itemNameLabelName,itemDescriptionLabelName),slot(slot){} + inline EquipSlotButton(geom2d::rectrect,EquipSlot slot,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="") + :MenuItemItemButton(rect,Item::BLANK,onClick,onHover,onMouseOut,itemNameLabelName,itemDescriptionLabelName),slot(slot){} inline void OnEquipStatsUpdate()override{ const std::weak_ptrequip=Inventory::GetEquip(slot); if(!ISBLANK(equip)){ diff --git a/Adventures in Lestoria/InventoryWindow.cpp b/Adventures in Lestoria/InventoryWindow.cpp index 0e3c7ed8..bee58797 100644 --- a/Adventures in Lestoria/InventoryWindow.cpp +++ b/Adventures in Lestoria/InventoryWindow.cpp @@ -81,7 +81,7 @@ void Menu::InitializeInventoryWindow(){ float buttonWidth=64; float textScaling=std::min(1.f,buttonWidth/textWidth); - auto button=inventoryWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect{{2,30+yOffset},{68,16}},category,MenuType::ENUM_END, + auto button=inventoryWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect{{2,30+yOffset},{68,16}},category, [&](MenuFuncData data){ //Close the old inventory window and show the proper one. Component(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Disable(); @@ -135,7 +135,7 @@ void Menu::InitializeInventoryWindow(){ #pragma region Inventory Description float inventoryDescriptionWidth=inventoryWindow->pos.x+inventoryWindow->size.x-26-224; inventoryWindow->ADD("Item Description Outline",MenuLabel)(geom2d::rect{{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END; - inventoryWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; + inventoryWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; inventoryWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END; inventoryWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect{{226,94},{inventoryDescriptionWidth-6,inventoryWindow->size.y-44-66}},"",0.5f,LEFT_ALIGN|SHADOW)END; #pragma endregion @@ -150,7 +150,7 @@ void Menu::InitializeInventoryWindow(){ Player::AddMoneyListener(moneyDisplay); #pragma endregion - inventoryWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{inventoryWindow->size.x/2-48,28+inventoryWindow->size.y-44+6},{96,24}},"Back",MenuType::ENUM_END, + inventoryWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{inventoryWindow->size.x/2-48,28+inventoryWindow->size.y-44+6},{96,24}},"Back", [](MenuFuncData data){ Menu::CloseMenu(); return true; diff --git a/Adventures in Lestoria/ItemLoadoutWindow.cpp b/Adventures in Lestoria/ItemLoadoutWindow.cpp index 06e58db0..3bb6401a 100644 --- a/Adventures in Lestoria/ItemLoadoutWindow.cpp +++ b/Adventures in Lestoria/ItemLoadoutWindow.cpp @@ -54,17 +54,35 @@ void Menu::InitializeItemLoadoutWindow(){ float buttonBorderPadding=64; - itemLoadoutWindow->ADD("Loadout Item 1",MenuItemItemButton)(geom2d::rect{{64,84},{48,48}},game->GetLoadoutItem(0),INVENTORY_CONSUMABLES,[](MenuFuncData data){Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=0; return true;},[](MenuFuncData data){return true;},[](MenuFuncData data){ + itemLoadoutWindow->ADD("Loadout Item 1",MenuItemItemButton)(geom2d::rect{{64,84},{48,48}},game->GetLoadoutItem(0),[](MenuFuncData data){ + Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=0; + Menu::OpenMenu(INVENTORY_CONSUMABLES); + return true; + },[](MenuFuncData data){ + return true; + },[](MenuFuncData data){ Component(ITEM_LOADOUT,"Item Name Label")->SetLabel(""); Component(ITEM_LOADOUT,"Item Description")->SetLabel(""); return true; },"Item Name Label","Item Description")END; - itemLoadoutWindow->ADD("Loadout Item 2",MenuItemItemButton)(geom2d::rect{{itemLoadoutWindowWidth/2-24,84},{48,48}},game->GetLoadoutItem(1),INVENTORY_CONSUMABLES,[](MenuFuncData data){Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=1;return true;},[](MenuFuncData data){return true;},[](MenuFuncData data){ + itemLoadoutWindow->ADD("Loadout Item 2",MenuItemItemButton)(geom2d::rect{{itemLoadoutWindowWidth/2-24,84},{48,48}},game->GetLoadoutItem(1),[](MenuFuncData data){ + Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=1; + Menu::OpenMenu(INVENTORY_CONSUMABLES); + return true; + },[](MenuFuncData data){ + return true; + },[](MenuFuncData data){ Component(ITEM_LOADOUT,"Item Name Label")->SetLabel(""); Component(ITEM_LOADOUT,"Item Description")->SetLabel(""); return true; },"Item Name Label","Item Description")END; - itemLoadoutWindow->ADD("Loadout Item 3",MenuItemItemButton)(geom2d::rect{{itemLoadoutWindowWidth-48-64,84},{48,48}},game->GetLoadoutItem(2),INVENTORY_CONSUMABLES,[](MenuFuncData data){Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=2;return true;},[](MenuFuncData data){return true;},[](MenuFuncData data){ + itemLoadoutWindow->ADD("Loadout Item 3",MenuItemItemButton)(geom2d::rect{{itemLoadoutWindowWidth-48-64,84},{48,48}},game->GetLoadoutItem(2),[](MenuFuncData data){ + Menu::menus.at(INVENTORY_CONSUMABLES)->I(A::LOADOUT_SLOT)=2; + Menu::OpenMenu(INVENTORY_CONSUMABLES); + return true; + },[](MenuFuncData data){ + return true; + },[](MenuFuncData data){ Component(ITEM_LOADOUT,"Item Name Label")->SetLabel(""); Component(ITEM_LOADOUT,"Item Description")->SetLabel(""); return true; diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index a347d888..a022e4af 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -125,7 +125,7 @@ Menu*Menu::CreateMenu(MenuType type,vf2d pos,vf2d size){ } void Menu::CheckClickAndPerformMenuSelect(AiL*game){ - if(game->KEY_CONFIRM.Released()&&(MOUSE_NAVIGATION||(!MOUSE_NAVIGATION&&!game->GetMouse(Mouse::LEFT).bReleased&&!game->GetMouse(Mouse::RIGHT).bReleased&&!game->GetMouse(Mouse::MIDDLE).bReleased))){ + if(game->KEY_CONFIRM.Released()&&!Menu::alreadyClicked&&(MOUSE_NAVIGATION||(!MOUSE_NAVIGATION&&!game->GetMouse(Mouse::LEFT).bReleased&&!game->GetMouse(Mouse::RIGHT).bReleased&&!game->GetMouse(Mouse::MIDDLE).bReleased))){ if(!GetSelection().expired()){ //If we are on controller/gamepad it's possible we haven't highlighted a button yet, so don't click this button right away. MenuSelect(game); Menu::alreadyClicked=true; @@ -150,17 +150,7 @@ void Menu::HoverMenuSelect(AiL*game){ void Menu::MenuSelect(AiL*game){ if(!game->IsFocused()||selection.expired()||selection.lock()->disable||selection.lock()->disableOutsideWindow||selection.lock()->grayedOut)return; - bool buttonStillValid=selection.lock()->onClick(MenuFuncData{*this,game,selection,dynamic_pointer_cast(selection.lock()->parentComponent.lock())}); - if(buttonStillValid){ - if(selection.lock()->menuDest!=MenuType::ENUM_END){ - if(stack.size()menuDest); //Navigate to the next menu. - }else{ - ERR("WARNING! Exceeded menu stack size limit!") - } - } - } + selection.lock()->onClick(MenuFuncData{*this,game,selection,dynamic_pointer_cast(selection.lock()->parentComponent.lock())}); } void Menu::Update(AiL*game){ @@ -327,6 +317,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ } for(auto&[input,data]:inputGroups){ + if(Menu::alreadyClicked)break; bool activated=false; switch(input.GetEngageType()){ case Released:{ @@ -621,6 +612,7 @@ vf2d Menu::center(){ } void Menu::CloseMenu(){ + Menu::alreadyClicked=true; game->TextEntryEnable(false); if(stack.size()>0){ stack.pop_back(); diff --git a/Adventures in Lestoria/Menu.h b/Adventures in Lestoria/Menu.h index d7ab4d61..a87123f7 100644 --- a/Adventures in Lestoria/Menu.h +++ b/Adventures in Lestoria/Menu.h @@ -120,6 +120,7 @@ class Menu:public IAttributable{ static vi2d lastActiveMousePos; int componentCount=0; float componentSelectionIndex=0.f; + //This variable is an override available to all menus that allows us to say we've clicked something, so do not handle any automatic clicking anymore of menus for this frame! static bool alreadyClicked; static bool scrolling; diff --git a/Adventures in Lestoria/MenuComponent.cpp b/Adventures in Lestoria/MenuComponent.cpp index b1248df6..76754909 100644 --- a/Adventures in Lestoria/MenuComponent.cpp +++ b/Adventures in Lestoria/MenuComponent.cpp @@ -47,17 +47,11 @@ INCLUDE_game using A=Attribute; MenuComponent::MenuComponent(geom2d::rectrect,std::string label,MenuFunc onClick,ButtonAttr attributes) - :rect(rect),originalPos(rect.pos),label(label),menuDest(MenuType::ENUM_END),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()),fitToLabel(attributes&ButtonAttr::FIT_TO_LABEL){} + :rect(rect),originalPos(rect.pos),label(label),onClick(onClick),hoverEffect(0),selectable(!(attributes&ButtonAttr::UNSELECTABLE)),selectableViaKeyboard(!(attributes&ButtonAttr::UNSELECTABLE_VIA_KEYBOARD)),memoryLeakInfo(Menu::GetMemoryLeakReportInfo()),fitToLabel(attributes&ButtonAttr::FIT_TO_LABEL){} -MenuComponent::MenuComponent(geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,ButtonAttr attributes) +MenuComponent::MenuComponent(geom2d::rectrect,std::string label,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes) :MenuComponent(rect,label,onClick,attributes){ //NOTE: This constructor also calls the other constructor above! - this->menuDest=menuDest; -} - -MenuComponent::MenuComponent(geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes) - :MenuComponent(rect,label,menuDest,onClick,attributes){ - //NOTE: This constructor also calls the other constructor above! this->labelScaling=labelScaling; } @@ -265,17 +259,7 @@ void MenuComponent::OnChapterUpdate(uint8_t newChapter){} void MenuComponent::Click(){ if(grayedOut||disable||disableOutsideWindow)return; - bool buttonStillValid=onClick(MenuFuncData{*Menu::menus[parentMenu],game,Menu::menus[parentMenu]->components[name]}); - if(buttonStillValid){ - if(menuDest!=MenuType::ENUM_END){ - if(Menu::stack.size()components[name]}); } void MenuComponent::SetLabel(std::string newLabel){ label=newLabel; diff --git a/Adventures in Lestoria/MenuComponent.h b/Adventures in Lestoria/MenuComponent.h index 245af043..6d087daa 100644 --- a/Adventures in Lestoria/MenuComponent.h +++ b/Adventures in Lestoria/MenuComponent.h @@ -79,7 +79,6 @@ class MenuComponent:public IAttributable{ friend class MenuItemItemButton; friend class RowItemDisplay; friend class InventoryConsumableWindow; - MenuType menuDest; MenuFunc onHover=[](MenuFuncData dat){return true;}; MenuFunc onMouseOut=[](MenuFuncData dat){return true;}; bool hoverState=false; @@ -137,8 +136,7 @@ public: MenuType parentMenu=MenuType::ENUM_END; std::weak_ptrparentComponent{}; MenuComponent(geom2d::rectrect,std::string label,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE); - MenuComponent(geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE); - MenuComponent(geom2d::rectrect,std::string label,MenuType menuDest,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes=ButtonAttr::NONE); + MenuComponent(geom2d::rectrect,std::string label,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes=ButtonAttr::NONE); virtual ~MenuComponent(); vf2d GetPos(); const vf2d&GetSize()const; diff --git a/Adventures in Lestoria/MenuIconButton.h b/Adventures in Lestoria/MenuIconButton.h index af04f9ac..aff4a178 100644 --- a/Adventures in Lestoria/MenuIconButton.h +++ b/Adventures in Lestoria/MenuIconButton.h @@ -56,9 +56,7 @@ protected: Pixel tint=WHITE; public: inline MenuIconButton(geom2d::rectrect,Decal*icon,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuIconButton(rect,icon,MenuType::ENUM_END,onClick,attributes){} - inline MenuIconButton(geom2d::rectrect,Decal*icon,MenuType menuDest,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuComponent(rect,"",menuDest,onClick,ButtonAttr(attributes)),icon(icon){ + :MenuComponent(rect,"",onClick,ButtonAttr(attributes)),icon(icon){ border=!(attributes&IconButtonAttr::NO_OUTLINE); background=!(attributes&IconButtonAttr::NO_BACKGROUND); } diff --git a/Adventures in Lestoria/MenuItemItemButton.h b/Adventures in Lestoria/MenuItemItemButton.h index 86cdb2fd..4f78febd 100644 --- a/Adventures in Lestoria/MenuItemItemButton.h +++ b/Adventures in Lestoria/MenuItemItemButton.h @@ -57,13 +57,13 @@ private: protected: std::weak_ptritemRef; public: - inline MenuItemItemButton(geom2d::rectrect,const std::weak_ptritemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuIconButton(rect,!ISBLANK(itemRef)?const_cast(itemRef.lock()->Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ + inline MenuItemItemButton(geom2d::rectrect,const std::weak_ptritemRef,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE) + :MenuIconButton(rect,!ISBLANK(itemRef)?const_cast(itemRef.lock()->Decal()):nullptr,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ draggable=false; valid=!ISBLANK(itemRef); } - inline MenuItemItemButton(geom2d::rectrect,const std::weak_ptritemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE) - :MenuIconButton(rect,!ISBLANK(itemRef)?const_cast(itemRef.lock()->Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ + inline MenuItemItemButton(geom2d::rectrect,const std::weak_ptritemRef,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE) + :MenuIconButton(rect,!ISBLANK(itemRef)?const_cast(itemRef.lock()->Decal()):nullptr,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ runHoverFunctions=true; draggable=false; valid=!ISBLANK(itemRef); diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index a8a76006..2f373ebd 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -41,7 +41,7 @@ enum MenuType{ /////////////////////////////////////////////////////////// /*DO NOT REMOVE!!*/ENUM_START,/////////////////////////////// /////////////////////////////////////////////////////////// - // 69% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) + // 73% Controller Compatibility. (100 total items, 4 items per menu * 25 menus) INVENTORY_CONSUMABLES, //100% Controller Compatibility CLASS_INFO, //100% Controller Compatibility CLASS_SELECTION, //100% Controller Compatibility @@ -61,7 +61,7 @@ enum MenuType{ CONSUMABLE_CRAFT_ITEM, //100% Controller Compatibility SAVE_FILE_NAME, //100% Controller Compatibility LOAD_GAME, //100% Controller Compatibility - Online Mode Tab switching - USER_ID, //0% Controller Compatibility + USER_ID, //100% Controller Compatibility SETTINGS, //0% Controller Compatibility SHERMAN, //0% Controller Compatibility INPUT_KEY_DISPLAY, //25% Controller Compatibility diff --git a/Adventures in Lestoria/MerchantWindow.cpp b/Adventures in Lestoria/MerchantWindow.cpp index 89ecf99c..15856164 100644 --- a/Adventures in Lestoria/MerchantWindow.cpp +++ b/Adventures in Lestoria/MerchantWindow.cpp @@ -146,7 +146,7 @@ void Menu::InitializeMerchantWindow(){ float buttonWidth=64; float textScaling=std::min(1.f,buttonWidth/textWidth); - auto button=merchantWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect{{2,30+yOffset},{68,16}},category,MenuType::ENUM_END, + auto button=merchantWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect{{2,30+yOffset},{68,16}},category, [&](MenuFuncData data){ //Close the old inventory window and show the proper one. Component(data.menu.GetType(),"Inventory Display - "+data.menu.S(A::LAST_INVENTORY_TYPE_OPENED))->Disable(); @@ -220,7 +220,7 @@ void Menu::InitializeMerchantWindow(){ #pragma region Inventory Description float inventoryDescriptionWidth=merchantWindow->pos.x+merchantWindow->size.x-26-224; merchantWindow->ADD("Item Description Outline",MenuLabel)(geom2d::rect{{224,28},{inventoryDescriptionWidth,merchantWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END; - merchantWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; + merchantWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; merchantWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; merchantWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect{{226,94},{inventoryDescriptionWidth-6,merchantWindow->size.y-44-66}},"",0.5f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END; #pragma endregion @@ -235,7 +235,7 @@ void Menu::InitializeMerchantWindow(){ Player::AddMoneyListener(moneyDisplay); #pragma endregion - merchantWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{merchantWindow->size.x/2-48,28+merchantWindow->size.y-44+6},{96,24}},"Leave",MenuType::ENUM_END, + merchantWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{merchantWindow->size.x/2-48,28+merchantWindow->size.y-44+6},{96,24}},"Leave", [](MenuFuncData data){ Menu::CloseMenu(); return true; diff --git a/Adventures in Lestoria/OverworldMapLevelWindow.cpp b/Adventures in Lestoria/OverworldMapLevelWindow.cpp index 7b80d829..6afba7ab 100644 --- a/Adventures in Lestoria/OverworldMapLevelWindow.cpp +++ b/Adventures in Lestoria/OverworldMapLevelWindow.cpp @@ -60,7 +60,10 @@ void Menu::InitializeOverworldMapLevelWindow(){ levelSelectWindow->ADD("Encounters Label",MenuLabel)(geom2d::rect{{0,52},{windowSize.x-1,12}},"Encounters:",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END; levelSelectWindow->ADD("Spawns List",EncountersSpawnListScrollableWindowComponent)(geom2d::rect{{1,64},{windowSize.x-2,84}},ComponentAttr::BACKGROUND)END; - levelSelectWindow->ADD("Change Loadout Button",MenuComponent)(geom2d::rect{{0,152},{windowSize.x-1,12}},"Change Loadout",ITEM_LOADOUT,[](MenuFuncData data){return true;})END; + levelSelectWindow->ADD("Change Loadout Button",MenuComponent)(geom2d::rect{{0,152},{windowSize.x-1,12}},"Change Loadout",[](MenuFuncData data){ + Menu::OpenMenu(ITEM_LOADOUT); + return true; + })END; levelSelectWindow->ADD("Enter Button",MenuComponent)(geom2d::rect{{0,166},{windowSize.x-1,16}},"Enter",[](MenuFuncData data){State_OverworldMap::StartLevel();return true;})END; #pragma region Keyboard Navigation Rules diff --git a/Adventures in Lestoria/SaveFileNameButton.h b/Adventures in Lestoria/SaveFileNameButton.h index d15aac82..166de1d1 100644 --- a/Adventures in Lestoria/SaveFileNameButton.h +++ b/Adventures in Lestoria/SaveFileNameButton.h @@ -43,7 +43,7 @@ All rights reserved. class SaveFileNameButton:public MenuComponent{ public: inline SaveFileNameButton(geom2d::rectrect,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes=ButtonAttr::FIT_TO_LABEL) - :MenuComponent(rect,"",MenuType::ENUM_END,onClick,labelScaling,attributes){} + :MenuComponent(rect,"",onClick,labelScaling,attributes){} inline void Update(AiL*game)override{ MenuComponent::Update(game); diff --git a/Adventures in Lestoria/SaveFileWindow.cpp b/Adventures in Lestoria/SaveFileWindow.cpp index 69f1cc70..fa587a4e 100644 --- a/Adventures in Lestoria/SaveFileWindow.cpp +++ b/Adventures in Lestoria/SaveFileWindow.cpp @@ -47,9 +47,10 @@ void Menu::InitializeSaveFileWindow(){ Component(SAVE_FILE_NAME,"Continue Button")->SetGrayedOut(updatedLabel.length()==0); },false,16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END; saveFileWindow->ADD("Back Button",MenuComponent)(geom2d::rect{{-8,68},{48,12}},"Cancel",[](MenuFuncData data){Menu::CloseMenu();game->TextEntryEnable(false);return true;})END; - saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect{{56,68},{48,12}},"Submit",MenuType::CLASS_SELECTION,[](MenuFuncData data){ + saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect{{56,68},{48,12}},"Submit",[](MenuFuncData data){ SaveFile::SetSaveFileName(game->TextEntryGetString()); game->TextEntryEnable(false); + Menu::CloseMenu(); return true; })END ->SetGrayedOut(true); @@ -60,15 +61,11 @@ void Menu::InitializeSaveFileWindow(){ returnData="Continue Button"; }, { //Button Key - {game->KEY_START,{"Confirm Character Name",[](MenuType type){ + {game->KEY_CONTROLLER_START,{"Confirm Character Name","Continue Button"}}, + {{game->KEY_ENTER},{"Confirm Character Name",[](MenuType type){ Component(type,"Continue Button")->Click(); }}}, - {game->KEY_ENTER,{"Confirm Character Name",[](MenuType type){ - Component(type,"Continue Button")->Click(); - }}}, - {game->KEY_SELECT,{"Cancel",[](MenuType type){ - Component(type,"Back Button")->Click(); - }}}, + {game->KEY_SELECT,{"Cancel","Back Button"}}, }, {}); } \ No newline at end of file diff --git a/Adventures in Lestoria/SettingsWindow.cpp b/Adventures in Lestoria/SettingsWindow.cpp index 16cccb86..7c1e2c79 100644 --- a/Adventures in Lestoria/SettingsWindow.cpp +++ b/Adventures in Lestoria/SettingsWindow.cpp @@ -116,13 +116,13 @@ void Menu::InitializeSettingsWindow(){ }; #pragma endregion - settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::ENUM_END,[&](MenuFuncData data){ + settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",[&](MenuFuncData data){ ChangeKeybindDisplayType(KEY); Component(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Keyboard Mappings"); Menu::OpenMenu(INPUT_KEY_DISPLAY); return true; },vf2d{1.5f,2.f})END; - settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::ENUM_END,[&](MenuFuncData data){ + settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){ ChangeKeybindDisplayType(CONTROLLER); Component(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings"); Menu::OpenMenu(INPUT_KEY_DISPLAY); diff --git a/Adventures in Lestoria/ShermanWindow.cpp b/Adventures in Lestoria/ShermanWindow.cpp index 056e49b0..a2960820 100644 --- a/Adventures in Lestoria/ShermanWindow.cpp +++ b/Adventures in Lestoria/ShermanWindow.cpp @@ -43,16 +43,16 @@ All rights reserved. void Menu::InitializeShermanWindow(){ Menu*shermanWindow=CreateMenu(SHERMAN,CENTERED,vi2d{144,88}); - shermanWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{0.f,4.f},{144.f,24.f}},"Leave",MenuType::ENUM_END,[](MenuFuncData data){ + shermanWindow->ADD("Leave Button",MenuComponent)(geom2d::rect{{0.f,4.f},{144.f,24.f}},"Leave",[](MenuFuncData data){ GameState::ChangeState(States::OVERWORLD_MAP,0.3f); return true; },vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END; - shermanWindow->ADD("Consumable Crafting Button",MenuComponent)(geom2d::rect{{0.f,32.f},{144.f,24.f}},"Consumable Crafting",MenuType::ENUM_END,[](MenuFuncData data){ + shermanWindow->ADD("Consumable Crafting Button",MenuComponent)(geom2d::rect{{0.f,32.f},{144.f,24.f}},"Consumable Crafting",[](MenuFuncData data){ Menu::OpenMenu(CRAFT_CONSUMABLE); return true; },vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END ->SetGrayedOut(true); - shermanWindow->ADD("Stay Button",MenuComponent)(geom2d::rect{{0.f,60.f},{144.f,24.f}},"Stay Here",MenuType::ENUM_END,[](MenuFuncData data){ + shermanWindow->ADD("Stay Button",MenuComponent)(geom2d::rect{{0.f,60.f},{144.f,24.f}},"Stay Here",[](MenuFuncData data){ Menu::CloseMenu(); return true; },vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END; diff --git a/Adventures in Lestoria/UserIDMenu.cpp b/Adventures in Lestoria/UserIDMenu.cpp index cf460df7..4c4d2234 100644 --- a/Adventures in Lestoria/UserIDMenu.cpp +++ b/Adventures in Lestoria/UserIDMenu.cpp @@ -69,4 +69,17 @@ void Menu::InitializeUserIDWindow(){ return true; })END ->SetGrayedOut(true); + + userIDWindow->SetupKeyboardNavigation( + [](MenuType type,Data&returnData){ //On Open + returnData="Submit Button"; + }, + { //Button Key + {game->KEY_CONTROLLER_START,{"Confirm ID","Submit Button"}}, + {{game->KEY_ENTER},{"Confirm ID",[](MenuType type){ + Component(type,"Submit Button")->Click(); + }}}, + {game->KEY_SELECT,{"Cancel","Back Button"}}, + }, + {}); } \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index bda03121..54a550d7 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7313 +#define VERSION_BUILD 7326 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 53801b39..1bc322b4 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ