mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
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.
48 lines
994 B
JavaScript
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;
|
|
}
|
|
}
|