Ticket #3970: lastmanstanding_v2.patch
File lastmanstanding_v2.patch, 6.7 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
353 353 "optionExploreMap", 354 354 "optionDisableTreasures", 355 355 "optionLockTeams", 356 "optionLastManStanding", 356 357 "optionCheats", 357 358 "optionRating", 358 359 "hideMoreOptions" … … 508 509 "ExploreMap": "exploreMap", 509 510 "DisableTreasures": "disableTreasures", 510 511 "LockTeams": "lockTeams", 512 "LastManStanding" : "lastManStanding", 511 513 "CheatsEnabled": "enableCheats" 512 514 }; 513 515 … … 525 527 Engine.GetGUIObjectByName("lockTeams").enabled = !this.checked; 526 528 updateGameAttributes(); 527 529 }; 530 Engine.GetGUIObjectByName("lockTeams").onPress = function() { 531 g_GameAttributes.settings.LockTeams = this.checked; 532 g_GameAttributes.settings.LastManStanding = !this.checked; 533 hideControl("lastManStanding", "lastManStandingText", !g_GameAttributes.settings.LockTeams); 534 updateGameAttributes(); 535 }; 528 536 } 529 537 530 538 /** … … 1173 1181 1174 1182 if (g_GameAttributes.mapType == "scenario") 1175 1183 delete g_GameAttributes.settings.WonderDuration; 1184 delete g_GameAttributes.settings.LastManStanding; 1176 1185 1177 1186 if (mapSettings.PlayerData) 1178 1187 sanitizePlayerData(mapSettings.PlayerData); … … 1371 1380 setGUIBoolean("exploreMap", "exploreMapText", !!mapSettings.ExploreMap); 1372 1381 setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap); 1373 1382 setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams); 1383 setGUIBoolean("lastManStanding", "lastManStandingText", !!mapSettings.LastManStanding); 1374 1384 setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled); 1375 1385 1376 1386 Engine.GetGUIObjectByName("optionWonderDuration").hidden = … … 1381 1391 1382 1392 Engine.GetGUIObjectByName("enableCheats").enabled = !mapSettings.RatingEnabled; 1383 1393 Engine.GetGUIObjectByName("lockTeams").enabled = !mapSettings.RatingEnabled; 1394 Engine.GetGUIObjectByName("lastManStandingText").hidden = mapSettings.LockTeams; 1384 1395 1385 1396 // Mapsize completely hidden for non-random maps 1386 1397 let isRandom = g_GameAttributes.mapType == "random"; … … 1389 1400 Engine.GetGUIObjectByName("mapSizeText").hidden = !isRandom || g_IsController; 1390 1401 hideControl("numPlayers", "numPlayersText", isRandom && g_IsController); 1391 1402 1392 let notScenario = g_GameAttributes.mapType != "scenario" && g_IsController 1403 let notScenario = g_GameAttributes.mapType != "scenario" && g_IsController; 1393 1404 1394 1405 for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap", 1395 1406 "startingResources", "ceasefire", "revealMap", 1396 1407 "exploreMap", "disableTreasures", "lockTeams"]) 1397 1408 hideControl(ctrl, ctrl + "Text", notScenario); 1409 hideControl("lastManStanding", "lastManStandingText", !mapSettings.LockTeams && notScenario); 1398 1410 1399 1411 Engine.GetGUIObjectByName("civResetButton").hidden = !notScenario; 1400 1412 -
binaries/data/mods/public/gui/gamesetup/gamesetup.xml
385 385 <translatableAttribute id="tooltip">Toggle locked teams.</translatableAttribute> 386 386 </object> 387 387 </object> 388 389 <object name="optionLastManStanding" size="14 338 94% 366"> 390 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 391 <translatableAttribute id="caption">Last Man Standing:</translatableAttribute> 392 </object> 393 <object name="lastManStandingText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/> 394 <object name="lastManStanding" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip"> 395 <translatableAttribute id="tooltip">Toggle if only one player can win (disables allied victory).</translatableAttribute> 396 </object> 397 </object> 388 398 389 <object name="optionCheats" size="14 3 38 94% 366" hidden="true">399 <object name="optionCheats" size="14 368 94% 396" hidden="true"> 390 400 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 391 401 <translatableAttribute id="caption">Cheats:</translatableAttribute> 392 402 </object> … … 396 406 </object> 397 407 </object> 398 408 399 <object name="optionRating" size="14 3 68 94% 396" hidden="true">409 <object name="optionRating" size="14 398 94% 426" hidden="true"> 400 410 <object size="0 0 40% 28" hidden="false" type="text" style="ModernRightLabelText"> 401 411 <translatableAttribute id="caption">Rated Game:</translatableAttribute> 402 412 </object> -
binaries/data/mods/public/simulation/components/EndGameManager.js
19 19 this.wonderDuration = 10 * 60 * 1000; 20 20 21 21 // Allied victory means allied players can win if victory conditions are met for each of them 22 // Would be false for a "last man standing" game (when diplomacy is fully implemented)22 // False for a "last man standing" game 23 23 this.alliedVictory = true; 24 24 }; 25 25 … … 81 81 return; 82 82 83 83 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 84 var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 84 85 var cmpPlayers = []; 85 86 86 87 var allies = []; … … 100 101 onlyAlliesLeft = false; 101 102 } 102 103 104 if (!this.alliedVictory && onlyAlliesLeft) 105 cmpGUIInterface.PushNotification({ 106 "message": markForTranslation("Last player remaining wins"), 107 "translateMessage": true 108 }); 109 103 110 // check if there are winners, or the game needs to continue 104 if (!allies.length || !onlyAlliesLeft || !this.alliedVictory) 105 return; 111 if (!allies.length || !onlyAlliesLeft || 112 !this.alliedVictory && cmpPlayers.filter(pData => pData.GetState() == "active").length != 1) 113 return; 106 114 107 115 for (var p of allies) 108 116 cmpPlayers[p].SetState("won"); -
binaries/data/mods/public/simulation/helpers/Setup.js
51 51 cmpEndGameManager.SetGameType(settings.GameType); 52 52 if (settings.WonderDuration) 53 53 cmpEndGameManager.SetWonderDuration(settings.WonderDuration * 60 * 1000); 54 if (settings.LastManStanding) 55 cmpEndGameManager.SetAlliedVictory(false); 54 56 55 57 if (settings.Garrison) 56 58 {