Fixed item quantities being gone from decal versions of MenuItemItemButton components.

pull/28/head
sigonasr2 12 months ago
parent 5abc789bcd
commit e4c777f60a
  1. 1
      Crawler/InventoryWindow.cpp
  2. 25
      Crawler/MenuItemButton.h
  3. 2
      Crawler/MenuItemItemButton.h
  4. 2
      Crawler/Version.h

@ -115,7 +115,6 @@ void Menu::InitializeInventoryWindow(){
inventoryWindow->ADD("Item Description Outline",MenuLabel)({{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END inventoryWindow->ADD("Item Description Outline",MenuLabel)({{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END
->decal=true; ->decal=true;
auto itemIcon=inventoryWindow->ADD("Item Icon",MenuItemItemButton)({{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END; auto itemIcon=inventoryWindow->ADD("Item Icon",MenuItemItemButton)({{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
itemIcon->SetShowQuantity(false);
itemIcon->decal=true; itemIcon->decal=true;
inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END
->decal=true; ->decal=true;

@ -144,17 +144,20 @@ protected:
virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{ virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
if(decal){ if(decal){
MenuIconButton::DrawDecal(game,parentPos,focused); MenuIconButton::DrawDecal(game,parentPos,focused);
if(valid){ if(selected!=-1){
int itemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex).Name()); //Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts... drawutil::DrawCrosshairDecal(game,{parentPos+rect.pos,rect.size},0);
if(&invRef==&Inventory::get("Monster Loot")||&invRef==&Inventory::get("Stage Loot")){ }
itemQuantity=invRef.at(inventoryIndex).Amt(); //So the item quantity comes from the stack itself and not our main inventory. }
} if(valid){
std::string quantityText="x"+std::to_string(itemQuantity); int itemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex).Name()); //Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts...
vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5; if(&invRef==&Inventory::get("Monster Loot")||&invRef==&Inventory::get("Stage Loot")){
vf2d drawPos=parentPos+rect.pos+rect.size-textSize; itemQuantity=invRef.at(inventoryIndex).Amt(); //So the item quantity comes from the stack itself and not our main inventory.
if(PointWithinParent(this,drawPos)){ }
game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5); std::string quantityText="x"+std::to_string(itemQuantity);
} vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5;
vf2d drawPos=parentPos+rect.pos+rect.size-textSize;
if(PointWithinParent(this,drawPos)){
game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5);
} }
} }
} }

@ -147,7 +147,7 @@ protected:
if(valid&&!hideQty){ if(valid&&!hideQty){
std::string quantityText="x"+std::to_string(itemRef.get().Amt()); std::string quantityText="x"+std::to_string(itemRef.get().Amt());
vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5; vf2d textSize=vf2d(game->GetTextSizeProp(quantityText))*0.5;
vf2d drawPos=parentPos+rect.pos+rect.size-textSize; vf2d drawPos=Menu::menus[parentMenu]->pos+parentPos+rect.pos+rect.size-textSize;
if(PointWithinParent(this,drawPos)){ if(PointWithinParent(this,drawPos)){
game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5); game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5);
} }

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 3803 #define VERSION_BUILD 3809
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save