Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/common/settings.js
Show All 31 Lines | |||||
* | * | ||||
* @returns {Object|undefined} | * @returns {Object|undefined} | ||||
*/ | */ | ||||
function loadSettingsValues() | function loadSettingsValues() | ||||
{ | { | ||||
var settings = { | var settings = { | ||||
"AIDescriptions": loadAIDescriptions(), | "AIDescriptions": loadAIDescriptions(), | ||||
"AIDifficulties": loadAIDifficulties(), | "AIDifficulties": loadAIDifficulties(), | ||||
"AIBehaviors": loadAIBehaviors(), | |||||
"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": loadBiomes(), | "Biomes": loadBiomes(), | ||||
"PlayerDefaults": loadPlayerDefaults(), | "PlayerDefaults": loadPlayerDefaults(), | ||||
"PopulationCapacities": loadPopulationCapacities(), | "PopulationCapacities": loadPopulationCapacities(), | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | return [ | ||||
}, | }, | ||||
{ | { | ||||
"Name": "very hard", | "Name": "very hard", | ||||
"Title": translateWithContext("aiDiff", "Very Hard") | "Title": translateWithContext("aiDiff", "Very Hard") | ||||
} | } | ||||
]; | ]; | ||||
} | } | ||||
function loadAIBehaviors() | |||||
{ | |||||
return [ | |||||
{ | |||||
"Name": "random", | |||||
"Title": translateWithContext("aiBehavior", "Random"), | |||||
"Default": true | |||||
}, | |||||
{ | |||||
"Name": "balanced", | |||||
"Title": translateWithContext("aiBehavior", "Balanced"), | |||||
}, | |||||
{ | |||||
"Name": "defensive", | |||||
"Title": translateWithContext("aiBehavior", "Defensive") | |||||
}, | |||||
{ | |||||
"Name": "aggressive", | |||||
"Title": translateWithContext("aiBehavior", "Aggressive") | |||||
} | |||||
]; | |||||
} | |||||
/** | /** | ||||
* Loads available victory times for victory conditions like Wonder and Capture the Relic. | * Loads available victory times for victory conditions like Wonder and Capture the Relic. | ||||
*/ | */ | ||||
function loadVictoryDuration() | function loadVictoryDuration() | ||||
{ | { | ||||
var jsonFile = "victory_times.json"; | var jsonFile = "victory_times.json"; | ||||
var json = Engine.ReadJSONFile(g_SettingsDirectory + jsonFile); | var json = Engine.ReadJSONFile(g_SettingsDirectory + jsonFile); | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
let difficulty = g_Settings.AIDifficulties[index]; | let difficulty = g_Settings.AIDifficulties[index]; | ||||
return difficulty ? difficulty.Title : translateWithContext("AI difficulty", "Unknown"); | return difficulty ? difficulty.Title : translateWithContext("AI difficulty", "Unknown"); | ||||
} | } | ||||
/** | /** | ||||
* Returns title or placeholder. | * Returns title or placeholder. | ||||
* | * | ||||
* @param {string} aiBehavior - for example "defensive" | |||||
*/ | |||||
function translateAIBehavior(aiBehavior) | |||||
{ | |||||
let behavior = g_Settings.AIBehaviors.find(b => b.Name == aiBehavior); | |||||
return behavior ? behavior.Title : translateWithContext("AI behavior", "Default"); | |||||
} | |||||
/** | |||||
* Returns title or placeholder. | |||||
* | |||||
* @param {string} mapType - for example "skirmish" | * @param {string} mapType - for example "skirmish" | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
function translateMapType(mapType) | function translateMapType(mapType) | ||||
{ | { | ||||
let type = g_Settings.MapTypes.find(t => t.Name == mapType); | let type = g_Settings.MapTypes.find(t => t.Name == mapType); | ||||
return type ? type.Title : translateWithContext("map type", "Unknown"); | return type ? type.Title : translateWithContext("map type", "Unknown"); | ||||
} | } | ||||
Show All 36 Lines |
Wildfire Games · Phabricator