Differential D4039 Diff 17917 ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapType.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapType.js
/** | /** | ||||
* Maptype design: | * Maptype design: | ||||
* Scenario maps have fixed terrain and all settings predetermined. | * Scenario maps have fixed terrain and all settings predetermined. | ||||
* Skirmish maps have fixed terrain, playercount but settings are free. | * Skirmish maps have fixed terrain, playercount but settings are free. | ||||
* For random maps, settings are fully determined by the player and the terrain is generated based on them. | * For random maps, settings are fully determined by the player and the terrain is generated based on them. | ||||
*/ | */ | ||||
GameSettingControls.MapType = class MapType extends GameSettingControlDropdown | GameSettingControls.MapType = class MapType extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.dropdown.list = g_MapTypes.Title; | this.dropdown.list = g_MapTypes.Title; | ||||
this.dropdown.list_data = g_MapTypes.Name; | this.dropdown.list_data = g_MapTypes.Name; | ||||
g_GameSettings.map.watch(() => this.render(), ["type"]); | |||||
this.render(); | |||||
} | } | ||||
onLoad() | onSettingsLoaded() | ||||
{ | |||||
if (this.gameSettingsController.guiData.lockSettings?.map) | |||||
this.setEnabled(false); | |||||
else | |||||
{ | { | ||||
g_GameSettings.map.watch(() => this.render(), ["type"]); | |||||
// Select a default map type if none are currently chosen. | // Select a default map type if none are currently chosen. | ||||
// This in cascade will select a default filter and a default map. | // This in cascade will select a default filter and a default map. | ||||
if (!g_GameSettings.map.type) | if (!g_GameSettings.map.type) | ||||
g_GameSettings.map.setType(g_MapTypes.Name[g_MapTypes.Default]); | g_GameSettings.map.setType(g_MapTypes.Name[g_MapTypes.Default]); | ||||
} | } | ||||
this.render(); | |||||
} | |||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = g_MapTypes.Description[this.dropdown.hovered] || this.Tooltip; | this.dropdown.tooltip = g_MapTypes.Description[this.dropdown.hovered] || this.Tooltip; | ||||
} | } | ||||
render() | render() | ||||
{ | { | ||||
if (!this.enabled) | |||||
{ | |||||
if (!this.hidden) | |||||
this.setHidden(true); | |||||
return; | |||||
} | |||||
this.setSelectedValue(g_GameSettings.map.type); | this.setSelectedValue(g_GameSettings.map.type); | ||||
} | } | ||||
getAutocompleteEntries() | getAutocompleteEntries() | ||||
{ | { | ||||
return g_MapTypes.Title; | return g_MapTypes.Title; | ||||
} | } | ||||
Show All 14 Lines |
Wildfire Games · Phabricator