Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetCivsButton.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetCivsButton.js
class ResetCivsButton | class ResetCivsButton | ||||
{ | { | ||||
constructor(setupWindow) | constructor(setupWindow) | ||||
{ | { | ||||
this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | ||||
this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | |||||
this.civResetButton = Engine.GetGUIObjectByName("civResetButton"); | this.civResetButton = Engine.GetGUIObjectByName("civResetButton"); | ||||
this.civResetButton.tooltip = this.Tooltip; | this.civResetButton.tooltip = this.Tooltip; | ||||
this.civResetButton.onPress = this.onPress.bind(this); | this.civResetButton.onPress = this.onPress.bind(this); | ||||
g_NewGameSettings.map.watch(() => this.render(), ["type"]); | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
if (g_GameAttributes.mapType) | this.civResetButton.hidden = g_NewGameSettings.map.type == "scenario" || !g_IsController; | ||||
this.civResetButton.hidden = g_GameAttributes.mapType == "scenario" || !g_IsController; | |||||
} | } | ||||
onPress() | onPress() | ||||
{ | { | ||||
if (!g_GameAttributes.settings || !g_GameAttributes.settings.PlayerData) | for (let i = 0; i < g_NewGameSettings.playerCount.nbPlayers; ++i) | ||||
return; | g_NewGameSettings.playerCiv.setValue(i, "random"); | ||||
for (let pData of g_GameAttributes.settings.PlayerData) | |||||
pData.Civ = this.RandomCivId; | |||||
this.gameSettingsControl.updateGameAttributes(); | this.gameSettingsControl.updateGameAttributes(); | ||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
} | } | ||||
ResetCivsButton.prototype.Tooltip = | ResetCivsButton.prototype.Tooltip = | ||||
translate("Reset any civilizations that have been selected to the default (random)."); | translate("Reset any civilizations that have been selected to the default (random)."); | ||||
ResetCivsButton.prototype.RandomCivId = | |||||
"random"; |
Wildfire Games · Phabricator