Add current (custom) resolution to Q3 UI video mode list

Custom resolution is displayed when entering system options menu and
settings can be changed without being forced to change video resolution.
This commit is contained in:
Zack Middleton 2019-04-15 22:04:20 -05:00
parent 9b4dcc809e
commit c61417b8e2

View file

@ -358,6 +358,7 @@ static int resToRatio[ MAX_RESOLUTIONS ];
static char resbuf[ MAX_STRING_CHARS ];
static const char* detectedResolutions[ MAX_RESOLUTIONS ];
static char currentResolution[ 20 ];
static const char** resolutions = builtinResolutions;
static qboolean resolutionsDetected = qfalse;
@ -487,7 +488,7 @@ GraphicsOptions_GetResolutions
*/
static void GraphicsOptions_GetResolutions( void )
{
Q_strncpyz(resbuf, UI_Cvar_VariableString("r_availableModes"), sizeof(resbuf));
trap_Cvar_VariableStringBuffer("r_availableModes", resbuf, sizeof(resbuf));
if(*resbuf)
{
char* s = resbuf;
@ -501,13 +502,28 @@ static void GraphicsOptions_GetResolutions( void )
}
detectedResolutions[ i ] = NULL;
if( i > 0 )
// add custom resolution if not in mode list
if ( i < ARRAY_LEN(detectedResolutions)-1 )
{
Com_sprintf( currentResolution, sizeof ( currentResolution ), "%dx%d", uis.glconfig.vidWidth, uis.glconfig.vidHeight );
for( i = 0; detectedResolutions[ i ]; i++ )
{
if ( strcmp( detectedResolutions[ i ], currentResolution ) == 0 )
break;
}
if ( detectedResolutions[ i ] == NULL )
{
detectedResolutions[ i++ ] = currentResolution;
detectedResolutions[ i ] = NULL;
}
}
resolutions = detectedResolutions;
resolutionsDetected = qtrue;
}
}
}
/*
=================