Differential D1703 Diff 11331 binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/Controls/MapDescription.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Pages/MapBrowserPage/Controls/MapDescription.js
- This file was added.
MapBrowserPageControls.MapDescription = class | |||||
{ | |||||
constructor(mapBrowserPage, gridBrowser, setupWindow) | |||||
{ | |||||
this.mapBrowserPage = mapBrowserPage; | |||||
this.gridBrowser = gridBrowser; | |||||
this.mapCache = setupWindow.controls.mapCache; | |||||
this.mapBrowserSelectedName = Engine.GetGUIObjectByName("mapBrowserSelectedName"); | |||||
this.mapBrowserSelectedPreview = Engine.GetGUIObjectByName("mapBrowserSelectedPreview"); | |||||
this.mapBrowserSelectedDescription = Engine.GetGUIObjectByName("mapBrowserSelectedDescription"); | |||||
let computedSize = this.mapBrowserSelectedPreview.getComputedSize(); | |||||
let top = this.mapBrowserSelectedName.size.bottom; | |||||
let height = Math.floor((computedSize.right - computedSize.left) / this.ImageRatio); | |||||
{ | |||||
let size = this.mapBrowserSelectedPreview.size; | |||||
size.top = top; | |||||
size.bottom = top + height; | |||||
this.mapBrowserSelectedPreview.size = size; | |||||
} | |||||
{ | |||||
let size = this.mapBrowserSelectedDescription.size; | |||||
size.top = top + height + 10; | |||||
this.mapBrowserSelectedDescription.size = size; | |||||
} | |||||
gridBrowser.registerSelectionChangeHandler(this.onSelectionChange.bind(this)); | |||||
} | |||||
onSelectionChange() | |||||
{ | |||||
let map = this.gridBrowser.mapList[this.gridBrowser.selected]; | |||||
if (!map) | |||||
return; | |||||
this.mapBrowserSelectedName.caption = map ? map.name : ""; | |||||
this.mapBrowserSelectedDescription.caption = map ? map.description : ""; | |||||
this.mapBrowserSelectedPreview.sprite = | |||||
this.mapCache.getMapPreview( | |||||
this.mapBrowserPage.controls.MapType.getSelected(), | |||||
map.file); | |||||
} | |||||
}; | |||||
MapBrowserPageControls.MapDescription.prototype.ImageRatio = 4 / 3; |
Wildfire Games · Phabricator