@ -261,9 +261,9 @@ enum {
* @ param * dest string that is checked and possibly truncated
* @ param * dest string that is checked and possibly truncated
* @ param maxw maximum width in pixels of the string
* @ param maxw maximum width in pixels of the string
* @ return new width of ( truncated ) string */
* @ return new width of ( truncated ) string */
static uint TruncateString ( char * str , u int maxw )
static int TruncateString ( char * str , int maxw )
{
{
u int w = 0 ;
int w = 0 ;
int base = _stringwidth_base ;
int base = _stringwidth_base ;
int ddd , ddd_w ;
int ddd , ddd_w ;
@ -273,7 +273,7 @@ static uint TruncateString(char *str, uint maxw)
base = _stringwidth_base ;
base = _stringwidth_base ;
ddd_w = ddd = GetCharacterWidth ( base + ' . ' ) * 3 ;
ddd_w = ddd = GetCharacterWidth ( base + ' . ' ) * 3 ;
for ( c = * str , ddd_pos = str ; * str ! = ' \0 ' ; c = ( * + + str ) ) {
for ( ddd_pos = str ; ( c = * str + + ) ! = ' \0 ' ; ) {
if ( c > = ASCII_LETTERSTART ) {
if ( c > = ASCII_LETTERSTART ) {
w + = GetCharacterWidth ( base + c ) ;
w + = GetCharacterWidth ( base + c ) ;
@ -298,14 +298,14 @@ static uint TruncateString(char *str, uint maxw)
// Remember the last position where three dots fit.
// Remember the last position where three dots fit.
if ( w + ddd < maxw ) {
if ( w + ddd < maxw ) {
ddd_w = w + ddd ;
ddd_w = w + ddd ;
ddd_pos = str + 1 ;
ddd_pos = str ;
}
}
}
}
return w ;
return w ;
}
}
static inline u int TruncateStringID ( StringID src , char * dest , u int maxw )
static inline int TruncateStringID ( StringID src , char * dest , int maxw )
{
{
GetString ( dest , src ) ;
GetString ( dest , src ) ;
return TruncateString ( dest , maxw ) ;
return TruncateString ( dest , maxw ) ;
@ -358,11 +358,11 @@ int DrawStringCentered(int x, int y, StringID str, uint16 color)
return w ;
return w ;
}
}
int DrawStringCenteredTruncated ( int x , int y , StringID str , uint16 color , uint maxw )
int DrawStringCenteredTruncated ( int x l, int xr , int y , StringID str , uint16 color )
{
{
char buffer [ 512 ] ;
char buffer [ 512 ] ;
u int w = TruncateStringID ( str , buffer , maxw ) ;
int w = TruncateStringID ( str , buffer , xr - xl ) ;
return DoDrawString ( buffer , x - ( w / 2 ) , y , color ) ;
return DoDrawString ( buffer , ( xl + xr - w ) / 2 , y , color ) ;
}
}
void DrawStringCenterUnderline ( int x , int y , StringID str , uint16 color )
void DrawStringCenterUnderline ( int x , int y , StringID str , uint16 color )
@ -371,10 +371,10 @@ void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
GfxFillRect ( x - ( w > > 1 ) , y + 10 , x - ( w > > 1 ) + w , y + 10 , _string_colorremap [ 1 ] ) ;
GfxFillRect ( x - ( w > > 1 ) , y + 10 , x - ( w > > 1 ) + w , y + 10 , _string_colorremap [ 1 ] ) ;
}
}
void DrawStringCenterUnderlineTruncated ( int x , int y , StringID str , uint16 color , uint maxw )
void DrawStringCenterUnderlineTruncated ( int x l, int xr , int y , StringID str , uint16 color )
{
{
int w = DrawStringCenteredTruncated ( x , y , str , color , maxw ) ;
int w = DrawStringCenteredTruncated ( x l, xr , y , str , color ) ;
GfxFillRect ( x - ( w > > 1 ) , y + 10 , x - ( w > > 1 ) + w , y + 10 , _string_colorremap [ 1 ] ) ;
GfxFillRect ( ( xl + xr - w ) / 2 , y + 10 , ( xl + xr + w ) / 2 , y + 10 , _string_colorremap [ 1 ] ) ;
}
}
static uint32 FormatStringLinebreaks ( char * str , int maxw )
static uint32 FormatStringLinebreaks ( char * str , int maxw )