Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -288,6 +288,9 @@ 8 = 8, Num8 9 = 9, Num9 +[hotkey.gamesetup] +mapbrowser.open = "M" + [hotkey.session] kill = Delete, Backspace ; Destroy selected units stop = "H" ; Stop the current action Index: ps/trunk/binaries/data/mods/public/gui/common/MapCache.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/MapCache.js +++ ps/trunk/binaries/data/mods/public/gui/common/MapCache.js @@ -1,92 +0,0 @@ -/** - * This class obtains, caches, and provides the game settings from map XML and JSON files. - */ -class MapCache -{ - constructor() - { - this.cache = {}; - } - - getMapData(mapType, mapPath) - { - if (!mapPath || mapPath == "random") - return undefined; - - if (!this.cache[mapPath]) - { - let mapData = g_Settings.MapTypes.find(type => type.Name == mapType).GetData(mapPath); - - // Remove gaia, TODO: Maps should be consistent - if (mapData && - mapData.settings && - mapData.settings.PlayerData && - mapData.settings.PlayerData.length && - !mapData.settings.PlayerData[0]) - { - mapData.settings.PlayerData.shift(); - } - - this.cache[mapPath] = mapData; - } - - return this.cache[mapPath]; - } - - /** - * Doesn't translate, so that lobby page viewers can do that locally. - * The result is to be used with translateMapName. - */ - getTranslatableMapName(mapType, mapPath) - { - if (mapPath == "random") - return "random"; - - let mapData = this.getMapData(mapType, mapPath); - return mapData && mapData.settings && mapData.settings.Name || undefined; - } - - translateMapName(mapName) - { - return mapName == "random" ? - translateWithContext("map selection", "Random") : - mapName ? translate(mapName) : ""; - } - - getTranslatedMapDescription(mapType, mapPath) - { - if (mapPath == "random") - return translate("A randomly selected map."); - - let mapData = this.getMapData(mapType, mapPath); - return mapData && mapData.settings && translate(mapData.settings.Description) || ""; - } - - getMapPreview(mapType, mapPath, gameAttributes = undefined) - { - let filename = gameAttributes && gameAttributes.settings && gameAttributes.settings.Preview || undefined; - - if (!filename) - { - let mapData = this.getMapData(mapType, mapPath); - filename = mapData && mapData.settings && mapData.settings.Preview || this.DefaultPreview; - } - - return "cropped:" + this.PreviewWidth + "," + this.PreviewHeight + ":" + this.PreviewsPath + filename; - } -} - -MapCache.prototype.TexturesPath = - "art/textures/ui/"; - -MapCache.prototype.PreviewsPath = - "session/icons/mappreview/"; - -MapCache.prototype.DefaultPreview = - "nopreview.png"; - -MapCache.prototype.PreviewWidth = - 400 / 512; - -MapCache.prototype.PreviewHeight = - 300 / 512; Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Controls/MapFilters.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/Controls/MapFilters.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Controls/MapFilters.js @@ -1,119 +0,0 @@ -class MapFilters -{ - constructor(mapCache) - { - this.mapCache = mapCache; - } - - /** - * Some map filters may reject every map of a particular mapType. - * This function allows identifying which map filters have any matches for that maptype. - */ - getAvailableMapFilters(mapTypeName) - { - return this.Filters.filter(filter => - this.getFilteredMaps(mapTypeName, filter.Name, true)); - } - - /** - * This function identifies all maps matching the given mapType and mapFilter. - * If existence is true, it will only test if there is at least one file for that mapType and mapFilter. - * Otherwise it returns an array with filename, translated map title and map description. - */ - getFilteredMaps(mapTypeName, filterName, existence) - { - let index = g_MapTypes.Name.findIndex(name => name == mapTypeName); - if (index == -1) - { - error("Can't get filtered maps for invalid maptype: " + mapTypeName); - return undefined; - } - - let mapFilter = this.Filters.find(filter => filter.Name == filterName); - if (!mapFilter) - { - error("Invalid mapfilter name: " + filterName); - return undefined; - } - - Engine.ProfileStart("getFilteredMaps"); - - let maps = []; - let mapTypePath = g_MapTypes.Path[index]; - for (let filename of listFiles(mapTypePath, g_MapTypes.Suffix[index], false)) - { - if (filename.startsWith(this.HiddenFilesPrefix)) - continue; - - let mapPath = mapTypePath + filename; - let mapData = this.mapCache.getMapData(mapTypeName, mapPath); - - // Map files may come with custom json files - if (!mapData || !mapData.settings) - continue; - - if (MatchesClassList(mapData.settings.Keywords || [], mapFilter.Match)) - { - if (existence) - { - Engine.ProfileStop(); - return true; - } - - maps.push({ - "file": mapPath, - "name": translate(mapData.settings.Name), - "description": translate(mapData.settings.Description) - }); - } - } - - Engine.ProfileStop(); - return existence ? false : maps; - } -} - -/** - * When maps start with this prefix, they will not appear in the maplist. - * Used for the Atlas _default.xml for instance. - */ -MapFilters.prototype.HiddenFilesPrefix = "_"; - -MapFilters.prototype.Filters = [ - { - "Name": "default", - "Title": translate("Default"), - "Description": translate("All maps except naval and demo maps."), - "Match": ["!naval !demo !hidden"] - }, - { - "Name": "naval", - "Title": translate("Naval Maps"), - "Description": translate("Maps where ships are needed to reach the enemy."), - "Match": ["naval"] - }, - { - "Name": "demo", - "Title": translate("Demo Maps"), - "Description": translate("These maps are not playable but for demonstration purposes only."), - "Match": ["demo"] - }, - { - "Name": "new", - "Title": translate("New Maps"), - "Description": translate("Maps that are brand new in this release of the game."), - "Match": ["new"] - }, - { - "Name": "trigger", - "Title": translate("Trigger Maps"), - "Description": translate("Maps that come with scripted events and potentially spawn enemy units."), - "Match": ["trigger"] - }, - { - "Name": "all", - "Title": translate("All Maps"), - "Description": translate("Every map of the chosen maptype."), - "Match": "!" - } -]; Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.js @@ -0,0 +1,25 @@ +/** + * This class is implemented by gamesettings that are controlled by a button. + */ +class GameSettingControlButton extends GameSettingControl +{ + setControl(gameSettingControlManager) + { + let row = gameSettingControlManager.getNextRow("buttonSettingFrame"); + this.frame = Engine.GetGUIObjectByName("buttonSettingFrame[" + row + "]"); + this.button = Engine.GetGUIObjectByName("buttonSettingControl[" + row + "]"); + this.button.onPress = this.onPress.bind(this); + if (this.Caption) + this.button.caption = this.Caption; + } + + setControlTooltip(tooltip) + { + this.button.tooltip = tooltip; + } + + setControlHidden(hidden) + { + this.button.hidden = hidden; + } +} Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.xml +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlButton.xml @@ -0,0 +1,13 @@ + +