|
|
@ -48,6 +48,7 @@ INCLUDE_game |
|
|
|
class MenuLabel:public MenuComponent{ |
|
|
|
class MenuLabel:public MenuComponent{ |
|
|
|
protected: |
|
|
|
protected: |
|
|
|
float scale=1; |
|
|
|
float scale=1; |
|
|
|
|
|
|
|
float shadowScale=1; |
|
|
|
bool shadow=false; |
|
|
|
bool shadow=false; |
|
|
|
bool centered=true; |
|
|
|
bool centered=true; |
|
|
|
bool multiLineCentered=false; |
|
|
|
bool multiLineCentered=false; |
|
|
@ -68,7 +69,7 @@ public: |
|
|
|
this->onLabelChangeFunc=onLabelChangeFunc; |
|
|
|
this->onLabelChangeFunc=onLabelChangeFunc; |
|
|
|
} |
|
|
|
} |
|
|
|
inline MenuLabel(geom2d::rect<float>rect,std::string label,float scale=1,ComponentAttr attributes=ComponentAttr::NONE) |
|
|
|
inline MenuLabel(geom2d::rect<float>rect,std::string label,float scale=1,ComponentAttr attributes=ComponentAttr::NONE) |
|
|
|
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),rightAlign(attributes&ComponentAttr::RIGHT_ALIGN),centered(!(attributes&ComponentAttr::LEFT_ALIGN)&&!(attributes&ComponentAttr::RIGHT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW),proportional(!(attributes&ComponentAttr::FIXED_WIDTH_FONT)),multiLineCentered(attributes&ComponentAttr::CENTER){ |
|
|
|
:MenuComponent(rect,label,MenuFunc{},ButtonAttr::UNSELECTABLE|ButtonAttr::UNSELECTABLE_VIA_KEYBOARD),scale(scale),shadowScale(scale),rightAlign(attributes&ComponentAttr::RIGHT_ALIGN),centered(!(attributes&ComponentAttr::LEFT_ALIGN)&&!(attributes&ComponentAttr::RIGHT_ALIGN)),shadow(attributes&ComponentAttr::SHADOW),proportional(!(attributes&ComponentAttr::FIXED_WIDTH_FONT)),multiLineCentered(attributes&ComponentAttr::CENTER){ |
|
|
|
border=attributes&ComponentAttr::OUTLINE; |
|
|
|
border=attributes&ComponentAttr::OUTLINE; |
|
|
|
this->background=attributes&ComponentAttr::BACKGROUND; |
|
|
|
this->background=attributes&ComponentAttr::BACKGROUND; |
|
|
|
showDefaultLabel=false; |
|
|
|
showDefaultLabel=false; |
|
|
@ -90,6 +91,7 @@ protected: |
|
|
|
censoredTextEntry=std::accumulate(GetLabel().begin(),GetLabel().end(),""s,[](std::string currentStr,const char&c){return std::move(currentStr)+'*';}); |
|
|
|
censoredTextEntry=std::accumulate(GetLabel().begin(),GetLabel().end(),""s,[](std::string currentStr,const char&c){return std::move(currentStr)+'*';}); |
|
|
|
std::string_view finalLabel=censored?censoredTextEntry:GetLabel(); |
|
|
|
std::string_view finalLabel=censored?censoredTextEntry:GetLabel(); |
|
|
|
vf2d adjustedScale={scale,scale}; |
|
|
|
vf2d adjustedScale={scale,scale}; |
|
|
|
|
|
|
|
vf2d adjustedShadowScale={shadowScale,shadowScale}; |
|
|
|
vf2d labelTextSize= |
|
|
|
vf2d labelTextSize= |
|
|
|
proportional? |
|
|
|
proportional? |
|
|
|
vf2d(game->GetWrappedTextSizeProp(finalLabel,rect.size.x-4,adjustedScale)): |
|
|
|
vf2d(game->GetWrappedTextSizeProp(finalLabel,rect.size.x-4,adjustedScale)): |
|
|
@ -103,6 +105,7 @@ protected: |
|
|
|
float sizeRatio=(labelTextSize.x)/(rect.size.x-4); |
|
|
|
float sizeRatio=(labelTextSize.x)/(rect.size.x-4); |
|
|
|
if(sizeRatio>1){ |
|
|
|
if(sizeRatio>1){ |
|
|
|
adjustedScale.x/=sizeRatio; |
|
|
|
adjustedScale.x/=sizeRatio; |
|
|
|
|
|
|
|
adjustedShadowScale.x/=sizeRatio; |
|
|
|
labelTextSize.x/=sizeRatio; |
|
|
|
labelTextSize.x/=sizeRatio; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -138,9 +141,9 @@ protected: |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
if(shadow){ |
|
|
|
if(shadow){ |
|
|
|
if(proportional){ |
|
|
|
if(proportional){ |
|
|
|
window.DrawShadowStringPropDecal(drawPos,finalLabel,WHITE,BLACK,adjustedScale,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-4); |
|
|
|
window.DrawShadowStringPropDecal(drawPos,finalLabel,WHITE,BLACK,adjustedScale,adjustedShadowScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-4); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
window.DrawShadowStringDecal(drawPos,finalLabel,WHITE,BLACK,adjustedScale,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-4); |
|
|
|
window.DrawShadowStringDecal(drawPos,finalLabel,WHITE,BLACK,adjustedScale,adjustedShadowScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x-4); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
if(proportional){ |
|
|
|
if(proportional){ |
|
|
|