Index: binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js +++ binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js @@ -73,6 +73,10 @@ if (!g_IsController || !Engine.HasXmppClient()) return; + // Wait until a map has been selected. + if (!g_GameSettings.map.map) + return; + Engine.ProfileStart("sendRegisterGameStanza"); if (this.timer !== undefined) Index: binaries/data/mods/public/gui/maps/MapFilters.js =================================================================== --- binaries/data/mods/public/gui/maps/MapFilters.js +++ binaries/data/mods/public/gui/maps/MapFilters.js @@ -66,7 +66,10 @@ maps.push({ "file": mapPath, "name": translate(mapData.settings.Name), - "description": translate(mapData.settings.Description) + "description": translate(mapData.settings.Description), + // For convenience when filtering, store which type/filter tuple returned this map. + "mapType": mapTypeName, + "filter": filterName }); } } Index: binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js =================================================================== --- binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js +++ binaries/data/mods/public/gui/maps/mapbrowser/MapBrowser.js @@ -19,10 +19,19 @@ submitMapSelection() { + 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( - this.gridBrowser.getSelectedFile(), - this.controls.MapFiltering.getSelectedMapType(), - this.controls.MapFiltering.getSelectedMapFilter() + file, + type, + filter ); this.closePage(); } Index: binaries/data/mods/public/gui/maps/mapbrowser/controls/MapFiltering.js =================================================================== --- binaries/data/mods/public/gui/maps/mapbrowser/controls/MapFiltering.js +++ binaries/data/mods/public/gui/maps/mapbrowser/controls/MapFiltering.js @@ -22,7 +22,10 @@ onOpenPage() { // setTimeout avoids having the hotkey key inserted into the input text. - setTimeout(() => this.searchBox.focus(), 0); + setTimeout(() => { + this.searchBox.control.caption = ""; + this.searchBox.focus(); + }, 0); } onClosePage() Index: binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowser.js =================================================================== --- binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowser.js +++ binaries/data/mods/public/gui/maps/mapbrowser/grid/MapGridBrowser.js @@ -37,9 +37,9 @@ Engine.UnsetGlobalHotkey(this.HotkeyConfigPrevious, "Press"); } - getSelectedFile() + getSelected() { - return this.mapList[this.selected].file || undefined; + return this.mapList[this.selected] || undefined; } select(mapFile) @@ -50,35 +50,36 @@ updateMapList() { - let selectedMap = - this.mapList[this.selected] && - this.mapList[this.selected].file || undefined; + const selectedMap = this.mapList[this.selected]?.file; + const mapType = this.mapBrowserPage.controls.MapFiltering.getSelectedMapType(); + const mapFilter = this.mapBrowserPage.controls.MapFiltering.getSelectedMapFilter(); + const filterText = this.mapBrowserPage.controls.MapFiltering.getSearchText(); + const randomMap = { + "file": "random", + "name": translate("Random"), + "description": translate("Pick a map at random."), + "mapType": "random", + "filter": "default" + }; - let mapList = this.mapFilters.getFilteredMaps( - this.mapBrowserPage.controls.MapFiltering.getSelectedMapType(), - this.mapBrowserPage.controls.MapFiltering.getSelectedMapFilter()); + let mapList = this.mapFilters.getFilteredMaps(mapType, mapFilter); + + if (mapType === "random") + mapList.unshift(randomMap); - let filterText = this.mapBrowserPage.controls.MapFiltering.getSearchText(); if (filterText) { mapList = MatchSort.get(filterText, mapList, "name"); if (!mapList.length) { - let filter = "all"; + const filter = "all"; + mapList.push(randomMap); for (let type of g_MapTypes.Name) for (let map of this.mapFilters.getFilteredMaps(type, filter)) mapList.push(Object.assign({ "type": type, "filter": filter }, map)); mapList = MatchSort.get(filterText, mapList, "name"); } } - if (this.mapBrowserPage.controls.MapFiltering.getSelectedMapType() == "random") - { - mapList = [{ - "file": "random", - "name": translateWithContext("random map pick", "Random"), - "description": translate("Pick a map at random."), - }, ...mapList]; - } this.mapList = mapList; this.itemCount = this.mapList.length; this.resizeGrid(); @@ -92,3 +93,7 @@ MapGridBrowser.prototype.DefaultItemWidth = 200; MapGridBrowser.prototype.MinItemWidth = 100; + +MapGridBrowser.prototype.HotkeyConfigNext = "tab.next"; + +MapGridBrowser.prototype.HotkeyConfigPrevious = "tab.prev";