Add skill menu buttons and text displays. Release Build 12209.
All checks were successful
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 10m6s

This commit is contained in:
sigonasr2 2025-06-02 13:28:44 -05:00
parent 93fb1fd48e
commit 3cf5651d95
6 changed files with 55 additions and 6 deletions

View File

@ -56,6 +56,14 @@ struct PrecastData{
PrecastData(float castTime,float range,float size);
};
enum class AbilitySlot{
ABILITY1,
ABILITY2,
ABILITY3,
ABILITY4,
DEFENSIVE
};
//Abilities are tied to class data which is defined in Class.cpp.
struct Ability{
std::string name="";

View File

@ -166,6 +166,7 @@ void Menu::InitializeCharacterMenuWindow(){
};
int equipSlot=1;
#pragma region Equipment Selection Boxes
for(int i=0;i<8;i++){
float x=31+(i%2)*33;
float y=24+(i/2)*28;
@ -335,6 +336,35 @@ 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
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++){
float x=0;
float y=24+i*28;
float labelX=31;
float labelY=24+i*28+36;
auto skillBox{characterMenuWindow->ADD(std::format("Skill Label {}",i),MenuComponent)(geom2d::rect<float>{{x,y+28},{24,24}},"",[](MenuFuncData data){
return true;
})END};
auto&[ability,slot]{abilityBoxes[i]};
skillBox->SetHoverFunc([&abilityNameLabel,&abilityDescriptionLabel,&ability](MenuFuncData data){
abilityNameLabel->SetLabel(ability.get().GetNameWithPlayerModifiers());
abilityDescriptionLabel->SetLabel(ability.get().GetDescriptionWithPlayerModifiers());
return true;
});
}
#pragma endregion
enum class ClickedTab{
EQUIPMENT,
@ -342,14 +372,26 @@ void Menu::InitializeCharacterMenuWindow(){
};
//Used in conjunction with the onClick events of MenuComponents tab.
auto OnTabClick=[](const ClickedTab tabClicked,const MenuFuncData&data){
auto OnTabClick=[&abilityBoxes,&abilityNameLabel,&abilityDescriptionLabel](const ClickedTab tabClicked,const MenuFuncData&data){
using enum ClickedTab;
for(int i=0;i<8;i++){
auto slot{Component<EquipSlotButton>(data.menu.GetType(),CharacterMenuWindow::slotNames[i])};
if(tabClicked==EQUIPMENT)slot->Enable();
else slot->Disable();
Component<MenuComponent>(data.menu.GetType(),"Equipment Tab")->SetSelected(tabClicked==EQUIPMENT);
Component<MenuComponent>(data.menu.GetType(),"Skills Tab")->SetSelected(tabClicked==SKILLS);
}
for(int i=0;i<abilityBoxes.size();i++){
auto slot{Component<MenuComponent>(data.menu.GetType(),std::format("Skill Label {}",i))};
if(tabClicked==SKILLS)slot->Enable();
else slot->Disable();
}
Component<MenuComponent>(data.menu.GetType(),"Equipment Tab")->SetSelected(tabClicked==EQUIPMENT);
Component<MenuComponent>(data.menu.GetType(),"Skills Tab")->SetSelected(tabClicked==SKILLS);
if(tabClicked==EQUIPMENT){
abilityNameLabel->Disable();
abilityDescriptionLabel->Disable();
}else{
abilityNameLabel->Enable();
abilityDescriptionLabel->Enable();
}
};

View File

@ -731,7 +731,7 @@ void Menu::AddChapterListener(std::weak_ptr<MenuComponent>component){
if(std::find_if(chapterListeners.begin(),chapterListeners.end(),[&](auto&ptr){return &*ptr.lock()==&*component.lock();})!=chapterListeners.end()){
ERR("WARNING! Component "<<component.lock()->name<<" has already been added to the Chapter listener list! There should not be any duplicates!!")
}
chapterListeners.push_back(component);
chapterListeners.emplace_back(component);
}
ToggleFuncData::ToggleFuncData(Menu&menu,AiL*const game,std::weak_ptr<MenuComponent>component,std::weak_ptr<ScrollableWindowComponent>parentComponent,bool checked)

View File

@ -139,7 +139,6 @@ class Menu:public IAttributable{
static std::vector<std::weak_ptr<MenuComponent>>equipStatListeners; //All menu components that care about stat/equip updates subscribe to this list indirectly (See Menu::AddStatListener()).
static std::vector<std::weak_ptr<MenuComponent>>chapterListeners; //All menu components that care about story chapter updates subscribe to this list indirectly (See Menu::AddChapterListener()).
const static bool CanModifyEquipSlots();
public:
//The constructor is private. Use CreateMenu() instead!

View File

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