@ -54,6 +54,7 @@ protected:
bool rightAlign = false ;
bool proportional = true ;
bool runOnLabelChangeFunc = false ;
bool censored = false ;
std : : function < void ( std : : string_view newLabel ) > onLabelChangeFunc ;
//Specific wrapping members.
@ -85,17 +86,20 @@ protected:
}
inline virtual void DrawDecal ( ViewPort & window , bool focused ) override {
MenuComponent : : DrawDecal ( window , focused ) ;
std : : string censoredTextEntry ;
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 ( ) ;
vf2d adjustedScale = { scale , scale } ;
vf2d labelTextSize =
proportional ?
vf2d ( game - > GetWrappedTextSizeProp ( GetLabel ( ) , rect . size . x - 2 , adjustedScale ) ) :
vf2d ( game - > GetWrappedTextSize ( GetLabel ( ) , rect . size . x - 2 , adjustedScale ) ) ;
vf2d ( game - > GetWrappedTextSizeProp ( finalLabel , rect . size . x - 2 , adjustedScale ) ) :
vf2d ( game - > GetWrappedTextSize ( finalLabel , rect . size . x - 2 , adjustedScale ) ) ;
if ( fitToLabel ) {
labelTextSize =
proportional ?
vf2d ( game - > GetTextSizeProp ( GetLabel ( ) ) * adjustedScale ) :
vf2d ( game - > GetTextSize ( GetLabel ( ) ) * adjustedScale ) ;
vf2d ( game - > GetTextSizeProp ( finalLabel ) * adjustedScale ) :
vf2d ( game - > GetTextSize ( finalLabel ) * adjustedScale ) ;
float sizeRatio = ( labelTextSize . x ) / ( rect . size . x - 2 ) ;
if ( sizeRatio > 1 ) {
adjustedScale . x / = sizeRatio ;
@ -134,15 +138,15 @@ protected:
} else {
if ( shadow ) {
if ( proportional ) {
window . DrawShadowStringPropDecal ( drawPos , GetLabel ( ) , WHITE , BLACK , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
window . DrawShadowStringPropDecal ( drawPos , finalLabel , WHITE , BLACK , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
} else {
window . DrawShadowStringDecal ( drawPos , GetLabel ( ) , WHITE , BLACK , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
window . DrawShadowStringDecal ( drawPos , finalLabel , WHITE , BLACK , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
}
} else {
if ( proportional ) {
window . DrawStringPropDecal ( drawPos , GetLabel ( ) , WHITE , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
window . DrawStringPropDecal ( drawPos , finalLabel , WHITE , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
} else {
window . DrawStringDecal ( drawPos , GetLabel ( ) , WHITE , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
window . DrawStringDecal ( drawPos , finalLabel , WHITE , adjustedScale , fitToLabel ? std : : numeric_limits < float > : : max ( ) : rect . size . x - 2 , 1.0f ) ;
}
}
}