From e656dc95b201dbd34f7e612e75d4eb3e8c7fe1d8 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 16 Dec 2023 23:07:54 -0600 Subject: [PATCH] Add an update icon call to SetItem for MenuItemItemComponent --- Crawler/InventoryScrollableWindowComponent.h | 4 +++- Crawler/Menu.cpp | 3 --- Crawler/MenuItemItemButton.h | 24 ++++++++++++++------ Crawler/Version.h | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Crawler/InventoryScrollableWindowComponent.h b/Crawler/InventoryScrollableWindowComponent.h index 9938afeb..6aeb45a1 100644 --- a/Crawler/InventoryScrollableWindowComponent.h +++ b/Crawler/InventoryScrollableWindowComponent.h @@ -95,7 +95,9 @@ public: MenuItemButton*itemButton=dynamic_cast(component); if(itemButton){ itemButton->SetCompactDescriptions(compact); - } + }else{ + ERR("WARNING! Attempting to cast a button that isn't a MenuItemButton!"); + } } } protected: diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index fb44a312..40768bc6 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -202,14 +202,11 @@ void Menu::Update(Crawler*game){ itemHovered=true; selection.y=key; selection.x=index; - goto selected; } } index++; } } - selected: - int a; } if(itemHovered&&draggingComponent==nullptr&&selection!=vi2d{-1,-1}&&(((!UsingMouseNavigation()&&(game->GetKey(ENTER).bHeld)||game->GetKey(SPACE).bHeld))||game->GetMouse(Mouse::LEFT).bHeld)){ diff --git a/Crawler/MenuItemItemButton.h b/Crawler/MenuItemItemButton.h index f21f9496..8e39e48d 100644 --- a/Crawler/MenuItemItemButton.h +++ b/Crawler/MenuItemItemButton.h @@ -73,6 +73,7 @@ public: return itemRef.get(); } inline Item&SetItem(Item&newItem){ + UpdateIcon(); return itemRef=std::reference_wrapper(newItem); } inline void SetShowQuantity(bool show){ @@ -94,19 +95,20 @@ protected: virtual inline void OnHover()override{ UpdateLabel(); } - void UpdateLabel(){ - if(itemRef.get().IsBlank())return; + inline void UpdateLabel(){ std::string labelNameText; std::string labelDescriptionText; - if(valid){ - icon=itemRef.get().Decal(); - labelNameText=itemRef.get().Name(); - labelDescriptionText=itemRef.get().Description(compact); - }else{ + + if(itemRef.get().IsBlank()){ icon=nullptr; labelNameText=""; labelDescriptionText=""; + return; } + + icon=itemRef.get().Decal(); + labelNameText=itemRef.get().Name(); + labelDescriptionText=itemRef.get().Description(compact); if(itemNameLabelName!=""){ Component(parentMenu,itemNameLabelName)->label=labelNameText; Component(parentMenu,itemNameLabelName)->Enable(true); @@ -135,4 +137,12 @@ protected: window.DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,quantityTextScale,quantityTextScale.x); } } +private: + inline void UpdateIcon(){ + if(itemRef.get().IsBlank()){ + icon=nullptr; + return; + } + icon=itemRef.get().Decal(); + } }; \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index 1efd0bc3..dcfd30fa 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 4019 +#define VERSION_BUILD 4023 #define stringify(a) stringify_(a) #define stringify_(a) #a