Do not require restart when chaning Background pause option

Background pause does require a game restart to take effect.
Adding function to update it on runtime since only place where it is
used is in main.cpp.

Differential revision: D4181
Fixes: #6236
Tested by: @Langbart
This was SVN commit r25866.
This commit is contained in:
Angen
2021-08-27 18:54:20 +00:00
parent 9ff8b0758c
commit 81ad9f746b
3 changed files with 10 additions and 2 deletions
@@ -19,7 +19,8 @@
"type": "boolean",
"label": "Background pause",
"tooltip": "Pause single-player games when window loses focus.",
"config": "pauseonfocusloss"
"config": "pauseonfocusloss",
"function": "PauseOnFocusLoss"
},
{
"type": "boolean",
@@ -188,6 +188,11 @@ bool SetFile(const std::wstring& cfgNsString, const Path& path)
return true;
}
void PauseOnFocusLoss(bool pause)
{
g_PauseOnFocusLoss = pause;
}
void RegisterScriptFunctions(const ScriptRequest& rq)
{
ScriptFunction::Register<&HasChanges>(rq, "ConfigDB_HasChanges");
@@ -201,5 +206,6 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
ScriptFunction::Register<&CreateAndWriteValueToFile>(rq, "ConfigDB_CreateAndWriteValueToFile");
ScriptFunction::Register<&SetFile>(rq, "ConfigDB_SetFile");
ScriptFunction::Register<&Reload>(rq, "ConfigDB_Reload");
ScriptFunction::Register<&PauseOnFocusLoss>(rq, "PauseOnFocusLoss");
}
}
+2 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2019 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -18,6 +18,7 @@
#ifndef INCLUDED_JSI_CONFIGDB
#define INCLUDED_JSI_CONFIGDB
extern bool g_PauseOnFocusLoss;
class ScriptRequest;
namespace JSI_ConfigDB