Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/WorldPopulationCap.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/WorldPopulationCap.js
GameSettingControls.WorldPopulationCap = class extends GameSettingControlDropdown | GameSettingControls.WorldPopulationCap = class extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.dropdown.list = g_WorldPopulationCapacities.Title; | this.dropdown.list = g_WorldPopulationCapacities.Title; | ||||
this.dropdown.list_data = g_WorldPopulationCapacities.Population; | this.dropdown.list_data = g_WorldPopulationCapacities.Population; | ||||
this.sprintfArgs = {}; | this.sprintfArgs = {}; | ||||
} | |||||
onMapChange(mapData) | |||||
{ | |||||
let mapValue; | |||||
if (mapData && | |||||
mapData.settings && | |||||
mapData.settings.WorldPopulationCap !== undefined) | |||||
mapValue = mapData.settings.WorldPopulationCap; | |||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.WorldPopulationCap) | |||||
{ | |||||
g_GameAttributes.settings.WorldPopulationCap = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
this.setEnabled(g_GameAttributes.mapType != "scenario"); | |||||
} | |||||
onGameAttributesChange() | g_NewGameSettings.population.watch(() => this.render(), ["useWorldPop", "cap"]); | ||||
{ | g_NewGameSettings.map.watch(() => this.render(), ["type"]); | ||||
if (g_GameAttributes.settings.WorldPopulation) | this.render(); | ||||
{ | |||||
this.setHidden(false); | |||||
if (g_GameAttributes.settings.WorldPopulationCap === undefined) | |||||
{ | |||||
g_GameAttributes.settings.WorldPopulationCap = g_WorldPopulationCapacities.Population[g_WorldPopulationCapacities.Default]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
this.setHidden(true); | |||||
g_GameAttributes.settings.WorldPopulationCap = undefined; | |||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
this.setSelectedValue(g_GameAttributes.settings.WorldPopulationCap); | this.setEnabled(g_NewGameSettings.map.type != "scenario"); | ||||
this.setHidden(!g_NewGameSettings.population.useWorldPop); | |||||
this.setSelectedValue(g_NewGameSettings.population.cap); | |||||
} | } | ||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
let tooltip = this.Tooltip; | let tooltip = this.Tooltip; | ||||
if (this.dropdown.hovered != -1) | if (this.dropdown.hovered != -1) | ||||
{ | { | ||||
let popCap = g_WorldPopulationCapacities.Population[this.dropdown.hovered]; | let popCap = g_WorldPopulationCapacities.Population[this.dropdown.hovered]; | ||||
if (popCap >= this.WorldPopulationCapacityRecommendation) | if (popCap >= this.WorldPopulationCapacityRecommendation) | ||||
{ | { | ||||
this.sprintfArgs.popCap = popCap; | this.sprintfArgs.popCap = popCap; | ||||
tooltip = setStringTags(sprintf(this.HoverTooltip, this.sprintfArgs), this.HoverTags); | tooltip = setStringTags(sprintf(this.HoverTooltip, this.sprintfArgs), this.HoverTags); | ||||
} | } | ||||
} | } | ||||
this.dropdown.tooltip = tooltip; | this.dropdown.tooltip = tooltip; | ||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
g_GameAttributes.settings.WorldPopulationCap = g_WorldPopulationCapacities.Population[itemIdx]; | g_NewGameSettings.population.setPopCap(true, g_WorldPopulationCapacities.Population[itemIdx]); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.WorldPopulationCap.prototype.TitleCaption = | GameSettingControls.WorldPopulationCap.prototype.TitleCaption = | ||||
translate("World Population Cap"); | translate("World Population Cap"); | ||||
GameSettingControls.WorldPopulationCap.prototype.Tooltip = | GameSettingControls.WorldPopulationCap.prototype.Tooltip = | ||||
Show All 13 Lines |
Wildfire Games · Phabricator