Differential D4039 Diff 17917 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js
GameSettingControls.MapSelection = class MapSelection extends GameSettingControlDropdown | GameSettingControls.MapSelection = class MapSelection extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.values = undefined; | this.values = undefined; | ||||
g_GameSettings.map.watch(() => this.render(), ["map"]); | |||||
g_GameSettings.map.watch(() => this.updateMapList(), ["type"]); | |||||
this.gameSettingsController.guiData.mapFilter.watch(() => this.updateMapList(), ["filter"]); | |||||
this.randomItem = { | this.randomItem = { | ||||
"file": this.RandomMapId, | "file": this.RandomMapId, | ||||
"name": setStringTags(this.RandomMapCaption, this.RandomItemTags), | "name": setStringTags(this.RandomMapCaption, this.RandomItemTags), | ||||
"description": this.RandomMapDescription | "description": this.RandomMapDescription | ||||
}; | }; | ||||
} | } | ||||
onSettingsLoaded() | |||||
{ | |||||
if (this.gameSettingsController.guiData.lockSettings?.map) | |||||
{ | |||||
if (!g_GameSettings.map) | |||||
{ | |||||
error("Map setting locked but no map is selected"); | |||||
throw new Error(); | |||||
} | |||||
this.setTitle(translate("Map")); | |||||
this.setEnabled(false); | |||||
// Watch only for map change. | |||||
g_GameSettings.map.watch(() => this.render(), ["map"]); | |||||
} | |||||
else | |||||
{ | |||||
g_GameSettings.map.watch(() => this.render(), ["map"]); | |||||
g_GameSettings.map.watch(() => this.updateMapList(), ["type"]); | |||||
this.gameSettingsController.guiData.mapFilter.watch(() => this.updateMapList(), ["filter"]); | |||||
this.updateMapList(); | |||||
} | |||||
this.render(); | |||||
} | |||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = this.values.description[this.dropdown.hovered] || this.Tooltip; | this.dropdown.tooltip = this.values.description[this.dropdown.hovered] || this.Tooltip; | ||||
} | } | ||||
render() | render() | ||||
{ | { | ||||
// Can happen with bad matchsettings | if (!this.enabled) | ||||
{ | |||||
const mapData = this.mapCache.getMapData(g_GameSettings.map.mapType, g_GameSettings.map.map); | |||||
this.label.caption = g_GameSettings.mapName.value || mapData.settings.Name; | |||||
return; | |||||
} | |||||
if (!this.values) | |||||
return; | |||||
// We can end up with incorrect map selection when dependent settings change. | |||||
if (this.values.file.indexOf(g_GameSettings.map.map) === -1) | if (this.values.file.indexOf(g_GameSettings.map.map) === -1) | ||||
{ | { | ||||
g_GameSettings.map.selectMap(this.values.file[this.values.Default]); | g_GameSettings.map.selectMap(this.values.file[this.values.Default]); | ||||
return; | return; | ||||
} | } | ||||
this.setSelectedValue(g_GameSettings.map.map); | this.setSelectedValue(g_GameSettings.map.map); | ||||
} | } | ||||
updateMapList() | updateMapList() | ||||
{ | { | ||||
Engine.ProfileStart("updateMapSelectionList"); | Engine.ProfileStart("updateMapSelectionList"); | ||||
if (!g_GameSettings.map.type) | if (!g_GameSettings.map.type) | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator