Index: binaries/data/mods/public/globalscripts/Templates.js =================================================================== --- binaries/data/mods/public/globalscripts/Templates.js +++ binaries/data/mods/public/globalscripts/Templates.js @@ -1,4 +1,36 @@ /** + * Loads history and gameplay data of all civs. + * Can be used from GUI and rmgen. + * + * @param scriptInterface - An object containing the JSON loading functions. + * @param selectableOnly {boolean} - Only load civs that can be selected + * in the gamesetup. Scenario maps might set non-selectable civs. + */ +function loadCivFiles(scriptInterface, selectableOnly) +{ + let civData = {}; + let civFiles = scriptInterface.BuildDirEntList("simulation/data/civs/", "*.json", false); + + for (let filename of civFiles) + { + let data = scriptInterface.ReadJSONFile(filename); + if (!data) + continue; + + if (!selectableOnly || data.SelectableInGameSetup) + civData[data.Code] = data; + + // Sanity check + for (let prop of ["Code", "Culture", "Name", "Emblem", "History", "Music", "Factions", "CivBonuses", + "TeamBonuses", "Structures", "StartEntities", "Formations", "AINames", "SelectableInGameSetup"]) + if (data[prop] === undefined) + throw new Error(filename + " doesn't contain " + prop); + } + + return civData; +} + +/** * Gets an array of all classes for this identity template */ function GetIdentityClasses(template) Index: binaries/data/mods/public/gui/civinfo/civinfo.xml =================================================================== --- binaries/data/mods/public/gui/civinfo/civinfo.xml +++ binaries/data/mods/public/gui/civinfo/civinfo.xml @@ -2,7 +2,6 @@ -