Page MenuHomeWildfire Games

Don't require application restart to change the pauseonfocusloss option
Needs RevisionPublic

Authored by elexis on May 29 2018, 2:59 AM.

Details

Reviewers
bb
vladislavbelov
Summary

As reported by Boudica (and bb?), changing the option to pause the game in singleplayer and replaymode when the window doesn't have focus doesn't take effect until restarting the program.

Test Plan

Didn't check if there are more options with the same problem. Have some ideas for more cleanup.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 6183
Build 10274: Vulcan BuildJenkins
Build 10273: arc lint + arc unit

Event Timeline

elexis created this revision.May 29 2018, 2:59 AM
Vulcan added a subscriber: Vulcan.May 29 2018, 3:03 AM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Default...
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 6 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 407| 407| 				// Players see colors depending on diplomacy
| 408| 408| 				g_DisplayedPlayerColors[i] =
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410|    |-					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
|    | 410|+						g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411| 411| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412| 412| 					getDiplomacyColor("enemy");
| 413| 413| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 7 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 408| 408| 				g_DisplayedPlayerColors[i] =
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410| 410| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411|    |-					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
|    | 411|+							g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412| 412| 					getDiplomacyColor("enemy");
| 413| 413| 
| 414| 414| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 8 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 409| 409| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 410| 410| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 411| 411| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 412|    |-					getDiplomacyColor("enemy");
|    | 412|+								getDiplomacyColor("enemy");
| 413| 413| 
| 414| 414| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
| 415| 415| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 665| 665| 					"civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14" }),
| 666| 666| 					"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
| 667| 667| 					"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
| 668|    |-			});
|    | 668|+				});
| 669| 669| 	}
| 670| 670| 
| 671| 671| 	// Following gaia can be interesting on scripted maps
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1261|1261| 
|1262|1262| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1263|1263| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1264|    |-		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|    |1264|+			"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1265|1265| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1266|1266| 	});
|1267|1267| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1262|1262| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1263|1263| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1264|1264| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1265|    |-		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|    |1265|+			"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1266|1266| 	});
|1267|1267| 
|1268|1268| 	let resCodes = g_ResourceData.GetCodes();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 1.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1263|1263| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1264|1264| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1265|1265| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1266|    |-	});
|    |1266|+		});
|1267|1267| 
|1268|1268| 	let resCodes = g_ResourceData.GetCodes();
|1269|1269| 	for (let r = 0; r < resCodes.length; ++r)
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1766|1766| 	for (let rct of resourcesCounterTypes)
|1767|1767| 		for (let rt of resourcesTypes)
|1768|1768| 			reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt];
|1769|    |-			// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|    |1769|+	// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|1770|1770| 
|1771|1771| 	reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood;
|1772|1772| 	for (let type of unitsClasses)

binaries/data/mods/public/gui/session/session.js
|1089| »   let·getPanelEntNameTooltip·=·panelEntState·=>·"[font=\"sans-bold-16\"]"·+·template.name.specific·+·"[/font]";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'panelEntState' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1164| »   »   button.onpress·=·(function(i)·{·return·function()·{·performGroup((Engine.HotkeyIsPressed("selection.add")·?·"add"·:·"select"),·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1165| »   »   button.ondoublepress·=·(function(i)·{·return·function()·{·performGroup("snap",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1166| »   »   button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

Link to build: https://jenkins.wildfiregames.com/job/differential/597/display/redirect

elexis planned changes to this revision.May 29 2018, 4:28 AM
elexis added inline comments.
binaries/data/mods/public/gui/session/session.js
1442 ↗(On Diff #6679)

doesnt work when changing while not in a running game.
doesn't error out, but the global isnt updated

elexis updated this revision to Diff 6682.May 29 2018, 4:45 AM

Should this be in Main or Game interface?

Doesn't really access the Game class, but seems logically related (compare with surrounding functions)

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/599/display/redirect

bb accepted this revision.Mar 16 2019, 5:41 PM
bb added a subscriber: bb.

The option doesn't do anything outside the in-game so I suppose in-Game is the place...

Patch to boring (it works) => accept

This revision is now accepted and ready to land.Mar 16 2019, 5:41 PM
vladislavbelov requested changes to this revision.Apr 4 2019, 10:51 PM
vladislavbelov added a subscriber: vladislavbelov.
vladislavbelov added inline comments.
source/ps/scripting/JSInterface_Game.cpp
130

Use the same way as it's done in Config.cpp:

CFG_GET_VAL("pauseonfocusloss", g_PauseOnFocusLoss);
184

Why not the same way as other variables and renderer parameters:
SetPausedOnFocusLoss(...)

This revision now requires changes to proceed.Apr 4 2019, 10:51 PM