Differential D3243 Diff 16499 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerTeam.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerTeam.js
PlayerSettingControls.PlayerTeam = class extends GameSettingControlDropdown | PlayerSettingControls.PlayerTeam = class PlayerTeam extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.values = prepareForDropdown([ | this.values = prepareForDropdown([ | ||||
{ | { | ||||
"label": this.NoTeam, | "label": this.NoTeam, | ||||
"id": this.NoTeamId | "id": this.NoTeamId | ||||
}, | }, | ||||
...Array.from( | ...Array.from( | ||||
new Array(g_MaxTeams), | new Array(g_MaxTeams), | ||||
(v, i) => ({ | (v, i) => ({ | ||||
"label": i + 1, | "label": i + 1, | ||||
"id": i | "id": i | ||||
})) | })) | ||||
]); | ]); | ||||
this.dropdown.list = this.values.label; | this.dropdown.list = this.values.label; | ||||
this.dropdown.list_data = this.values.id; | this.dropdown.list_data = this.values.id; | ||||
g_NewGameSettings.playerTeam.watch(() => this.render(), ["values", "locked"]); | |||||
this.render(); | |||||
} | } | ||||
setControl() | setControl() | ||||
{ | { | ||||
this.label = Engine.GetGUIObjectByName("playerTeamText[" + this.playerIndex + "]"); | this.label = Engine.GetGUIObjectByName("playerTeamText[" + this.playerIndex + "]"); | ||||
this.dropdown = Engine.GetGUIObjectByName("playerTeam[" + this.playerIndex + "]"); | this.dropdown = Engine.GetGUIObjectByName("playerTeam[" + this.playerIndex + "]"); | ||||
} | } | ||||
onMapChange(mapData) | render() | ||||
{ | |||||
let mapPData = this.gameSettingsControl.getPlayerData(mapData, this.playerIndex); | |||||
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex); | |||||
if (pData && mapPData && mapPData.Team !== undefined) | |||||
{ | |||||
pData.Team = mapPData.Team; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesChange() | |||||
{ | { | ||||
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex); | this.setEnabled(g_NewGameSettings.map.type != "scenario"); | ||||
if (!pData) | this.setSelectedValue(g_NewGameSettings.playerTeam.values[this.playerIndex]); | ||||
return; | |||||
if (pData.Team === undefined) | |||||
{ | |||||
pData.Team = this.NoTeamId; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesBatchChange() | |||||
{ | |||||
let pData = this.gameSettingsControl.getPlayerData(g_GameAttributes, this.playerIndex); | |||||
if (!pData) | |||||
return; | |||||
this.setEnabled(g_GameAttributes.mapType != "scenario"); | |||||
this.setSelectedValue(pData.Team); | |||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
g_GameAttributes.settings.PlayerData[this.playerIndex].Team = itemIdx - 1; | g_NewGameSettings.playerTeam.setValue(this.playerIndex, itemIdx - 1); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
PlayerSettingControls.PlayerTeam.prototype.Tooltip = | PlayerSettingControls.PlayerTeam.prototype.Tooltip = | ||||
translate("Select player's team."); | translate("Select player's team."); | ||||
PlayerSettingControls.PlayerTeam.prototype.NoTeam = | PlayerSettingControls.PlayerTeam.prototype.NoTeam = | ||||
translateWithContext("team", "None"); | translateWithContext("team", "None"); | ||||
PlayerSettingControls.PlayerTeam.prototype.NoTeamId = -1; | PlayerSettingControls.PlayerTeam.prototype.NoTeamId = -1; |
Wildfire Games · Phabricator