Ticket #3987: random_cultures_option.patch
File random_cultures_option.patch, 4.2 KB (added by , 8 years ago) |
---|
-
gamesetup.js
353 353 "optionExploreMap", 354 354 "optionDisableTreasures", 355 355 "optionLockTeams", 356 "optionRandomCivs", 356 357 "optionCheats", 357 358 "optionRating", 358 359 "hideMoreOptions" … … 508 509 "ExploreMap": "exploreMap", 509 510 "DisableTreasures": "disableTreasures", 510 511 "LockTeams": "lockTeams", 512 "RandomCivs" : "randomCivs", 511 513 "CheatsEnabled": "enableCheats" 512 514 }; 513 515 … … 1246 1248 // Get a unique array of selectable cultures 1247 1249 let cultures = Object.keys(g_CivData).filter(civ => g_CivData[civ].SelectableInGameSetup).map(civ => g_CivData[civ].Culture); 1248 1250 cultures = cultures.filter((culture, index) => cultures.indexOf(culture) === index); 1251 let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].SelectableInGameSetup) 1249 1252 1250 1253 // Determine random civs and botnames 1251 1254 for (let i in g_GameAttributes.settings.PlayerData) … … 1254 1257 let chosenCiv = g_GameAttributes.settings.PlayerData[i].Civ || "random"; 1255 1258 if (chosenCiv == "random") 1256 1259 { 1257 let culture = cultures[Math.floor(Math.random() * cultures.length)]; 1258 let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].Culture == culture); 1259 chosenCiv = civs[Math.floor(Math.random() * civs.length)]; 1260 if (g_GameAttributes.settings.RandomCivs) 1261 { 1262 let culture = cultures[Math.floor(Math.random() * cultures.length)]; 1263 let civs = Object.keys(g_CivData).filter(civ => g_CivData[civ].Culture == culture); 1264 chosenCiv = civs[Math.floor(Math.random() * civs.length)]; 1265 } 1266 else 1267 { 1268 chosenCiv = civs[Math.floor(Math.random() * civs.length)]; 1269 } 1260 1270 } 1261 1271 g_GameAttributes.settings.PlayerData[i].Civ = chosenCiv; 1262 1272 … … 1371 1381 setGUIBoolean("exploreMap", "exploreMapText", !!mapSettings.ExploreMap); 1372 1382 setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap); 1373 1383 setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams); 1384 setGUIBoolean("randomCivs", "randomCivsText", !!mapSettings.RandomCivs); 1374 1385 setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled); 1375 1386 1376 1387 Engine.GetGUIObjectByName("optionWonderDuration").hidden = … … 1393 1404 1394 1405 for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap", 1395 1406 "startingResources", "ceasefire", "revealMap", 1396 "exploreMap", "disableTreasures", "lockTeams" ])1407 "exploreMap", "disableTreasures", "lockTeams", "randomCivs"]) 1397 1408 hideControl(ctrl, ctrl + "Text", notScenario); 1398 1409 1399 1410 for (let i = 0; i < g_MaxPlayers; ++i) -
gamesetup.xml
376 376 </object> 377 377 </object> 378 378 379 <object name="option Cheats" size="14 338 94% 366" hidden="true">379 <object name="optionRandomCivs" size="14 338 94% 366"> 380 380 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 381 <translatableAttribute id="caption">Random Cultures:</translatableAttribute> 382 </object> 383 <object name="randomCivsText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/> 384 <object name="randomCivs" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip"> 385 <translatableAttribute id="tooltip">Toggle the selection of random civilizations by culture.</translatableAttribute> 386 </object> 387 </object> 388 389 <object name="optionCheats" size="14 368 94% 396" hidden="true"> 390 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 381 391 <translatableAttribute id="caption">Cheats:</translatableAttribute> 382 392 </object> 383 393 <object name="enableCheatsText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/> … … 386 396 </object> 387 397 </object> 388 398 389 <object name="optionRating" size="14 3 68 94% 396" hidden="true">399 <object name="optionRating" size="14 398 94% 426" hidden="true"> 390 400 <object size="0 0 40% 28" hidden="false" type="text" style="ModernRightLabelText"> 391 401 <translatableAttribute id="caption">Rated Game:</translatableAttribute> 392 402 </object>