Skip to content

Commit

Permalink
Add current (custom) resolution to Q3 UI video mode list
Browse files Browse the repository at this point in the history
Custom resolution is displayed when entering system options menu and
settings can be changed without being forced to change video resolution.
  • Loading branch information
zturtleman committed Apr 16, 2019
1 parent 9b4dcc8 commit c61417b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions code/q3_ui/ui_video.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -501,11 +502,26 @@ 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 )
{
resolutions = detectedResolutions;
resolutionsDetected = qtrue;
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;
}
}

Expand Down

0 comments on commit c61417b

Please sign in to comment.