Skip to content

Commit 7d3bf1d

Browse files
committed
Replicate in Generals
1 parent 259046e commit 7d3bf1d

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ enum OSDisplayOtherFlags CPP_11(: UnsignedInt)
6363
// This function will return the button pressed to close the dialog.
6464
OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedInt buttonFlags, UnsignedInt otherFlags);
6565

66+
// TheSuperHackers @feature Tell the Operating System that the game is considered busy
67+
// and we would not like the display screen and/or system to shut off.
68+
void OSDisplaySetBusyState(Bool busyDisplay, Bool busySystem);
69+
6670
#endif /* __OSDISPLAY_H__ */

Generals/Code/GameEngine/Include/GameLogic/GameLogic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class GameLogic : public SubsystemInterface, public Snapshot
173173
Bool isInInternetGame( void );
174174
Bool isInShellGame( void );
175175
Bool isInMultiplayerGame( void );
176+
Bool isInInteractiveGame() const;
176177

177178
static Bool isInInteractiveGame(GameMode mode) { return mode != GAME_NONE && mode != GAME_SHELL; }
178179

@@ -254,6 +255,8 @@ class GameLogic : public SubsystemInterface, public Snapshot
254255

255256
private:
256257

258+
void updateDisplayBusyState();
259+
257260
void pauseGameLogic(Bool paused);
258261
void pauseGameSound(Bool paused);
259262
void pauseGameMusic(Bool paused);
@@ -397,6 +400,7 @@ inline GameMode GameLogic::getGameMode( void ) { return m_gameMode; }
397400
inline Bool GameLogic::isInLanGame( void ) { return (m_gameMode == GAME_LAN); }
398401
inline Bool GameLogic::isInSkirmishGame( void ) { return (m_gameMode == GAME_SKIRMISH); }
399402
inline Bool GameLogic::isInMultiplayerGame( void ) { return (m_gameMode == GAME_LAN) || (m_gameMode == GAME_INTERNET) ; }
403+
inline Bool GameLogic::isInInteractiveGame() const { return isInInteractiveGame(m_gameMode); }
400404
inline Bool GameLogic::isInReplayGame( void ) { return (m_gameMode == GAME_REPLAY); }
401405
inline Bool GameLogic::isInInternetGame( void ) { return (m_gameMode == GAME_INTERNET); }
402406
inline Bool GameLogic::isInShellGame( void ) { return (m_gameMode == GAME_SHELL); }

Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Common/LatchRestore.h"
4141
#include "Common/MapObject.h"
4242
#include "Common/MultiplayerSettings.h"
43+
#include "Common/OSDisplay.h"
4344
#include "Common/PerfTimer.h"
4445
#include "Common/Player.h"
4546
#include "Common/PlayerList.h"
@@ -981,6 +982,16 @@ void GameLogic::setGameLoading( Bool loading )
981982
m_loadingScene = loading;
982983
}
983984

985+
// ------------------------------------------------------------------------------------------------
986+
// ------------------------------------------------------------------------------------------------
987+
void GameLogic::updateDisplayBusyState()
988+
{
989+
const Bool busySystem = isInInteractiveGame() && !isGamePaused();
990+
const Bool busyDisplay = busySystem && !TheGlobalData->m_headless;
991+
992+
OSDisplaySetBusyState(busyDisplay, busySystem);
993+
}
994+
984995
// ------------------------------------------------------------------------------------------------
985996
// ------------------------------------------------------------------------------------------------
986997
void GameLogic::setGameMode( GameMode mode )
@@ -989,6 +1000,8 @@ void GameLogic::setGameMode( GameMode mode )
9891000
m_gameMode = mode;
9901001

9911002
TheMouse->onGameModeChanged(prev, mode);
1003+
1004+
updateDisplayBusyState();
9921005
}
9931006

9941007
// ------------------------------------------------------------------------------------------------
@@ -3736,6 +3749,8 @@ void GameLogic::setGamePaused( Bool paused, Bool pauseMusic, Bool pauseInput )
37363749
pauseGameSound(paused);
37373750
pauseGameMusic(paused && pauseMusic);
37383751
pauseGameInput(paused && pauseInput);
3752+
3753+
updateDisplayBusyState();
37393754
}
37403755

37413756
// ------------------------------------------------------------------------------------------------

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,13 @@ OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedIn
123123

124124
return OSDBT_CANCEL;
125125
}
126+
127+
//-------------------------------------------------------------------------------------------------
128+
void OSDisplaySetBusyState(Bool busyDisplay, Bool busySystem)
129+
{
130+
EXECUTION_STATE state = ES_CONTINUOUS;
131+
state |= busyDisplay ? ES_DISPLAY_REQUIRED : 0;
132+
state |= busySystem ? ES_SYSTEM_REQUIRED : 0;
133+
134+
::SetThreadExecutionState(state);
135+
}

0 commit comments

Comments
 (0)