Add an update icon call to SetItem for MenuItemItemComponent
This commit is contained in:
@@ -95,7 +95,9 @@ public:
|
|||||||
MenuItemButton*itemButton=dynamic_cast<MenuItemButton*>(component);
|
MenuItemButton*itemButton=dynamic_cast<MenuItemButton*>(component);
|
||||||
if(itemButton){
|
if(itemButton){
|
||||||
itemButton->SetCompactDescriptions(compact);
|
itemButton->SetCompactDescriptions(compact);
|
||||||
}
|
}else{
|
||||||
|
ERR("WARNING! Attempting to cast a button that isn't a MenuItemButton!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -202,14 +202,11 @@ void Menu::Update(Crawler*game){
|
|||||||
itemHovered=true;
|
itemHovered=true;
|
||||||
selection.y=key;
|
selection.y=key;
|
||||||
selection.x=index;
|
selection.x=index;
|
||||||
goto selected;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index++;
|
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)){
|
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();
|
return itemRef.get();
|
||||||
}
|
}
|
||||||
inline Item&SetItem(Item&newItem){
|
inline Item&SetItem(Item&newItem){
|
||||||
|
UpdateIcon();
|
||||||
return itemRef=std::reference_wrapper<Item>(newItem);
|
return itemRef=std::reference_wrapper<Item>(newItem);
|
||||||
}
|
}
|
||||||
inline void SetShowQuantity(bool show){
|
inline void SetShowQuantity(bool show){
|
||||||
@@ -94,19 +95,20 @@ protected:
|
|||||||
virtual inline void OnHover()override{
|
virtual inline void OnHover()override{
|
||||||
UpdateLabel();
|
UpdateLabel();
|
||||||
}
|
}
|
||||||
void UpdateLabel(){
|
inline void UpdateLabel(){
|
||||||
if(itemRef.get().IsBlank())return;
|
|
||||||
std::string labelNameText;
|
std::string labelNameText;
|
||||||
std::string labelDescriptionText;
|
std::string labelDescriptionText;
|
||||||
if(valid){
|
|
||||||
icon=itemRef.get().Decal();
|
if(itemRef.get().IsBlank()){
|
||||||
labelNameText=itemRef.get().Name();
|
|
||||||
labelDescriptionText=itemRef.get().Description(compact);
|
|
||||||
}else{
|
|
||||||
icon=nullptr;
|
icon=nullptr;
|
||||||
labelNameText="";
|
labelNameText="";
|
||||||
labelDescriptionText="";
|
labelDescriptionText="";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icon=itemRef.get().Decal();
|
||||||
|
labelNameText=itemRef.get().Name();
|
||||||
|
labelDescriptionText=itemRef.get().Description(compact);
|
||||||
if(itemNameLabelName!=""){
|
if(itemNameLabelName!=""){
|
||||||
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
|
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
|
||||||
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable(true);
|
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable(true);
|
||||||
@@ -135,4 +137,12 @@ protected:
|
|||||||
window.DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,quantityTextScale,quantityTextScale.x);
|
window.DrawShadowStringDecal(drawPos,quantityText,WHITE,BLACK,quantityTextScale,quantityTextScale.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
inline void UpdateIcon(){
|
||||||
|
if(itemRef.get().IsBlank()){
|
||||||
|
icon=nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
icon=itemRef.get().Decal();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
+1
-1
@@ -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 4019
|
#define VERSION_BUILD 4023
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
Reference in New Issue
Block a user