Item Attribute systems reworked from being an enum class to being a class. Added support for the Buff Item Script to modify items. Implemented Damage Reduction proposal.

This commit is contained in:
2023-12-23 21:15:08 -06:00
parent 51cbf81204
commit 668a5ca1b1
28 changed files with 704 additions and 331 deletions
+22 -24
View File
@@ -61,14 +61,14 @@ void Menu::InitializeCharacterMenuWindow(){
characterMenuWindow->ADD("Equip Slot Outline",MenuComponent)({{0,28},{120,windowSize.y-37}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END;
characterMenuWindow->ADD("Character Rotating Display",CharacterRotatingDisplay)({{135,28},{90,windowSize.y-48}},GFX[classutils::GetClassInfo(game->GetPlayer()->GetClassName()).classFullImgName].Decal())END;
const static std::array<ItemAttribute,7>displayAttrs{
ItemAttribute::health,
ItemAttribute::attack,
ItemAttribute::defense,
ItemAttribute::moveSpdPct,
ItemAttribute::cdrPct,
ItemAttribute::critPct,
ItemAttribute::critDmgPct,
const static std::array<std::string,7>displayAttrs{
"Health",
"Attack",
"Defense",
"Move Spd %",
"CDR",
"Crit Rate",
"Crit Dmg",
};
@@ -85,8 +85,8 @@ void Menu::InitializeCharacterMenuWindow(){
Component<MenuComponent>(data.component->parentMenu,"Equip Selection Bottom Outline")->Enable(false);
Component<MenuComponent>(data.component->parentMenu,"Equip Selection Select Button")->Enable(false);
Component<CharacterRotatingDisplay>(data.component->parentMenu,"Character Rotating Display")->Enable(true);
for(int counter=0;ItemAttribute attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
for(int counter=0;const std::string&attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
statDisplayLabel->SetStatChangeAmt(0);
}
equipmentWindowOpened=false;
@@ -96,10 +96,9 @@ void Menu::InitializeCharacterMenuWindow(){
equipSelectionSelectButton->Enable(false);
const static auto GetLabelText=[](ItemAttribute attribute){
AttributeData data=ItemAttributable::GetDisplayInfo(attribute);
std::string attrStr=data.name+":\n ";
std::string attrStr=std::string(attribute.Name())+":\n ";
attrStr+=std::to_string(game->GetPlayer()->GetStat(attribute));
if(data.displayAsPercent){
if(attribute.DisplayAsPercent()){
attrStr+="%";
}
return attrStr;
@@ -149,8 +148,8 @@ void Menu::InitializeCharacterMenuWindow(){
}
}
comp->SetSelected(true);
for(int counter=0;ItemAttribute attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
for(int counter=0;const std::string&attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
statDisplayLabel->SetStatChangeAmt(0);
}
MenuItemItemButton*equipButton=Component<MenuItemItemButton>(CHARACTER_MENU,"Equip Slot "+slotNames[data.parentComponent->I(A::INDEXED_THEME)]);
@@ -168,13 +167,13 @@ void Menu::InitializeCharacterMenuWindow(){
const std::weak_ptr<Item>buttonItem=button->GetItem();
std::vector<int>statsBeforeEquip;
EquipSlot slot=EquipSlot(button->I(Attribute::EQUIP_TYPE));
for(ItemAttribute attribute:displayAttrs){
for(const std::string&attribute:displayAttrs){
statsBeforeEquip.push_back(game->GetPlayer()->GetStat(attribute));
}
std::weak_ptr<Item>equippedItem=Inventory::GetEquip(slot);
Inventory::EquipItem(buttonItem,slot);
for(int counter=0;ItemAttribute attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
for(int counter=0;const std::string&attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
int statChangeAmt=game->GetPlayer()->GetStat(attribute)-statsBeforeEquip[counter];
statDisplayLabel->SetStatChangeAmt(statChangeAmt);
counter++;
@@ -190,8 +189,8 @@ void Menu::InitializeCharacterMenuWindow(){
});
equip->SetMouseOutFunc(
[](MenuFuncData data){
for(int counter=0;ItemAttribute attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+ItemAttributable::GetDisplayInfo(attribute).name+" Label");
for(int counter=0;const std::string&attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
statDisplayLabel->SetStatChangeAmt(0);
counter++;
}
@@ -241,10 +240,9 @@ void Menu::InitializeCharacterMenuWindow(){
characterMenuWindow->ADD("Stat Display Outline",MenuComponent)({{245,28},{62,windowSize.y-37}},"",DO_NOTHING,ButtonAttr::UNSELECTABLE)END;
int yOffset=0;
for(ItemAttribute attribute:displayAttrs){
std::string attrStr=GetLabelText(attribute);
AttributeData data=ItemAttributable::GetDisplayInfo(attribute);
auto attrLabel=characterMenuWindow->ADD("Attribute "+data.name+" Label",StatLabel)({{245,28+2+float(yOffset)},{62,18}},attribute,1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
for(const std::string&attribute:displayAttrs){
std::string attrStr=GetLabelText(ItemAttribute::Get(attribute));
auto attrLabel=characterMenuWindow->ADD("Attribute "+attribute+" Label",StatLabel)({{245,28+2+float(yOffset)},{62,18}},ItemAttribute::Get(attribute),1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
Menu::AddEquipStatListener(attrLabel);
yOffset+=20;
}