Add main menu window interface outlines. Fixed menu labels not being centered properly.

This commit is contained in:
2023-10-20 22:49:12 -05:00
parent e9952ca1be
commit b702fa2fe5
14 changed files with 92 additions and 62 deletions
+7 -6
View File
@@ -9,9 +9,10 @@ INCLUDE_game
class MenuLabel:public MenuComponent{
bool shadow=false;
bool centered=true;
int scale=1;
public:
inline MenuLabel(MenuType parent,geom2d::rect<float>rect,std::string label,bool centered=true,bool shadow=false)
:MenuComponent(parent,rect,label,MenuFunc{},false),centered(centered),shadow(shadow){
inline MenuLabel(MenuType parent,geom2d::rect<float>rect,std::string label,int scale=1,bool centered=true,bool shadow=false)
:MenuComponent(parent,rect,label,MenuFunc{},false),scale(scale),centered(centered),shadow(shadow){
border=false;
}
inline void SetLabel(std::string text){
@@ -22,15 +23,15 @@ protected:
MenuComponent::Update(game);
}
virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{
std::string wrappedText=util::WrapText(game,label,rect.size.x,true,{1,1});
vf2d drawPos=parentPos+rect.middle()-game->GetTextSizeProp(wrappedText)/2; //Assume centered.
std::string wrappedText=util::WrapText(game,label,rect.size.x,true,{float(scale),float(scale)});
vf2d drawPos=-parentPos+rect.middle()-game->GetTextSizeProp(wrappedText)*float(scale)/2; //Assume centered.
if(!centered){
drawPos=rect.pos+parentPos;
}
if(shadow){
game->DrawShadowStringProp(drawPos,wrappedText,focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F);
game->DrawShadowStringProp(drawPos,wrappedText,focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F,BLACK,{float(scale),float(scale)});
}else{
game->DrawStringProp(drawPos,wrappedText,focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F);
game->DrawStringProp(drawPos,wrappedText,focused?WHITE:WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F,scale);
}
}
};