Differential D2483 Diff 10834 binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/PlayerCount.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/PlayerCount.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
GameSettingControls.PlayerCount = class extends GameSettingControlDropdown | |||||
{ | |||||
constructor(...args) | |||||
{ | |||||
super(...args); | |||||
this.values = Array.from( | |||||
new Array(g_MaxPlayers), | |||||
(v, i) => i + 1); | |||||
this.dropdown.list = this.values; | |||||
this.dropdown.list_data = this.values; | |||||
} | |||||
onMapChange(mapData) | |||||
{ | |||||
if (mapData && | |||||
mapData.settings && | |||||
mapData.settings.PlayerData && | |||||
mapData.settings.PlayerData.length != g_GameAttributes.settings.PlayerData.length) | |||||
{ | |||||
this.onSelectionChange(this.values.indexOf(mapData.settings.PlayerData.length)); | |||||
} | |||||
this.setEnabled(g_GameAttributes.mapType == "random"); | |||||
} | |||||
onGameAttributesChange() | |||||
{ | |||||
this.setSelectedValue(g_GameAttributes.settings.PlayerData.length); | |||||
} | |||||
onSelectionChange(itemIdx) | |||||
{ | |||||
let length = this.values[itemIdx]; | |||||
if (g_GameAttributes.settings.PlayerData.length == length) | |||||
return; | |||||
g_GameAttributes.settings.PlayerData.length = length; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | |||||
this.playerAssignmentsControl.unassignInvalidPlayers(); | |||||
} | |||||
}; | |||||
GameSettingControls.PlayerCount.prototype.TitleCaption = | |||||
translate("Number of Players"); | |||||
GameSettingControls.PlayerCount.prototype.Tooltip = | |||||
translate("Select number of players."); | |||||
/** | |||||
* This number is used when selecting the random map type, which doesn't provide PlayerData. | |||||
*/ | |||||
GameSettingControls.PlayerCount.prototype.DefaultPlayerCount = 4; |
Wildfire Games · Phabricator