Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/settings.js
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | return { | ||||
"Id": biomeID, | "Id": biomeID, | ||||
"Title": translateWithContext("biome definition", description.Title), | "Title": translateWithContext("biome definition", description.Title), | ||||
"Description": translateWithContext("biome definition", description.Description) | "Description": translateWithContext("biome definition", description.Description) | ||||
}; | }; | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Loads available gametypes. | * Loads available victoryCondtions from json files. | ||||
* | * | ||||
* @returns {Array|undefined} | * @returns {Array|undefined} | ||||
*/ | */ | ||||
function loadVictoryConditions() | function loadVictoryConditions() | ||||
{ | { | ||||
let subdir = "victory_conditions/"; | let subdir = "victory_conditions/"; | ||||
let victoryConditions = listFiles(g_SettingsDirectory + subdir, ".json", false).map(victoryScriptName => { | let victoryConditions = listFiles(g_SettingsDirectory + subdir, ".json", false).map(victoryScriptName => { | ||||
let vc = loadSettingValuesFile(subdir + victoryScriptName + ".json"); | let vc = loadSettingValuesFile(subdir + victoryScriptName + ".json"); | ||||
if (vc) | if (vc) | ||||
vc.Name = victoryScriptName; | vc.Name = victoryScriptName; | ||||
return vc; | return vc; | ||||
}); | }); | ||||
elexis: (Often we use an object to map from identifier to data, but not here, so I didn't say anything… | |||||
if (victoryConditions.some(vc => vc == undefined)) | if (victoryConditions.some(vc => vc == undefined)) | ||||
return undefined; | return undefined; | ||||
// TODO: We might support enabling victory conditions separately sometime. | // TODO: We might support enabling victory conditions separately sometime. | ||||
// Until then, we supplement the endless gametype here. | // Until then, we supplement the endless gametype here. | ||||
victoryConditions.push({ | victoryConditions.push({ | ||||
"Name": "endless", | "Name": "endless", | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
let popCap = g_Settings.PopulationCapacities.find(p => p.Population == population); | let popCap = g_Settings.PopulationCapacities.find(p => p.Population == population); | ||||
return popCap ? popCap.Title : translateWithContext("population capacity", "Unknown"); | return popCap ? popCap.Title : translateWithContext("population capacity", "Unknown"); | ||||
} | } | ||||
/** | /** | ||||
* Returns title or placeholder. | * Returns title or placeholder. | ||||
* | * | ||||
* @param {string} gameType - for example "conquest" | * @param {string} victoryCondition - for example "conquest" | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function translateVictoryCondition(gameType) | function translateVictoryCondition(victoryCondition) | ||||
{ | { | ||||
let victoryCondition = g_Settings.VictoryConditions.find(vc => vc.Name == gameType); | let victoryConditionData = g_Settings.VictoryConditions.find(vc => vc.Name == victoryCondition); | ||||
return victoryCondition ? victoryCondition.Title : translateWithContext("victory condition", "Unknown"); | return victoryConditionData ? victoryConditionData.Title : translateWithContext("victory condition", "Unknown"); | ||||
} | } |
Wildfire Games · Phabricator
(Often we use an object to map from identifier to data, but not here, so I didn't say anything and this is ok)