Differential D4678 Diff 20444 ps/trunk/binaries/data/mods/public/gamesettings/attributes/VictoryConditions.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gamesettings/attributes/VictoryConditions.js
Show All 23 Lines | GameSettings.prototype.Attributes.VictoryConditions = class VictoryConditions extends GameSetting | ||||
toInitAttributes(attribs) | toInitAttributes(attribs) | ||||
{ | { | ||||
attribs.settings.VictoryConditions = Array.from(this.active); | attribs.settings.VictoryConditions = Array.from(this.active); | ||||
} | } | ||||
fromInitAttributes(attribs) | fromInitAttributes(attribs) | ||||
{ | { | ||||
let legacy = this.getLegacySetting(attribs, "VictoryConditions"); | const initAttribs = this.getLegacySetting(attribs, "VictoryConditions"); | ||||
if (legacy) | if (initAttribs) | ||||
{ | this.fromList(initAttribs); | ||||
this.disabled = new Set(); | |||||
this.active = new Set(); | |||||
for (let cond of legacy) | |||||
this._add(cond); | |||||
} | |||||
} | } | ||||
onMapChange() | onMapChange() | ||||
{ | { | ||||
if (this.settings.map.type != "scenario") | if (this.settings.map.type != "scenario") | ||||
return; | return; | ||||
// If a map specifies victory conditions, replace them all. | // If a map specifies victory conditions, replace them all. | ||||
if (!this.getMapSetting("VictoryConditions")) | const conditions = this.getMapSetting("VictoryConditions"); | ||||
if (conditions) | |||||
this.fromList(conditions); | |||||
} | |||||
fromList(conditionList) | |||||
{ | |||||
conditionList = conditionList.filter(cond => cond in this.conditions); | |||||
if (!conditionList) | |||||
return; | return; | ||||
this.disabled = new Set(); | this.disabled = new Set(); | ||||
this.active = new Set(); | this.active = new Set(); | ||||
// TODO: could be optimised. | // TODO: could be optimised. | ||||
for (let cond of this.getMapSetting("VictoryConditions")) | for (const cond of conditionList) | ||||
this._add(cond); | this._add(cond); | ||||
} | } | ||||
_reconstructDisabled(active) | _reconstructDisabled(active) | ||||
{ | { | ||||
let disabled = new Set(); | let disabled = new Set(); | ||||
for (let cond of active) | for (let cond of active) | ||||
if (this.conditions[cond].DisabledWhenChecked) | if (this.conditions[cond].DisabledWhenChecked) | ||||
Show All 36 Lines |
Wildfire Games · Phabricator