|
|
|
@ -55,9 +55,19 @@ private: |
|
|
|
|
MenuType itemDescriptionMenu; |
|
|
|
|
std::string itemNameLabelName; |
|
|
|
|
std::string itemDescriptionLabelName; |
|
|
|
|
bool runHoverFunctions=false; |
|
|
|
|
MenuFunc onHover; |
|
|
|
|
MenuFunc onMouseOut; |
|
|
|
|
bool hoverState=false; |
|
|
|
|
public: |
|
|
|
|
inline MenuItemItemButton(MenuType parent,geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuType itemDescriptionMenu,std::string itemNameLabelName,std::string itemDescriptionLabelName) |
|
|
|
|
:MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName){ |
|
|
|
|
:MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(itemDescriptionMenu),itemNameLabelName(itemNameLabelName),itemDescriptionLabelName(itemDescriptionLabelName),onHover(DO_NOTHING){ |
|
|
|
|
draggable=false; |
|
|
|
|
valid=!itemRef.IsBlank(); |
|
|
|
|
} |
|
|
|
|
inline MenuItemItemButton(MenuType parent,geom2d::rect<float>rect,Item&itemRef,MenuType menuDest,MenuFunc onClick,MenuFunc onHover,MenuFunc onMouseOut) |
|
|
|
|
:MenuIconButton(parent,rect,(!itemRef.IsBlank())?itemRef.Decal():nullptr,menuDest,onClick),itemRef(itemRef),itemDescriptionMenu(MenuType::ENUM_END),itemNameLabelName(""),itemDescriptionLabelName(""),onHover(onHover),onMouseOut(onMouseOut){ |
|
|
|
|
runHoverFunctions=true; |
|
|
|
|
draggable=false; |
|
|
|
|
valid=!itemRef.IsBlank(); |
|
|
|
|
} |
|
|
|
@ -68,18 +78,31 @@ protected: |
|
|
|
|
virtual inline void Update(Crawler*game)override{ |
|
|
|
|
MenuIconButton::Update(game); |
|
|
|
|
valid=!itemRef.IsBlank(); |
|
|
|
|
std::string labelNameText; |
|
|
|
|
std::string labelDescriptionText; |
|
|
|
|
if(valid){ |
|
|
|
|
icon=itemRef.Decal(); |
|
|
|
|
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=itemRef.Name(); |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=itemRef.Description(); |
|
|
|
|
} |
|
|
|
|
labelNameText=itemRef.Name(); |
|
|
|
|
labelDescriptionText=itemRef.Description(); |
|
|
|
|
}else{ |
|
|
|
|
icon=nullptr; |
|
|
|
|
if(hovered&&itemDescriptionMenu!=MenuType::ENUM_END){ |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=""; |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=""; |
|
|
|
|
labelNameText=""; |
|
|
|
|
labelDescriptionText=""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(hovered){ |
|
|
|
|
if(itemDescriptionMenu!=MenuType::ENUM_END){ |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemNameLabelName)->label=labelNameText; |
|
|
|
|
Component<MenuLabel>(itemDescriptionMenu,itemDescriptionLabelName)->label=labelDescriptionText; |
|
|
|
|
} |
|
|
|
|
if(runHoverFunctions&&!hoverState){ |
|
|
|
|
hoverState=true; |
|
|
|
|
onHover(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)}); |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(runHoverFunctions&&hoverState){ |
|
|
|
|
hoverState=false; |
|
|
|
|
onMouseOut(MenuFuncData{*Menu::menus[parentMenu],game,this,(ScrollableWindowComponent*)(parentComponent)}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
virtual inline void Draw(Crawler*game,vf2d parentPos)override{ |
|
|
|
|