Skip to content

Commit e76db9a

Browse files
committed
refactor(client): Use constants for default display width and height values
1 parent 1eceff5 commit e76db9a

File tree

9 files changed

+29
-28
lines changed

9 files changed

+29
-28
lines changed

Core/GameEngine/Include/Common/GameDefines.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@
6767
#define USE_OBSOLETE_GENERALS_CODE (1)
6868
#endif
6969
#endif
70+
71+
#define MIN_DISPLAY_BIT_DEPTH 16
72+
#define DEFAULT_DISPLAY_BIT_DEPTH 32
73+
#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for
74+
#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for

GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ GlobalData::GlobalData()
619619
m_chipSetType = 0;
620620
m_headless = FALSE;
621621
m_windowed = 0;
622-
m_xResolution = 800;
623-
m_yResolution = 600;
622+
m_xResolution = DEFAULT_DISPLAY_WIDTH;
623+
m_yResolution = DEFAULT_DISPLAY_HEIGHT;
624624
m_maxShellScreens = 0;
625625
m_useCloudMap = FALSE;
626626
m_use3WayTerrainBlends = 1;

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarResizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ void ControlBarResizer::sizeWindowsAlt( void )
180180
{
181181
ResizerWindowList::iterator it = m_resizerWindowsList.begin();
182182
GameWindow *win = NULL;
183-
Real x = (Real)TheDisplay->getWidth() / 800;
184-
Real y = (Real)TheDisplay->getHeight() / 600;
183+
Real x = (Real)TheDisplay->getWidth() / DEFAULT_DISPLAY_WIDTH;
184+
Real y = (Real)TheDisplay->getHeight() / DEFAULT_DISPLAY_HEIGHT;
185185
while (it != m_resizerWindowsList.end())
186186
{
187187
ResizerWindow *rWin = *it;

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ static void setDefaults( void )
880880
for( Int i = 0; i < numResolutions; ++i )
881881
{ Int xres,yres,bitDepth;
882882
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
883-
if (xres == 800 && yres == 600) //keep track of default mode in case we need it.
883+
if (xres == DEFAULT_DISPLAY_WIDTH && yres == DEFAULT_DISPLAY_HEIGHT) //keep track of default mode in case we need it.
884884
{ defaultResIndex=i;
885885
break;
886886
}
@@ -1715,12 +1715,15 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
17151715

17161716
// get resolution from saved preferences file
17171717
AsciiString selectedResolution = (*pref) ["Resolution"];
1718-
Int selectedXRes=800,selectedYRes=600;
1718+
Int selectedXRes=DEFAULT_DISPLAY_WIDTH;
1719+
Int selectedYRes=DEFAULT_DISPLAY_HEIGHT;
17191720
Int selectedResIndex=-1;
17201721
if (!selectedResolution.isEmpty())
17211722
{ //try to parse 2 integers out of string
17221723
if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)
1723-
{ selectedXRes=800; selectedYRes=600;
1724+
{
1725+
selectedXRes=DEFAULT_DISPLAY_WIDTH;
1726+
selectedYRes=DEFAULT_DISPLAY_HEIGHT;
17241727
}
17251728
}
17261729

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupPlayerInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ void ResetBattleHonorInsertion(void)
468468
}
469469
void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString, Int extra = 0)
470470
{
471-
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
472-
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);
471+
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH);
472+
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT);
473473

474474
static Int enabledColor = 0xFFFFFFFF;
475475
static Int disabledColor = GameMakeColor(80, 80, 80, 255);

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg,
829829
else if (controlID == buttonQuickMatchID)
830830
{
831831
GameSpyMiscPreferences mPref;
832-
if ((TheDisplay->getWidth() != 800 || TheDisplay->getHeight() != 600) && mPref.getQuickMatchResLocked())
832+
if ((TheDisplay->getWidth() != DEFAULT_DISPLAY_WIDTH || TheDisplay->getHeight() != DEFAULT_DISPLAY_HEIGHT) && mPref.getQuickMatchResLocked())
833833
{
834834
GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:QuickMatch800x600"));
835835
}

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,8 +4183,8 @@ void InGameUI::militarySubtitle( const AsciiString& label, Int duration )
41834183

41844184
// calculate where this screen position should be since the position being passed in is based off 8x6
41854185
Coord2D multiplier;
4186-
multiplier.x = (float)TheDisplay->getWidth() / 800.0f;
4187-
multiplier.y = (float)TheDisplay->getHeight() / 600.0f;
4186+
multiplier.x = (Real)TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH;
4187+
multiplier.y = (Real)TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT;
41884188

41894189
// lets bring out the data structure!
41904190
m_militarySubtitle = NEW MilitarySubtitleData;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ static void drawFramerateBar(void);
111111

112112

113113
// DEFINE AND ENUMS ///////////////////////////////////////////////////////////
114-
#define DEFAULT_DISPLAY_BIT_DEPTH 32
115-
#define MIN_DISPLAY_BIT_DEPTH 16
116-
#define MIN_DISPLAY_RESOLUTION_X 800
117-
#define MIN_DISPLAY_RESOLUTION_Y 600
118114

119115
#define no_SAMPLE_DYNAMIC_LIGHT 1
120116
#ifdef SAMPLE_DYNAMIC_LIGHT
@@ -481,7 +477,7 @@ inline Bool isResolutionSupported(const ResolutionDescClass &res)
481477
{
482478
static const Int minBitDepth = 24;
483479

484-
return res.Width >= MIN_DISPLAY_RESOLUTION_X && res.BitDepth >= minBitDepth;
480+
return res.Width >= DEFAULT_DISPLAY_WIDTH && res.BitDepth >= minBitDepth;
485481
}
486482

487483
/*Return number of screen modes supported by the current device*/
@@ -751,15 +747,15 @@ void W3DDisplay::init( void )
751747
// if the custom resolution did not succeed. This is unlikely to happen but is possible
752748
// if the user writes an unsupported resolution in the Option Preferences or if the
753749
// graphics adapter does not support the minimum display resolution to begin with.
754-
Int xres = MIN_DISPLAY_RESOLUTION_X;
755-
Int yres = MIN_DISPLAY_RESOLUTION_Y;
750+
Int xres = DEFAULT_DISPLAY_WIDTH;
751+
Int yres = DEFAULT_DISPLAY_HEIGHT;
756752
Int bitDepth = DEFAULT_DISPLAY_BIT_DEPTH;
757753
Int displayModeCount = getDisplayModeCount();
758754
Int displayModeIndex = 0;
759755
for (; displayModeIndex < displayModeCount; ++displayModeIndex)
760756
{
761757
getDisplayModeDescription(displayModeIndex, &xres, &yres, &bitDepth);
762-
if (xres * yres >= MIN_DISPLAY_RESOLUTION_X * MIN_DISPLAY_RESOLUTION_Y)
758+
if (xres * yres >= DEFAULT_DISPLAY_WIDTH * DEFAULT_DISPLAY_HEIGHT)
763759
break; // Is good enough. Use it.
764760
}
765761
TheWritableGlobalData->m_xResolution = xres;

GeneralsMD/Code/Main/WinMain.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ const Char *g_strFile = "data\\Generals.str";
7979
const Char *g_csfFile = "data\\%s\\Generals.csf";
8080
const char *gAppPrefix = ""; /// So WB can have a different debug log file name.
8181

82-
#define DEFAULT_XRESOLUTION 800
83-
#define DEFAULT_YRESOLUTION 600
84-
8582
static Bool gInitializing = false;
8683
static Bool gDoPaint = true;
8784
static Bool isWinMainActive = false;
@@ -601,7 +598,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
601598
Int savContext = ::SaveDC(dc);
602599
HDC tmpDC = ::CreateCompatibleDC(dc);
603600
HBITMAP savBitmap = (HBITMAP)::SelectObject(tmpDC, gLoadScreenBitmap);
604-
::BitBlt(dc, 0, 0, DEFAULT_XRESOLUTION, DEFAULT_YRESOLUTION, tmpDC, 0, 0, SRCCOPY);
601+
::BitBlt(dc, 0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT, tmpDC, 0, 0, SRCCOPY);
605602
::SelectObject(tmpDC, savBitmap);
606603
::DeleteDC(tmpDC);
607604
::RestoreDC(dc, savContext);
@@ -683,8 +680,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
683680
static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWindowed )
684681
{
685682
DWORD windowStyle;
686-
Int startWidth = DEFAULT_XRESOLUTION,
687-
startHeight = DEFAULT_YRESOLUTION;
683+
Int startWidth = DEFAULT_DISPLAY_WIDTH,
684+
startHeight = DEFAULT_DISPLAY_HEIGHT;
688685

689686
// register the window class
690687

@@ -710,8 +707,8 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin
710707
AdjustWindowRect (&rect, windowStyle, FALSE);
711708
if (runWindowed) {
712709
// Makes the normal debug 800x600 window center in the screen.
713-
startWidth = DEFAULT_XRESOLUTION;
714-
startHeight= DEFAULT_YRESOLUTION;
710+
startWidth = DEFAULT_DISPLAY_WIDTH;
711+
startHeight= DEFAULT_DISPLAY_HEIGHT;
715712
}
716713

717714
gInitializing = true;

0 commit comments

Comments
 (0)