Differential D4232 Diff 18618 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/ResourceBalance.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/ResourceBalance.js
GameSettingControls.ResourceBalance = class ResourceBalance extends GameSettingControlDropdown | |||||
{ | |||||
constructor(...args) | |||||
{ | |||||
super(...args); | |||||
this.values = undefined; | |||||
g_GameSettings.resourceBalance.watch(() => this.render(), ["value", "data"]); | |||||
this.render(); | |||||
} | |||||
onHoverChange() | |||||
{ | |||||
this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; | |||||
} | |||||
render() | |||||
{ | |||||
this.setHidden(!g_GameSettings.resourceBalance.data); | |||||
if (!g_GameSettings.resourceBalance.data) | |||||
return; | |||||
this.values = prepareForDropdown([ | |||||
...g_GameSettings.resourceBalance.data.map(item => ({ | |||||
"Id": item.Id, | |||||
"Name": translate(item.Name), | |||||
"Description": translate(item.Description) | |||||
})) | |||||
]); | |||||
this.dropdown.list = this.values.Name; | |||||
this.dropdown.list_data = this.values.Id; | |||||
this.setSelectedValue(g_GameSettings.resourceBalance.value); | |||||
} | |||||
getAutocompleteEntries() | |||||
{ | |||||
return this.values && this.values.Name.slice(1); | |||||
} | |||||
onSelectionChange(itemIdx) | |||||
{ | |||||
g_GameSettings.resourceBalance.setValue(this.values.Id[itemIdx]); | |||||
this.gameSettingsController.setNetworkInitAttributes(); | |||||
} | |||||
}; | |||||
GameSettingControls.ResourceBalance.prototype.TitleCaption = | |||||
translate("Resource balance"); | |||||
GameSettingControls.ResourceBalance.prototype.Tooltip = | |||||
translate("Select how resource balance around players should be done"); | |||||
GameSettingControls.ResourceBalance.prototype.AutocompleteOrder = 0; |
Wildfire Games · Phabricator