Differential D3243 Diff 16284 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetTeamsButton.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/Buttons/ResetTeamsButton.js
class ResetTeamsButton | class ResetTeamsButton | ||||
{ | { | ||||
constructor(setupWindow) | constructor(setupWindow) | ||||
{ | { | ||||
this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | this.gameSettingsControl = setupWindow.controls.gameSettingsControl; | ||||
this.gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); | |||||
this.teamResetButton = Engine.GetGUIObjectByName("teamResetButton"); | this.teamResetButton = Engine.GetGUIObjectByName("teamResetButton"); | ||||
this.teamResetButton.tooltip = this.Tooltip; | this.teamResetButton.tooltip = this.Tooltip; | ||||
this.teamResetButton.onPress = this.onPress.bind(this); | this.teamResetButton.onPress = this.onPress.bind(this); | ||||
g_NewGameSettings.map.watch(() => this.render(), ["type"]); | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
if (!g_GameAttributes.mapType) | this.teamResetButton.hidden = g_NewGameSettings.map.type == "scenario" || !g_IsController; | ||||
return; | |||||
this.teamResetButton.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.playerTeam.setValue(i, -1); | ||||
for (let pData of g_GameAttributes.settings.PlayerData) | |||||
pData.Team = -1; | |||||
this.gameSettingsControl.updateGameAttributes(); | this.gameSettingsControl.updateGameAttributes(); | ||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
} | } | ||||
ResetTeamsButton.prototype.Tooltip = | ResetTeamsButton.prototype.Tooltip = | ||||
translate("Reset all teams to the default."); | translate("Reset all teams to the default."); |
Wildfire Games · Phabricator