Skip to content

Commit 3354474

Browse files
authored
refactor: Remove string conversion code for MessageBox (#2523)
1 parent f83b376 commit 3354474

10 files changed

Lines changed: 3 additions & 133 deletions

File tree

Core/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ set(GAMEENGINE_SRC
120120
Include/Common/STLTypedefs.h
121121
Include/Common/StreamingArchiveFile.h
122122
Include/Common/SubsystemInterface.h
123-
# Include/Common/SystemInfo.h
124123
# Include/Common/Team.h
125124
# Include/Common/Terrain.h
126125
# Include/Common/TerrainTypes.h

Core/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
#include "Common/CommandLine.h"
6262
#include "Common/Debug.h"
6363
#include "Common/CRCDebug.h"
64-
#include "Common/SystemInfo.h"
6564
#include "Common/UnicodeString.h"
6665
#include "GameClient/ClientInstance.h"
6766
#include "GameClient/GameText.h"
@@ -848,21 +847,7 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
848847
}
849848
}
850849

851-
if (TheSystemIsUnicode)
852-
{
853-
::MessageBoxW(nullptr, mesg.str(), prompt.str(), MB_OK|MB_SYSTEMMODAL|MB_ICONERROR);
854-
}
855-
else
856-
{
857-
// However, if we're using the default version of the message box, we need to
858-
// translate the string into an AsciiString
859-
AsciiString promptA, mesgA;
860-
promptA.translate(prompt);
861-
mesgA.translate(mesg);
862-
//Make sure main window is not TOP_MOST
863-
::SetWindowPos(ApplicationHWnd, HWND_NOTOPMOST, 0, 0, 0, 0,SWP_NOSIZE |SWP_NOMOVE);
864-
::MessageBoxA(nullptr, mesgA.str(), promptA.str(), MB_OK|MB_TASKMODAL|MB_ICONERROR);
865-
}
850+
::MessageBoxW(nullptr, mesg.str(), prompt.str(), MB_OK | MB_SYSTEMMODAL | MB_ICONERROR);
866851

867852
char prevbuf[ _MAX_PATH ];
868853
char curbuf[ _MAX_PATH ];

Generals/Code/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ set(GAMEENGINE_SRC
108108
# Include/Common/STLTypedefs.h
109109
# Include/Common/StreamingArchiveFile.h
110110
# Include/Common/SubsystemInterface.h
111-
Include/Common/SystemInfo.h
112111
Include/Common/Team.h
113112
Include/Common/Terrain.h
114113
Include/Common/TerrainTypes.h

Generals/Code/GameEngine/Include/Common/SystemInfo.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

Generals/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,11 +1058,3 @@ void updateTGAtoDDS()
10581058

10591059
system(CONVERT_EXEC1);
10601060
}
1061-
1062-
//-------------------------------------------------------------------------------------------------
1063-
// System things
1064-
1065-
// If we're using the Wide character version of MessageBox, then there's no additional
1066-
// processing necessary. Please note that this is a sleazy way to get this information,
1067-
// but pending a better one, this'll have to do.
1068-
extern const Bool TheSystemIsUnicode = (((void*) (::MessageBox)) == ((void*) (::MessageBoxW)));

Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32OSDisplay.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "Common/SubsystemInterface.h"
3434
#include "Common/STLTypedefs.h"
3535
#include "Common/AsciiString.h"
36-
#include "Common/SystemInfo.h"
3736
#include "Common/UnicodeString.h"
3837
#include "GameClient/GameText.h"
3938

@@ -100,23 +99,7 @@ OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedIn
10099

101100
// @todo Make this return more than just ok/cancel - jkmcd
102101
// (we need a function to translate back the other way.)
103-
Int returnResult = 0;
104-
if (TheSystemIsUnicode)
105-
{
106-
returnResult = ::MessageBoxW(nullptr, mesgStr.str(), promptStr.str(), windowsOptionsFlags);
107-
}
108-
else
109-
{
110-
// However, if we're using the default version of the message box, we need to
111-
// translate the string into an AsciiString
112-
AsciiString promptA, mesgA;
113-
promptA.translate(promptStr);
114-
mesgA.translate(mesgStr);
115-
//Make sure main window is not TOP_MOST
116-
::SetWindowPos(ApplicationHWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
117-
returnResult = ::MessageBoxA(nullptr, mesgA.str(), promptA.str(), windowsOptionsFlags);
118-
}
119-
102+
const Int returnResult = ::MessageBoxW(nullptr, mesgStr.str(), promptStr.str(), windowsOptionsFlags);
120103
if (returnResult == IDOK) {
121104
return OSDBT_OK;
122105
}

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ set(GAMEENGINE_SRC
113113
# Include/Common/STLTypedefs.h
114114
# Include/Common/StreamingArchiveFile.h
115115
# Include/Common/SubsystemInterface.h
116-
Include/Common/SystemInfo.h
117116
Include/Common/Team.h
118117
Include/Common/Terrain.h
119118
Include/Common/TerrainTypes.h

GeneralsMD/Code/GameEngine/Include/Common/SystemInfo.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,11 +1109,3 @@ void updateTGAtoDDS()
11091109

11101110
system(CONVERT_EXEC1);
11111111
}
1112-
1113-
//-------------------------------------------------------------------------------------------------
1114-
// System things
1115-
1116-
// If we're using the Wide character version of MessageBox, then there's no additional
1117-
// processing necessary. Please note that this is a sleazy way to get this information,
1118-
// but pending a better one, this'll have to do.
1119-
extern const Bool TheSystemIsUnicode = (((void*) (::MessageBox)) == ((void*) (::MessageBoxW)));

GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32OSDisplay.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "Common/SubsystemInterface.h"
3434
#include "Common/STLTypedefs.h"
3535
#include "Common/AsciiString.h"
36-
#include "Common/SystemInfo.h"
3736
#include "Common/UnicodeString.h"
3837
#include "GameClient/GameText.h"
3938

@@ -100,23 +99,7 @@ OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedIn
10099

101100
// @todo Make this return more than just ok/cancel - jkmcd
102101
// (we need a function to translate back the other way.)
103-
Int returnResult = 0;
104-
if (TheSystemIsUnicode)
105-
{
106-
returnResult = ::MessageBoxW(nullptr, mesgStr.str(), promptStr.str(), windowsOptionsFlags);
107-
}
108-
else
109-
{
110-
// However, if we're using the default version of the message box, we need to
111-
// translate the string into an AsciiString
112-
AsciiString promptA, mesgA;
113-
promptA.translate(promptStr);
114-
mesgA.translate(mesgStr);
115-
//Make sure main window is not TOP_MOST
116-
::SetWindowPos(ApplicationHWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
117-
returnResult = ::MessageBoxA(nullptr, mesgA.str(), promptA.str(), windowsOptionsFlags);
118-
}
119-
102+
const Int returnResult = ::MessageBoxW(nullptr, mesgStr.str(), promptStr.str(), windowsOptionsFlags);
120103
if (returnResult == IDOK) {
121104
return OSDBT_OK;
122105
}

0 commit comments

Comments
 (0)