Ticket #3355: t3355_move_starting_resources_v1.patch
File t3355_move_starting_resources_v1.patch, 7.6 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/settings.js
30 30 function loadAvailableSettings() 31 31 { 32 32 var settings = {}; 33 33 34 34 settings.Ceasefire = loadCeasefire(); 35 35 if (!settings.Ceasefire) 36 36 return undefined; 37 37 38 settings.StartingResources = loadAvailableSettingsFile("starting_resources.json"); 39 if (!settings.StartingResources) 40 return undefined; 41 38 42 return settings; 39 43 } 40 44 41 45 /** 46 * Returns an array of objects reflecting all possible values for a given setting. 47 * 48 * @param {string} filename 49 * @see simulation/data/settings/ 50 * @returns {Array|undefined} 51 */ 52 function loadAvailableSettingsFile(filename) 53 { 54 var json = Engine.ReadJSONFile(g_SettingsDirectory + filename); 55 56 if (!json || !json.Data) 57 { 58 error("Couldn't load " + filename + "!"); 59 return undefined; 60 } 61 62 if (json.TranslatedKeys) 63 translateObjectKeys(json, json.TranslatedKeys); 64 65 return json.Data; 66 } 67 68 /** 42 69 * Loads available ceasefire settings. 43 70 * 44 71 * @returns {Array|undefined} 45 72 */ 46 73 function loadCeasefire() 47 74 { 48 75 var json = Engine.ReadJSONFile(g_SettingsDirectory + "ceasefire.json"); 49 76 -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
5 5 6 6 const VICTORY_DEFAULTIDX = 1; 7 7 8 8 // TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too 9 9 // Translation: Type of victory condition. 10 10 const POPULATION_CAP = ["50", "100", "150", "200", "250", "300", translate("Unlimited")]; 11 11 const POPULATION_CAP_DATA = [50, 100, 150, 200, 250, 300, 10000]; 12 12 const POPULATION_CAP_DEFAULTIDX = 5; 13 // Translation: Amount of starting resources.14 const STARTING_RESOURCES = [translateWithContext("startingResources", "Very Low"), translateWithContext("startingResources", "Low"), translateWithContext("startingResources", "Medium"), translateWithContext("startingResources", "High"), translateWithContext("startingResources", "Very High"), translateWithContext("startingResources", "Deathmatch")];15 const STARTING_RESOURCES_DATA = [100, 300, 500, 1000, 3000, 50000];16 const STARTING_RESOURCES_DEFAULTIDX = 1;17 13 14 const g_StartingResources = prepareForDropdown(g_Settings ? g_Settings.StartingResources : undefined); 18 15 const g_Ceasefire = prepareForDropdown(g_Settings ? g_Settings.Ceasefire : undefined); 19 16 20 17 //////////////////////////////////////////////////////////////////////////////////////////////// 21 18 22 19 // Is this is a networked game, or offline 23 20 var g_IsNetworked; 24 21 25 22 // Is this user in control of game settings (i.e. is a network server, or offline player) … … 208 205 populationCaps.onSelectionChange = function() { 209 206 if (this.selected != -1) 210 207 g_GameAttributes.settings.PopulationCap = POPULATION_CAP_DATA[this.selected]; 211 208 212 209 updateGameAttributes(); 213 210 } 214 211 215 212 var startingResourcesL = Engine.GetGUIObjectByName("startingResources"); 216 startingResourcesL.list = STARTING_RESOURCES;217 startingResourcesL.list_data = STARTING_RESOURCES_DATA;218 startingResourcesL.selected = STARTING_RESOURCES_DEFAULTIDX;213 startingResourcesL.list = g_StartingResources.Title; 214 startingResourcesL.list_data = g_StartingResources.Resources; 215 startingResourcesL.selected = g_StartingResources.Default; 219 216 startingResourcesL.onSelectionChange = function() { 220 217 if (this.selected != -1) 221 g_GameAttributes.settings.StartingResources = STARTING_RESOURCES_DATA[this.selected];218 g_GameAttributes.settings.StartingResources = g_StartingResources.Resources[this.selected]; 222 219 223 220 updateGameAttributes(); 224 221 } 225 222 226 223 var ceasefireL = Engine.GetGUIObjectByName("ceasefire"); 227 224 ceasefireL.list = g_Ceasefire.Title; 228 225 ceasefireL.list_data = g_Ceasefire.Duration; 229 226 ceasefireL.selected = g_Ceasefire.Default; … … 1250 1247 1251 1248 observerLateJoin.checked = g_GameAttributes.settings.ObserverLateJoin; 1252 1249 observerLateJoinText.caption = observerLateJoin.checked ? translate("Yes") : translate("No"); 1253 1250 1254 1251 gameSpeedText.caption = g_GameSpeeds.names[speedIdx]; 1255 1252 gameSpeedBox.selected = speedIdx; 1256 1253 populationCap.selected = (mapSettings.PopulationCap !== undefined && POPULATION_CAP_DATA.indexOf(mapSettings.PopulationCap) != -1 ? POPULATION_CAP_DATA.indexOf(mapSettings.PopulationCap) : POPULATION_CAP_DEFAULTIDX); 1257 1254 populationCapText.caption = POPULATION_CAP[populationCap.selected]; 1258 startingResources.selected = (mapSettings.StartingResources !== undefined && STARTING_RESOURCES_DATA.indexOf(mapSettings.StartingResources) != -1 ? STARTING_RESOURCES_DATA.indexOf(mapSettings.StartingResources) : STARTING_RESOURCES_DEFAULTIDX);1259 startingResourcesText.caption = STARTING_RESOURCES[startingResources.selected];1255 startingResources.selected = mapSettings.StartingResources !== undefined && g_StartingResources.Resources.indexOf(mapSettings.StartingResources) != -1 ? g_StartingResources.Resources.indexOf(mapSettings.StartingResources) : g_StartingResources.Default; 1256 startingResourcesText.caption = g_StartingResources.Title[startingResources.selected]; 1260 1257 ceasefire.selected = mapSettings.Ceasefire !== undefined && g_Ceasefire.Duration.indexOf(mapSettings.Ceasefire) != -1 ? g_Ceasefire.Duration.indexOf(mapSettings.Ceasefire) : g_Ceasefire.Default; 1261 1258 ceasefireText.caption = g_Ceasefire.Title[ceasefire.selected]; 1262 1259 1263 1260 // Update map preview 1264 1261 Engine.GetGUIObjectByName("mapPreview").sprite = "cropped:(0.78125,0.5859375)session/icons/mappreview/" + getMapPreview(mapName); 1265 1262 1266 1263 // Hide/show settings depending on whether we can change them or not 1267 1264 var updateDisplay = function(guiObjChg, guiObjDsp, chg) { -
binaries/data/mods/public/l10n/messages.json
460 460 "keywords": [ 461 461 "Name" 462 462 ] 463 463 } 464 464 }, 465 465 { 466 466 "extractor": "json", 467 467 "filemasks": [ 468 "simulation/data/settings/starting_resources.json" 469 ], 470 "options": { 471 "keywords": ["Title"], 472 "context": "startingResources" 473 } 474 }, 475 { 476 "extractor": "json", 477 "filemasks": [ 468 478 "simulation/data/map_sizes.json" 469 479 ], 470 480 "options": { 471 481 "keywords": [ 472 482 "Name", 473 483 "LongName" 474 484 ] 475 485 } -
binaries/data/mods/public/simulation/data/settings/starting_resources.json
1 { 2 "TranslatedKeys": { "Title": "startingResources" }, 3 "Data": 4 [ 5 { 6 "Resources": 100, 7 "Title": "Very Low" 8 }, 9 { 10 "Resources": 300, 11 "Title": "Low", 12 "Default": true 13 }, 14 { 15 "Resources": 500, 16 "Title": "Medium" 17 }, 18 { 19 "Resources": 1000, 20 "Title": "High" 21 }, 22 { 23 "Resources": 3000, 24 "Title": "Very High" 25 }, 26 { 27 "Resources": 50000, 28 "Title": "Deathmatch" 29 } 30 ] 31 }