I_FillScreenResolutionsList: shrink list if it is too large
we check against MAXMODEDESCS, which is the maximum of modes the videomode can list just in case we really get a display with a fuckton of resolutions, which most likely wont ever be the case though this just removes the smallest modes from the list (accounting for the canonicals), to keep things simple
This commit is contained in:
1 parent
d074f375ca
commit
b5bb2b42bf
3 files changed
+39
-7
No files matched your search
@@ -9409,9 +9409,6 @@ static void M_ResetControls(INT32 choice)
|
||||
// ===============
|
||||
|
||||
//added : 30-01-98:
|
||||
#define MAXCOLUMNMODES 12 //max modes displayed in one column
|
||||
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
|
||||
|
||||
static modedesc_t modedescs[MAXMODEDESCS];
|
||||
|
||||
void M_VideoModeMenu(INT32 choice)
|
||||
|
||||
@@ -221,6 +221,9 @@ extern menu_t *currentMenu;
|
||||
|
||||
extern menu_t MainDef;
|
||||
extern menu_t SP_LoadDef;
|
||||
|
||||
#define MAXCOLUMNMODES 12 //max modes displayed in one column
|
||||
#define MAXMODEDESCS (MAXCOLUMNMODES*3)
|
||||
extern menu_t OP_VideoModeDef;
|
||||
void M_VideoModeMenu(INT32 choice);
|
||||
|
||||
|
||||
+36
-4
@@ -1557,6 +1557,18 @@ static void I_AppendResolution(SDL_DisplayMode *mode, int *list_size)
|
||||
(*list_size)++;
|
||||
}
|
||||
|
||||
// small helper to check if a video mode is canonical
|
||||
static boolean IsModeCanonical(int w, int h)
|
||||
{
|
||||
for (int i = 0; i < num_canonicals; i++)
|
||||
{
|
||||
if (canonicals[i].w == w && canonicals[i].h == h)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// I_FillScreenResolutionsList
|
||||
// Get all the supported screen resolutions
|
||||
@@ -1603,10 +1615,6 @@ static void I_FillScreenResolutionsList(boolean force)
|
||||
// make sure the canonical resolutions are always available
|
||||
if (i > count - 1)
|
||||
{
|
||||
// no hard-coded resolutions for mode-changing fullscreen
|
||||
//if (exclusive_fullscreen)
|
||||
//continue;
|
||||
|
||||
mode.w = canonicals[i - count].w;
|
||||
mode.h = canonicals[i - count].h;
|
||||
}
|
||||
@@ -1662,6 +1670,30 @@ static void I_FillScreenResolutionsList(boolean force)
|
||||
// [FG] sort the list
|
||||
SDL_qsort(windowedModes, list_size, sizeof(*windowedModes), cmp_resolutions);
|
||||
|
||||
// if we have more video modes than we can list
|
||||
// try to shrink the list, lowest resolutions first
|
||||
// whilst keeping the canonicals
|
||||
if (list_size > MAXMODEDESCS)
|
||||
{
|
||||
// list is sorted from largest to smallest, so start at the end
|
||||
for (i = list_size - 1; i >= 0 && list_size > MAXMODEDESCS; i--)
|
||||
{
|
||||
if (IsModeCanonical(windowedModes[i].w, windowedModes[i].h))
|
||||
continue;
|
||||
|
||||
// Should we like, instead prioritize checking for non aspect correct resolutions to remove?
|
||||
|
||||
// we gotta shift everything
|
||||
// due to canonicals we cant just shrink the list
|
||||
for (int k = i; k < list_size - 1; k++)
|
||||
{
|
||||
windowedModes[k] = windowedModes[k + 1];
|
||||
}
|
||||
|
||||
list_size--;
|
||||
}
|
||||
}
|
||||
|
||||
windowedModes[list_size].name[0] = '\0';
|
||||
vid_nummodes = list_size;
|
||||
|
||||
|
||||
Reference in new issue
Block a user