Ticket #3216: t3216_capture_statistics_v10_rebasedv2.patch
File t3216_capture_statistics_v10_rebasedv2.patch, 19.9 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/summary/counters.js
66 66 function calculateMilitaryScore(playerState) 67 67 { 68 68 return Math.round((playerState.statistics.enemyUnitsKilledValue + 69 playerState.statistics.enemyBuildingsDestroyedValue) / 10); 69 playerState.statistics.enemyBuildingsDestroyedValue + 70 playerState.statistics.buildingsCapturedValue) / 10); 70 71 } 71 72 72 73 function calculateExplorationScore(playerState) … … 114 115 { 115 116 let type = g_BuildingsTypes[position]; 116 117 return g_TrainedColor + playerState.statistics.buildingsConstructed[type] + '[/color] / ' + 117 g_LostColor + playerState.statistics.buildingsLost[type] + '[/color] / ' + 118 g_KilledColor + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]'; 118 g_KilledColor + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]\n' + 119 g_CapturedColor + playerState.statistics.buildingsCaptured[type] + '[/color] / ' + 120 g_LostColor + playerState.statistics.buildingsLost[type] + '[/color]\n'; 119 121 } 120 122 121 function calculate ColorsTeam(counters)123 function calculateBuildingsTeam(counters) 122 124 { 123 125 for (let t in g_Teams) 124 126 { … … 128 130 for (let w in counters) 129 131 { 130 132 let total = { 133 constructed : 0, 134 destroyed : 0, 135 captured : 0, 136 lost : 0 137 }; 138 for (let p = 0; p < g_Teams[t]; ++p) 139 { 140 let caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 141 // clean [Color=""], [/Color] and white space for make the sum more easy 142 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, ""); 143 144 let splitCaption = caption.split("\n"); 145 let first = splitCaption[0].split("/"); 146 let second = splitCaption[1].split("/"); 147 148 total.constructed += (+first[0]); 149 total.destroyed += (+first[1]); 150 total.captured += (+second[0]); 151 total.lost += (+second[1]); 152 } 153 let teamTotal = TRAINED_COLOR + total.constructed + '[/color] / ' + 154 KILLED_COLOR + total.destroyed + '[/color]\n' + 155 CAPTURED_COLOR + total.captured + '[/color] / ' + 156 LOST_COLOR + total.lost + '[/color]\n'; 157 158 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal; 159 } 160 } 161 } 162 163 function calculateUnitsTeam(counters) 164 { 165 for (let t in g_Teams) 166 { 167 if (t == -1) 168 continue; 169 170 for (let w in counters) 171 { 172 let total = { 131 173 "c": 0, 132 174 "l": 0, 133 175 "d": 0 -
binaries/data/mods/public/gui/summary/layout.js
9 9 ], 10 10 "titleHeadings": [], 11 11 "counters": [ // counters on score panel 12 { "width": 100, "fn": calculateEconomyScore },13 { "width": 100, "fn": calculateMilitaryScore },14 { "width": 100, "fn": calculateExplorationScore },15 { "width": 100, "fn": calculateScoreTotal }12 { "width": 100, "fn": calculateEconomyScore, "verticalOffset": 12 }, 13 { "width": 100, "fn": calculateMilitaryScore, "verticalOffset": 12 }, 14 { "width": 100, "fn": calculateExplorationScore, "verticalOffset": 12 }, 15 { "width": 100, "fn": calculateScoreTotal, "verticalOffset": 12 } 16 16 ], 17 17 "teamCounterFn": calculateScoreTeam 18 18 }, … … 29 29 { "caption": translate("Wonders"), "yStart": 34, "width": 85 } 30 30 ], 31 31 "titleHeadings": [ 32 { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) }, // width = 700 32 { 33 "caption": sprintf(translate("Buildings Statistics (%(constructed)s / %(destroyed)s / %(captured)s / %(lost)s)"), 34 { 35 constructed: g_TrainedColor + translate("Constructed") + '[/color]', 36 destroyed: g_KilledColor + translate("Destroyed") + '[/color]', 37 captured: g_CapturedColor + translate("Captured") + '[/color]', 38 lost: g_LostColor + translate("Lost") + '[/color]' 39 }), 40 "yStart": 16, 41 "width": (85 * 7 + 105) 42 }, // width = 735 33 43 ], 34 44 "counters": [ // counters on buildings panel 35 { "width": 105, "fn": calculateBuildings 36 { "width": 85, "fn": calculateBuildings 37 { "width": 85, "fn": calculateBuildings 38 { "width": 85, "fn": calculateBuildings 39 { "width": 85, "fn": calculateBuildings 40 { "width": 85, "fn": calculateBuildings 41 { "width": 85, "fn": calculateBuildings 42 { "width": 85, "fn": calculateBuildings 45 { "width": 105, "fn": calculateBuildings, "verticalOffset": 3}, 46 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 47 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 48 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 49 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 50 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 51 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3}, 52 { "width": 85, "fn": calculateBuildings, "verticalOffset": 3} 43 53 ], 44 "teamCounterFn": calculate ColorsTeam54 "teamCounterFn": calculateBuildingsTeam 45 55 }, 46 56 { // units panel 47 57 "headings": [ // headings on units panel … … 56 66 { "caption": translate("Traders"), "yStart": 34, "width": 100 } 57 67 ], 58 68 "titleHeadings": [ 59 { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820 69 { 70 "caption": sprintf(translate("Units Statistics (%(trained)s / %(lost)s / %(killed)s)"), 71 { 72 trained: g_TrainedColor + translate("Trained") + '[/color]', 73 lost: g_LostColor + translate("Lost") + '[/color]', 74 killed: g_KilledColor + translate("Killed") + '[/color]' 75 }), 76 "yStart": 16, 77 "width": (100 * 7 + 120) 78 }, // width = 720 60 79 ], 61 80 "counters": [ // counters on units panel 62 { "width": 120, "fn": calculateUnits },63 { "width": 100, "fn": calculateUnits },64 { "width": 100, "fn": calculateUnits },65 { "width": 100, "fn": calculateUnits },66 { "width": 100, "fn": calculateUnits },67 { "width": 100, "fn": calculateUnits },68 { "width": 100, "fn": calculateUnits },69 { "width": 100, "fn": calculateUnits }81 { "width": 120, "fn": calculateUnits, "verticalOffset": 12 }, 82 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 83 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 84 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 85 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 86 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 87 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }, 88 { "width": 100, "fn": calculateUnits, "verticalOffset": 12 } 70 89 ], 71 "teamCounterFn": calculate ColorsTeam90 "teamCounterFn": calculateUnitsTeam 72 91 }, 73 92 { // resources panel 74 93 "headings": [ // headings on resources panel … … 78 97 { "caption": translate("Stone"), "yStart": 34, "width": 100 }, 79 98 { "caption": translate("Metal"), "yStart": 34, "width": 100 }, 80 99 { "caption": translate("Total"), "yStart": 34, "width": 110 }, 81 { "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 }, 100 { 101 "caption": sprintf(translate("Tributes \n(%(sent)s / %(received)s)"), 102 { 103 sent: g_IncomeColor + translate("Sent") + '[/color]', 104 received: g_OutcomeColor + translate("Received") + '[/color]' 105 }), 106 "yStart": 16, 107 "width": 121 108 }, 82 109 { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 }, 83 110 { "caption": translate("Loot"), "yStart": 16, "width": 100 } 84 111 ], 85 112 "titleHeadings": [ 86 { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510 113 { 114 "caption": sprintf(translate("Resource Statistics (%(gathered)s / %(used)s)"), 115 { 116 gathered: g_IncomeColor + translate("Gathered") + '[/color]', 117 used: g_OutcomeColor + translate("Used") + '[/color]' 118 }), 119 "yStart": 16, 120 "width": (100 * 4 + 110) 121 }, // width = 510 87 122 ], 88 123 "counters": [ // counters on resources panel 89 { "width": 100, "fn": calculateResources },90 { "width": 100, "fn": calculateResources },91 { "width": 100, "fn": calculateResources },92 { "width": 100, "fn": calculateResources },93 { "width": 110, "fn": calculateTotalResources },94 { "width": 121, "fn": calculateTributeSent },95 { "width": 100, "fn": calculateTreasureCollected },96 { "width": 100, "fn": calculateLootCollected }124 { "width": 100, "fn": calculateResources, "verticalOffset": 12 }, 125 { "width": 100, "fn": calculateResources, "verticalOffset": 12 }, 126 { "width": 100, "fn": calculateResources, "verticalOffset": 12 }, 127 { "width": 100, "fn": calculateResources, "verticalOffset": 12 }, 128 { "width": 110, "fn": calculateTotalResources, "verticalOffset": 12 }, 129 { "width": 121, "fn": calculateTributeSent, "verticalOffset": 12 }, 130 { "width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12 }, 131 { "width": 100, "fn": calculateLootCollected, "verticalOffset": 12 } 97 132 ], 98 133 "teamCounterFn": calculateResourcesTeam 99 134 }, … … 109 144 ], 110 145 "titleHeadings": [], 111 146 "counters": [ // counters on market panel 112 { "width": 100, "fn": calculateResourceExchanged },113 { "width": 100, "fn": calculateResourceExchanged },114 { "width": 100, "fn": calculateResourceExchanged },115 { "width": 100, "fn": calculateResourceExchanged },116 { "width": 100, "fn": calculateBarterEfficiency },117 { "width": 100, "fn": calculateTradeIncome }147 { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 }, 148 { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 }, 149 { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 }, 150 { "width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12 }, 151 { "width": 100, "fn": calculateBarterEfficiency, "verticalOffset": 12 }, 152 { "width": 100, "fn": calculateTradeIncome, "verticalOffset": 12 } 118 153 ], 119 154 "teamCounterFn": calculateMarketTeam 120 155 }, … … 132 167 { "caption": translate("Map control"), "xOffset": 400, "yStart": 16, "width": 200 } 133 168 ], 134 169 "counters": [ // counters on miscellaneous panel 135 { "width": 100, "fn": calculateVegetarianRatio },136 { "width": 100, "fn": calculateFeminization },137 { "width": 100, "fn": calculateKillDeathRatio },138 { "width": 100, "fn": calculateMapExploration },139 { "width": 100, "fn": calculateMapPeakControl },140 { "width": 100, "fn": calculateMapFinalControl }170 { "width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12 }, 171 { "width": 100, "fn": calculateFeminization, "verticalOffset": 12 }, 172 { "width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12 }, 173 { "width": 100, "fn": calculateMapExploration, "verticalOffset": 12 }, 174 { "width": 100, "fn": calculateMapPeakControl, "verticalOffset": 12 }, 175 { "width": 100, "fn": calculateMapFinalControl, "verticalOffset": 12 } 141 176 ], 142 177 "teamCounterFn": calculateMiscellaneous 143 178 } … … 214 249 for (let w in counters) 215 250 { 216 251 counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]"); 217 counterObject.size = left + " 6" + (left + counters[w].width) + " 100%";252 counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%"; 218 253 counterObject.hidden = false; 219 254 left += counters[w].width; 220 255 } … … 229 264 for (let w in counters) 230 265 { 231 266 counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]"); 232 counterObject.size = left + " 6" + (left + counters[w].width) + " 100%";267 counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%"; 233 268 counterObject.hidden = false; 234 269 235 270 if (g_Teams[t]) 236 271 { 237 let yStart = 30 + g_Teams[t] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;272 let yStart = 25 + g_Teams[t] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 3 + counters[w].verticalOffset; 238 273 counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]"); 239 274 counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%"; 240 275 counterTotalObject.hidden = false; … … 272 307 Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1); 273 308 274 309 let teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]"); 275 let yStartTotal = 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;276 teamHeading.size = "50 " +yStartTotal+" 100% "+(yStartTotal+20);310 let yStartTotal = 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 10; 311 teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20); 277 312 teamHeading.caption = translate("Team total"); 278 313 } 279 314 -
binaries/data/mods/public/gui/summary/summary.js
3 3 // const for filtering long collective headings 4 4 const g_LongHeadingWidth = 250; 5 5 // Vertical size of player box 6 const g_PlayerBoxYSize = 30;6 const g_PlayerBoxYSize = 40; 7 7 // Gap between players boxes 8 8 const g_PlayerBoxGap = 2; 9 9 // Alpha for player box … … 11 11 // Alpha for player color box 12 12 const g_PlayerColorBoxAlpha = " 255"; 13 13 // yStart value for spacing teams boxes (and noTeamsBox) 14 const g_TeamsBoxYStart = 65;14 const g_TeamsBoxYStart = 40; 15 15 // Colors used for units and buildings 16 16 const g_TrainedColor = '[color="201 255 200"]'; 17 17 const g_LostColor = '[color="255 213 213"]'; 18 18 const g_KilledColor = '[color="196 198 255"]'; 19 const g_CapturedColor = '[color="255 255 157"]'; 19 20 20 21 const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ]; 21 22 const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ]; -
binaries/data/mods/public/gui/summary/summary.xml
14 14 15 15 <!-- After settings.js, which defines g_Settings and g_MaxPlayers. --> 16 16 <script file="gui/summary/counters.js"/> 17 <script file="gui/summary/summary.js"/> 17 18 <script file="gui/summary/layout.js"/> 18 <script file="gui/summary/summary.js"/>19 19 20 20 <object type="image" 21 21 style="ModernWindow" … … 122 122 <object size="0 30 100% 100%"> 123 123 <repeat count="8" var="n"> 124 124 <object type="image" name="playerBoxt[i][n]" size="10 0 10 30" hidden="true"> 125 <object name="playerColorBoxt[i][n]" type="image" size="10 4 30 24"/> 126 <object name="playerNamet[i][n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText" /> 127 <object name="civIcont[i][n]" type="image" size="208 0 240 32"/> 125 <object type="image" sprite="ForegroundBox" size="10 9 34 33"> 126 <object name="playerColorBoxt[i][n]" type="image" size="2 2 22 22"/> 127 </object> 128 <object name="playerNamet[i][n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText"/> 129 <object name="civIcont[i][n]" type="image" size="208 5 240 37"/> 128 130 <repeat var="x" count="8"> 129 131 <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText"> 130 132 </object> … … 143 145 <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true"> 144 146 <repeat count="8"> 145 147 <object type="image" name="playerBox[n]" size="10 0 10 30" hidden="true"> 146 <object type="image" sprite="ForegroundBox" size="10 4 34 28">148 <object type="image" sprite="ForegroundBox" size="10 9 34 33"> 147 149 <object name="playerColorBox[n]" type="image" size="2 2 22 22"/> 148 150 </object> 149 151 <object name="playerName[n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText"/> 150 <object name="civIcon[n]" type="image" size="208 0 240 32"/>152 <object name="civIcon[n]" type="image" size="208 5 240 37"/> 151 153 <repeat var="x" count="8"> 152 154 <object name="valueData[n][x]" type="text" style="ModernTabLabelText"> 153 155 </object> -
binaries/data/mods/public/simulation/components/Capturable.js
151 151 if (this.cp[i] >= this.cp[bestPlayer]) 152 152 bestPlayer = +i; 153 153 154 let cmpLostPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 155 if (cmpLostPlayerStatisticsTracker) 156 cmpLostPlayerStatisticsTracker.LostEntity(this.entity); 157 154 158 cmpOwnership.SetOwner(bestPlayer); 159 160 let cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 161 if (cmpCapturedPlayerStatisticsTracker) 162 cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity); 155 163 }; 156 164 157 165 Capturable.prototype.GetRegenRate = function() -
binaries/data/mods/public/simulation/components/StatisticsTracker.js
93 93 "total": 0 94 94 }; 95 95 this.enemyBuildingsDestroyedValue = 0; 96 this.buildingsCaptured = { 97 "House": 0, 98 "Economic": 0, 99 "Outpost": 0, 100 "Military": 0, 101 "Fortress": 0, 102 "CivCentre": 0, 103 "Wonder": 0, 104 "total": 0 105 }; 106 this.buildingsCapturedValue = 0; 96 107 // resources 97 108 this.resourcesGathered = { 98 109 "food": 0, … … 152 163 "unitsLostValue": this.unitsLostValue, 153 164 "enemyUnitsKilled": this.enemyUnitsKilled, 154 165 "enemyUnitsKilledValue": this.enemyUnitsKilledValue, 155 "buildingsConstructed": this.buildingsConstructed, 156 "buildingsLost": this.buildingsLost, 166 "buildingsConstructed": this.buildingsConstructed, 167 "buildingsLost": this.buildingsLost, 157 168 "buildingsLostValue": this.buildingsLostValue, 158 169 "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed, 159 170 "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, 171 "buildingsCaptured": this.buildingsCaptured, 172 "buildingsCapturedValue": this.buildingsCapturedValue, 160 173 "resourcesGathered": this.resourcesGathered, 161 174 "resourcesUsed": this.resourcesUsed, 162 175 "resourcesSold": this.resourcesSold, 163 "resourcesBought": this.resourcesBought, 164 "tributesSent": this.tributesSent, 176 "resourcesBought": this.resourcesBought, 177 "tributesSent": this.tributesSent, 165 178 "tributesReceived": this.tributesReceived, 166 179 "tradeIncome": this.tradeIncome, 167 180 "treasuresCollected": this.treasuresCollected, … … 306 319 } 307 320 }; 308 321 309 /** 310 * @param type Generic type of resource (string) 311 * @param amount Amount of resource, whick should be added (integer) 312 * @param specificType Specific type of resource (string, optional) 313 */ 322 StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding) 323 { 324 let cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity); 325 let cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost); 326 let costs = cmpCost.GetResourceCosts(); 327 328 for (let type of this.buildingsClasses) 329 this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type); 330 331 this.buildingsCaptured.total++; 332 333 for (let i in costs) 334 this.buildingsCapturedValue += costs[i]; 335 }; 336 337 /** 338 * @param type Generic type of resource (string) 339 * @param amount Amount of resource, whick should be added (integer) 340 * @param specificType Specific type of resource (string, optional) 341 */ 314 342 StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType) 315 343 { 316 344 this.resourcesGathered[type] += amount;