Differential D3243 Diff 16503 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/TriggerDifficulty.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/TriggerDifficulty.js
GameSettingControls.TriggerDifficulty = class extends GameSettingControlDropdown | GameSettingControls.TriggerDifficulty = class TriggerDifficulty extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.values = undefined; | this.values = undefined; | ||||
g_NewGameSettings.triggerDifficulty.watch(() => this.render(), ["value", "available"]); | |||||
this.render(); | |||||
} | } | ||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = | this.dropdown.tooltip = | ||||
this.values && this.values.Tooltip[this.dropdown.hovered] || | this.values && this.values.Tooltip[this.dropdown.hovered] || | ||||
this.Tooltip; | this.Tooltip; | ||||
} | } | ||||
onMapChange(mapData) | render() | ||||
{ | { | ||||
let available = mapData && mapData.settings && mapData.settings.SupportedTriggerDifficulties || undefined; | this.setHidden(!g_NewGameSettings.triggerDifficulty.available); | ||||
this.setHidden(!available); | if (!g_NewGameSettings.triggerDifficulty.available) | ||||
if (available) | |||||
{ | { | ||||
Engine.ProfileStart("updateTriggerDifficultyList"); | this.gameSettingsControl.updateGameAttributes(); | ||||
let values = g_Settings.TriggerDifficulties; | return; | ||||
if (Array.isArray(available.Values)) | } | ||||
values = values.filter(diff => available.Values.indexOf(diff.Name) != -1); | |||||
this.values = prepareForDropdown(values); | this.values = prepareForDropdown(g_NewGameSettings.triggerDifficulty.getAvailableSettings()); | ||||
this.dropdown.list = this.values.Title; | this.dropdown.list = this.values.Title; | ||||
this.dropdown.list_data = this.values.Difficulty; | this.dropdown.list_data = this.values.Difficulty; | ||||
if (mapData.settings.TriggerDifficulty && | this.setSelectedValue(g_NewGameSettings.triggerDifficulty.value); | ||||
this.values.Difficulty.indexOf(mapData.settings.TriggerDifficulty) != -1) | |||||
g_GameAttributes.settings.TriggerDifficulty = mapData.settings.TriggerDifficulty; | |||||
Engine.ProfileStop(); | |||||
} | |||||
else | |||||
{ | |||||
this.values = undefined; | |||||
this.defaultValue = undefined; | |||||
} | |||||
} | |||||
onGameAttributesChange() | |||||
{ | |||||
if (!g_GameAttributes.mapType) | |||||
return; | |||||
if (this.values) | |||||
{ | |||||
if (this.values.Difficulty.indexOf(g_GameAttributes.settings.TriggerDifficulty || undefined) == -1) | |||||
{ | |||||
g_GameAttributes.settings.TriggerDifficulty = this.values.Difficulty[this.values.Default]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else if (g_GameAttributes.settings.TriggerDifficulty !== undefined) | |||||
{ | |||||
delete g_GameAttributes.settings.TriggerDifficulty; | |||||
this.gameSettingsControl.updateGameAttributes(); | this.gameSettingsControl.updateGameAttributes(); | ||||
} | } | ||||
} | |||||
onGameAttributesBatchChange() | |||||
{ | |||||
if (this.values) | |||||
this.setSelectedValue(g_GameAttributes.settings.TriggerDifficulty); | |||||
} | |||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
g_GameAttributes.settings.TriggerDifficulty = this.values.Difficulty[itemIdx]; | g_NewGameSettings.triggerDifficulty.setValue(this.values.Difficulty[itemIdx]); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.TriggerDifficulty.prototype.TitleCaption = | GameSettingControls.TriggerDifficulty.prototype.TitleCaption = | ||||
translate("Difficulty"); | translate("Difficulty"); | ||||
GameSettingControls.TriggerDifficulty.prototype.Tooltip = | GameSettingControls.TriggerDifficulty.prototype.Tooltip = | ||||
translate("Select the difficulty of this scenario."); | translate("Select the difficulty of this scenario."); |
Wildfire Games · Phabricator