Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -29,8 +29,9 @@ ; Show detailed tooltips (Unit stats) showdetailedtooltips = false -; Pause the game on window focus loss (Only applicable to single player mode) -pauseonfocusloss = true +; Pause game and rendering of the game on window focus loss (Pause only to single player game) +; (0 - Disabled, 1 - Pause Game, 2 - Pause Game and Rendering, 3 - Pause Rendering) +pauseonfocusloss = 1 ; Persist settings after leaving the game setup screen persistmatchsettings = true Index: binaries/data/mods/public/gui/options/options.json =================================================================== --- binaries/data/mods/public/gui/options/options.json +++ binaries/data/mods/public/gui/options/options.json @@ -22,10 +22,17 @@ "config": "windowed" }, { - "type": "boolean", + "type": "dropdown", "label": "Background Pause", - "tooltip": "Pause single player games when window loses focus", - "config": "pauseonfocusloss" + "tooltip": "Pause game (only single player) or rendering of the game when window loses focus.", + "config": "pauseonfocusloss", + "function": "UpdatePauseOnFocusLoss", + "list": [ + { "value": 0, "label": "Disabled" }, + { "value": 1, "label": "Pause Game" }, + { "value": 2, "label": "Pause Game and Rendering" }, + { "value": 3, "label": "Pause Rendering" } + ] }, { "type": "boolean", Index: source/main.cpp =================================================================== --- source/main.cpp +++ source/main.cpp @@ -305,13 +305,13 @@ ENSURE(realTimeSinceLastFrame > 0.0f); // decide if update/render is necessary - bool need_render = !g_app_minimized; + bool need_render = !g_app_minimized && (!g_PauseRendererOnFocusLoss || g_app_has_focus); bool need_update = true; // If we are not running a multiplayer game, disable updates when the game is // minimized or out of focus and relinquish the CPU a bit, in order to make // debugging easier. - if (g_PauseOnFocusLoss && !g_NetClient && !g_app_has_focus) + if (g_PauseGameOnFocusLoss && !g_NetClient && !g_app_has_focus) { PROFILE3("non-focus delay"); need_update = false; Index: source/ps/GameSetup/Config.h =================================================================== --- source/ps/GameSetup/Config.h +++ source/ps/GameSetup/Config.h @@ -42,7 +42,10 @@ //----------------------------------------------------------------------------- // flag to pause the game on window focus loss -extern bool g_PauseOnFocusLoss; +extern bool g_PauseGameOnFocusLoss; + +// flag to pause the renderer on window focus loss +extern bool g_PauseRendererOnFocusLoss; // flag to switch on actor rendering extern bool g_RenderActors; @@ -96,6 +99,8 @@ extern CStrW g_CursorName; extern const wchar_t g_DefaultCursor[]; +extern void ConfigSetPauseOnFocusLoss(); + class CmdLineArgs; extern void CONFIG_Init(const CmdLineArgs& args); Index: source/ps/GameSetup/Config.cpp =================================================================== --- source/ps/GameSetup/Config.cpp +++ source/ps/GameSetup/Config.cpp @@ -35,7 +35,8 @@ bool g_NoGLAutoMipmap = false; bool g_NoGLVBO = false; -bool g_PauseOnFocusLoss = false; +bool g_PauseGameOnFocusLoss = false; +bool g_PauseRendererOnFocusLoss = false; bool g_RenderActors = true; @@ -92,7 +93,9 @@ CFG_GET_VAL("nos3tc", g_NoGLS3TC); CFG_GET_VAL("noautomipmap", g_NoGLAutoMipmap); CFG_GET_VAL("novbo", g_NoGLVBO); - CFG_GET_VAL("pauseonfocusloss", g_PauseOnFocusLoss); + + ConfigSetPauseOnFocusLoss(); + CFG_GET_VAL("renderactors", g_RenderActors); CFG_GET_VAL("shadows", g_Shadows); CFG_GET_VAL("shadowpcf", g_ShadowPCF); @@ -115,6 +118,25 @@ CFG_GET_VAL("gui.scale", g_GuiScale); } +void ConfigSetPauseOnFocusLoss() +{ + int pauseOnFocusLoss = 0; + CFG_GET_VAL("pauseonfocusloss", pauseOnFocusLoss); + + g_PauseGameOnFocusLoss = false; + g_PauseRendererOnFocusLoss = false; + + switch (pauseOnFocusLoss) + { + case 3: + g_PauseRendererOnFocusLoss = true; + break; + case 2: + g_PauseRendererOnFocusLoss = true; + case 1: + g_PauseGameOnFocusLoss = true; + } +} static void ProcessCommandLineArgs(const CmdLineArgs& args) { Index: source/ps/scripting/JSInterface_Main.h =================================================================== --- source/ps/scripting/JSInterface_Main.h +++ source/ps/scripting/JSInterface_Main.h @@ -33,6 +33,7 @@ bool HotkeyIsPressed_(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyName); int GetFps(ScriptInterface::CxPrivate* pCxPrivate); int GetTextWidth(ScriptInterface::CxPrivate* pCxPrivate, const std::string& fontName, const std::wstring& text); + void UpdatePauseOnFocusLoss(ScriptInterface::CxPrivate* pCxPrivate); void RegisterScriptFunctions(const ScriptInterface& scriptInterface); } Index: source/ps/scripting/JSInterface_Main.cpp =================================================================== --- source/ps/scripting/JSInterface_Main.cpp +++ source/ps/scripting/JSInterface_Main.cpp @@ -26,6 +26,7 @@ #include "ps/CStrIntern.h" #include "ps/GUID.h" #include "ps/GameSetup/Atlas.h" +#include "ps/GameSetup/Config.h" #include "ps/Globals.h" #include "ps/Hotkey.h" #include "tools/atlas/GameInterface/GameLoop.h" @@ -108,6 +109,11 @@ return width; } +void JSI_Main::UpdatePauseOnFocusLoss(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) +{ + ConfigSetPauseOnFocusLoss(); +} + void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface) { scriptInterface.RegisterFunction("Exit"); @@ -121,4 +127,5 @@ scriptInterface.RegisterFunction("HotkeyIsPressed"); scriptInterface.RegisterFunction("GetFPS"); scriptInterface.RegisterFunction("GetTextWidth"); + scriptInterface.RegisterFunction("UpdatePauseOnFocusLoss"); }