mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 06:43:58 -07:00
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/gui/maps
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
72 lines
1.4 KiB
JavaScript
72 lines
1.4 KiB
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;
|
|
}
|
|
|
|
submitMapSelection()
|
|
{
|
|
if (!this.allowSelection)
|
|
return;
|
|
|
|
let file = this.gridBrowser.getSelected();
|
|
let type = this.controls.MapFiltering.getSelectedMapType();
|
|
let filter = this.controls.MapFiltering.getSelectedMapFilter();
|
|
if (file)
|
|
{
|
|
type = file.mapType;
|
|
filter = file.filter;
|
|
file = file.file;
|
|
}
|
|
this.onSubmitMapSelection(
|
|
file,
|
|
type,
|
|
filter
|
|
);
|
|
this.closePage();
|
|
}
|
|
|
|
// TODO: this is mostly gamesetup specific stuff.
|
|
registerOpenPageHandler(handler)
|
|
{
|
|
this.openPageHandlers.add(handler);
|
|
}
|
|
|
|
registerClosePageHandler(handler)
|
|
{
|
|
this.closePageHandlers.add(handler);
|
|
}
|
|
|
|
openPage(allowSelection)
|
|
{
|
|
if (this.open)
|
|
return;
|
|
for (const handler of this.openPageHandlers)
|
|
handler(allowSelection);
|
|
|
|
this.allowSelection = allowSelection;
|
|
this.open = true;
|
|
}
|
|
|
|
closePage()
|
|
{
|
|
if (!this.open)
|
|
return;
|
|
for (const handler of this.closePageHandlers)
|
|
handler();
|
|
this.open = false;
|
|
}
|
|
}
|