Implemented color code text in PGE.

This commit is contained in:
2023-12-06 18:55:18 -06:00
parent e615831ded
commit 808cc32418
7 changed files with 178 additions and 41 deletions
+3 -25
View File
@@ -84,7 +84,7 @@ void Menu::InitializeCharacterMenuWindow(){
characterMenuWindow->AddComponent("Equip Selection Bottom Outline",equipSelectionBottomOutline);
characterMenuWindow->AddComponent("Equip Selection Select Button",equipSelectionSelectButton);
const std::array<ItemAttribute,7>displayAttrs{
const static std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
@@ -133,43 +133,22 @@ void Menu::InitializeCharacterMenuWindow(){
},[&](MenuFuncData data){
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
Item&buttonItem=button->GetItem();
const std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
ItemAttribute::moveSpdPct,
ItemAttribute::cdrPct,
ItemAttribute::critPct,
ItemAttribute::critDmgPct,
};
for(ItemAttribute attribute:displayAttrs){
int stat=buttonItem.GetStats().get(attribute);
if(stat>0){
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT);
std::string newLabel=baseLabel+" (+"+std::to_string(stat)+")";
statDisplayLabel->SetLabel(newLabel);
statDisplayLabel->I(Attribute::STAT_CHANGE)=stat;
}
}
return true;
},[&](MenuFuncData data){
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
Item&buttonItem=button->GetItem();
const std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
ItemAttribute::moveSpdPct,
ItemAttribute::cdrPct,
ItemAttribute::critPct,
ItemAttribute::critDmgPct,
};
for(ItemAttribute attribute:displayAttrs){
int stat=buttonItem.GetStats().get(attribute);
if(stat>0){
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
std::string baseLabel=statDisplayLabel->S(Attribute::DISPLAY_TEXT);
statDisplayLabel->SetLabel(baseLabel);
statDisplayLabel->I(Attribute::STAT_CHANGE)=stat;
}
}
return true;
@@ -206,7 +185,6 @@ void Menu::InitializeCharacterMenuWindow(){
attrStr+="%";
}
MenuLabel*attrLabel=NEW MenuLabel(CHARACTER_MENU,{{245,36+2+float(yOffset)},{62,18}},attrStr,1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN);
attrLabel->S(Attribute::DISPLAY_TEXT)=attrStr;
yOffset+=20;
characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel);
}