mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 06:43:58 -07:00
It is possible to modify sizes by setting the properties directly. (Without having to create a copy of it) This allows to shorten those passages quite a bit without any functional change.
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
MapBrowserPageControls.prototype.MapDescription = class
|
|
{
|
|
constructor(mapBrowserPage, gridBrowser)
|
|
{
|
|
this.ImageRatio = 4 / 3;
|
|
|
|
this.mapBrowserPage = mapBrowserPage;
|
|
this.gridBrowser = gridBrowser;
|
|
this.mapCache = mapBrowserPage.mapCache;
|
|
|
|
this.mapBrowserSelectedName = Engine.GetGUIObjectByName("mapBrowserSelectedName");
|
|
this.mapBrowserSelectedPreview = Engine.GetGUIObjectByName("mapBrowserSelectedPreview");
|
|
this.mapBrowserSelectedDescription = Engine.GetGUIObjectByName("mapBrowserSelectedDescription");
|
|
|
|
const computedSize = this.mapBrowserSelectedPreview.getComputedSize();
|
|
const top = this.mapBrowserSelectedName.size.bottom;
|
|
const height = Math.floor((computedSize.right - computedSize.left) / this.ImageRatio);
|
|
|
|
this.mapBrowserSelectedPreview.size.top = top;
|
|
this.mapBrowserSelectedPreview.size.bottom = top + height;
|
|
this.mapBrowserSelectedDescription.size.top = top + height + 10;
|
|
|
|
gridBrowser.registerSelectionChangeHandler(this.onSelectionChange.bind(this));
|
|
}
|
|
|
|
onSelectionChange()
|
|
{
|
|
const 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.MapFiltering.getSelectedMapType(),
|
|
map.file);
|
|
}
|
|
};
|