Differential D3041 Diff 13661 binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/Landscape.js
GameSettingControls.Landscape = class extends GameSettingControlDropdown | GameSettingControls.Landscape = class extends GameSettingControlDropdown | ||||
{ | { | ||||
constructor(...args) | constructor(...args) | ||||
{ | { | ||||
super(...args); | super(...args); | ||||
this.values = undefined; | this.values = undefined; | ||||
this.lastLandscape = undefined; | |||||
this.mapData = undefined; | this.mapData = undefined; | ||||
} | } | ||||
onHoverChange() | onHoverChange() | ||||
{ | { | ||||
this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; | this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; | ||||
} | } | ||||
Show All 22 Lines | if (mapData && mapData.settings && mapData.settings.Landscapes) | ||||
]); | ]); | ||||
this.dropdown.list = this.values.Name; | this.dropdown.list = this.values.Name; | ||||
this.dropdown.list_data = this.values.Id; | this.dropdown.list_data = this.values.Id; | ||||
} | } | ||||
else | else | ||||
this.values = undefined; | this.values = undefined; | ||||
this.lastLandscape = undefined; | |||||
this.setHidden(!this.values); | this.setHidden(!this.values); | ||||
} | } | ||||
translateItem(item) | translateItem(item) | ||||
{ | { | ||||
return { | return { | ||||
"Id": item.Id, | "Id": item.Id, | ||||
"Name": translate(item.Name), | "Name": translate(item.Name), | ||||
"Description": translate(item.Description), | "Description": translate(item.Description), | ||||
"Preview": item.Preview | "Preview": item.Preview | ||||
}; | }; | ||||
} | } | ||||
onGameAttributesChange() | onGameAttributesChange() | ||||
{ | { | ||||
if (this.values) | if (this.values) | ||||
{ | { | ||||
if (this.values.Id.indexOf(g_GameAttributes.settings.Landscape || undefined) == -1) | if (this.values.Id.indexOf(g_GameAttributes.settings.Landscape || undefined) == -1) | ||||
{ | { | ||||
g_GameAttributes.settings.Landscape = "random"; | g_GameAttributes.settings.Landscape = "random"; | ||||
this.gameSettingsControl.updateGameAttributes(); | this.gameSettingsControl.updateGameAttributes(); | ||||
} | } | ||||
if (this.lastLandscape != g_GameAttributes.settings.Landscape) | let landscapePreview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)]; | ||||
{ | if (!g_GameAttributes.settings.Preview || g_GameAttributes.settings.Preview != landscapePreview) | ||||
g_GameAttributes.settings.Preview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)]; | g_GameAttributes.settings.Preview = landscapePreview; | ||||
this.lastLandscape = g_GameAttributes.settings.Biome; | |||||
} | |||||
} | } | ||||
else if (g_GameAttributes.settings.Landscape !== undefined) | else if (g_GameAttributes.settings.Landscape !== undefined) | ||||
{ | { | ||||
delete g_GameAttributes.settings.Landscape; | delete g_GameAttributes.settings.Landscape; | ||||
this.gameSettingsControl.updateGameAttributes(); | this.gameSettingsControl.updateGameAttributes(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator