Differential D3243 Diff 16556 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapFilter.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapFilter.js
GameSettingControls.MapFilter = class extends GameSettingControlDropdown | GameSettingControls.MapFilter = class MapFilter extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.values = undefined; | this.values = undefined; | ||||
this.previousMapType = undefined; | |||||
g_GameSettings.map.watch(() => this.checkMapTypeChange(), ["type"]); | |||||
} | } | ||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; | this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; | ||||
} | } | ||||
onGameAttributesChange() | |||||
{ | |||||
this.checkMapTypeChange(); | |||||
if (this.values) | |||||
{ | |||||
if (this.values.Name.indexOf(g_GameAttributes.mapFilter || undefined) == -1) | |||||
{ | |||||
g_GameAttributes.mapFilter = this.values.Name[this.values.Default]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
else if (g_GameAttributes.mapFilter !== undefined) | |||||
{ | |||||
delete g_GameAttributes.mapFilter; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
checkMapTypeChange() | checkMapTypeChange() | ||||
{ | { | ||||
if (!g_GameAttributes.mapType || this.previousMapType == g_GameAttributes.mapType) | if (!g_GameSettings.map.type) | ||||
return; | return; | ||||
Engine.ProfileStart("updateMapFilterList"); | |||||
this.previousMapType = g_GameAttributes.mapType; | |||||
let values = prepareForDropdown( | let values = prepareForDropdown( | ||||
this.mapFilters.getAvailableMapFilters( | this.mapFilters.getAvailableMapFilters( | ||||
g_GameAttributes.mapType)); | g_GameSettings.map.type)); | ||||
if (values.Name.length) | if (values.Name.length) | ||||
{ | { | ||||
this.dropdown.list = values.Title; | this.dropdown.list = values.Title; | ||||
this.dropdown.list_data = values.Name; | this.dropdown.list_data = values.Name; | ||||
this.values = values; | this.values = values; | ||||
} | } | ||||
else | else | ||||
this.values = undefined; | this.values = undefined; | ||||
this.setHidden(!this.values); | if (this.values && this.values.Name.indexOf(this.gameSettingsControl.guiData.mapFilter.filter) === -1) | ||||
Engine.ProfileStop(); | { | ||||
this.gameSettingsControl.guiData.mapFilter.filter = this.values.Name[this.values.Default]; | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | |||||
} | } | ||||
// Index may have changed, reset. | |||||
this.setSelectedValue(this.gameSettingsControl.guiData.mapFilter.filter); | |||||
onGameAttributesBatchChange() | this.setHidden(!this.values); | ||||
{ | |||||
if (this.values && g_GameAttributes.mapFilter) | |||||
this.setSelectedValue(g_GameAttributes.mapFilter); | |||||
} | } | ||||
getAutocompleteEntries() | getAutocompleteEntries() | ||||
{ | { | ||||
return this.values && this.values.Title; | return this.values && this.values.Title; | ||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
if (this.values) | this.gameSettingsControl.guiData.mapFilter.filter = this.values.Name[itemIdx]; | ||||
{ | |||||
g_GameAttributes.mapFilter = this.values.Name[itemIdx]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesFinalize() | |||||
{ | |||||
// This setting is only relevant in the game-setup stage. | |||||
delete g_GameAttributes.mapFilter; | |||||
} | } | ||||
}; | }; | ||||
GameSettingControls.MapFilter.prototype.TitleCaption = | GameSettingControls.MapFilter.prototype.TitleCaption = | ||||
translate("Map Filter"); | translate("Map Filter"); | ||||
GameSettingControls.MapFilter.prototype.Tooltip = | GameSettingControls.MapFilter.prototype.Tooltip = | ||||
translate("Select a map filter."); | translate("Select a map filter."); | ||||
GameSettingControls.MapFilter.prototype.AutocompleteOrder = 0; | GameSettingControls.MapFilter.prototype.AutocompleteOrder = 0; |
Wildfire Games · Phabricator