Differential D3243 Diff 16503 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSize.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSize.js
GameSettingControls.MapSize = class extends GameSettingControlDropdown | GameSettingControls.MapSize = class MapSize extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.dropdown.list = g_MapSizes.Name; | this.dropdown.list = g_MapSizes.Name; | ||||
this.dropdown.list_data = g_MapSizes.Tiles; | this.dropdown.list_data = g_MapSizes.Tiles; | ||||
g_NewGameSettings.mapSize.watch(() => this.render(), ["size", "available"]); | |||||
this.render(); | |||||
} | } | ||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = g_MapSizes.Tooltip[this.dropdown.hovered] || this.Tooltip; | this.dropdown.tooltip = g_MapSizes.Tooltip[this.dropdown.hovered] || this.Tooltip; | ||||
} | } | ||||
onMapChange(mapData) | render() | ||||
{ | |||||
let mapValue; | |||||
if (mapData && | |||||
mapData.settings && | |||||
mapData.settings.Size !== undefined) | |||||
mapValue = mapData.settings.Size; | |||||
if (g_GameAttributes.mapType == "random" && mapValue !== undefined && mapValue != g_GameAttributes.settings.Size) | |||||
{ | |||||
g_GameAttributes.settings.Size = mapValue; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | |||||
onGameAttributesChange() | |||||
{ | { | ||||
if (!g_GameAttributes.mapType || | this.setHidden(!g_NewGameSettings.mapSize.available); | ||||
!g_GameAttributes.settings) | this.setSelectedValue(g_NewGameSettings.mapSize.size); | ||||
return; | // TODO: select first entry. | ||||
let available = g_GameAttributes.mapType == "random"; | |||||
this.setHidden(!available); | |||||
if (available) | |||||
{ | |||||
if (g_GameAttributes.settings.Size === undefined) | |||||
{ | |||||
g_GameAttributes.settings.Size = g_MapSizes.Tiles[g_MapSizes.Default]; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
this.setSelectedValue(g_GameAttributes.settings.Size); | |||||
} | |||||
else if (g_GameAttributes.settings.Size !== undefined) | |||||
{ | |||||
delete g_GameAttributes.settings.Size; | |||||
this.gameSettingsControl.updateGameAttributes(); | |||||
} | |||||
} | } | ||||
getAutocompleteEntries() | getAutocompleteEntries() | ||||
{ | { | ||||
return g_MapSizes.Name; | return g_MapSizes.Name; | ||||
} | } | ||||
onSelectionChange(itemIdx) | onSelectionChange(itemIdx) | ||||
{ | { | ||||
g_GameAttributes.settings.Size = g_MapSizes.Tiles[itemIdx]; | g_NewGameSettings.mapSize.setSize(g_MapSizes.Tiles[itemIdx]); | ||||
this.gameSettingsControl.updateGameAttributes(); | |||||
this.gameSettingsControl.setNetworkGameAttributes(); | this.gameSettingsControl.setNetworkGameAttributes(); | ||||
} | } | ||||
}; | }; | ||||
GameSettingControls.MapSize.prototype.TitleCaption = | GameSettingControls.MapSize.prototype.TitleCaption = | ||||
translate("Map Size"); | translate("Map Size"); | ||||
GameSettingControls.MapSize.prototype.Tooltip = | GameSettingControls.MapSize.prototype.Tooltip = | ||||
translate("Select map size. (Larger sizes may reduce performance.)"); | translate("Select map size. (Larger sizes may reduce performance.)"); | ||||
GameSettingControls.MapSize.prototype.AutocompleteOrder = 0; | GameSettingControls.MapSize.prototype.AutocompleteOrder = 0; |
Wildfire Games · Phabricator