[+] Add CPreference::PauseOnLeave parameter to control the game pause when the window is inactive
This commit is contained in:
parent
e6d1b09470
commit
a126ed9962
3 changed files with 6 additions and 2 deletions
|
@ -417,13 +417,15 @@ class CPreference
|
|||
public:
|
||||
CPreference() : ShowSightRange(false), ShowReactionRange(false),
|
||||
ShowAttackRange(false), ShowMessages(true),
|
||||
BigScreen(false), ShowOrders(0), ShowNameDelay(0), ShowNameTime(0) {};
|
||||
BigScreen(false), PauseOnLeave(true), ShowOrders(0), ShowNameDelay(0),
|
||||
ShowNameTime(0) {};
|
||||
|
||||
bool ShowSightRange; /// Show sight range.
|
||||
bool ShowReactionRange; /// Show reaction range.
|
||||
bool ShowAttackRange; /// Show attack range.
|
||||
bool ShowMessages; /// Show messages.
|
||||
bool BigScreen; /// If true, shows the big screen(without panels)
|
||||
bool PauseOnLeave; /// If true, game pauses when cursor is gone
|
||||
|
||||
int ShowOrders; /// How many second show orders of unit on map.
|
||||
int ShowNameDelay; /// How many cycles need to wait until unit's name popup will appear.
|
||||
|
|
|
@ -22,6 +22,7 @@ class CPreference
|
|||
bool ShowAttackRange;
|
||||
bool ShowMessages;
|
||||
bool BigScreen;
|
||||
bool PauseOnLeave;
|
||||
|
||||
unsigned int ShowOrders;
|
||||
unsigned int ShowNameDelay;
|
||||
|
|
|
@ -94,6 +94,7 @@
|
|||
#include "sound_server.h"
|
||||
#include "translate.h"
|
||||
#include "ui.h"
|
||||
#include "unit.h"
|
||||
#include "video.h"
|
||||
#include "widgets.h"
|
||||
|
||||
|
@ -860,7 +861,7 @@ static void SdlDoEvent(const EventCallback &callbacks, SDL_Event &event)
|
|||
}
|
||||
InMainWindow = (event.active.gain != 0);
|
||||
}
|
||||
if (event.active.state & SDL_APPACTIVE || SDL_GetAppState() & SDL_APPACTIVE) {
|
||||
if (Preference.PauseOnLeave && (event.active.state & SDL_APPACTIVE || SDL_GetAppState() & SDL_APPACTIVE)) {
|
||||
static bool DoTogglePause = false;
|
||||
|
||||
if (IsSDLWindowVisible && !event.active.gain) {
|
||||
|
|
Loading…
Add table
Reference in a new issue