Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/functions_utility.js
Show All 31 Lines | |||||
function getJSONFileList(pathname) | function getJSONFileList(pathname) | ||||
{ | { | ||||
// Remove the path and extension from each name, since we just want the filename | // Remove the path and extension from each name, since we just want the filename | ||||
return Engine.BuildDirEntList(pathname, "*.json", false).map( | return Engine.BuildDirEntList(pathname, "*.json", false).map( | ||||
filename => filename.substring(pathname.length, filename.length - 5)); | filename => filename.substring(pathname.length, filename.length - 5)); | ||||
} | } | ||||
/** | |||||
* Returns translated history and gameplay data of all civs, optionally including a mock gaia civ. | |||||
*/ | |||||
function loadCivData(selectableOnly, gaia) | |||||
{ | |||||
let civData = loadCivFiles(selectableOnly); | |||||
for (let civ in civData) | |||||
translateObjectKeys(civData[civ], ["Name", "Description", "History", "Special"]); | |||||
elexis: unneeded loop | |||||
if (gaia) | |||||
civData.gaia = { "Code": "gaia", "Name": translate("Gaia") }; | |||||
return deepfreeze(civData); | |||||
} | |||||
// A sorting function for arrays of objects with 'name' properties, ignoring case | // A sorting function for arrays of objects with 'name' properties, ignoring case | ||||
function sortNameIgnoreCase(x, y) | function sortNameIgnoreCase(x, y) | ||||
{ | { | ||||
let lowerX = x.name.toLowerCase(); | let lowerX = x.name.toLowerCase(); | ||||
let lowerY = y.name.toLowerCase(); | let lowerY = y.name.toLowerCase(); | ||||
if (lowerX < lowerY) | if (lowerX < lowerY) | ||||
return -1; | return -1; | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
unneeded loop