Refactor menucomponent internal draw function a little bit for code organizing.
This commit is contained in:
parent
fe8cbb022a
commit
c82a3c5980
@ -276,13 +276,13 @@ void Menu::Draw(Crawler*game){
|
||||
game->Clear(BLANK);
|
||||
for(auto&component:displayComponents){
|
||||
if(component->renderInMain){
|
||||
component->_Draw(game,{0,0});
|
||||
component->_Draw(game);
|
||||
}
|
||||
}
|
||||
for(auto&key:buttons){
|
||||
for(auto&button:key.second){
|
||||
if(button->renderInMain){
|
||||
button->_Draw(game,{0,0});
|
||||
button->_Draw(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,13 +292,13 @@ void Menu::Draw(Crawler*game){
|
||||
game->DrawDecal(pos,r.Decal());
|
||||
for(auto&component:displayComponents){
|
||||
if(component->renderInMain){
|
||||
component->_DrawDecal(game,{0,0},this==Menu::stack.back());
|
||||
component->_DrawDecal(game,this==Menu::stack.back());
|
||||
}
|
||||
}
|
||||
for(auto&key:buttons){
|
||||
for(auto&button:key.second){
|
||||
if(button->renderInMain){
|
||||
button->_DrawDecal(game,{0,0},this==Menu::stack.back());
|
||||
button->_DrawDecal(game,this==Menu::stack.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,16 +45,20 @@ void MenuComponent::_Update(Crawler*game){
|
||||
|
||||
void MenuComponent::Draw(Crawler*game,vf2d parentPos){
|
||||
if(background){
|
||||
game->FillRect(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
|
||||
game->FillRect(rect.pos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F));
|
||||
}
|
||||
if(border){
|
||||
game->DrawRect(rect.pos+parentPos,rect.size);
|
||||
game->DrawRect(rect.pos,rect.size);
|
||||
}
|
||||
if(showDefaultLabel){
|
||||
game->DrawStringProp(rect.pos+parentPos+rect.size/2-game->GetTextSizeProp(label)/2,label);
|
||||
game->DrawStringProp(rect.pos+rect.size/2-game->GetTextSizeProp(label)/2,label);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuComponent::_Draw(Crawler*game){
|
||||
_Draw(game,{0,0});
|
||||
}
|
||||
|
||||
void MenuComponent::_Draw(Crawler*game,vf2d parentPos){
|
||||
if(!disabled){
|
||||
Draw(game,parentPos);
|
||||
@ -63,6 +67,10 @@ void MenuComponent::_Draw(Crawler*game,vf2d parentPos){
|
||||
|
||||
void MenuComponent::DrawDecal(Crawler*game,vf2d parentPos,bool focused){}
|
||||
|
||||
void MenuComponent::_DrawDecal(Crawler*game,bool focused){
|
||||
_DrawDecal(game,{0,0},focused);
|
||||
}
|
||||
|
||||
void MenuComponent::_DrawDecal(Crawler*game,vf2d parentPos,bool focused){
|
||||
if(!disabled){
|
||||
DrawDecal(game,parentPos,focused);
|
||||
|
||||
@ -40,7 +40,9 @@ public:
|
||||
MenuComponent(MenuType parent,geom2d::rect<float>rect,std::string label,MenuType menuDest,MenuFunc onClick,bool selectable=true,bool selectableViaKeyboard=true);
|
||||
virtual ~MenuComponent();
|
||||
void _Update(Crawler*game);
|
||||
void _Draw(Crawler*game);
|
||||
void _Draw(Crawler*game,vf2d parentPos);
|
||||
void _DrawDecal(Crawler*game,bool focused);
|
||||
void _DrawDecal(Crawler*game,vf2d parentPos,bool focused);
|
||||
vf2d GetPos();
|
||||
//We picked up a draggable component, we should make a copy and return it here. If a nullptr is returned here, the pickup is not allowed.
|
||||
|
||||
@ -38,7 +38,6 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){
|
||||
|
||||
for(ConnectionPoint&cp:connections){
|
||||
if(game->GetMouse(Mouse::LEFT).bPressed&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){
|
||||
Menu::OpenMenu(MenuType::INVENTORY);
|
||||
for(int neighborInd:currentConnectionPoint->neighbors){
|
||||
if(neighborInd==-1)continue;
|
||||
ConnectionPoint&neighbor=ConnectionPointFromIndex(neighborInd);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 2536
|
||||
#define VERSION_BUILD 2541
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user