0ad/binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js
wraitii ae9ea5b859 Map browser, used in the gamesetup and in the main menu.
This grid-based system allows browsing all available maps at a glance,
encouraging more diversity and making it nicer to pick a map.

Moves the mapCache and the map filters controller to the gui maps/
folders, and include that folder where it is used, instead of them being
in common/ or the gamesetup.

Comments By: Freagarach
Patch By: Nani (reworked by elexis then wraitii)
Fixes #5315 (though further work, such as proper scrolling, would be
nice).

Differential Revision: https://code.wildfiregames.com/D1703
This was SVN commit r24459.
2020-12-27 15:26:19 +00:00

48 lines
994 B
JavaScript

class MapBrowser
{
constructor(mapCache, mapFilters, setupWindow = undefined)
{
this.openPageHandlers = new Set();
this.closePageHandlers = new Set();
this.mapCache = mapCache;
this.mapFilters = mapFilters;
this.mapBrowserPage = Engine.GetGUIObjectByName("mapBrowserPage");
this.mapBrowserPageDialog = Engine.GetGUIObjectByName("mapBrowserPageDialog");
this.gridBrowser = new MapGridBrowser(this, setupWindow);
this.controls = new MapBrowserPageControls(this, this.gridBrowser);
this.open = false;
}
// TODO: this is mostly gamesetup specific stuff.
registerOpenPageHandler(handler)
{
this.openPageHandlers.add(handler);
}
registerClosePageHandler(handler)
{
this.closePageHandlers.add(handler);
}
openPage()
{
if (this.open)
return;
for (let handler of this.openPageHandlers)
handler();
this.open = true;
}
closePage()
{
if (!this.open)
return;
for (let handler of this.closePageHandlers)
handler();
this.open = false;
}
}