From e4c777f60a53d4a760c05f80832776d0b4c11837 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 12 Dec 2023 05:41:44 -0600 Subject: [PATCH] Fixed item quantities being gone from decal versions of MenuItemItemButton components. --- Crawler/InventoryWindow.cpp | 1 - Crawler/MenuItemButton.h | 25 ++++++++++++++----------- Crawler/MenuItemItemButton.h | 2 +- Crawler/Version.h | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Crawler/InventoryWindow.cpp b/Crawler/InventoryWindow.cpp index e13dec84..d9ad0e8b 100644 --- a/Crawler/InventoryWindow.cpp +++ b/Crawler/InventoryWindow.cpp @@ -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 ->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; - itemIcon->SetShowQuantity(false); itemIcon->decal=true; inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END ->decal=true; diff --git a/Crawler/MenuItemButton.h b/Crawler/MenuItemButton.h index bfdb4ddf..5cbdcd16 100644 --- a/Crawler/MenuItemButton.h +++ b/Crawler/MenuItemButton.h @@ -144,17 +144,20 @@ protected: virtual inline void DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{ if(decal){ MenuIconButton::DrawDecal(game,parentPos,focused); - if(valid){ - 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... - 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. - } - 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); - } + if(selected!=-1){ + drawutil::DrawCrosshairDecal(game,{parentPos+rect.pos,rect.size},0); + } + } + if(valid){ + 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... + 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. + } + 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); } } } diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index 71187dea..fe9442f2 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -147,7 +147,7 @@ protected: if(valid&&!hideQty){ std::string quantityText="x"+std::to_string(itemRef.get().Amt()); 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)){ game->DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,{0.5,0.5},0.5); } diff --git a/Crawler/Version.h b/Crawler/Version.h index beb8b5f0..1d63bbcf 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 3803 +#define VERSION_BUILD 3809 #define stringify(a) stringify_(a) #define stringify_(a) #a