Ticket #1605: used.patch
File used.patch, 9.6 KB (added by , 12 years ago) |
---|
-
gui/summary/summary.js
101 101 102 102 left = 50; 103 103 getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth; 104 getGUIObjectByName("foodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 104 getGUIObjectByName("resourceHeading").size = left + " 16 " + (left + width * 4) + " 100%"; 105 getGUIObjectByName("foodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 106 getGUIObjectByName("woodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 107 getGUIObjectByName("stoneGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 108 getGUIObjectByName("metalGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width; 105 109 getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 106 getGUIObjectByName("woodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;107 getGUIObjectByName("stoneGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;108 getGUIObjectByName("metalGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;109 110 getGUIObjectByName("treasuresCollectedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width; 110 111 111 112 left = 50; … … 158 159 var mapExploration = getGUIObjectByName("mapExploration["+i+"]"); 159 160 160 161 var foodGathered = getGUIObjectByName("foodGathered["+i+"]"); 161 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");162 162 var woodGathered = getGUIObjectByName("woodGathered["+i+"]"); 163 163 var stoneGathered = getGUIObjectByName("stoneGathered["+i+"]"); 164 164 var metalGathered = getGUIObjectByName("metalGathered["+i+"]"); 165 var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]"); 165 166 var treasuresCollected = getGUIObjectByName("treasuresCollected["+i+"]"); 166 167 167 168 var exchangedFood = getGUIObjectByName("exchangedFood["+i+"]"); … … 195 196 196 197 left = 240; 197 198 foodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 198 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width;199 199 woodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 200 200 stoneGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 201 201 metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width; 202 vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width; 202 203 treasuresCollected.size = left + " 2 " + (left + width) + " 100%"; left += width; 203 204 size = getGUIObjectByName("playerBox2["+i+"]").size; 204 205 size.right = left + 10; … … 227 228 enemyCivCentresDestroyed.caption = playerState.statistics.enemyCivCentresDestroyed; 228 229 mapExploration.caption = playerState.statistics.percentMapExplored + "%"; 229 230 230 foodGathered.caption = playerState.statistics.resourcesGathered.food; 231 foodGathered.caption = playerState.statistics.resourcesGathered.food + " / " + 232 (playerState.statistics.resourcesUsed.food - playerState.statistics.resourcesSold.food); 233 woodGathered.caption = playerState.statistics.resourcesGathered.wood + " / " + 234 (playerState.statistics.resourcesUsed.wood - playerState.statistics.resourcesSold.wood); 235 stoneGathered.caption = playerState.statistics.resourcesGathered.stone + " / " + 236 (playerState.statistics.resourcesUsed.stone - playerState.statistics.resourcesSold.stone); 237 metalGathered.caption = playerState.statistics.resourcesGathered.metal + " / " + 238 (playerState.statistics.resourcesUsed.metal - playerState.statistics.resourcesSold.metal); 231 239 vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ? 232 240 (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%"; 233 woodGathered.caption = playerState.statistics.resourcesGathered.wood;234 stoneGathered.caption = playerState.statistics.resourcesGathered.stone;235 metalGathered.caption = playerState.statistics.resourcesGathered.metal;236 241 treasuresCollected.caption = playerState.statistics.treasuresCollected; 237 242 238 243 const SOLD_COLOR = "201 255 200"; -
gui/summary/summary.xml
158 158 <object name="playerName2Heading" type="text" style="LeftTabLabelText"> 159 159 Player name 160 160 </object> 161 <object name="resourceHeading" type="text" style="CenteredTabLabelText"> 162 Resource Statistics (Gathered / Used) 163 </object> 161 164 <object name="foodGatheredHeading" type="text" style="CenteredTabLabelText"> 162 Food gathered165 Food 163 166 </object> 164 <object name="vegetarianRatioHeading" type="text" style="CenteredTabLabelText">165 Vegetarian ratio166 </object>167 167 <object name="woodGatheredHeading" type="text" style="CenteredTabLabelText"> 168 Wood gathered168 Wood 169 169 </object> 170 170 <object name="stoneGatheredHeading" type="text" style="CenteredTabLabelText"> 171 Stone gathered171 Stone 172 172 </object> 173 173 <object name="metalGatheredHeading" type="text" style="CenteredTabLabelText"> 174 Metal gathered174 Metal 175 175 </object> 176 <object name="vegetarianRatioHeading" type="text" style="CenteredTabLabelText"> 177 Vegetarian ratio 178 </object> 176 179 <object name="treasuresCollectedHeading" type="text" style="CenteredTabLabelText"> 177 180 Treasures collected 178 181 </object> … … 185 188 <object name="playerName2[n]" type="text" style="LeftLabelText" size="40 2 208 100%" /> 186 189 <object name="civIcon2[n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/> 187 190 <object name="foodGathered[n]" type="text" style="CenteredLabelText"/> 188 <object name="vegetarianRatio[n]" type="text" style="CenteredLabelText"/>189 191 <object name="woodGathered[n]" type="text" style="CenteredLabelText"/> 190 192 <object name="stoneGathered[n]" type="text" style="CenteredLabelText" /> 191 193 <object name="metalGathered[n]" type="text" style="CenteredLabelText"/> 194 <object name="vegetarianRatio[n]" type="text" style="CenteredLabelText"/> 192 195 <object name="treasuresCollected[n]" type="text" style="CenteredLabelText"/> 193 196 </object> 194 197 </repeat> -
simulation/components/Foundation.js
80 80 { 81 81 var scaled = Math.floor(this.costs[r] * (1.0 - this.buildProgress)); 82 82 if (scaled) 83 { 83 84 cmpPlayer.AddResource(r, scaled); 85 var cmpStatisticsTracker = QueryPlayerIDInterface(this.owner, IID_StatisticsTracker); 86 if (cmpStatisticsTracker) 87 cmpStatisticsTracker.IncreaseResourceUsedCounter(r, -scaled); 88 } 84 89 } 85 90 86 91 // Reset the timer -
simulation/components/Player.js
191 191 else 192 192 { 193 193 // Subtract the resources 194 var cmpStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker); 194 195 for (var type in amounts) 196 { 195 197 this.resourceCount[type] -= amounts[type]; 198 if (cmpStatisticsTracker) 199 cmpStatisticsTracker.IncreaseResourceUsedCounter(type, amounts[type]); 200 } 196 201 } 197 202 198 203 return true; -
simulation/components/ProductionQueue.js
309 309 310 310 // Refund the resource cost for this batch 311 311 var totalCosts = {}; 312 var cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 312 313 for each (var r in ["food", "wood", "stone", "metal"]) 314 { 313 315 totalCosts[r] = Math.floor(item.count * item.resources[r]); 316 if (cmpStatisticsTracker) 317 cmpStatisticsTracker.IncreaseResourceUsedCounter(r, -totalCosts[r]); 318 } 314 319 315 320 cmpPlayer.AddResources(totalCosts); 316 321 -
simulation/components/StatisticsTracker.js
24 24 "stone": 0, 25 25 "vegetarianFood": 0 26 26 }; 27 this.resourcesUsed = { 28 "food": 0, 29 "wood": 0, 30 "metal": 0, 31 "stone": 0, 32 }; 27 33 this.resourcesSold = { 28 34 "food": 0, 29 35 "wood": 0, … … 52 58 "civCentresBuilt": this.civCentresBuilt, 53 59 "enemyCivCentresDestroyed": this.enemyCivCentresDestroyed, 54 60 "resourcesGathered": this.resourcesGathered, 61 "resourcesUsed": this.resourcesUsed, 55 62 "resourcesSold": this.resourcesSold, 56 63 "resourcesBought": this.resourcesBought, 57 64 "tradeIncome": this.tradeIncome, … … 135 142 this.resourcesGathered["vegetarianFood"] += amount; 136 143 }; 137 144 145 /** 146 * @param type Generic type of resource (string) 147 * @param amount Amount of resource which has been used (integer) 148 */ 149 StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount) 150 { 151 this.resourcesUsed[type] += amount; 152 }; 153 138 154 StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function() 139 155 { 140 156 return this.treasuresCollected++;