Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 4f4baca

Browse files
committed
Changes to FrameMan::IsValidResolution to remove ancient small or higher than physical screen resolutions for a cleaner resolution list in settings
Some cleanup and new resolution notations in MainMenuGUI::UpdateResolutionCombo
1 parent 0d7aa55 commit 4f4baca

File tree

2 files changed

+48
-86
lines changed

2 files changed

+48
-86
lines changed

Managers/FrameMan.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,15 @@ namespace RTE {
387387
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
388388

389389
bool FrameMan::IsValidResolution(int width, int height) const {
390-
int actualWidth = width;
391-
int actualHeight = height;
392-
393-
// If width is greater than 1280, the game will switch itself in 2X mode lowering actual resolution twice.
394-
if (width >= 1280) {
395-
actualWidth = width / 2;
396-
actualHeight = height / 2;
390+
if ((width >= 800 && height >= 600) && (width <= m_ScreenResX || height <= m_ScreenResY)) {
391+
// Disallow 1366x768 because it's not supported by Allegro.
392+
if (width == 1366 && height == 768) {
393+
return false;
394+
}
395+
return true;
396+
} else {
397+
return false;
397398
}
398-
return (actualWidth < 360 || actualHeight < 360) ? false : true;
399399
}
400400

401401
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Menus/MainMenuGUI.cpp

Lines changed: 40 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,119 +2030,81 @@ void MainMenuGUI::UpdateTeamBoxes()
20302030
//////////////////////////////////////////////////////////////////////////////////////////
20312031
// Description: Updates the contents of the screen resolution combo box
20322032

2033-
void MainMenuGUI::UpdateResolutionCombo()
2034-
{
2033+
void MainMenuGUI::UpdateResolutionCombo() {
20352034
// Refill possible resolutions
20362035
m_pResolutionCombo->SetText("");
20372036
m_pResolutionCombo->ClearList();
20382037

2039-
// Only refill possible resolutions if empty
2040-
if (m_pResolutionCombo->GetCount() <= 0)
2041-
{
2042-
GFX_MODE_LIST *pList = get_gfx_mode_list(GFX_DIRECTX_ACCEL);
2038+
if (m_pResolutionCombo->GetCount() <= 0) {
2039+
// Get a list of modes from the fullscreen driver even though we're not using it. This is so we don't need to populate the list manually and has all the reasonable resolutions.
2040+
GFX_MODE_LIST *resList = get_gfx_mode_list(GFX_DIRECTX_ACCEL);
20432041

20442042
int width = 0;
20452043
int height = 0;
2046-
char resString[256] = "";
2044+
char resString[256] = "";
20472045
// Index of found useful resolution (32bit)
20482046
int foundIndex = 0;
2049-
// The saved index of the entry that has the current resolution setting
20502047
int currentResIndex = -1;
20512048

20522049
// Process and annotate the list
2053-
for (int i = 0; pList && i < pList->num_modes; ++i)
2054-
{
2050+
for (int i = 0; resList && i < resList->num_modes; ++i) {
20552051
// Only list 32 bpp modes
2056-
if (pList->mode[i].bpp == 32)
2057-
{
2058-
width = pList->mode[i].width;
2059-
height = pList->mode[i].height;
2052+
if (resList->mode[i].bpp == 32) {
2053+
width = resList->mode[i].width;
2054+
height = resList->mode[i].height;
20602055

20612056
// Resolutions must be multiples of 4 or we'll get 'Overlays not supported' during GFX mode init
2062-
if (g_FrameMan.IsValidResolution(width, height) && width % 4 == 0)
2063-
{
2057+
if (g_FrameMan.IsValidResolution(width, height) && width % 4 == 0) {
20642058
// Fix wacky resolutions that are taller than wide
2065-
if (height > width)
2066-
{
2067-
height = pList->mode[i].width;
2068-
width = pList->mode[i].height;
2059+
if (height > width) {
2060+
height = resList->mode[i].width;
2061+
width = resList->mode[i].height;
20692062
}
2070-
2071-
// Try to figure the max available resotion
2072-
if (width > m_MaxResX)
2073-
{
2063+
// Try to figure the max available resolution
2064+
if (width > m_MaxResX) {
20742065
m_MaxResX = width;
20752066
m_MaxResY = height;
20762067
}
2077-
2078-
// Construct and add the resolution string to the combobox
20792068
sprintf_s(resString, sizeof(resString), "%ix%i", width, height);
20802069

20812070
// Add useful notation to the standardized resolutions
2082-
if (width == 320 && height == 200)
2083-
strcat(resString, " CGA");
2084-
if (width == 320 && height == 240)
2085-
strcat(resString, " QVGA");
2086-
if (width == 640 && height == 480)
2087-
strcat(resString, " VGA");
2088-
if (width == 720 && height == 480)
2089-
strcat(resString, " NTSC");
2090-
if (width == 768 && height == 576)
2091-
strcat(resString, " PAL");
2092-
if ((width == 800 || height == 854) && height == 480)
2093-
strcat(resString, " WVGA");
2094-
if (width == 800 && height == 600)
2095-
strcat(resString, " SVGA");
2096-
if (width == 1024 && height == 600)
2097-
strcat(resString, " WSVGA");
2098-
if (width == 1024 && height == 768)
2099-
strcat(resString, " XGA");
2100-
if (width == 1280 && height == 720)
2101-
strcat(resString, " HD720");
2102-
if (width == 1280 && (height == 768 || height == 800))
2103-
strcat(resString, " WXGA");
2104-
// These below are forced to be done in 2X pixels fullscreen
2105-
if (width == 1280 && height == 1024)
2106-
strcat(resString, " SXGA");
2107-
if (width == 1400 && height == 1050)
2108-
strcat(resString, " SXGA+");
2109-
if (width == 1600 && height == 1200)
2110-
strcat(resString, " UGA");
2111-
if (width == 1680 && height == 1050)
2112-
strcat(resString, " WSXGA+");
2113-
if (width == 1920 && height == 1080)
2114-
strcat(resString, " HD1080");
2115-
if (width == 1920 && height == 1200)
2116-
strcat(resString, " WUXGA");
2117-
if (width == 2048 && height == 1080)
2118-
strcat(resString, " 2K");
2071+
if (width == 800 && height == 600) { strcat_s(resString, sizeof(resString), " SVGA"); }
2072+
if (width == 1024 && height == 600) { strcat_s(resString, sizeof(resString), " WSVGA"); }
2073+
if (width == 1024 && height == 768) { strcat_s(resString, sizeof(resString), " XGA"); }
2074+
if (width == 1280 && height == 720) { strcat_s(resString, sizeof(resString), " HD"); }
2075+
if (width == 1280 && (height == 768 || height == 800)) { strcat_s(resString, sizeof(resString), " WXGA"); }
2076+
if (width == 1280 && height == 1024) { strcat_s(resString, sizeof(resString), " SXGA"); }
2077+
if (width == 1400 && height == 1050) { strcat_s(resString, sizeof(resString), " SXGA+"); }
2078+
if (width == 1600 && height == 900) { strcat_s(resString, sizeof(resString), " HD+"); }
2079+
if (width == 1600 && height == 1200) { strcat_s(resString, sizeof(resString), " UGA"); }
2080+
if (width == 1680 && height == 1050) { strcat_s(resString, sizeof(resString), " WSXGA+"); }
2081+
if (width == 1920 && height == 1080) { strcat_s(resString, sizeof(resString), " FHD"); }
2082+
if (width == 1920 && height == 1200) { strcat_s(resString, sizeof(resString), " WUXGA"); }
2083+
if (width == 2048 && height == 1080) { strcat_s(resString, sizeof(resString), " DCI 2K"); }
2084+
if (width == 2560 && height == 1440) { strcat_s(resString, sizeof(resString), " QHD"); }
2085+
if (width == 3200 && height == 1800) { strcat_s(resString, sizeof(resString), " QHD+"); }
2086+
if (width == 3840 && height == 2160) { strcat_s(resString, sizeof(resString), " 4K UHD"); }
2087+
if (width == 4096 && height == 2160) { strcat_s(resString, sizeof(resString), " DCI 4K"); }
21192088

21202089
m_pResolutionCombo->AddItem(resString);
21212090

21222091
// If this is what we're currently set to have at next start, select it afterward
2123-
if ((g_FrameMan.GetNewResX() * g_FrameMan.GetNewNxFullscreen()) == width && (g_FrameMan.GetNewResY() * g_FrameMan.GetNewNxFullscreen()) == height)
2092+
if ((g_FrameMan.GetNewResX() * g_FrameMan.ResolutionMultiplier()) == width && (g_FrameMan.GetNewResY() * g_FrameMan.ResolutionMultiplier()) == height) {
21242093
currentResIndex = foundIndex;
2125-
2094+
}
21262095
// Only increment this when we find a usable 32bit resolution
21272096
foundIndex++;
21282097
}
21292098
}
21302099
}
2131-
2132-
// Get rid of the mode list, we're done with it
2133-
if (pList)
2134-
{
2135-
destroy_gfx_mode_list(pList);
2136-
}
2100+
if (resList) { destroy_gfx_mode_list(resList); }
21372101

21382102
// If none of the listed matched our resolution set for next start, add a 'custom' one to display as the current res
2139-
if (currentResIndex < 0)
2140-
{
2141-
sprintf_s(resString, sizeof(resString), "%ix%i Custom", g_FrameMan.GetNewResX() * g_FrameMan.GetNewNxFullscreen(), g_FrameMan.GetNewResY() * g_FrameMan.GetNewNxFullscreen());
2142-
m_pResolutionCombo->AddItem(resString);
2143-
currentResIndex = m_pResolutionCombo->GetCount() - 1;
2144-
}
2145-
2103+
if (currentResIndex < 0) {
2104+
sprintf_s(resString, sizeof(resString), "%ix%i Custom", g_FrameMan.GetNewResX() * g_FrameMan.ResolutionMultiplier(), g_FrameMan.GetNewResY() * g_FrameMan.ResolutionMultiplier());
2105+
m_pResolutionCombo->AddItem(resString);
2106+
currentResIndex = m_pResolutionCombo->GetCount() - 1;
2107+
}
21462108
// Show the current resolution item to be the selected one
21472109
m_pResolutionCombo->SetSelectedIndex(currentResIndex);
21482110
}

0 commit comments

Comments
 (0)