Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/common/settings.js
Show All 9 Lines | |||||
const g_MaxTeams = 4; | const g_MaxTeams = 4; | ||||
/** | /** | ||||
* Directory containing all editable settings. | * Directory containing all editable settings. | ||||
*/ | */ | ||||
const g_SettingsDirectory = "simulation/data/settings/"; | 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. | * An object containing all values given by setting name. | ||||
* Used by lobby, gamesetup, session, summary screen and replay menu. | * Used by lobby, gamesetup, session, summary screen and replay menu. | ||||
*/ | */ | ||||
const g_Settings = loadSettingsValues(); | const g_Settings = loadSettingsValues(); | ||||
/** | /** | ||||
* Loads and translates all values of all settings which | * Loads and translates all values of all settings which | ||||
* can be configured by dropdowns in the gamesetup. | * can be configured by dropdowns in the gamesetup. | ||||
* | * | ||||
* @returns {Object|undefined} | * @returns {Object|undefined} | ||||
*/ | */ | ||||
function loadSettingsValues() | function loadSettingsValues() | ||||
{ | { | ||||
var settings = { | var settings = { | ||||
"AIDescriptions": loadAIDescriptions(), | "AIDescriptions": loadAIDescriptions(), | ||||
"AIDifficulties": loadAIDifficulties(), | "AIDifficulties": loadAIDifficulties(), | ||||
"Ceasefire": loadCeasefire(), | "Ceasefire": loadCeasefire(), | ||||
"VictoryDurations": loadVictoryDuration(), | "VictoryDurations": loadVictoryDuration(), | ||||
"GameSpeeds": loadSettingValuesFile("game_speeds.json"), | "GameSpeeds": loadSettingValuesFile("game_speeds.json"), | ||||
"MapTypes": loadMapTypes(), | "MapTypes": loadMapTypes(), | ||||
"MapSizes": loadSettingValuesFile("map_sizes.json"), | "MapSizes": loadSettingValuesFile("map_sizes.json"), | ||||
"Biomes": loadSettingValuesFile("biomes.json"), | "Biomes": loadBiomes(), | ||||
"PlayerDefaults": loadPlayerDefaults(), | "PlayerDefaults": loadPlayerDefaults(), | ||||
"PopulationCapacities": loadPopulationCapacities(), | "PopulationCapacities": loadPopulationCapacities(), | ||||
"StartingResources": loadSettingValuesFile("starting_resources.json"), | "StartingResources": loadSettingValuesFile("starting_resources.json"), | ||||
"VictoryConditions": loadVictoryConditions() | "VictoryConditions": loadVictoryConditions() | ||||
}; | }; | ||||
if (Object.keys(settings).some(key => settings[key] === undefined)) | if (Object.keys(settings).some(key => settings[key] === undefined)) | ||||
return undefined; | return undefined; | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | return [ | ||||
{ | { | ||||
"Name": "scenario", | "Name": "scenario", | ||||
"Title": translateWithContext("map", "Scenario"), | "Title": translateWithContext("map", "Scenario"), | ||||
"Description": translate("A map with a predefined landscape and matchsettings.") | "Description": translate("A map with a predefined landscape and matchsettings.") | ||||
} | } | ||||
]; | ]; | ||||
} | } | ||||
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. | * Loads available gametypes. | ||||
* | * | ||||
* @returns {Array|undefined} | * @returns {Array|undefined} | ||||
*/ | */ | ||||
function loadVictoryConditions() | function loadVictoryConditions() | ||||
{ | { | ||||
let subdir = "victory_conditions/"; | let subdir = "victory_conditions/"; | ||||
▲ Show 20 Lines • Show All 169 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator