Add biome descriptions.

Display biomes in the objectives dialog and gamesetup map description
panel.
Complete the mod support of 871ed04521 by leaving the code
biome-agnostic.
Fix an oversight in unknown nomad in 2c5a6052ea.

Differential Revision: https://code.wildfiregames.com/D884
Strings By: Hannibal_Barca
This was SVN commit r20139.
This commit is contained in:
elexis 2017-09-09 00:10:08 +00:00
parent 339c1f2210
commit 74bfe5fd55
15 changed files with 79 additions and 55 deletions

View file

@ -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({

View file

@ -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.
*

View file

@ -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(

View file

@ -665,6 +665,19 @@
}
}
}
},
{
"extractor": "json",
"filemasks": [
"maps/random/rmbiome/biomes/**.json"
],
"options": {
"keywords": [
"Title",
"Description"
],
"context": "biome definition"
}
}
]
},

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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": {

View file

@ -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)

View file

@ -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)]

View file

@ -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"
}
]
}