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/Toggleable.h

42 lines
1.1 KiB

#pragma once
class IToggleable{
friend class Crawler;
public:
inline std::vector<IToggleable*>GetToggleGroup(){
return toggleGroup;
}
inline void Select(){
for(IToggleable*item:toggleGroup){
item->selected=false;
}
selected=true;
}
inline bool IsSelected(){
return selected;
}
inline void SetToggleGroup(){
if(toggleGroupInitialized){
std::cout<<"WARNING! Toggle group for this component was set twice for some reason! THIS SHOULD NOT BE HAPPENING!"<<std::endl;
throw;
}
toggleGroupInitialized=true;
std::erase_if(uninitializedToggleGroupItems,[&](IToggleable*item){return this==item;});
}
inline void SetToggleGroup(std::vector<IToggleable*>toggleGroup){
this->toggleGroup=toggleGroup;
SetToggleGroup();
}
inline IToggleable(){
uninitializedToggleGroupItems.push_back(this);
if("debug_toggleable_items"_I){
std::cout<<"\tInitialized Toggle Item Ptr: 0x"<<std::hex<<this<<std::endl;
}
}
protected:
std::vector<IToggleable*>toggleGroup;
private:
bool selected=false;
bool toggleGroupInitialized=false;
inline static std::vector<IToggleable*>uninitializedToggleGroupItems;
};