Add Skill display tab and Equipment display tab in Character menu.
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 2m43s

This commit is contained in:
sigonasr2 2025-07-30 08:14:28 -05:00
parent 3602de5c3b
commit 9a3793daa9
5 changed files with 130 additions and 4 deletions

View File

@ -335,6 +335,113 @@ void Menu::InitializeCharacterMenuWindow(){
characterMenuWindow->ADD("Equip Label "+CharacterMenuWindow::slotNames[i],PopupMenuLabel)(geom2d::rect<float>{{labelX,labelY},{24,16}},CharacterMenuWindow::slotNames[i],vf2d{0.5,1.f},ComponentAttr::SHADOW)END;
Menu::AddEquipStatListener(equipmentSlot);
}
#pragma endregion
auto abilityNameLabel{characterMenuWindow->ADD("Ability Name Text",MenuLabel)(geom2d::rect<float>{{125,30},{116,windowSize.y-39}},"",1.f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END};
auto abilityDescriptionLabel{characterMenuWindow->ADD("Ability Description Text",MenuLabel)(geom2d::rect<float>{{125,30+16},{116,windowSize.y-39-16}},"",1.f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END};
#pragma region Skill Selection Boxes
const std::array abilityBoxes{
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility1(),AbilitySlot::ABILITY1},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility2(),AbilitySlot::ABILITY2},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility3(),AbilitySlot::ABILITY3},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility4(),AbilitySlot::ABILITY4},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetRightClickAbility(),AbilitySlot::DEFENSIVE},
};
for(size_t i{0};auto&[ability,slot]:abilityBoxes){
float x=8;
float y=14+i*28;
float labelX=24;
float labelY=24+i*26+28;
auto skillBox{characterMenuWindow->ADD(std::format("Skill Icon Label {}",i),MenuIconButton)(geom2d::rect<float>{{x,y+28},{24,24}},GFX[ability.get().icon].Decal(),DO_NOTHING)END};
auto skillNameLabel{characterMenuWindow->ADD(std::format("Skill Name Label {}",i),MenuLabel)(geom2d::rect<float>{{labelX+4,labelY-6},{96,24}},ability.get().GetNameWithPlayerModifiers())END};
skillBox->SetHoverFunc([slot](MenuFuncData data){
const auto&ability{game->GetPlayer()->GetAbility(slot)};
Component<MenuLabel>(data.menu.GetType(),"Ability Name Text")->SetLabel(ability.GetNameWithPlayerModifiers());
Component<MenuLabel>(data.menu.GetType(),"Ability Description Text")->SetLabel(ability.GetDescriptionWithPlayerModifiers());
return true;
});
skillBox->Disable(); //Hide these by default.
i++;
}
#pragma endregion
enum class ClickedTab{
EQUIPMENT,
SKILLS
};
enum class AbilitySlot{
ABILITY1,
ABILITY2,
ABILITY3,
ABILITY4,
DEFENSIVE,
};
//Used in conjunction with the onClick events of MenuComponents tab.
auto OnTabClick=[](const ClickedTab tabClicked,const MenuFuncData&data){
using enum ClickedTab;
auto abilityNameLabel{Component<MenuLabel>(data.menu.GetType(),"Ability Name Text")};
auto abilityDescriptionLabel{Component<MenuLabel>(data.menu.GetType(),"Ability Description Text")};
for(int i=0;i<8;i++){
auto slot{Component<EquipSlotButton>(data.menu.GetType(),std::format("Equip Slot {}",CharacterMenuWindow::slotNames[i]))};
if(tabClicked==EQUIPMENT)slot->Enable();
else slot->Disable();
}
const std::array abilityBoxes{
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility1(),AbilitySlot::ABILITY1},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility2(),AbilitySlot::ABILITY2},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility3(),AbilitySlot::ABILITY3},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility4(),AbilitySlot::ABILITY4},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetRightClickAbility(),AbilitySlot::DEFENSIVE},
};
for(int i=0;i<abilityBoxes.size();i++){
auto&[ability,slot]{abilityBoxes[i]};
auto abilityIcon{Component<MenuIconButton>(data.menu.GetType(),std::format("Skill Icon Label {}",i))};
auto abilityText{Component<MenuLabel>(data.menu.GetType(),std::format("Skill Name Label {}",i))};
abilityIcon->SetIcon(GFX[ability.get().icon].Decal());
abilityText->SetLabel(ability.get().GetNameWithPlayerModifiers());
if(tabClicked==SKILLS){
abilityIcon->Enable();
abilityText->Enable();
}else{
abilityIcon->Disable();
abilityText->Disable();
}
}
Component<MenuComponent>(data.menu.GetType(),"Equipment Tab")->SetSelected(tabClicked==EQUIPMENT);
Component<MenuComponent>(data.menu.GetType(),"Skills Tab")->SetSelected(tabClicked==SKILLS);
const static std::array<std::string,8>slotNames{"Helmet","Weapon","Armor","Gloves","Pants","Shoes","Ring 1","Ring 2"};
if(tabClicked==EQUIPMENT){
abilityNameLabel->Disable();
abilityDescriptionLabel->Disable();
for(size_t ind{0};ind<slotNames.size();ind++){
Component<MenuItemItemButton>(CHARACTER_MENU,"Equip Slot "+slotNames[ind])->Enable();
Component<PopupMenuLabel>(CHARACTER_MENU,"Equip Label "+slotNames[ind])->Enable();
}
}else{
abilityNameLabel->Enable();
abilityDescriptionLabel->Enable();
for(size_t ind{0};ind<slotNames.size();ind++){
Component<MenuItemItemButton>(CHARACTER_MENU,"Equip Slot "+slotNames[ind])->Disable();
Component<PopupMenuLabel>(CHARACTER_MENU,"Equip Label "+slotNames[ind])->Disable();
}
}
SoundEffect::PlaySFX("Button Click",SoundEffect::CENTERED);
};
auto equipmentTab = characterMenuWindow->ADD("Equipment Tab",MenuComponent)(geom2d::rect<float>{{2,30},{58,10}},"Equipment",[&OnTabClick](MenuFuncData data){
OnTabClick(ClickedTab::EQUIPMENT,data);
return true;
},ButtonAttr::FIT_TO_LABEL)END;
equipmentTab->SetSelectionType(HIGHLIGHT);
equipmentTab->SetSelected(true);
auto skillsTab = characterMenuWindow->ADD("Skills Tab",MenuComponent)(geom2d::rect<float>{{62,30},{56,10}},"Skills",[&OnTabClick](MenuFuncData data){
OnTabClick(ClickedTab::SKILLS,data);
return true;
},ButtonAttr::FIT_TO_LABEL)END;
skillsTab->SetSelectionType(HIGHLIGHT);
skillsTab->SetSelected(false);
characterMenuWindow->ADD("Stat Display Outline",MenuComponent)(geom2d::rect<float>{{245,28},{62,windowSize.y-37}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END;

View File

@ -36,7 +36,7 @@ All rights reserved.
*/
#pragma endregion
#include "Menu.h"
#include "MenuIconButton.h"
#include "MenuComponent.h"
#include "GameState.h"
#include "MenuLabel.h"
@ -44,6 +44,7 @@ All rights reserved.
#include "CharacterRotatingDisplay.h"
#include "ClassInfo.h"
#include "Unlock.h"
#include "ItemEnchant.h"
INCLUDE_game
INCLUDE_GFX
@ -59,6 +60,24 @@ void Menu::InitializePauseWindow(){
pauseWindow->ADD("Character Button",MenuComponent)(geom2d::rect<float>{{6.f,28.f},{84.f,24.f}},"Character",[](MenuFuncData data){
Component<CharacterRotatingDisplay>(CHARACTER_MENU,"Character Rotating Display")->SetIcon(GFX[classutils::GetClassInfo(game->GetPlayer()->GetClassName()).classFullImgName].Decal());
Component<MenuComponent>(CHARACTER_MENU,"Equip Selection Select Button")->Click();
std::array abilityBoxes{
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility1(),AbilitySlot::ABILITY1},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility2(),AbilitySlot::ABILITY2},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility3(),AbilitySlot::ABILITY3},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetAbility4(),AbilitySlot::ABILITY4},
std::pair<std::reference_wrapper<Ability>,AbilitySlot>{game->GetPlayer()->GetRightClickAbility(),AbilitySlot::DEFENSIVE},
};
for(size_t i{0};auto&[ability,slot]:abilityBoxes){
//Attempt to update icons in case the abilities have changed at some point.
//Attempt to update labels in case they have changed.
auto skillBox{Component<MenuIconButton>(CHARACTER_MENU,std::format("Skill Icon Label {}",i))};
auto skillNameLabel{Component<MenuLabel>(CHARACTER_MENU,std::format("Skill Name Label {}",i))};
skillBox->SetIcon(GFX[ability.get().icon].Decal());
skillNameLabel->SetLabel(ability.get().GetNameWithPlayerModifiers());
skillBox->Disable();
skillNameLabel->Disable();
i++;
}
Menu::OpenMenu(CHARACTER_MENU);
return true;
},ButtonAttr::FIT_TO_LABEL)END;

View File

@ -79,11 +79,11 @@ void State_MainMenu::OnUserUpdate(AiL*game){
game->UpdateCamera(game->GetElapsedTime());
game->ClearTimedOutGarbage();
};
}
void State_MainMenu::Draw(AiL*game){
game->RenderWorld(game->GetElapsedTime());
TitleScreen::Draw();
};
}
const ZoneData&State_MainMenu::ChooseRandomFocusArea(){
//std::vector<ZoneData>

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 12140
#define VERSION_BUILD 12246
#define stringify(a) stringify_(a)
#define stringify_(a) #a