Differential D3243 Diff 16503 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Sliders/RelicCount.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Sliders/RelicCount.js
GameSettingControls.RelicCount = class extends GameSettingControlSlider | GameSettingControls.RelicCount = class RelicCount extends GameSettingControlSlider | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.sprintfValue = {}; | this.sprintfValue = {}; | ||||
this.available = false; | this.available = false; | ||||
} | |||||
onMapChange(mapData) | |||||
{ | |||||
this.setEnabled(g_GameAttributes.mapType != "scenario"); | |||||
let mapValue; | |||||
if (mapData && | |||||
mapData.settings && | |||||
mapData.settings.VictoryConditions && | |||||
mapData.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1 && | |||||
mapData.settings.RelicCount !== undefined) | |||||
mapValue = mapData.settings.RelicCount; | |||||
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; | g_NewGameSettings.relic.watch(() => this.render(), ["count", "available"]); | ||||
this.gameSettingsControl.updateGameAttributes(); | g_NewGameSettings.map.watch(() => this.render(), ["type"]); | ||||
this.render(); | |||||
} | } | ||||
onGameAttributesChange() | render() | ||||
{ | { | ||||
if (!g_GameAttributes.settings.VictoryConditions) | this.setHidden(!g_NewGameSettings.relic.available); | ||||
return; | this.setEnabled(g_NewGameSettings.map.type != "scenario"); | ||||
this.available = g_GameAttributes.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1; | if (g_NewGameSettings.relic.available) | ||||
if (this.available) | |||||
{ | |||||
if (g_GameAttributes.settings.RelicCount === undefined) | |||||
{ | |||||
g_GameAttributes.settings.RelicCount = this.DefaultValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else if (g_GameAttributes.settings.RelicCount !== undefined) | |||||
{ | { | ||||
delete g_GameAttributes.settings.RelicCount; | let value = g_NewGameSettings.relic.count; | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesBatchChange() | |||||
{ | |||||
this.setHidden(!this.available); | |||||
if (this.available) | |||||
{ | |||||
let value = Math.round(g_GameAttributes.settings.RelicCount); | |||||
this.sprintfValue.number = value; | this.sprintfValue.number = value; | ||||
this.setSelectedValue( | this.setSelectedValue( | ||||
g_GameAttributes.settings.RelicCount, | g_NewGameSettings.relic.count, | ||||
value == 0 ? this.InstantVictory : sprintf(this.CaptionRelicCount(value), this.sprintfValue)); | value == 0 ? this.InstantVictory : sprintf(this.CaptionRelicCount(value), this.sprintfValue)); | ||||
} | } | ||||
} | } | ||||
onValueChange(value) | onValueChange(value) | ||||
{ | { | ||||
g_GameAttributes.settings.RelicCount = value; | g_NewGameSettings.relic.setCount(value); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
onGameAttributesFinalize() | |||||
{ | |||||
if (this.available) | |||||
g_GameAttributes.settings.RelicCount = Math.round(g_GameAttributes.settings.RelicCount); | |||||
} | |||||
}; | }; | ||||
GameSettingControls.RelicCount.prototype.TitleCaption = | GameSettingControls.RelicCount.prototype.TitleCaption = | ||||
translate("Relic Count"); | translate("Relic Count"); | ||||
GameSettingControls.RelicCount.prototype.CaptionRelicCount = | GameSettingControls.RelicCount.prototype.CaptionRelicCount = | ||||
relicCount => translatePlural("%(number)s relic", "%(number)s relics", relicCount); | relicCount => translatePlural("%(number)s relic", "%(number)s relics", relicCount); | ||||
GameSettingControls.RelicCount.prototype.Tooltip = | 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."); | 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 = | GameSettingControls.RelicCount.prototype.NameCaptureTheRelic = | ||||
"capture_the_relic"; | "capture_the_relic"; | ||||
GameSettingControls.RelicCount.prototype.MinValue = 1; | GameSettingControls.RelicCount.prototype.MinValue = 1; | ||||
GameSettingControls.RelicCount.prototype.MaxValue = Object.keys(g_CivData).length; | GameSettingControls.RelicCount.prototype.MaxValue = Object.keys(g_CivData).length; | ||||
GameSettingControls.RelicCount.prototype.DefaultValue = 2; |
Wildfire Games · Phabricator