Ticket #1649: wonderVictory.3.diff
File wonderVictory.3.diff, 10.5 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
4 4 const DEFAULT_OFFLINE_MAP = "Acropolis 01"; 5 5 6 6 // TODO: Move these somewhere like simulation\data\game_types.json, Atlas needs them too 7 const VICTORY_TEXT = ["Conquest", " None"];8 const VICTORY_DATA = ["conquest", " endless"];7 const VICTORY_TEXT = ["Conquest", "Wonder", "None"]; 8 const VICTORY_DATA = ["conquest", "wonder", "endless"]; 9 9 const VICTORY_DEFAULTIDX = 0; 10 10 const POPULATION_CAP = ["50", "100", "150", "200", "250", "300", "Unlimited"]; 11 11 const POPULATION_CAP_DATA = [50, 100, 150, 200, 250, 300, 10000]; -
binaries/data/mods/public/gui/session/messages.js
136 136 var messages = []; 137 137 for each (var n in notifications) 138 138 messages.push(n.message); 139 getGUIObjectByName("notificationText").caption = messages.join("\n"); 140 } 141 142 // Returns [username, playercolor] for the given player 143 function getUsernameAndColor(player) 144 { 139 getGUIObjectByName("notificationText").caption = messages.join("\n"); 140 } 141 142 function updateTimeNotifications() 143 { 144 getGUIObjectByName("timeNotificationText").caption = Engine.GuiInterfaceCall("GetTimeNotificationText"); 145 } 146 147 // Returns [username, playercolor] for the given player 148 function getUsernameAndColor(player) 149 { 145 150 // This case is hit for AIs, whose names don't exist in playerAssignments. 146 151 var color = g_Players[player].color; 147 152 return [ -
binaries/data/mods/public/gui/session/session.js
440 440 updateResearchDisplay(); 441 441 updateBuildingPlacementPreview(); 442 442 updateTimeElapsedCounter(); 443 updateTimeNotifications(); 443 444 444 445 // Update music state on basis of battle state. 445 446 var battleState = Engine.GuiInterfaceCall("GetBattleState", Engine.GetPlayerID()); -
binaries/data/mods/public/gui/session/session.xml
346 346 <object name="notificationPanel" type="image" size="50%-300 60 50%+300 120" ghost="true"> 347 347 <object name="notificationText" size="0 0 100% 100%" type="text" style="notificationPanel" ghost="true"/> 348 348 </object> 349 <object name="timeNotificationPanel" type="image" size="100%-600 60 100%-20 120" ghost="true"> 350 <object name="timeNotificationText" size="0 0 100% 100%" type="text" style="notificationPanel" ghost="true"/> 351 </object> 349 352 353 350 354 <!-- ================================ ================================ --> 351 355 <!-- Chat --> 352 356 <!-- ================================ ================================ --> -
binaries/data/mods/public/simulation/components/EndGameManager.js
31 31 this.alliedVictory = flag; 32 32 }; 33 33 34 EndGameManager.prototype.RegisterWonder = function(entity) 35 { 36 if (this.gameType != "wonder") 37 return; 38 39 var cmpWon = QueryOwnerInterface(entity, IID_Player); 40 cmpWon.SetState("won"); 41 42 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 43 var numPlayers = cmpPlayerManager.GetNumPlayers(); 44 for (var i = 1; i < numPlayers; i++) 45 { 46 var playerEntityId = cmpPlayerManager.GetPlayerByID(i); 47 var cmpPlayer = Engine.QueryInterface(playerEntityId, IID_Player); 48 if (cmpPlayer.GetState() != "active") 49 continue; 50 if (this.alliedVictory && cmpPlayer.IsMutualAlly(cmpWon.GetPlayerID())) 51 cmpPlayer.SetState("won") 52 else 53 Engine.PostMessage(playerEntityId, MT_PlayerDefeated, { "playerId": i } ); 54 } 55 }; 56 34 57 EndGameManager.prototype.PlayerLostAllConquestCriticalEntities = function(playerID) 35 58 { 36 59 if (this.gameType == "endless") -
binaries/data/mods/public/simulation/components/GuiInterface.js
22 22 this.placementWallLastAngle = 0; 23 23 this.notifications = []; 24 24 this.renamedEntities = []; 25 this.timeNotificationID = 1; 26 this.timeNotifications = []; 25 27 }; 26 28 27 29 /* … … 691 693 return cmpPlayer.GetNeededResources(amounts); 692 694 }; 693 695 696 GuiInterface.prototype.AddTimeNotification = function(notification) 697 { 698 var time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime(); 699 notification.endTime = notification.time + time; 700 notification.id = ++this.timeNotificationID; 701 this.timeNotifications.push(notification); 702 this.timeNotifications.sort(function (n1, n2){return n2.endTime - n1.endTime}); 703 return this.timeNotificationID; 704 }; 694 705 706 GuiInterface.prototype.DeleteTimeNotification = function(notificationID) 707 { 708 for (var i in this.timeNotifications) 709 { 710 if (this.timeNotifications[i].id == notificationID) 711 { 712 this.timeNotifications.splice(i); 713 return; 714 } 715 } 716 }; 717 718 GuiInterface.prototype.GetTimeNotificationText = function(playerID) 719 { 720 var formatTime = function(time) 721 { 722 // add 1000 ms to get ceiled instead of floored millisecons 723 // displaying 00:00 for a full second isn't nice 724 time += 1000; 725 var hours = Math.floor(time / 1000 / 60 / 60); 726 var minutes = Math.floor(time / 1000 / 60) % 60; 727 var seconds = Math.floor(time / 1000) % 60; 728 return (hours ? hours + ':' : "") + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); 729 }; 730 var time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime(); 731 var text = ""; 732 for each (var n in this.timeNotifications) 733 { 734 if (time >= n.endTime) 735 { 736 // delete the notification and start over 737 this.DeleteTimeNotification(n.id); 738 return this.GetTimeNotificationText(playerID); 739 } 740 if (n.players.indexOf(playerID) >= 0) 741 text += n.message.replace("%T",formatTime(n.endTime - time))+"\n"; 742 } 743 return text; 744 }; 745 695 746 GuiInterface.prototype.PushNotification = function(notification) 696 747 { 697 748 this.notifications.push(notification); … … 1793 1844 "GetIncomingAttacks": 1, 1794 1845 "GetNeededResources": 1, 1795 1846 "GetNextNotification": 1, 1847 "GetTimeNotificationText": 1, 1796 1848 1797 1849 "GetAvailableFormations": 1, 1798 1850 "GetFormationRequirements": 1, -
binaries/data/mods/public/simulation/components/ProductionQueue.js
203 203 var buildTime = ApplyValueModificationsToTemplate("Cost/BuildTime", +template.Cost.BuildTime, cmpPlayer.GetPlayerID(), template); 204 204 var time = timeMult * buildTime; 205 205 206 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 207 cmpGuiInterface.AddTimeNotification( 208 { 209 "message" : "Unit will be spawned in %T", 210 "time" : time*1000, 211 "players" : [cmpPlayer.GetPlayerID()], 212 }); 213 206 214 for (var r in template.Cost.Resources) 207 215 { 208 216 costs[r] = ApplyValueModificationsToTemplate("Cost/Resources/"+r, +template.Cost.Resources[r], cmpPlayer.GetPlayerID(), template); -
binaries/data/mods/public/simulation/components/Wonder.js
1 function Wonder() {} 2 3 Wonder.prototype.Schema = 4 "<element name='TimeTillVictory'>" + 5 "<data type='nonNegativeInteger'/>" + 6 "</element>"; 7 8 Wonder.prototype.Init = function() 9 { 10 }; 11 12 Wonder.prototype.OnOwnershipChanged = function(msg) 13 { 14 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 15 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 16 if (this.timer) 17 { 18 cmpTimer.CancelTimer(this.timer); 19 cmpGuiInterface.DeleteTimeNotification(this.ownMessage); 20 cmpGuiInterface.DeleteTimeNotification(this.otherMessage); 21 } 22 if (msg.to == -1) 23 return; 24 25 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 26 var numPlayers = cmpPlayerManager.GetNumPlayers(); 27 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 28 var players = []; 29 for (var i = 1; i < numPlayers; i++) 30 { 31 if (i != msg.to) 32 players.push(i); 33 } 34 this.otherMessage = cmpGuiInterface.AddTimeNotification( 35 { 36 "message": cmpPlayer.GetName() + " will have won in %T", 37 "players": players, 38 "time": +this.template.TimeTillVictory*1000 39 }); 40 this.ownMessage = cmpGuiInterface.AddTimeNotification( 41 { 42 "message": "You will have won in %T", 43 "players": [msg.to], 44 "time": +this.template.TimeTillVictory*1000 45 }); 46 this.timer = cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_EndGameManager, "RegisterWonder", +this.template.TimeTillVictory*1000, this.entity); 47 }; 48 49 Engine.RegisterComponentType(IID_Wonder, "Wonder", Wonder); -
binaries/data/mods/public/simulation/components/interfaces/Wonder.js
1 Engine.RegisterInterface("Wonder"); -
binaries/data/mods/public/simulation/templates/template_structure_wonder.xml
76 76 <VisualActor> 77 77 <FoundationActor>structures/fndn_6x6.xml</FoundationActor> 78 78 </VisualActor> 79 <Wonder> 80 <TimeTillVictory>300</TimeTillVictory> 81 </Wonder> 79 82 </Entity>