The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
AdventuresInLestoria/Crawler/MenuAnimatedIconToggleButton.h

35 lines
1.3 KiB

#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::rect<float>rect,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);
}
}
};