#pragma once #include "MenuAnimatedIconButton.h" #include "DEFINES.h" #include "Crawler.h" #include "Toggleable.h" INCLUDE_game class MenuAnimatedIconToggleButton:public MenuAnimatedIconButton,public IToggleable{ protected: MenuFunc _onClick; //What the user-defined behavior is. This toggle has its own custom-built onClick stuff to do. private: float animationTime=0; public: inline MenuAnimatedIconToggleButton(MenuType parent,geom2d::rectrect,std::string animation,MenuFunc onClick) :MenuAnimatedIconButton(parent,rect,animation,[](MenuFuncData data){ MenuAnimatedIconToggleButton*button=(MenuAnimatedIconToggleButton*)data.component; button->Select(); button->_onClick(data); return true; }),_onClick(onClick){} protected: virtual inline void Update(Crawler*game)override{ MenuAnimatedIconButton::Update(game); if(IsSelected()){ hoverEffect="ThemeGlobal.HighlightTime"_F; //A hack that allows us to make it look like we have this selected. } } virtual inline void Draw(Crawler*game,vf2d parentPos)override{ MenuAnimatedIconButton::Draw(game,parentPos); if(IsSelected()){ game->DrawRect(rect.pos+vi2d{2,2},rect.size-vi2d{4,4},YELLOW); } } };