Fixed issues with one input bleeding into multiple inputs. Removed old redundant system where we can specify a menu to navigate to. Implemented controller compatibility for UserID menu. Release Build 7326.

pull/35/head
sigonasr2 9 months ago
parent 7434079e0d
commit a39a841166
  1. 2
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 4
      Adventures in Lestoria/BlacksmithCraftingWindow.cpp
  4. 2
      Adventures in Lestoria/CharacterMenuWindow.cpp
  5. 11
      Adventures in Lestoria/ClassSelectionWindow.cpp
  6. 4
      Adventures in Lestoria/ConsumableCraftingWindow.cpp
  7. 4
      Adventures in Lestoria/EquipSlotButton.h
  8. 6
      Adventures in Lestoria/InventoryWindow.cpp
  9. 24
      Adventures in Lestoria/ItemLoadoutWindow.cpp
  10. 16
      Adventures in Lestoria/Menu.cpp
  11. 1
      Adventures in Lestoria/Menu.h
  12. 22
      Adventures in Lestoria/MenuComponent.cpp
  13. 4
      Adventures in Lestoria/MenuComponent.h
  14. 4
      Adventures in Lestoria/MenuIconButton.h
  15. 8
      Adventures in Lestoria/MenuItemItemButton.h
  16. 4
      Adventures in Lestoria/MenuType.h
  17. 6
      Adventures in Lestoria/MerchantWindow.cpp
  18. 5
      Adventures in Lestoria/OverworldMapLevelWindow.cpp
  19. 2
      Adventures in Lestoria/SaveFileNameButton.h
  20. 13
      Adventures in Lestoria/SaveFileWindow.cpp
  21. 4
      Adventures in Lestoria/SettingsWindow.cpp
  22. 6
      Adventures in Lestoria/ShermanWindow.cpp
  23. 13
      Adventures in Lestoria/UserIDMenu.cpp
  24. 2
      Adventures in Lestoria/Version.h
  25. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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<int>(GPButtons::START)});
KEY_CONTROLLER_START.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::START)});
KEY_SELECT.AddKeybind({KEY,ESCAPE});
KEY_SELECT.AddKeybind({CONTROLLER,static_cast<int>(GPButtons::SELECT)});

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

@ -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<float>{{224,28},{inventoryDescriptionWidth,blacksmithWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
blacksmithWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
blacksmithWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect<float>{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END;
blacksmithWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect<float>{{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<float>{{blacksmithWindow->size.x/2-48,28+blacksmithWindow->size.y-44+6},{96,24}},"Leave",MenuType::ENUM_END,
blacksmithWindow->ADD("Leave Button",MenuComponent)(geom2d::rect<float>{{blacksmithWindow->size.x/2-48,28+blacksmithWindow->size.y-44+6},{96,24}},"Leave",
[](MenuFuncData data){
Menu::CloseMenu();
return true;

@ -124,7 +124,7 @@ void Menu::InitializeCharacterMenuWindow(){
labelY-=8;
}
EquipSlot slot=EquipSlot(equipSlot);
auto equipmentSlot=characterMenuWindow->ADD("Equip Slot "+slotNames[i],EquipSlotButton)(geom2d::rect<float>{{x,y+28},{24,24}},slot,MenuType::ENUM_END,
auto equipmentSlot=characterMenuWindow->ADD("Equip Slot "+slotNames[i],EquipSlotButton)(geom2d::rect<float>{{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);

@ -135,11 +135,12 @@ void Menu::InitializeClassSelectionWindow(){
auto classLabel=classSelectionWindow->ADD(className+" Background",MenuLabel)(geom2d::rect<float>{backgroundOffsetPos,backgroundSize},"",1,ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
auto classButton=classSelectionWindow->ADD(className+" Button",MenuComponent)(geom2d::rect<float>{offsetPos,buttonSize},"Info",CLASS_INFO,
auto classButton=classSelectionWindow->ADD(className+" Button",MenuComponent)(geom2d::rect<float>{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<MenuComponent>(type,"Back")->Click();
}}},
{game->KEY_START,{"Confirm",[](MenuType type){
{game->KEY_START,{[](MenuFuncData data){
if(Component<MenuComponent>(data.menu.GetType(),"Confirm")->IsEnabled()){
return "Confirm";
}else{
return "";
}
},[](MenuType type){
Component<MenuComponent>(type,"Confirm")->Click();
}}},
{game->KEY_FACEUP,{"Change Player Name",[](MenuType type){

@ -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<float>{{224,28},{inventoryDescriptionWidth,consumableCraftingWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
consumableCraftingWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{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<float>{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END;
consumableCraftingWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect<float>{{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<float>{{consumableCraftingWindow->size.x/2-48,28+consumableCraftingWindow->size.y-44+6},{96,24}},"Back",MenuType::ENUM_END,
consumableCraftingWindow->ADD("Back Button",MenuComponent)(geom2d::rect<float>{{consumableCraftingWindow->size.x/2-48,28+consumableCraftingWindow->size.y-44+6},{96,24}},"Back",
[](MenuFuncData data){
Menu::CloseMenu();
return true;

@ -47,8 +47,8 @@ class EquipSlotButton:public MenuItemItemButton{
private:
EquipSlot slot;
public:
inline EquipSlotButton(geom2d::rect<float>rect,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::rect<float>rect,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_ptr<Item>equip=Inventory::GetEquip(slot);
if(!ISBLANK(equip)){

@ -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<float>{{2,30+yOffset},{68,16}},category,MenuType::ENUM_END,
auto button=inventoryWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect<float>{{2,30+yOffset},{68,16}},category,
[&](MenuFuncData data){
//Close the old inventory window and show the proper one.
Component<RowInventoryScrollableWindowComponent>(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<float>{{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END;
inventoryWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
inventoryWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect<float>{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END;
inventoryWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect<float>{{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<float>{{inventoryWindow->size.x/2-48,28+inventoryWindow->size.y-44+6},{96,24}},"Back",MenuType::ENUM_END,
inventoryWindow->ADD("Back Button",MenuComponent)(geom2d::rect<float>{{inventoryWindow->size.x/2-48,28+inventoryWindow->size.y-44+6},{96,24}},"Back",
[](MenuFuncData data){
Menu::CloseMenu();
return true;

@ -54,17 +54,35 @@ void Menu::InitializeItemLoadoutWindow(){
float buttonBorderPadding=64;
itemLoadoutWindow->ADD("Loadout Item 1",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{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<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;
},"Item Name Label","Item Description")END;
itemLoadoutWindow->ADD("Loadout Item 2",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{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<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;
},"Item Name Label","Item Description")END;
itemLoadoutWindow->ADD("Loadout Item 3",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{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<MenuLabel>(ITEM_LOADOUT,"Item Name Label")->SetLabel("");
Component<MenuLabel>(ITEM_LOADOUT,"Item Description")->SetLabel("");
return true;

@ -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<ScrollableWindowComponent>(selection.lock()->parentComponent.lock())});
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!")
}
}
}
selection.lock()->onClick(MenuFuncData{*this,game,selection,dynamic_pointer_cast<ScrollableWindowComponent>(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();

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

@ -47,17 +47,11 @@ INCLUDE_game
using A=Attribute;
MenuComponent::MenuComponent(geom2d::rect<float>rect,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::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,ButtonAttr attributes)
MenuComponent::MenuComponent(geom2d::rect<float>rect,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::rect<float>rect,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()<MAX_MENUS){
Menu::OpenMenu(menuDest); //Navigate to the next menu.
}else{
ERR("WARNING! Exceeded menu stack size limit!")
}
}
}
onClick(MenuFuncData{*Menu::menus[parentMenu],game,Menu::menus[parentMenu]->components[name]});
}
void MenuComponent::SetLabel(std::string newLabel){
label=newLabel;

@ -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_ptr<ScrollableWindowComponent>parentComponent{};
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,ButtonAttr attributes=ButtonAttr::NONE);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes=ButtonAttr::NONE);
MenuComponent(geom2d::rect<float>rect,std::string label,MenuFunc onClick,vf2d labelScaling,ButtonAttr attributes=ButtonAttr::NONE);
virtual ~MenuComponent();
vf2d GetPos();
const vf2d&GetSize()const;

@ -56,9 +56,7 @@ protected:
Pixel tint=WHITE;
public:
inline MenuIconButton(geom2d::rect<float>rect,Decal*icon,MenuFunc onClick,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
:MenuIconButton(rect,icon,MenuType::ENUM_END,onClick,attributes){}
inline MenuIconButton(geom2d::rect<float>rect,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);
}

@ -57,13 +57,13 @@ private:
protected:
std::weak_ptr<Item>itemRef;
public:
inline MenuItemItemButton(geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,MenuType menuDest,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
:MenuIconButton(rect,!ISBLANK(itemRef)?const_cast<Decal*>(itemRef.lock()->Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){
inline MenuItemItemButton(geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,MenuFunc onClick,std::string itemNameLabelName,std::string itemDescriptionLabelName,IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
:MenuIconButton(rect,!ISBLANK(itemRef)?const_cast<Decal*>(itemRef.lock()->Decal()):nullptr,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){
draggable=false;
valid=!ISBLANK(itemRef);
}
inline MenuItemItemButton(geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
:MenuIconButton(rect,!ISBLANK(itemRef)?const_cast<Decal*>(itemRef.lock()->Decal()):nullptr,menuDest,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){
inline MenuItemItemButton(geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut,std::string itemNameLabelName="",std::string itemDescriptionLabelName="",IconButtonAttr attributes=IconButtonAttr::SELECTABLE)
:MenuIconButton(rect,!ISBLANK(itemRef)?const_cast<Decal*>(itemRef.lock()->Decal()):nullptr,onClick,attributes),itemRef(itemRef),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){
runHoverFunctions=true;
draggable=false;
valid=!ISBLANK(itemRef);

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

@ -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<float>{{2,30+yOffset},{68,16}},category,MenuType::ENUM_END,
auto button=merchantWindow->ADD(category+" Inventory Tab",MenuComponent)(geom2d::rect<float>{{2,30+yOffset},{68,16}},category,
[&](MenuFuncData data){
//Close the old inventory window and show the proper one.
Component<RowInventoryScrollableWindowComponent>(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<float>{{224,28},{inventoryDescriptionWidth,merchantWindow->size.y-44}},"",1,ComponentAttr::LEFT_ALIGN|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
merchantWindow->ADD("Item Icon",MenuItemItemButton)(geom2d::rect<float>{{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<float>{{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
merchantWindow->ADD("Item Name Label",MenuLabel)(geom2d::rect<float>{{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END;
merchantWindow->ADD("Item Description Label",MenuLabel)(geom2d::rect<float>{{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<float>{{merchantWindow->size.x/2-48,28+merchantWindow->size.y-44+6},{96,24}},"Leave",MenuType::ENUM_END,
merchantWindow->ADD("Leave Button",MenuComponent)(geom2d::rect<float>{{merchantWindow->size.x/2-48,28+merchantWindow->size.y-44+6},{96,24}},"Leave",
[](MenuFuncData data){
Menu::CloseMenu();
return true;

@ -60,7 +60,10 @@ void Menu::InitializeOverworldMapLevelWindow(){
levelSelectWindow->ADD("Encounters Label",MenuLabel)(geom2d::rect<float>{{0,52},{windowSize.x-1,12}},"Encounters:",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
levelSelectWindow->ADD("Spawns List",EncountersSpawnListScrollableWindowComponent)(geom2d::rect<float>{{1,64},{windowSize.x-2,84}},ComponentAttr::BACKGROUND)END;
levelSelectWindow->ADD("Change Loadout Button",MenuComponent)(geom2d::rect<float>{{0,152},{windowSize.x-1,12}},"Change Loadout",ITEM_LOADOUT,[](MenuFuncData data){return true;})END;
levelSelectWindow->ADD("Change Loadout Button",MenuComponent)(geom2d::rect<float>{{0,152},{windowSize.x-1,12}},"Change Loadout",[](MenuFuncData data){
Menu::OpenMenu(ITEM_LOADOUT);
return true;
})END;
levelSelectWindow->ADD("Enter Button",MenuComponent)(geom2d::rect<float>{{0,166},{windowSize.x-1,16}},"Enter",[](MenuFuncData data){State_OverworldMap::StartLevel();return true;})END;
#pragma region Keyboard Navigation Rules

@ -43,7 +43,7 @@ All rights reserved.
class SaveFileNameButton:public MenuComponent{
public:
inline SaveFileNameButton(geom2d::rect<float>rect,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);

@ -47,9 +47,10 @@ void Menu::InitializeSaveFileWindow(){
Component<MenuComponent>(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<float>{{-8,68},{48,12}},"Cancel",[](MenuFuncData data){Menu::CloseMenu();game->TextEntryEnable(false);return true;})END;
saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect<float>{{56,68},{48,12}},"Submit",MenuType::CLASS_SELECTION,[](MenuFuncData data){
saveFileWindow->ADD("Continue Button",MenuComponent)(geom2d::rect<float>{{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<MenuComponent>(type,"Continue Button")->Click();
}}},
{game->KEY_ENTER,{"Confirm Character Name",[](MenuType type){
Component<MenuComponent>(type,"Continue Button")->Click();
}}},
{game->KEY_SELECT,{"Cancel",[](MenuType type){
Component<MenuComponent>(type,"Back Button")->Click();
}}},
{game->KEY_SELECT,{"Cancel","Back Button"}},
},
{});
}

@ -116,13 +116,13 @@ void Menu::InitializeSettingsWindow(){
};
#pragma endregion
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",MenuType::ENUM_END,[&](MenuFuncData data){
settingsWindow->ADD("Keyboard Bindings Button",MenuComponent)(geom2d::rect<float>{{28,132.f},vf2d{windowSize.x-32,24}},"Keyboard Bindings",[&](MenuFuncData data){
ChangeKeybindDisplayType(KEY);
Component<MenuLabel>(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<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",MenuType::ENUM_END,[&](MenuFuncData data){
settingsWindow->ADD("Controller Bindings Button",MenuComponent)(geom2d::rect<float>{{28,160.f},vf2d{windowSize.x-32,24}},"Controller Bindings",[&](MenuFuncData data){
ChangeKeybindDisplayType(CONTROLLER);
Component<MenuLabel>(INPUT_KEY_DISPLAY,"Keyboard Mapping Label")->SetLabel("Controller Mappings");
Menu::OpenMenu(INPUT_KEY_DISPLAY);

@ -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<float>{{0.f,4.f},{144.f,24.f}},"Leave",MenuType::ENUM_END,[](MenuFuncData data){
shermanWindow->ADD("Leave Button",MenuComponent)(geom2d::rect<float>{{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<float>{{0.f,32.f},{144.f,24.f}},"Consumable Crafting",MenuType::ENUM_END,[](MenuFuncData data){
shermanWindow->ADD("Consumable Crafting Button",MenuComponent)(geom2d::rect<float>{{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<float>{{0.f,60.f},{144.f,24.f}},"Stay Here",MenuType::ENUM_END,[](MenuFuncData data){
shermanWindow->ADD("Stay Button",MenuComponent)(geom2d::rect<float>{{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;

@ -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<MenuComponent>(type,"Submit Button")->Click();
}}},
{game->KEY_SELECT,{"Cancel","Back Button"}},
},
{});
}

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

Loading…
Cancel
Save