Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Core/GameEngine/Include/Common/GameDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@
#define USE_OBSOLETE_GENERALS_CODE (1)
#endif
#endif

#define MIN_DISPLAY_BIT_DEPTH 16
#define DEFAULT_DISPLAY_BIT_DEPTH 32
#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for
#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to make these static const or CONSTEXPR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After VC6, yes. With VC6 this ideally is an enum value or macro.

4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,8 @@ GlobalData::GlobalData()
m_chipSetType = 0;
m_headless = FALSE;
m_windowed = 0;
m_xResolution = 800;
m_yResolution = 600;
m_xResolution = DEFAULT_DISPLAY_WIDTH;
m_yResolution = DEFAULT_DISPLAY_HEIGHT;
m_maxShellScreens = 0;
m_useCloudMap = FALSE;
m_use3WayTerrainBlends = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ void ControlBarResizer::sizeWindowsAlt( void )
{
ResizerWindowList::iterator it = m_resizerWindowsList.begin();
GameWindow *win = NULL;
Real x = (Real)TheDisplay->getWidth() / 800;
Real y = (Real)TheDisplay->getHeight() / 600;
Real x = (Real)TheDisplay->getWidth() / DEFAULT_DISPLAY_WIDTH;
Real y = (Real)TheDisplay->getHeight() / DEFAULT_DISPLAY_HEIGHT;
while (it != m_resizerWindowsList.end())
{
ResizerWindow *rWin = *it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static void setDefaults( void )
for( Int i = 0; i < numResolutions; ++i )
{ Int xres,yres,bitDepth;
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
if (xres == 800 && yres == 600) //keep track of default mode in case we need it.
if (xres == DEFAULT_DISPLAY_WIDTH && yres == DEFAULT_DISPLAY_HEIGHT) //keep track of default mode in case we need it.
{ defaultResIndex=i;
break;
}
Expand Down Expand Up @@ -1648,12 +1648,15 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )

// get resolution from saved preferences file
AsciiString selectedResolution = (*pref) ["Resolution"];
Int selectedXRes=800,selectedYRes=600;
Int selectedXRes=DEFAULT_DISPLAY_WIDTH;
Int selectedYRes=DEFAULT_DISPLAY_HEIGHT;
Int selectedResIndex=-1;
if (!selectedResolution.isEmpty())
{ //try to parse 2 integers out of string
if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)
{ selectedXRes=800; selectedYRes=600;
{
selectedXRes=DEFAULT_DISPLAY_WIDTH;
selectedYRes=DEFAULT_DISPLAY_HEIGHT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ void ResetBattleHonorInsertion(void)
}
void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString)
{
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH);
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT);

static Int enabledColor = 0xFFFFFFFF;
static Int disabledColor = GameMakeColor(80, 80, 80, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg,
else if (controlID == buttonQuickMatchID)
{
GameSpyMiscPreferences mPref;
if ((TheDisplay->getWidth() != 800 || TheDisplay->getHeight() != 600) && mPref.getQuickMatchResLocked())
if ((TheDisplay->getWidth() != DEFAULT_DISPLAY_WIDTH || TheDisplay->getHeight() != DEFAULT_DISPLAY_HEIGHT) && mPref.getQuickMatchResLocked())
{
GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:QuickMatch800x600"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,

Int GlobalLanguage::adjustFontSize(Int theFontSize)
{
Real adjustFactor = TheGlobalData->m_xResolution/800.0f;
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
if (adjustFactor<1.0f) adjustFactor = 1.0f;
if (adjustFactor>2.0f) adjustFactor = 2.0f;
Expand Down
4 changes: 2 additions & 2 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4029,8 +4029,8 @@ void InGameUI::militarySubtitle( const AsciiString& label, Int duration )

// calculate where this screen position should be since the position being passed in is based off 8x6
Coord2D multiplyer;
multiplyer.x = TheDisplay->getWidth() / 800;
multiplyer.y = TheDisplay->getHeight() / 600;
multiplyer.x = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH;
multiplyer.y = TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT;

// lets bring out the data structure!
m_militarySubtitle = NEW MilitarySubtitleData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void advancePosition(GameWindow *window, const Image *image, UnsignedInt
}
static Int Width = size.x + image->getImageWidth();

static Int x = -800;
static Int x = -DEFAULT_DISPLAY_WIDTH;
static Int y = pos.y - (image->getImageHeight()/2);

static UnsignedInt m_startTime = timeGetTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void W3DGadgetHorizontalSliderImageDraw( GameWindow *window,

SliderData *s = (SliderData *)window->winGetUserData();

Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;
Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / DEFAULT_DISPLAY_WIDTH;

// figure out how many boxes we draw for this slider
Int numBoxes = 0;
Expand Down Expand Up @@ -229,8 +229,8 @@ void W3DGadgetHorizontalSliderImageDrawB( GameWindow *window,

SliderData *s = (SliderData *)window->winGetUserData();

Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;
Real yMulti = INT_TO_REAL(TheDisplay->getHeight())/ 600;
Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / DEFAULT_DISPLAY_WIDTH;
Real yMulti = INT_TO_REAL(TheDisplay->getHeight()) / DEFAULT_DISPLAY_HEIGHT;
// get image offset
xOffset = instData->m_imageOffset.x;
yOffset = instData->m_imageOffset.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ static void drawFramerateBar(void);


// DEFINE AND ENUMS ///////////////////////////////////////////////////////////
#define DEFAULT_DISPLAY_BIT_DEPTH 32
#define MIN_DISPLAY_BIT_DEPTH 16
#define MIN_DISPLAY_RESOLUTION_X 800
#define MIN_DISPLAY_RESOLUTION_Y 600

#define no_SAMPLE_DYNAMIC_LIGHT 1
#ifdef SAMPLE_DYNAMIC_LIGHT
Expand Down Expand Up @@ -432,7 +428,7 @@ inline Bool isResolutionSupported(const ResolutionDescClass &res)
{
static const Int minBitDepth = 24;

return res.Width >= MIN_DISPLAY_RESOLUTION_X && res.BitDepth >= minBitDepth;
return res.Width >= DEFAULT_DISPLAY_WIDTH && res.BitDepth >= minBitDepth;
}

/*Return number of screen modes supported by the current device*/
Expand Down Expand Up @@ -701,15 +697,15 @@ void W3DDisplay::init( void )
// if the custom resolution did not succeed. This is unlikely to happen but is possible
// if the user writes an unsupported resolution in the Option Preferences or if the
// graphics adapter does not support the minimum display resolution to begin with.
Int xres = MIN_DISPLAY_RESOLUTION_X;
Int yres = MIN_DISPLAY_RESOLUTION_Y;
Int xres = DEFAULT_DISPLAY_WIDTH;
Int yres = DEFAULT_DISPLAY_HEIGHT;
Int bitDepth = DEFAULT_DISPLAY_BIT_DEPTH;
Int displayModeCount = getDisplayModeCount();
Int displayModeIndex = 0;
for (; displayModeIndex < displayModeCount; ++displayModeIndex)
{
getDisplayModeDescription(displayModeIndex, &xres, &yres, &bitDepth);
if (xres * yres >= MIN_DISPLAY_RESOLUTION_X * MIN_DISPLAY_RESOLUTION_Y)
if (xres * yres >= DEFAULT_DISPLAY_WIDTH * DEFAULT_DISPLAY_HEIGHT)
break; // Is good enough. Use it.
}
TheWritableGlobalData->m_xResolution = xres;
Expand Down
13 changes: 5 additions & 8 deletions Generals/Code/Main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ const Char *g_strFile = "data\\Generals.str";
const Char *g_csfFile = "data\\%s\\Generals.csf";
const char *gAppPrefix = ""; /// So WB can have a different debug log file name.

#define DEFAULT_XRESOLUTION 800
#define DEFAULT_YRESOLUTION 600

static Bool gInitializing = false;
static Bool gDoPaint = true;
static Bool isWinMainActive = false;
Expand Down Expand Up @@ -579,7 +576,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
Int savContext = ::SaveDC(dc);
HDC tmpDC = ::CreateCompatibleDC(dc);
HBITMAP savBitmap = (HBITMAP)::SelectObject(tmpDC, gLoadScreenBitmap);
::BitBlt(dc, 0, 0, DEFAULT_XRESOLUTION, DEFAULT_YRESOLUTION, tmpDC, 0, 0, SRCCOPY);
::BitBlt(dc, 0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT, tmpDC, 0, 0, SRCCOPY);
::SelectObject(tmpDC, savBitmap);
::DeleteDC(tmpDC);
::RestoreDC(dc, savContext);
Expand Down Expand Up @@ -661,8 +658,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWindowed )
{
DWORD windowStyle;
Int startWidth = DEFAULT_XRESOLUTION,
startHeight = DEFAULT_YRESOLUTION;
Int startWidth = DEFAULT_DISPLAY_WIDTH,
startHeight = DEFAULT_DISPLAY_HEIGHT;

// register the window class

Expand All @@ -688,8 +685,8 @@ static Bool initializeAppWindows( HINSTANCE hInstance, Int nCmdShow, Bool runWin
AdjustWindowRect (&rect, windowStyle, FALSE);
if (runWindowed) {
// Makes the normal debug 800x600 window center in the screen.
startWidth = DEFAULT_XRESOLUTION;
startHeight= DEFAULT_YRESOLUTION;
startWidth = DEFAULT_DISPLAY_WIDTH;
startHeight= DEFAULT_DISPLAY_HEIGHT;
}

gInitializing = true;
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ GlobalData::GlobalData()
m_chipSetType = 0;
m_headless = FALSE;
m_windowed = 0;
m_xResolution = 800;
m_yResolution = 600;
m_xResolution = DEFAULT_DISPLAY_WIDTH;
m_yResolution = DEFAULT_DISPLAY_HEIGHT;
m_maxShellScreens = 0;
m_useCloudMap = FALSE;
m_use3WayTerrainBlends = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ void ControlBarResizer::sizeWindowsAlt( void )
{
ResizerWindowList::iterator it = m_resizerWindowsList.begin();
GameWindow *win = NULL;
Real x = (Real)TheDisplay->getWidth() / 800;
Real y = (Real)TheDisplay->getHeight() / 600;
Real x = (Real)TheDisplay->getWidth() / DEFAULT_DISPLAY_WIDTH;
Real y = (Real)TheDisplay->getHeight() / DEFAULT_DISPLAY_HEIGHT;
while (it != m_resizerWindowsList.end())
{
ResizerWindow *rWin = *it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ static void setDefaults( void )
for( Int i = 0; i < numResolutions; ++i )
{ Int xres,yres,bitDepth;
TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);
if (xres == 800 && yres == 600) //keep track of default mode in case we need it.
if (xres == DEFAULT_DISPLAY_WIDTH && yres == DEFAULT_DISPLAY_HEIGHT) //keep track of default mode in case we need it.
{ defaultResIndex=i;
break;
}
Expand Down Expand Up @@ -1715,12 +1715,15 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )

// get resolution from saved preferences file
AsciiString selectedResolution = (*pref) ["Resolution"];
Int selectedXRes=800,selectedYRes=600;
Int selectedXRes=DEFAULT_DISPLAY_WIDTH;
Int selectedYRes=DEFAULT_DISPLAY_HEIGHT;
Int selectedResIndex=-1;
if (!selectedResolution.isEmpty())
{ //try to parse 2 integers out of string
if (sscanf(selectedResolution.str(),"%d%d", &selectedXRes, &selectedYRes) != 2)
{ selectedXRes=800; selectedYRes=600;
{
selectedXRes=DEFAULT_DISPLAY_WIDTH;
selectedYRes=DEFAULT_DISPLAY_HEIGHT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ void ResetBattleHonorInsertion(void)
}
void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int itemData, Int& row, Int& column, UnicodeString text = UnicodeString::TheEmptyString, Int extra = 0)
{
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / 800.0f);
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / 600.0f);
Int width = MAX_BATTLE_HONOR_IMAGE_WIDTH * (TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH);
Int height = MAX_BATTLE_HONOR_IMAGE_HEIGHT * (TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT);

static Int enabledColor = 0xFFFFFFFF;
static Int disabledColor = GameMakeColor(80, 80, 80, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg,
else if (controlID == buttonQuickMatchID)
{
GameSpyMiscPreferences mPref;
if ((TheDisplay->getWidth() != 800 || TheDisplay->getHeight() != 600) && mPref.getQuickMatchResLocked())
if ((TheDisplay->getWidth() != DEFAULT_DISPLAY_WIDTH || TheDisplay->getHeight() != DEFAULT_DISPLAY_HEIGHT) && mPref.getQuickMatchResLocked())
{
GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:QuickMatch800x600"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store,

Int GlobalLanguage::adjustFontSize(Int theFontSize)
{
Real adjustFactor = TheGlobalData->m_xResolution/800.0f;
Real adjustFactor = TheGlobalData->m_xResolution / (Real)DEFAULT_DISPLAY_WIDTH;
adjustFactor = 1.0f + (adjustFactor-1.0f) * m_resolutionFontSizeAdjustment;
if (adjustFactor<1.0f) adjustFactor = 1.0f;
if (adjustFactor>2.0f) adjustFactor = 2.0f;
Expand Down
4 changes: 2 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4183,8 +4183,8 @@ void InGameUI::militarySubtitle( const AsciiString& label, Int duration )

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

// lets bring out the data structure!
m_militarySubtitle = NEW MilitarySubtitleData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void advancePosition(GameWindow *window, const Image *image, UnsignedInt
}
static Int Width = size.x + image->getImageWidth();

static Int x = -800;
static Int x = -DEFAULT_DISPLAY_WIDTH;
static Int y = pos.y - (image->getImageHeight()/2);

static UnsignedInt m_startTime = timeGetTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void W3DGadgetHorizontalSliderImageDraw( GameWindow *window,

SliderData *s = (SliderData *)window->winGetUserData();

Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;
Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / DEFAULT_DISPLAY_WIDTH;

// figure out how many boxes we draw for this slider
Int numBoxes = 0;
Expand Down Expand Up @@ -229,8 +229,8 @@ void W3DGadgetHorizontalSliderImageDrawB( GameWindow *window,

SliderData *s = (SliderData *)window->winGetUserData();

Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / 800;
Real yMulti = INT_TO_REAL(TheDisplay->getHeight())/ 600;
Real xMulti = INT_TO_REAL(TheDisplay->getWidth()) / DEFAULT_DISPLAY_WIDTH;
Real yMulti = INT_TO_REAL(TheDisplay->getHeight()) / DEFAULT_DISPLAY_HEIGHT;
// get image offset
xOffset = instData->m_imageOffset.x;
yOffset = instData->m_imageOffset.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ static void drawFramerateBar(void);


// DEFINE AND ENUMS ///////////////////////////////////////////////////////////
#define DEFAULT_DISPLAY_BIT_DEPTH 32
#define MIN_DISPLAY_BIT_DEPTH 16
#define MIN_DISPLAY_RESOLUTION_X 800
#define MIN_DISPLAY_RESOLUTION_Y 600

#define no_SAMPLE_DYNAMIC_LIGHT 1
#ifdef SAMPLE_DYNAMIC_LIGHT
Expand Down Expand Up @@ -481,7 +477,7 @@ inline Bool isResolutionSupported(const ResolutionDescClass &res)
{
static const Int minBitDepth = 24;

return res.Width >= MIN_DISPLAY_RESOLUTION_X && res.BitDepth >= minBitDepth;
return res.Width >= DEFAULT_DISPLAY_WIDTH && res.BitDepth >= minBitDepth;
}

/*Return number of screen modes supported by the current device*/
Expand Down Expand Up @@ -751,15 +747,15 @@ void W3DDisplay::init( void )
// if the custom resolution did not succeed. This is unlikely to happen but is possible
// if the user writes an unsupported resolution in the Option Preferences or if the
// graphics adapter does not support the minimum display resolution to begin with.
Int xres = MIN_DISPLAY_RESOLUTION_X;
Int yres = MIN_DISPLAY_RESOLUTION_Y;
Int xres = DEFAULT_DISPLAY_WIDTH;
Int yres = DEFAULT_DISPLAY_HEIGHT;
Int bitDepth = DEFAULT_DISPLAY_BIT_DEPTH;
Int displayModeCount = getDisplayModeCount();
Int displayModeIndex = 0;
for (; displayModeIndex < displayModeCount; ++displayModeIndex)
{
getDisplayModeDescription(displayModeIndex, &xres, &yres, &bitDepth);
if (xres * yres >= MIN_DISPLAY_RESOLUTION_X * MIN_DISPLAY_RESOLUTION_Y)
if (xres * yres >= DEFAULT_DISPLAY_WIDTH * DEFAULT_DISPLAY_HEIGHT)
break; // Is good enough. Use it.
}
TheWritableGlobalData->m_xResolution = xres;
Expand Down
Loading
Loading