Ticket #3216: 3216.9.patch
File 3216.9.patch, 18.5 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/summary/counters.js
27 27 function calculateMilitaryScore(playerState, position) 28 28 { 29 29 return Math.round((playerState.statistics.enemyUnitsKilledValue + 30 playerState.statistics.enemyBuildingsDestroyedValue) / 10); 30 playerState.statistics.enemyBuildingsDestroyedValue + 31 playerState.statistics.buildingsCapturedValue) / 10); 31 32 } 32 33 33 34 function calculateExplorationScore(playerState, position) … … 63 64 function calculateBuildings(playerState, position) 64 65 { 65 66 var type = BUILDINGS_TYPES[position]; 66 return TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + '[/color] / ' + 67 LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color] / ' + 68 KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]'; 67 return ' ' + TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + '[/color] / ' + 68 KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]\n' + 69 CAPTURED_COLOR + playerState.statistics.buildingsCaptured[type] + '[/color] / ' + 70 LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color]'; 69 71 } 70 72 71 function calculate ColorsTeam(counters)73 function calculateBuildingsTeam(counters) 72 74 { 73 75 for (var t in g_Teams) 74 76 { … … 78 80 for (var w in counters) 79 81 { 80 82 var total = { 83 constructed : 0, 84 destroyed : 0, 85 captured : 0, 86 lost : 0 87 }; 88 for (var p = 0; p < g_Teams[t]; ++p) 89 { 90 var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 91 // clean [Color=""], [/Color] and white space for make the sum more easy 92 caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, ""); 93 94 var splitCaption = caption.split("\n"); 95 var first = splitCaption[0].split("/"); 96 var second = splitCaption[1].split("/"); 97 98 total.constructed += (+first[0]); 99 total.destroyed += (+first[1]); 100 total.captured += (+second[0]); 101 total.lost += (+second[1]); 102 } 103 var teamTotal = ' ' + TRAINED_COLOR + total.constructed + '[/color] / ' + 104 KILLED_COLOR + total.destroyed + '[/color]\n' + 105 CAPTURED_COLOR + total.captured + '[/color] / ' + 106 LOST_COLOR + total.lost + '[/color]'; 107 108 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal; 109 } 110 } 111 } 112 113 function calculateUnitsTeam(counters) 114 { 115 for (var t in g_Teams) 116 { 117 if (t == -1) 118 continue; 119 120 for (var w in counters) 121 { 122 var total = { 81 123 c : 0, 82 124 l : 0, 83 125 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 = 735 32 { 33 "caption": sprintf(translate("Buildings Statistics (%(constructed)s / %(destroyed)s / %(captured)s / %(lost)s)"), 34 { 35 constructed: '[color="201 255 200"]' + translate("Constructed") + '[/color]', 36 destroyed: '[color="196 198 255"]' + translate("Destroyed") + '[/color]', 37 captured: '[color="255 255 157"]' + translate("Captured") + '[/color]', 38 lost: '[color="255 213 213"]' + 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 … … 55 65 { "caption": translate("Navy"), "yStart": 34, "width": 100 } 56 66 ], 57 67 "titleHeadings": [ 58 { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 6 + 120) }, // width = 720 68 { 69 "caption": sprintf(translate("Units Statistics (%(trained)s / %(lost)s / %(killed)s)"), 70 { 71 trained: '[color="201 255 200"]' + translate("Trained") + '[/color]', 72 lost: '[color="255 213 213"]' + translate("Lost") + '[/color]', 73 killed: '[color="196 198 255"]' + translate("Killed") + '[/color]' 74 }), 75 "yStart": 16, 76 "width": (100 * 6 + 120) 77 }, // width = 720 59 78 ], 60 79 "counters": [ // counters on units panel 61 {"width": 120, "fn": calculateUnits },62 {"width": 100, "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 }80 {"width": 120, "fn": calculateUnits, "verticalOffset": 12}, 81 {"width": 100, "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} 68 87 ], 69 "teamCounterFn": calculate ColorsTeam88 "teamCounterFn": calculateUnitsTeam 70 89 }, 71 90 { // resources panel 72 91 "headings": [ // headings on resources panel … … 77 96 { "caption": translate("Metal"), "yStart": 34, "width": 100 }, 78 97 { "caption": translate("Total"), "yStart": 34, "width": 110 }, 79 98 { "caption": translate("Treasures collected"), "yStart": 16, "width": 100 }, 80 { "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 } 99 { 100 "caption": sprintf(translate("Tributes (%(sent)s / %(received)s)"), 101 { 102 sent: '[color="201 255 200"]' + translate("Sent") + '[/color]', 103 received: '[color="255 213 213"]' + translate("Received") + '[/color]' 104 }), 105 "yStart": 16, 106 "width": 121 107 } 81 108 ], 82 109 "titleHeadings": [ 83 { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510 110 { 111 "caption": sprintf(translate("Resource Statistics (%(gathered)s / %(used)s)"), 112 { 113 gathered: '[color="201 255 200"]' + translate("Gathered") + '[/color]', 114 used: '[color="255 213 213"]' + translate("Used") + '[/color]' 115 }), 116 "yStart": 16, 117 "width": (100 * 4 + 110) 118 }, // width = 510 84 119 ], 85 120 "counters": [ // counters on resources panel 86 {"width": 100, "fn": calculateResources },87 {"width": 100, "fn": calculateResources },88 {"width": 100, "fn": calculateResources },89 {"width": 100, "fn": calculateResources },90 {"width": 110, "fn": calculateTotalResources },91 {"width": 100, "fn": calculateTreasureCollected },92 {"width": 121, "fn": calculateTributeSent }121 {"width": 100, "fn": calculateResources, "verticalOffset": 12}, 122 {"width": 100, "fn": calculateResources, "verticalOffset": 12}, 123 {"width": 100, "fn": calculateResources, "verticalOffset": 12}, 124 {"width": 100, "fn": calculateResources, "verticalOffset": 12}, 125 {"width": 110, "fn": calculateTotalResources, "verticalOffset": 12}, 126 {"width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12}, 127 {"width": 121, "fn": calculateTributeSent, "verticalOffset": 12} 93 128 ], 94 129 "teamCounterFn": calculateResourcesTeam 95 130 }, … … 105 140 ], 106 141 "titleHeadings": [], 107 142 "counters": [ // counters on market panel 108 {"width": 100, "fn": calculateResourceExchanged },109 {"width": 100, "fn": calculateResourceExchanged },110 {"width": 100, "fn": calculateResourceExchanged },111 {"width": 100, "fn": calculateResourceExchanged },112 {"width": 100, "fn": calculateBatteryEfficiency },113 {"width": 100, "fn": calculateTradeIncome }143 {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12}, 144 {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12}, 145 {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12}, 146 {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12}, 147 {"width": 100, "fn": calculateBatteryEfficiency, "verticalOffset": 12}, 148 {"width": 100, "fn": calculateTradeIncome, "verticalOffset": 12} 114 149 ], 115 150 "teamCounterFn": calculateMarketTeam 116 151 }, … … 124 159 ], 125 160 "titleHeadings": [], 126 161 "counters": [ // counters on miscellaneous panel 127 {"width": 100, "fn": calculateVegetarianRatio },128 {"width": 100, "fn": calculateFeminisation },129 {"width": 100, "fn": calculateKillDeathRatio },130 {"width": 100, "fn": calculateMapExploration }162 {"width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12}, 163 {"width": 100, "fn": calculateFeminisation, "verticalOffset": 12}, 164 {"width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12}, 165 {"width": 100, "fn": calculateMapExploration, "verticalOffset": 12} 131 166 ], 132 167 "teamCounterFn": calculateMiscellaneous 133 168 } … … 189 224 { 190 225 var rowPlayerObjectWidth = 0; 191 226 var left = 0; 227 192 228 for (var p = 0; p < MAX_SLOTS; ++p) 193 229 { 194 230 left = 240; … … 196 232 for (var w in counters) 197 233 { 198 234 counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]"); 199 counterObject.size = left + " 6" + (left + counters[w].width) + " 100%";235 counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%"; 200 236 counterObject.hidden = false; 201 237 left += counters[w].width; 202 238 } … … 210 246 for (var w in counters) 211 247 { 212 248 counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]"); 213 counterObject.size = left + " 6" + (left + counters[w].width) + " 100%";249 counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%"; 214 250 counterObject.hidden = false; 215 251 216 252 if (g_Teams[t]) 217 253 { 218 var yStart = 30 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;254 var yStart = 25 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 3 + counters[w].verticalOffset; 219 255 counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]"); 220 256 counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%"; 221 257 counterTotalObject.hidden = false; … … 250 286 Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1); 251 287 252 288 var teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]"); 253 var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;254 teamHeading.size = "50 " +yStartTotal+" 100% "+(yStartTotal+20);289 var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 10; 290 teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20); 255 291 teamHeading.caption = translate("Team total"); 256 292 } 257 293 // If there are no players without team, hide "player name" heading -
binaries/data/mods/public/gui/summary/summary.js
6 6 // const for filtering long collective headings 7 7 const LONG_HEADING_WIDTH = 250; 8 8 // vertical size of player box 9 const PLAYER_BOX_Y_SIZE = 30;9 const PLAYER_BOX_Y_SIZE = 40; 10 10 // gap between players boxes 11 11 const PLAYER_BOX_GAP = 2; 12 12 // alpha for player box … … 14 14 // alpha for player color box 15 15 const PLAYER_COLOR_BOX_ALPHA = " 255"; 16 16 // yStart value for spacing teams boxes (and noTeamsBox) 17 const TEAMS_BOX_Y_START = 65;17 const TEAMS_BOX_Y_START = 40; 18 18 // colors used for units and buildings 19 19 const TRAINED_COLOR = '[color="201 255 200"]'; 20 20 const LOST_COLOR = '[color="255 213 213"]'; 21 21 const KILLED_COLOR = '[color="196 198 255"]'; 22 const CAPTURED_COLOR = '[color="255 255 157"]'; 22 23 23 24 const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ]; 24 25 const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship" ]; -
binaries/data/mods/public/gui/summary/summary.xml
119 119 <object size="0 30 100% 100%"> 120 120 <repeat count="8" var="n"> 121 121 <object type="image" name="playerBoxt[i][n]" size="10 0 10 30" hidden="true"> 122 <object name="playerColorBoxt[i][n]" type="image" size="10 4 30 24"/> 122 <object type="image" sprite="ForegroundBox" size="10 9 34 33"> 123 <object name="playerColorBoxt[i][n]" type="image" size="2 2 22 22"/> 124 </object> 123 125 <object name="playerNamet[i][n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText" /> 124 <object name="civIcont[i][n]" type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/>126 <object name="civIcont[i][n]" type="image" size="208 5 240 37" tooltip_style="sessionToolTip"/> 125 127 <repeat var="x" count="8"> 126 128 <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText"> 127 129 </object> … … 140 142 <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true"> 141 143 <repeat count="8"> 142 144 <object type="image" name="playerBox[n]" size="10 0 10 30" hidden="true"> 143 <object type="image" sprite="ForegroundBox" size="10 4 34 28">145 <object type="image" sprite="ForegroundBox" size="10 9 34 33"> 144 146 <object name="playerColorBox[n]" type="image" size="2 2 22 22"/> 145 147 </object> 146 148 <object name="playerName[n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText"/> 147 <object name="civIcon[n]" type="image" size="208 0 240 32"/>149 <object name="civIcon[n]" type="image" size="208 5 240 37"/> 148 150 <repeat var="x" count="8"> 149 151 <object name="valueData[n][x]" type="text" style="ModernTabLabelText"> 150 152 </object> -
binaries/data/mods/public/simulation/components/Capturable.js
103 103 for (let i in this.cp) 104 104 if (this.cp[i] >= this.cp[bestPlayer]) 105 105 bestPlayer = +i; 106 107 var cmpLostPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 108 if (cmpLostPlayerStatisticsTracker) 109 cmpLostPlayerStatisticsTracker.LostEntity(this.entity); 106 110 107 111 cmpOwnership.SetOwner(bestPlayer); 108 112 113 var cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); 114 if (cmpCapturedPlayerStatisticsTracker) 115 cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity); 116 109 117 return takenCp; 110 118 }; 111 119 -
binaries/data/mods/public/simulation/components/StatisticsTracker.js
76 76 "CivCentre": 0, 77 77 "Wonder": 0, 78 78 "total": 0 79 79 }; 80 80 this.buildingsLostValue = 0; 81 81 this.enemyBuildingsDestroyed = { 82 82 "House": 0, … … 87 87 "CivCentre": 0, 88 88 "Wonder": 0, 89 89 "total": 0 90 }; 91 this.enemyBuildingsDestroyedValue = 0; 90 }; 91 this.enemyBuildingsDestroyedValue = 0; 92 this.buildingsCaptured = { 93 "House": 0, 94 "Economic": 0, 95 "Outpost": 0, 96 "Military": 0, 97 "Fortress": 0, 98 "CivCentre": 0, 99 "Wonder": 0, 100 "total": 0 101 }; 102 this.buildingsCapturedValue = 0; 92 103 // resources 93 104 this.resourcesGathered = { 94 105 "food": 0, … … 149 160 "buildingsLost": this.buildingsLost, 150 161 "buildingsLostValue": this.buildingsLostValue, 151 162 "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed, 152 "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, 163 "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue, 164 "buildingsCaptured": this.buildingsCaptured, 165 "buildingsCapturedValue": this.buildingsCapturedValue, 153 166 "resourcesGathered": this.resourcesGathered, 154 167 "resourcesUsed": this.resourcesUsed, 155 168 "resourcesSold": this.resourcesSold, … … 292 305 for each (var cost in costs) 293 306 this.buildingsLostValue += cost; 294 307 } 308 }; 309 310 StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding) 311 { 312 var cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity); 313 var cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost); 314 var costs = cmpCost.GetResourceCosts(); 315 316 for each (var type in this.buildingsClasses) 317 this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type); 318 319 this.buildingsCaptured.total++; 320 321 for each (var cost in costs) 322 this.buildingsCapturedValue += cost; 295 323 }; 296 324 297 325 /**