diff --git a/binaries/data/mods/public/gui/common/gamedescription.js b/binaries/data/mods/public/gui/common/gamedescription.js index 5b5abd4f7b..1277b4b6b7 100644 --- a/binaries/data/mods/public/gui/common/gamedescription.js +++ b/binaries/data/mods/public/gui/common/gamedescription.js @@ -348,6 +348,15 @@ function getGameDescription(extended = false) translate("Sorry, no description available."), }); + if (g_GameAttributes.settings.Biome) + { + let biome = g_Settings.Biomes.find(biome => biome.Id == g_GameAttributes.settings.Biome); + titles.push({ + "label": translate("Biome"), + "value": biome ? biome.Title : translateWithContext("biome", "Random") + }); + } + if (extended) { titles.push({ diff --git a/binaries/data/mods/public/gui/common/settings.js b/binaries/data/mods/public/gui/common/settings.js index 061a010f27..3a121ae393 100644 --- a/binaries/data/mods/public/gui/common/settings.js +++ b/binaries/data/mods/public/gui/common/settings.js @@ -14,6 +14,12 @@ const g_MaxTeams = 4; */ const g_SettingsDirectory = "simulation/data/settings/"; +/** + * Directory containing all biomes supported for random map scripts. + */ +const g_BiomesDirectory = "maps/random/rmbiome/biomes/"; + + /** * An object containing all values given by setting name. * Used by lobby, gamesetup, session, summary screen and replay menu. @@ -36,7 +42,7 @@ function loadSettingsValues() "GameSpeeds": loadSettingValuesFile("game_speeds.json"), "MapTypes": loadMapTypes(), "MapSizes": loadSettingValuesFile("map_sizes.json"), - "Biomes": loadSettingValuesFile("biomes.json"), + "Biomes": loadBiomes(), "PlayerDefaults": loadPlayerDefaults(), "PopulationCapacities": loadPopulationCapacities(), "StartingResources": loadSettingValuesFile("starting_resources.json"), @@ -203,6 +209,18 @@ function loadMapTypes() ]; } +function loadBiomes() +{ + return Engine.BuildDirEntList(g_BiomesDirectory, "*.json", false).map(file => { + let description = Engine.ReadJSONFile(file).Description; + return { + "Id": file.substr(g_BiomesDirectory.length).slice(0, -".json".length), + "Title": translateWithContext("biome definition", description.Title), + "Description": translateWithContext("biome definition", description.Description) + }; + }); +} + /** * Loads available gametypes. * diff --git a/binaries/data/mods/public/gui/gamesetup/gamesetup.js b/binaries/data/mods/public/gui/gamesetup/gamesetup.js index 0630a6e23c..1c3dfac613 100644 --- a/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ b/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -472,7 +472,7 @@ var g_Dropdowns = { }, "biome": { "title": () => translate("Biome"), - "tooltip": (hoverIdx) => translate("Select the flora and fauna."), + "tooltip": (hoverIdx) => g_BiomeList && g_BiomeList.Description && g_BiomeList.Description[hoverIdx] || translate("Select the flora and fauna."), "labels": () => g_BiomeList ? g_BiomeList.Title : [], "colors": (idx) => g_BiomeList ? g_BiomeList.Color : [], "ids": () => g_BiomeList ? g_BiomeList.Id : [], @@ -1501,14 +1501,8 @@ function reloadBiomeList() if (g_GameAttributes.settings.SupportedBiomes === true) biomeList = g_Settings.Biomes; else - { biomeList = g_Settings.Biomes.filter( biome => g_GameAttributes.settings.SupportedBiomes.indexOf(biome.Id) != -1); - - for (let biome of g_GameAttributes.settings.SupportedBiomes) - if (g_Settings.Biomes.every(bio => bio.Id != biome)) - warn("Map '" + g_GameAttributes.map + "' contains unknown biome '" + biome + "'") - } } g_BiomeList = biomeList && prepareForDropdown( diff --git a/binaries/data/mods/public/l10n/messages.json b/binaries/data/mods/public/l10n/messages.json index 72cae45b5c..4192fc17c6 100644 --- a/binaries/data/mods/public/l10n/messages.json +++ b/binaries/data/mods/public/l10n/messages.json @@ -665,6 +665,19 @@ } } } + }, + { + "extractor": "json", + "filemasks": [ + "maps/random/rmbiome/biomes/**.json" + ], + "options": { + "keywords": [ + "Title", + "Description" + ], + "context": "biome definition" + } } ] }, diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/alpine.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/alpine.json index 6740293ec3..a93976923d 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/alpine.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/alpine.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Alpine", + "Description": "A region in the high snowy mountains. Biting winds sweep through the abundant conifer forests, making even the more resilient deer and mountain goats shiver." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/autumn.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/autumn.json index 3976337a9b..95e5c6c92f 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/autumn.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/autumn.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Autumn", + "Description": "Autumn at its peak. The landscape is a dazzling dash of colors irrevocably intertwined. The native beech and oak trees of this temperate zone display a multi-coloured foliage while the evergreen pines look on with indifference at the approaching winter." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/desert.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/desert.json index 676fa5df08..68d5ac0359 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/desert.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/desert.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Desert", + "Description": "A semi-desert area that boasts numerous clumps of date palms and tamarix trees. Herds of camels roam the wild and the occasional gazelle jumps up in fright at being disturbed." + }, "Environment": { "SunColor": { "r": 0.733, "g": 0.746, "b": 0.574 }, "Water": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/mediterranean.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/mediterranean.json index 7e30de1df7..90d9f68779 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/mediterranean.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/mediterranean.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Mediterranean", + "Description": "Start in a region blessed with the Mediterranean climate, a warm and inviting land. The cypresses are in a perpetual struggle with the dominant fan palms while deer graze in their shadows, blissfully unaware." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/savanna.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/savanna.json index 3f2720f59e..dcdc4478f8 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/savanna.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/savanna.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Savanna", + "Description": "The savanna, a dry climate in which only the hardy Baobab trees thrive. Solitary gazelles graze the sparse grass, while herds of zebras, wildebeest, giraffes or elephants roam the wild in search of food." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/snowy.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/snowy.json index e2541de71d..39de58e868 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/snowy.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/snowy.json @@ -1,6 +1,9 @@ { - "Environment": - { + "Description": { + "Title": "Snowy", + "Description": "Settle in the cold regions of the North, the native habitat of the wooly muskox. Here you can pine away to your content and also hunt the occasional walrus or two." + }, + "Environment": { "SunColor": { "r": 0.550, "g": 0.601, "b": 0.644 }, "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/temperate.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/temperate.json index d4e9f9f76c..3cabb0dfd3 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/temperate.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/temperate.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Temperate", + "Description": "Lush grasslands carpet the land, in places giving way to magnificent and diverse broadleaf forests. Poplars, pines, beeches and oaks all vie for supremacy but this root-war is a neverending struggle. Numerous apple trees dot the land, deer and sheep gorge themselves on this years fallen fruit." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/biomes/tropic.json b/binaries/data/mods/public/maps/random/rmbiome/biomes/tropic.json index 4475fe5e0b..23d0317524 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/biomes/tropic.json +++ b/binaries/data/mods/public/maps/random/rmbiome/biomes/tropic.json @@ -1,4 +1,8 @@ { + "Description": { + "Title": "Tropic", + "Description": "Explore the mysterious tropics. An extremely green, but also extremely humid environment awaits. The tall Toona trees look on disapprovingly at this invasion of their privacy and ferocious tigers are determined to defend their territory at all costs." + }, "Environment": { "Water": { "WaterBody": { diff --git a/binaries/data/mods/public/maps/random/rmbiome/randombiome.js b/binaries/data/mods/public/maps/random/rmbiome/randombiome.js index 9e6ed04846..6a02365380 100644 --- a/binaries/data/mods/public/maps/random/rmbiome/randombiome.js +++ b/binaries/data/mods/public/maps/random/rmbiome/randombiome.js @@ -62,7 +62,8 @@ function loadBiomeFile(file) }; for (let rmsGlobal in biome) - copyProperties(biome[rmsGlobal], global["g_" + rmsGlobal]); + if (rmsGlobal != "Description") + copyProperties(biome[rmsGlobal], global["g_" + rmsGlobal]); } function rBiomeTreeCount(multiplier = 1) diff --git a/binaries/data/mods/public/maps/random/unknown_nomad.js b/binaries/data/mods/public/maps/random/unknown_nomad.js index e58278be57..1a17a6c5a5 100644 --- a/binaries/data/mods/public/maps/random/unknown_nomad.js +++ b/binaries/data/mods/public/maps/random/unknown_nomad.js @@ -1611,12 +1611,8 @@ for (var i = 0; i < types.length; ++i) ); } -var planetm = 1; -if (rt==7) -{ - planetm = 8; -} -//create small grass tufts +var planetm = currentBiome() == "tropic" ? 8 : 1; + log("Creating small grass tufts..."); group = new SimpleGroup( [new SimpleObject(aGrassShort, 1,2, 0,1, -PI/8,PI/8)] diff --git a/binaries/data/mods/public/simulation/data/settings/biomes.json b/binaries/data/mods/public/simulation/data/settings/biomes.json deleted file mode 100644 index b74487da98..0000000000 --- a/binaries/data/mods/public/simulation/data/settings/biomes.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "TranslatedKeys": ["Title"], - "Data": - [ - { - "Id": "temperate", - "Title": "Temperate" - }, - { - "Id": "snowy", - "Title": "Snowy" - }, - { - "Id": "desert", - "Title": "Desert" - }, - { - "Id": "alpine", - "Title": "Alpine" - }, - { - "Id": "mediterranean", - "Title": "Mediterranean" - }, - { - "Id": "savanna", - "Title": "Savanna" - }, - { - "Id": "tropic", - "Title": "Tropic" - }, - { - "Id": "autumn", - "Title": "Autumn" - } - ] -}