Ticket #1649: wonderVictory.5.diff
File wonderVictory.5.diff, 11.4 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
481 481 updateResearchDisplay(); 482 482 updateBuildingPlacementPreview(); 483 483 updateTimeElapsedCounter(); 484 updateTimeNotifications(); 484 485 485 486 // Update music state on basis of battle state. 486 487 var battleState = Engine.GuiInterfaceCall("GetBattleState", Engine.GetPlayerID()); -
binaries/data/mods/public/gui/session/session.xml
345 345 <object name="notificationPanel" type="image" size="50%-300 60 50%+300 120" ghost="true"> 346 346 <object name="notificationText" size="0 0 100% 100%" type="text" style="notificationPanel" ghost="true"/> 347 347 </object> 348 <object name="timeNotificationPanel" type="image" size="100%-600 60 100%-20 120" ghost="true"> 349 <object name="timeNotificationText" size="0 0 100% 100%" type="text" style="notificationPanel" ghost="true"/> 350 </object> 348 351 352 349 353 <!-- ================================ ================================ --> 350 354 <!-- Chat --> 351 355 <!-- ================================ ================================ --> -
binaries/data/mods/public/simulation/components/EndGameManager.js
24 24 EndGameManager.prototype.SetGameType = function(newGameType) 25 25 { 26 26 this.gameType = newGameType; 27 Engine.BroadcastMessage(MT_GameTypeChanged, {}); 27 28 }; 28 29 30 EndGameManager.prototype.CheckGameType = function(type) 31 { 32 return this.gameType == type; 33 }; 34 35 EndGameManager.prototype.RegisterWonder = function(entity) 36 { 37 if (!this.CheckGameType("wonder")) 38 return; 39 40 var cmpWon = QueryOwnerInterface(entity, IID_Player); 41 cmpWon.SetState("won"); 42 43 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 44 var numPlayers = cmpPlayerManager.GetNumPlayers(); 45 for (var i = 1; i < numPlayers; i++) 46 { 47 var playerEntityId = cmpPlayerManager.GetPlayerByID(i); 48 var cmpPlayer = Engine.QueryInterface(playerEntityId, IID_Player); 49 if (cmpPlayer.GetState() != "active") 50 continue; 51 if (this.alliedVictory && cmpPlayer.IsMutualAlly(cmpWon.GetPlayerID())) 52 cmpPlayer.SetState("won") 53 else 54 Engine.PostMessage(playerEntityId, MT_PlayerDefeated, { "playerId": i } ); 55 } 56 57 // Reveal the map to all players 58 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 59 cmpRangeManager.SetLosRevealAll(-1, true); 60 }; 61 29 62 EndGameManager.prototype.SetAlliedVictory = function(flag) 30 63 { 31 64 this.alliedVictory = flag; -
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 /* … … 728 730 return cmpPlayer.GetNeededResources(amounts); 729 731 }; 730 732 733 GuiInterface.prototype.AddTimeNotification = function(notification) 734 { 735 var time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime(); 736 notification.endTime = notification.time + time; 737 notification.id = ++this.timeNotificationID; 738 this.timeNotifications.push(notification); 739 this.timeNotifications.sort(function (n1, n2){return n2.endTime - n1.endTime}); 740 return this.timeNotificationID; 741 }; 731 742 743 GuiInterface.prototype.DeleteTimeNotification = function(notificationID) 744 { 745 for (var i in this.timeNotifications) 746 { 747 if (this.timeNotifications[i].id == notificationID) 748 { 749 this.timeNotifications.splice(i); 750 return; 751 } 752 } 753 }; 754 755 GuiInterface.prototype.GetTimeNotificationText = function(playerID) 756 { 757 var formatTime = function(time) 758 { 759 // add 1000 ms to get ceiled instead of floored millisecons 760 // displaying 00:00 for a full second isn't nice 761 time += 1000; 762 var hours = Math.floor(time / 1000 / 60 / 60); 763 var minutes = Math.floor(time / 1000 / 60) % 60; 764 var seconds = Math.floor(time / 1000) % 60; 765 return (hours ? hours + ':' : "") + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds); 766 }; 767 var time = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetTime(); 768 var text = ""; 769 for each (var n in this.timeNotifications) 770 { 771 if (time >= n.endTime) 772 { 773 // delete the notification and start over 774 this.DeleteTimeNotification(n.id); 775 return this.GetTimeNotificationText(playerID); 776 } 777 if (n.players.indexOf(playerID) >= 0) 778 text += n.message.replace("%T",formatTime(n.endTime - time))+"\n"; 779 } 780 return text; 781 }; 782 732 783 GuiInterface.prototype.PushNotification = function(notification) 733 784 { 734 785 this.notifications.push(notification); … … 1837 1888 "GetIncomingAttacks": 1, 1838 1889 "GetNeededResources": 1, 1839 1890 "GetNextNotification": 1, 1891 "GetTimeNotificationText": 1, 1840 1892 1841 1893 "GetAvailableFormations": 1, 1842 1894 "GetFormationRequirements": 1, -
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 this.ResetTimer(msg.to); 15 }; 16 17 Wonder.prototype.OnGameTypeChanged = function() 18 { 19 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 20 if (!cmpPlayer) 21 return; 22 this.ResetTimer(cmpPlayer.GetPlayerID()); 23 }; 24 25 Wonder.prototype.ResetTimer = function(ownerID) 26 { 27 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 28 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 29 // remove existing messages if any 30 if (this.timer) 31 { 32 cmpTimer.CancelTimer(this.timer); 33 cmpGuiInterface.DeleteTimeNotification(this.ownMessage); 34 cmpGuiInterface.DeleteTimeNotification(this.otherMessage); 35 } 36 if (ownerID <= 0) 37 return; 38 39 var cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); 40 if (!cmpEndGameManager.CheckGameType("wonder")) 41 return; 42 43 // create new messages, and start timer to register defeat. 44 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 45 var numPlayers = cmpPlayerManager.GetNumPlayers(); 46 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 47 var players = []; 48 for (var i = 1; i < numPlayers; i++) 49 if (i != ownerID) 50 players.push(i); 51 52 this.otherMessage = cmpGuiInterface.AddTimeNotification( 53 { 54 "message": cmpPlayer.GetName() + " will have won in %T", 55 "players": players, 56 "time": +this.template.TimeTillVictory*1000 57 }); 58 this.ownMessage = cmpGuiInterface.AddTimeNotification( 59 { 60 "message": "You will have won in %T", 61 "players": [ownerID], 62 "time": +this.template.TimeTillVictory*1000 63 }); 64 this.timer = cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_EndGameManager, "RegisterWonder", +this.template.TimeTillVictory*1000, this.entity); 65 }; 66 67 Engine.RegisterComponentType(IID_Wonder, "Wonder", Wonder); -
binaries/data/mods/public/simulation/components/interfaces/EndGameManager.js
1 1 Engine.RegisterInterface("EndGameManager"); 2 2 Engine.RegisterMessageType("PlayerDefeated"); 3 Engine.RegisterMessageType("GameTypeChanged"); -
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> -
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
145 145 146 146 wxArrayString gameTypes; 147 147 gameTypes.Add(_T("conquest")); 148 gameTypes.Add(_T("wonder")); 148 149 gameTypes.Add(_T("endless")); 149 150 150 151 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);