Differential D3243 Diff 16284 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapType.js
Changeset View
Changeset View
Standalone View
Standalone View
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 extends GameSettingControlDropdown | GameSettingControls.MapType = class 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_NewGameSettings.map.watch(() => this.render(), ["type"]); | |||||
this.render(); | |||||
} | } | ||||
onHoverChange() | onLoad() | ||||
{ | { | ||||
this.dropdown.tooltip = g_MapTypes.Description[this.dropdown.hovered] || this.Tooltip; | // Select a default map type if none are currently chosen. | ||||
// This in cascade will select a default filter and a default map. | |||||
if (!g_NewGameSettings.map.type) | |||||
g_NewGameSettings.map.setType(g_MapTypes.Name[g_MapTypes.Default]); | |||||
} | } | ||||
onGameAttributesChange() | onHoverChange() | ||||
{ | |||||
if (g_MapTypes.Name.indexOf(g_GameAttributes.mapType || undefined) == -1) | |||||
{ | { | ||||
g_GameAttributes.mapType = g_MapTypes.Name[g_MapTypes.Default]; | this.dropdown.tooltip = g_MapTypes.Description[this.dropdown.hovered] || this.Tooltip; | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
onGameAttributesBatchChange() | render() | ||||
{ | { | ||||
this.setSelectedValue(g_GameAttributes.mapType); | this.setSelectedValue(g_NewGameSettings.map.type); | ||||
} | } | ||||
getAutocompleteEntries() | getAutocompleteEntries() | ||||
{ | { | ||||
return g_MapTypes.Title; | return g_MapTypes.Title; | ||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
let mapType = g_MapTypes.Name[itemIdx]; | g_NewGameSettings.map.setType(g_MapTypes.Name[itemIdx]); | ||||
if (g_GameAttributes.mapType == mapType) | |||||
return; | |||||
if (mapType == "scenario") | |||||
g_GameAttributes = { | |||||
"mapFilter": g_GameAttributes.mapFilter | |||||
}; | |||||
g_GameAttributes.mapType = mapType; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.MapType.prototype.TitleCaption = | GameSettingControls.MapType.prototype.TitleCaption = | ||||
translate("Map Type"); | translate("Map Type"); | ||||
GameSettingControls.MapType.prototype.Tooltip = | GameSettingControls.MapType.prototype.Tooltip = | ||||
translate("Select a map type."); | translate("Select a map type."); | ||||
GameSettingControls.MapType.prototype.AutocompleteOrder = 0; | GameSettingControls.MapType.prototype.AutocompleteOrder = 0; |
Wildfire Games · Phabricator