Add an update icon call to SetItem for MenuItemItemComponent

pull/28/head
sigonasr2 1 year ago
parent 46926be340
commit e656dc95b2
  1. 4
      Crawler/InventoryScrollableWindowComponent.h
  2. 3
      Crawler/Menu.cpp
  3. 24
      Crawler/MenuItemItemButton.h
  4. 2
      Crawler/Version.h

@ -95,7 +95,9 @@ public:
MenuItemButton*itemButton=dynamic_cast<MenuItemButton*>(component);
if(itemButton){
itemButton->SetCompactDescriptions(compact);
}
}else{
ERR("WARNING! Attempting to cast a button that isn't a MenuItemButton!");
}
}
}
protected:

@ -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)){

@ -73,6 +73,7 @@ public:
return itemRef.get();
}
inline Item&SetItem(Item&newItem){
UpdateIcon();
return itemRef=std::reference_wrapper<Item>(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<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
Component<MenuLabel>(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();
}
};

@ -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

Loading…
Cancel
Save