Add in consumable crafting. Allow specifying a quantity for item crafts. Add Flower Petals to Flower Turret drop table.

This commit is contained in:
2023-12-29 02:43:59 -06:00
parent c876f8a6ea
commit 9fef977a3a
16 changed files with 190 additions and 44 deletions
+15 -9
View File
@@ -42,6 +42,7 @@ All rights reserved.
class RequiredMaterialsList:public MenuLabel{
std::weak_ptr<Item>itemRef;
uint8_t qty=1;
public:
inline RequiredMaterialsList(geom2d::rect<float>rect,const std::weak_ptr<Item>itemRef,ComponentAttr attributes=ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)
:MenuLabel(rect,"",1.f,attributes),itemRef(itemRef){}
@@ -51,6 +52,9 @@ public:
inline const std::weak_ptr<Item>GetItem()const{
return itemRef;
}
inline void SetQuantity(uint8_t quantity){
this->qty=quantity;
}
protected:
inline virtual void DrawDecal(ViewPort&window,bool focused)override final{
MenuComponent::DrawDecal(window,focused);
@@ -70,23 +74,25 @@ protected:
int index=0;
for(const auto&[name,amt]:itemRef.lock()->GetEnhancementInfo()[itemRef.lock()->EnhancementLevel()+1].craftingRequirement.GetItems()){
Pixel textCol=WHITE;
if(Inventory::GetItemCount(name)<amt)textCol=RED;
if(Inventory::GetItemCount(name)<amt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string labelText=std::format("{}",name);
float labelWidth=game->GetTextSizeProp(labelText).x;
window.DrawShadowStringDecal(drawPos,std::format("{:>3}",amt),textCol,BLACK);
window.DrawShadowStringDecal(drawPos,std::format("{:>3}",amt*qty),textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{26,0},labelText,textCol,BLACK,{std::min(1.f,(drawWidth-26-2)/labelWidth),1.f});
index++;
}
Pixel textCol=WHITE;
uint32_t goldAmt=itemRef.lock()->GetEnhancementInfo()[itemRef.lock()->EnhancementLevel()+1].craftingRequirement.GetCost();
if(game->GetPlayer()->GetMoney()<goldAmt)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string goldAmtText=std::format("{:>3}",goldAmt);
std::string labelText=std::format("{}","Item.Currency Name"_S);
float goldAmtWidth=game->GetTextSize(goldAmtText).x;
window.DrawShadowStringDecal(drawPos,goldAmtText,textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{goldAmtWidth+2,0},labelText,textCol,BLACK);
if(goldAmt>0){
if(game->GetPlayer()->GetMoney()<goldAmt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string goldAmtText=std::format("{:>3}",goldAmt*qty);
std::string labelText=std::format("{}","Item.Currency Name"_S);
float goldAmtWidth=game->GetTextSize(goldAmtText).x;
window.DrawShadowStringDecal(drawPos,goldAmtText,textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{goldAmtWidth+2,0},labelText,textCol,BLACK);
}
index++;
}
}