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