Differential D3243 Diff 16276 binaries/data/mods/public/gui/gamesettings/attributes/TriggerDifficulty.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesettings/attributes/TriggerDifficulty.js
- This file was added.
GameSettings.prototype.Attributes.TriggerDifficulty = class extends GameSetting | |||||
{ | |||||
Init() | |||||
{ | |||||
this.difficulties = loadSettingValuesFile("trigger_difficulties.json"); | |||||
this.available = undefined; | |||||
this.value = undefined; | |||||
this.settings.map.watch(() => this.onMapChange(), ["map"]); | |||||
} | |||||
LegacySerialize(attribs) | |||||
{ | |||||
if (this.available) | |||||
attribs.settings.TriggerDifficulty = this.value; | |||||
} | |||||
LegacyDeserialize(attribs) | |||||
{ | |||||
if (!!this.getLegacySetting(attribs, "TriggerDifficulty")) | |||||
this.setValue(this.getLegacySetting(attribs, "TriggerDifficulty")); | |||||
} | |||||
getAvailableSettings() | |||||
{ | |||||
return this.difficulties.filter(x => this.available.indexOf(x.Name) !== -1); | |||||
} | |||||
onMapChange() | |||||
{ | |||||
if (!this.getMapSetting("SupportedTriggerDifficulties")) | |||||
{ | |||||
this.value = undefined; | |||||
this.available = undefined; | |||||
return; | |||||
} | |||||
// TODO: should probably validate that they fit one of the known schemes. | |||||
this.available = this.getMapSetting("SupportedTriggerDifficulties").Values; | |||||
this.value = this.difficulties.find(x => x.Default && this.available.indexOf(x.Name) !== -1).Difficulty; | |||||
} | |||||
setValue(val) | |||||
{ | |||||
this.value = val; | |||||
} | |||||
getData() | |||||
{ | |||||
if (!this.value) | |||||
return undefined; | |||||
return this.difficulties[this.value]; | |||||
} | |||||
}; |
Wildfire Games · Phabricator