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": description.Description ? translateWithContext("biome definition", description.Description) : "" | "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 victoryCondition = loadSettingValuesFile(subdir + victoryScriptName + ".json"); | ||||
if (vc) | if (victoryCondition) | ||||
vc.Name = victoryScriptName; | victoryCondition.Name = victoryScriptName; | ||||
return vc; | return victoryCondition; | ||||
}); | }); | ||||
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(victoryCondition => victoryCondition == undefined)) | ||||
return undefined; | return undefined; | ||||
// TODO: We might support enabling victory conditions separately sometime. | |||||
// Until then, we supplement the endless gametype here. | |||||
victoryConditions.push({ | |||||
"Name": "endless", | |||||
"Title": translateWithContext("victory condition", "None"), | |||||
"Description": translate("Endless game."), | |||||
"Scripts": [] | |||||
}); | |||||
return victoryConditions; | return victoryConditions; | ||||
} | } | ||||
/** | /** | ||||
* Loads the default player settings (like civs and colors). | * Loads the default player settings (like civs and colors). | ||||
* | * | ||||
* @returns {Array|undefined} | * @returns {Array|undefined} | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 138 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} victoryConditionName - For example "conquest". | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function translateVictoryCondition(gameType) | function translateVictoryCondition(victoryConditionName) | ||||
{ | { | ||||
let victoryCondition = g_Settings.VictoryConditions.find(vc => vc.Name == gameType); | let victoryCondition = g_Settings.VictoryConditions.find(victoryCondition => victoryCondition.Name == victoryConditionName); | ||||
return victoryCondition ? victoryCondition.Title : translateWithContext("victory condition", "Unknown"); | return victoryCondition ? victoryCondition.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)