Ticket #1831: tribute-summary.patch
File tribute-summary.patch, 6.8 KB (added by , 11 years ago) |
---|
-
simulation/components/StatisticsTracker.js
46 46 "metal": 0, 47 47 "stone": 0 48 48 }; 49 this.tributesSent = 0; 50 this.tributesReceived = 0; 49 51 this.tradeIncome = 0; 50 52 this.treasuresCollected = 0; 51 53 }; … … 69 71 "resourcesUsed": this.resourcesUsed, 70 72 "resourcesSold": this.resourcesSold, 71 73 "resourcesBought": this.resourcesBought, 74 "tributesSent": this.tributesSent, 75 "tributesReceived": this.tributesReceived, 72 76 "tradeIncome": this.tradeIncome, 73 77 "treasuresCollected": this.treasuresCollected, 74 78 "percentMapExplored": this.GetPercentMapExplored() … … 106 110 var targetIsCivCentre = cmpTargetEntityIdentity.HasClass("CivCentre"); 107 111 108 112 var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership); 109 113 110 114 // Don't increase counters if target player is gaia (player 0) 111 115 if (cmpTargetOwnership.GetOwner() != 0) 112 116 { … … 202 206 this.resourcesBought[type] += amount; 203 207 } 204 208 209 StatisticsTracker.prototype.IncreaseTributesSentCounter = function(amount) 210 { 211 this.tributesSent += amount; 212 } 213 214 StatisticsTracker.prototype.IncreaseTributesReceivedCounter = function(amount) 215 { 216 this.tributesReceived += amount; 217 } 218 205 219 StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount) 206 220 { 207 221 this.tradeIncome += amount; -
simulation/components/Player.js
543 543 this.resourceCount[type] -= amounts[type]; 544 544 545 545 cmpPlayer.AddResources(amounts); 546 // TODO: notify the receiver 546 547 var total = Object.keys(amounts).reduce(function (sum, type) sum + amounts[type], 0); 548 var cmpMyStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker); 549 if (cmpMyStatisticsTracker) 550 cmpMyStatisticsTracker.IncreaseTributesSentCounter(total); 551 var cmpTheirStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker); 552 if (cmpTheirStatisticsTracker) 553 cmpTheirStatisticsTracker.IncreaseTributesReceivedCounter(total); 554 // TODO: notify the receiver 547 555 } 548 556 // else not enough resources... TODO: send gui notification 549 557 }; -
gui/summary/summary.js
115 115 getGUIObjectByName("metalGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 116 116 getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 117 117 getGUIObjectByName("treasuresCollectedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 118 getGUIObjectByName("resourcesTributedHeading").size = left + " 16 " + Math.floor(left + width * 1.8) + " 100%"; left += width; 118 119 119 120 left = 50; 120 121 getGUIObjectByName("playerName4Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; … … 176 177 var metalGathered = getGUIObjectByName("metalGathered["+i+"]"); 177 178 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]"); 178 179 var treasuresCollected = getGUIObjectByName("treasuresCollected["+i+"]"); 180 var resourcesTributed = getGUIObjectByName("resourcesTributed["+i+"]"); 179 181 180 182 var exchangedFood = getGUIObjectByName("exchangedFood["+i+"]"); 181 183 var exchangedWood = getGUIObjectByName("exchangedWood["+i+"]"); … … 222 224 metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 223 225 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 224 226 treasuresCollected.size = left + " 2 " + (left + width) + " 100%"; left += width; 227 resourcesTributed.size = left + " 2 " + (left + width) + " 100%"; left += width; 225 228 size = getGUIObjectByName("playerBox3["+i+"]").size; 226 size.right = left + 10;229 size.right = left + 30; 227 230 getGUIObjectByName("playerBox3["+i+"]").size = size; 228 231 229 232 left = 240; … … 268 271 vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ? 269 272 (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%"; 270 273 treasuresCollected.caption = playerState.statistics.treasuresCollected; 274 resourcesTributed.caption = SOLD_COLOR + playerState.statistics.tributesSent + '[/color] / ' + BOUGHT_COLOR + playerState.statistics.tributesReceived + "[/color]"; 271 275 272 276 exchangedFood.caption = SOLD_COLOR + '+' + playerState.statistics.resourcesBought.food 273 277 + '[/color] ' + BOUGHT_COLOR + '-' + playerState.statistics.resourcesSold.food + '[/color]'; -
gui/summary/summary.xml
118 118 119 119 </object> 120 120 <object name="unitsBuildingsPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 121 121 122 122 <object size="0 0 100% 100%-50"> 123 123 <object name="playerName1Heading" type="text" style="LeftTabLabelText"> 124 124 Player name … … 193 193 194 194 </object> 195 195 <object name="resourcesPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%-58" hidden="true"> 196 196 197 197 <object size="0 0 100% 100%-50"> 198 198 <object name="playerName3Heading" type="text" style="LeftTabLabelText"> 199 199 Player name … … 219 219 <object name="treasuresCollectedHeading" type="text" style="CenteredTabLabelText"> 220 220 Treasures collected 221 221 </object> 222 <object name="resourcesTributedHeading" type="text" style="CenteredTabLabelText"> 223 Tributes (Sent / Received) 224 </object> 222 225 </object> 223 226 224 227 <object size="0 65 100% 100%-50"> … … 233 236 <object name="metalGathered[n]" type="text" style="CenteredLabelText"/> 234 237 <object name="vegetarianRatio[n]" type="text" style="CenteredLabelText"/> 235 238 <object name="treasuresCollected[n]" type="text" style="CenteredLabelText"/> 239 <object name="resourcesTributed[n]" type="text" style="CenteredLabelText"/> 236 240 </object> 237 241 </repeat> 238 242 </object> 239 243 240 244 </object> 241 <object name="marketPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100% -58" hidden="true">245 <object name="marketPanel" type="image" sprite="ForegroundBody" size="20 120 100%-20 100%" hidden="true"> 242 246 243 247 <object size="0 0 100% 100%-50"> 244 248 <object name="playerName4Heading" type="text" style="LeftTabLabelText">