Incorporated stat differences to equip menu display.
This commit is contained in:
@@ -133,23 +133,37 @@ void Menu::InitializeCharacterMenuWindow(){
|
||||
},[&](MenuFuncData data){
|
||||
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
|
||||
Item&buttonItem=button->GetItem();
|
||||
std::vector<int>statsBeforeEquip;
|
||||
EquipSlot slot=EquipSlot(button->I(Attribute::EQUIP_TYPE));
|
||||
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");
|
||||
statDisplayLabel->I(Attribute::STAT_CHANGE)=stat;
|
||||
statsBeforeEquip.push_back(game->GetPlayer()->GetStat(attribute));
|
||||
}
|
||||
Item*equippedItem=Inventory::GetEquip(slot);
|
||||
Inventory::EquipItem(buttonItem,slot);
|
||||
for(int counter=0;ItemAttribute attribute:displayAttrs){
|
||||
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
|
||||
int statChangeAmt=game->GetPlayer()->GetStat(attribute)-statsBeforeEquip[counter];
|
||||
std::string baseLabel=statDisplayLabel->S(Attribute::BASE_TEXT);
|
||||
if(statChangeAmt>0){
|
||||
baseLabel+=Color::Green+"(+"+std::to_string(statChangeAmt)+")";
|
||||
}else
|
||||
if(statChangeAmt<0){
|
||||
baseLabel+=Color::Red+"("+std::to_string(statChangeAmt)+")";
|
||||
}
|
||||
statDisplayLabel->SetLabel(baseLabel);
|
||||
counter++;
|
||||
}
|
||||
Inventory::UnequipItem(slot);
|
||||
if(*equippedItem!=Item::BLANK){
|
||||
Inventory::EquipItem(*equippedItem,slot);
|
||||
}
|
||||
return true;
|
||||
},[&](MenuFuncData data){
|
||||
MenuItemItemButton*button=(MenuItemItemButton*)data.component;
|
||||
Item&buttonItem=button->GetItem();
|
||||
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");
|
||||
statDisplayLabel->I(Attribute::STAT_CHANGE)=stat;
|
||||
}
|
||||
MenuLabel*statDisplayLabel=Component<MenuLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
|
||||
statDisplayLabel->SetLabel(statDisplayLabel->S(Attribute::BASE_TEXT));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -185,6 +199,7 @@ 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::BASE_TEXT)=attrStr;
|
||||
yOffset+=20;
|
||||
characterMenuWindow->AddComponent("Attribute "+data.name+" Label",attrLabel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user