Differential D2483 Diff 10834 binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/RelicCount.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/RelicCount.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
GameSettingControls.RelicCount = class extends GameSettingControlDropdown | |||||
{ | |||||
constructor(...args) | |||||
{ | |||||
super(...args); | |||||
this.values = Array.from(new Array(g_CivData.length), (v, i) => i + 1); | |||||
this.dropdown.list = this.values; | |||||
this.dropdown.list_data = this.values; | |||||
} | |||||
onMapChange(mapData) | |||||
{ | |||||
this.setEnabled(g_GameAttributes.mapType != "scenario"); | |||||
let mapValue = | |||||
mapData && | |||||
mapData.settings && | |||||
mapData.settings.VictoryConditions && | |||||
mapData.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1 && | |||||
mapData.settings.RelicCount || undefined; | |||||
if (mapValue === undefined || mapValue == g_GameAttributes.settings.RelicCount) | |||||
return; | |||||
if (!g_GameAttributes.settings.VictoryConditions) | |||||
g_GameAttributes.settings.VictoryConditions = []; | |||||
if (g_GameAttributes.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) == -1) | |||||
g_GameAttributes.settings.VictoryConditions.push(this.NameCaptureTheRelic); | |||||
g_GameAttributes.settings.RelicCount = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
onGameAttributesChange() | |||||
{ | |||||
if (!g_GameAttributes.settings.VictoryConditions) | |||||
return; | |||||
let available = g_GameAttributes.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1; | |||||
this.setHidden(!available); | |||||
if (available) | |||||
{ | |||||
if (g_GameAttributes.settings.RelicCount === undefined) | |||||
{ | |||||
g_GameAttributes.settings.RelicCount = this.DefaultRelicCount; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
this.setSelectedValue(g_GameAttributes.settings.RelicCount); | |||||
} | |||||
else if (g_GameAttributes.settings.RelicCount !== undefined) | |||||
{ | |||||
delete g_GameAttributes.settings.RelicCount; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onSelectionChange(itemIdx) | |||||
{ | |||||
g_GameAttributes.settings.RelicCount = this.values[itemIdx]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | |||||
} | |||||
}; | |||||
GameSettingControls.RelicCount.prototype.TitleCaption = | |||||
translate("Relic Count"); | |||||
GameSettingControls.RelicCount.prototype.Tooltip = | |||||
translate("Total number of relics spawned on the map. Relic victory is most realistic with only one or two relics. With greater numbers, the relics are important to capture to receive aura bonuses."); | |||||
GameSettingControls.RelicCount.prototype.NameCaptureTheRelic = | |||||
this.NameCaptureTheRelic; | |||||
GameSettingControls.RelicCount.prototype.DefaultRelicCount = 2; |
Wildfire Games · Phabricator