Skip to content

Commit

Permalink
support font scaling in server info page
Browse files Browse the repository at this point in the history
Shrink font if needed to allow large info values to fit on the screen.
  • Loading branch information
Chomenor committed Nov 14, 2022
1 parent f7c5d3f commit f98755c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions code/common/aspect_correct.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,23 @@ qboolean AspectCorrect_UseCorrectedGunPosition( void ) {
}
#endif

#ifdef MODULE_UI
/*
================
AspectCorrect_WidthScale
Returns the ratio of stretched graphics width to centered width.
================
*/
float AspectCorrect_WidthScale( void ) {
if ( ASPECT_CORRECT_ENABLED ) {
return uix.XStretchFactor / uix.XScaledFactor;
} else {
return 1.0f;
}
}
#endif

/*
================
AspectCorrect_RunFrame
Expand Down
1 change: 1 addition & 0 deletions code/common/aspect_correct.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void AspectCorrect_ResetMode( void );
void AspectCorrect_AdjustFrom640( float *x, float *y, float *w, float *h );
void AspectCorrect_DrawAdjustedStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
qboolean AspectCorrect_UseCorrectedGunPosition( void );
float AspectCorrect_WidthScale( void );
void AspectCorrect_RunFrame( void );
void AspectCorrect_Shutdown( void );
void AspectCorrect_Init( int width, int height );
4 changes: 3 additions & 1 deletion code/ui/ui_servers2.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ void BrowserServerInfo_RenderInfoField( int *currentLine, const char *key, const
char buffer[128];
Com_sprintf( buffer, sizeof( buffer ), "%s:", key );
UI_DrawProportionalString( 375 - 8, yPos, buffer, UI_RIGHT | UI_SMALLFONT | UI_NO_BLACK, colorTable[CT_LTBLUE2] );
UI_DrawProportionalString( 375 + 8, yPos, value, UI_LEFT | UI_SMALLFONT | UI_NO_BLACK, colorTable[CT_LTGOLD1] );
// let string use the entire right side of the screen before shrinking
UI_DrawAutoProportionalString( 375 + 8, yPos, value, UI_LEFT | UI_NO_BLACK, colorTable[CT_LTGOLD1],
320 * AspectCorrect_WidthScale() - ( 375 + 8 - 320 ), 4 );
}
}

Expand Down

0 comments on commit f98755c

Please sign in to comment.