Index: binaries/data/mods/public/gui/common/settings.js =================================================================== --- binaries/data/mods/public/gui/common/settings.js +++ binaries/data/mods/public/gui/common/settings.js @@ -42,6 +42,7 @@ "VictoryDurations": loadVictoryDuration(), "GameSpeeds": loadSettingValuesFile("game_speeds.json"), "MapTypes": loadMapTypes(), + "MapFilters" : loadMapFilters(), "MapSizes": loadSettingValuesFile("map_sizes.json"), "Biomes": loadBiomes(), "PlayerDefaults": loadPlayerDefaults(), @@ -219,21 +220,75 @@ "Name": "skirmish", "Title": translateWithContext("map", "Skirmish"), "Description": translate("A map with a predefined landscape and number of players. Freely select the other gamesettings."), + "Path": "maps/skirmishes/", + "Extension": ".xml", "Default": true }, { "Name": "random", "Title": translateWithContext("map", "Random"), - "Description": translate("Create a unique map with a different resource distribution each time. Freely select the number of players and teams.") + "Description": translate("Create a unique map with a different resource distribution each time. Freely select the number of players and teams."), + "Path": "maps/random/", + "Extension": ".json" }, { "Name": "scenario", "Title": translateWithContext("map", "Scenario"), - "Description": translate("A map with a predefined landscape and matchsettings.") + "Description": translate("A map with a predefined landscape and matchsettings."), + "Path": "maps/scenarios/", + "Extension": ".xml" } ]; } +/** + * Hardcoded, as modding is not supported without major changes. + * + * @returns {Array} + */ +function loadMapFilters() +{ + return [ + { + "id": "default", + "name": translateWithContext("map filter", "Default"), + "tooltip": translateWithContext("map filter", "All maps except naval and demo maps."), + "filter": mapKeywords => mapKeywords.every(keyword => ["naval", "demo", "hidden"].indexOf(keyword) == -1), + "Default": true + }, + { + "id": "naval", + "name": translate("Naval Maps"), + "tooltip": translateWithContext("map filter", "Maps where ships are needed to reach the enemy."), + "filter": mapKeywords => mapKeywords.indexOf("naval") != -1 + }, + { + "id": "demo", + "name": translate("Demo Maps"), + "tooltip": translateWithContext("map filter", "These maps are not playable but for demonstration purposes only."), + "filter": mapKeywords => mapKeywords.indexOf("demo") != -1 + }, + { + "id": "new", + "name": translate("New Maps"), + "tooltip": translateWithContext("map filter", "Maps that are brand new in this release of the game."), + "filter": mapKeywords => mapKeywords.indexOf("new") != -1 + }, + { + "id": "trigger", + "name": translate("Trigger Maps"), + "tooltip": translateWithContext("map filter", "Maps that come with scripted events and potentially spawn enemy units."), + "filter": mapKeywords => mapKeywords.indexOf("trigger") != -1 + }, + { + "id": "all", + "name": translate("All Maps"), + "tooltip": translateWithContext("map filter", "Every map of the chosen maptype."), + "filter": mapKeywords => true + }, + ]; +} + function loadBiomes() { return listFiles(g_BiomesDirectory, ".json", true).filter(biomeID => biomeID != "defaultbiome").map(biomeID => { Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -100,15 +100,6 @@ var g_PlayerColorPickerList = g_Settings && g_Settings.PlayerDefaults.slice(1).map(pData => pData.Color); /** - * Directory containing all maps of the given type. - */ -var g_MapPath = { - "random": "maps/random/", - "scenario": "maps/scenarios/", - "skirmish": "maps/skirmishes/" -}; - -/** * Containing the colors to highlight the ready status of players, * the chat ready messages and * the tooltips and captions for the ready button @@ -167,46 +158,6 @@ "clientlist": (msg, user) => getUsernameList(), }; -var g_MapFilters = [ - { - "id": "default", - "name": translateWithContext("map filter", "Default"), - "tooltip": translateWithContext("map filter", "All maps except naval and demo maps."), - "filter": mapKeywords => mapKeywords.every(keyword => ["naval", "demo", "hidden"].indexOf(keyword) == -1), - "Default": true - }, - { - "id": "naval", - "name": translate("Naval Maps"), - "tooltip": translateWithContext("map filter", "Maps where ships are needed to reach the enemy."), - "filter": mapKeywords => mapKeywords.indexOf("naval") != -1 - }, - { - "id": "demo", - "name": translate("Demo Maps"), - "tooltip": translateWithContext("map filter", "These maps are not playable but for demonstration purposes only."), - "filter": mapKeywords => mapKeywords.indexOf("demo") != -1 - }, - { - "id": "new", - "name": translate("New Maps"), - "tooltip": translateWithContext("map filter", "Maps that are brand new in this release of the game."), - "filter": mapKeywords => mapKeywords.indexOf("new") != -1 - }, - { - "id": "trigger", - "name": translate("Trigger Maps"), - "tooltip": translateWithContext("map filter", "Maps that come with scripted events and potentially spawn enemy units."), - "filter": mapKeywords => mapKeywords.indexOf("trigger") != -1 - }, - { - "id": "all", - "name": translate("All Maps"), - "tooltip": translateWithContext("map filter", "Every map of the chosen maptype."), - "filter": mapKeywords => true - }, -]; - /** * This contains only filters that have at least one map matching them. */ @@ -482,7 +433,7 @@ "select": (itemIdx) => { g_MapData = {}; g_GameAttributes.mapType = g_MapTypes.Name[itemIdx]; - g_GameAttributes.mapPath = g_MapPath[g_GameAttributes.mapType]; + g_GameAttributes.mapPath = g_MapTypes.Path[itemIdx]; delete g_GameAttributes.map; if (g_GameAttributes.mapType != "scenario") @@ -1691,7 +1642,7 @@ */ function getFilteredMaps(filterFunc) { - if (!g_MapPath[g_GameAttributes.mapType]) + if (g_MapTypes.Name.indexOf(g_GameAttributes.mapType) == -1) { error("Unexpected map type: " + g_GameAttributes.mapType); return []; @@ -1725,7 +1676,7 @@ */ function reloadMapFilterList() { - g_MapFilterList = prepareForDropdown(g_MapFilters.filter( + g_MapFilterList = prepareForDropdown(g_Settings.MapFilters.filter( mapFilter => getFilteredMaps(mapFilter.filter).length )); @@ -1832,7 +1783,7 @@ function loadMapData(name) { - if (!name || !g_MapPath[g_GameAttributes.mapType]) + if (!name || g_MapTypes.Name.indexOf(g_GameAttributes.mapType) == -1) return undefined; if (name == "random")