Ticket #3518: ticket3518_summarystyle.diff
File ticket3518_summarystyle.diff, 15.7 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/summary/counters.js
2 2 var teamMiscHelperData = []; 3 3 4 4 function resetDataHelpers() 5 {6 5 teamMiscHelperData = []; 7 }8 6 9 7 function updateCountersPlayer(playerState, counters, idGUI) 10 8 { 11 for ( varw in counters)9 for (let w in counters) 12 10 { 13 11 var fn = counters[w].fn; 14 12 Engine.GetGUIObjectByName(idGUI + "[" + w + "]").caption = fn && fn(playerState, w); … … 18 16 function calculateEconomyScore(playerState, position) 19 17 { 20 18 let total = 0; 21 for each ( varres in playerState.statistics.resourcesGathered)19 for each (let res in playerState.statistics.resourcesGathered) 22 20 total += res; 23 21 24 22 return Math.round(total / 10); … … 26 24 27 25 function calculateMilitaryScore(playerState, position) 28 26 { 29 return Math.round((playerState.statistics.enemyUnitsKilledValue + 30 27 return Math.round((playerState.statistics.enemyUnitsKilledValue + 28 playerState.statistics.enemyBuildingsDestroyedValue) / 10); 31 29 } 32 30 33 31 function calculateExplorationScore(playerState, position) … … 38 36 function calculateScoreTotal(playerState, position) 39 37 { 40 38 return calculateEconomyScore(playerState) + 41 calculateMilitaryScore(playerState) +42 39 calculateMilitaryScore(playerState) + 40 calculateExplorationScore(playerState); 43 41 } 44 42 45 43 function calculateScoreTeam(counters) 46 44 { 47 for ( vart in g_Teams)45 for (let t in g_Teams) 48 46 { 49 47 if (t == -1) 50 48 continue; 51 49 52 for ( varw in counters)50 for (let w in counters) 53 51 { 54 52 var total = 0; 55 for ( varp = 0; p < g_Teams[t]; ++p)53 for (let p = 0; p < g_Teams[t]; ++p) 56 54 total += (+Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption); 57 55 58 56 Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = total; … … 64 62 { 65 63 var type = BUILDINGS_TYPES[position]; 66 64 return TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + '[/color] / ' + 67 LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color] / ' +68 KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]';65 LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color] / ' + 66 KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]'; 69 67 } 70 68 71 69 function calculateColorsTeam(counters) 72 70 { 73 for ( vart in g_Teams)71 for (let t in g_Teams) 74 72 { 75 73 if (t == -1) 76 74 continue; 77 75 78 for ( varw in counters)76 for (let w in counters) 79 77 { 80 78 var total = { 81 79 c : 0, … … 82 80 l : 0, 83 81 d : 0 84 82 }; 85 for ( varp = 0; p < g_Teams[t]; ++p)83 for (let p = 0; p < g_Teams[t]; ++p) 86 84 { 87 85 var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 88 86 // clean [Color=""], [/Color] and white space for make the sum more easy … … 106 104 { 107 105 var type = UNITS_TYPES[position]; 108 106 return TRAINED_COLOR + playerState.statistics.unitsTrained[type] + '[/color] / ' + 109 LOST_COLOR + playerState.statistics.unitsLost[type] + '[/color] / ' +110 KILLED_COLOR + playerState.statistics.enemyUnitsKilled[type] + '[/color]';107 LOST_COLOR + playerState.statistics.unitsLost[type] + '[/color] / ' + 108 KILLED_COLOR + playerState.statistics.enemyUnitsKilled[type] + '[/color]'; 111 109 } 112 110 113 111 function calculateResources(playerState, position) … … 114 112 { 115 113 var type = RESOURCES_TYPES[position]; 116 114 return INCOME_COLOR + playerState.statistics.resourcesGathered[type] + '[/color] / ' + 117 OUTCOME_COLOR + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + '[/color]';115 OUTCOME_COLOR + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + '[/color]'; 118 116 } 119 117 120 118 function calculateTotalResources(playerState, position) … … 122 120 var totalGathered = 0; 123 121 var totalUsed = 0; 124 122 125 for each ( vartype in RESOURCES_TYPES)123 for each (let type in RESOURCES_TYPES) 126 124 { 127 125 totalGathered += playerState.statistics.resourcesGathered[type]; 128 126 totalUsed += playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]; … … 143 141 144 142 function calculateTributeSent(playerState, position) 145 143 { 146 return INCOME_COLOR + playerState.statistics.tributesSent + "[/color] / " + OUTCOME_COLOR + playerState.statistics.tributesReceived + "[/color]"; 144 return INCOME_COLOR + playerState.statistics.tributesSent + "[/color] / " + 145 OUTCOME_COLOR + playerState.statistics.tributesReceived + "[/color]"; 147 146 } 148 147 149 148 function calculateResourcesTeam(counters) 150 149 { 151 for ( vart in g_Teams)150 for (let t in g_Teams) 152 151 { 153 152 if (t == -1) 154 153 continue; 155 154 156 for ( varw in counters)155 for (let w in counters) 157 156 { 158 157 var teamTotal = "undefined"; 159 158 … … 161 160 i : 0, 162 161 o : 0 163 162 }; 164 for ( varp = 0; p < g_Teams[t]; ++p)163 for (let p = 0; p < g_Teams[t]; ++p) 165 164 { 166 165 var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 167 166 // clean [Color=""], [/Color] and white space for make the sum more easy … … 192 191 { 193 192 var type = RESOURCES_TYPES[position]; 194 193 return INCOME_COLOR + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' + 195 194 OUTCOME_COLOR + '-' + playerState.statistics.resourcesSold[type] + '[/color]'; 196 195 } 197 196 198 197 function calculateBatteryEfficiency(playerState, position) 199 198 { 200 199 var totalBought = 0; 201 for each ( varboughtAmount in playerState.statistics.resourcesBought)200 for each (let boughtAmount in playerState.statistics.resourcesBought) 202 201 totalBought += boughtAmount; 203 202 var totalSold = 0; 204 for each ( varsoldAmount in playerState.statistics.resourcesSold)203 for each (let soldAmount in playerState.statistics.resourcesSold) 205 204 totalSold += soldAmount; 206 205 207 206 return Math.floor(totalSold > 0 ? (totalBought / totalSold) * 100 : 0) + "%"; … … 214 213 215 214 function calculateMarketTeam(counters) 216 215 { 217 for ( vart in g_Teams)216 for (let t in g_Teams) 218 217 { 219 218 if (t == -1) 220 219 continue; 221 220 222 for ( varw in counters)221 for (let w in counters) 223 222 { 224 223 var teamTotal = "undefined"; 225 224 … … 227 226 i : 0, 228 227 o : 0 229 228 }; 230 for ( varp = 0; p < g_Teams[t]; ++p)229 for (let p = 0; p < g_Teams[t]; ++p) 231 230 { 232 231 var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption; 233 232 // clean [Color=""], [/Color], white space, + and % for make the sum more easy … … 334 333 335 334 function calculateMiscellaneous(counters) 336 335 { 337 for ( vart in g_Teams)336 for (let t in g_Teams) 338 337 { 339 338 if (t == -1) 340 339 continue; 341 340 342 for ( varw in counters)341 for (let w in counters) 343 342 { 344 343 var teamTotal = "undefined"; 345 344 -
binaries/data/mods/public/gui/summary/layout.js
16 16 ], 17 17 "teamCounterFn": calculateScoreTeam 18 18 }, 19 19 { // buildings panel 20 20 "headings": [ // headings on buildings panel 21 21 { "caption": translate("Player name"), "yStart": 26, "width": 200 }, 22 22 { "caption": translate("Total"), "yStart": 34, "width": 105 }, … … 32 32 { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) }, // width = 700 33 33 ], 34 34 "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}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 } 43 43 ], 44 44 "teamCounterFn": calculateColorsTeam 45 45 }, … … 59 59 { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820 60 60 ], 61 61 "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}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 } 70 70 ], 71 71 "teamCounterFn": calculateColorsTeam 72 72 }, … … 86 86 { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510 87 87 ], 88 88 "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}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 } 97 97 ], 98 98 "teamCounterFn": calculateResourcesTeam 99 99 }, … … 109 109 ], 110 110 "titleHeadings": [], 111 111 "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": calculateBatteryEfficiency},117 { "width": 100, "fn": calculateTradeIncome}112 { "width": 100, "fn": calculateResourceExchanged }, 113 { "width": 100, "fn": calculateResourceExchanged }, 114 { "width": 100, "fn": calculateResourceExchanged }, 115 { "width": 100, "fn": calculateResourceExchanged }, 116 { "width": 100, "fn": calculateBatteryEfficiency }, 117 { "width": 100, "fn": calculateTradeIncome } 118 118 ], 119 119 "teamCounterFn": calculateMarketTeam 120 120 }, … … 132 132 { "caption": translate("Map control"), "xOffset": 400, "yStart": 16, "width": 200 } 133 133 ], 134 134 "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}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 } 141 141 ], 142 142 "teamCounterFn": calculateMiscellaneous 143 143 } … … 145 145 146 146 function resetGeneralPanel() 147 147 { 148 for ( varh = 0; h < MAX_HEADINGTITLE; ++h)148 for (let h = 0; h < MAX_HEADINGTITLE; ++h) 149 149 { 150 150 Engine.GetGUIObjectByName("titleHeading["+ h +"]").hidden = true; 151 151 Engine.GetGUIObjectByName("Heading[" + h + "]").hidden = true; … … 164 164 function updateGeneralPanelHeadings(headings) 165 165 { 166 166 var left = 50; 167 for ( varh in headings)167 for (let h in headings) 168 168 { 169 169 var headerGUIName = "playerNameHeading"; 170 170 if (h > 0) … … 183 183 function updateGeneralPanelTitles(titleHeadings) 184 184 { 185 185 var left = 250; 186 for ( varth in titleHeadings)186 for (let th in titleHeadings) 187 187 { 188 188 if (th >= MAX_HEADINGTITLE) 189 189 break; … … 209 209 { 210 210 left = 240; 211 211 var counterObject; 212 for ( varw in counters)212 for (let w in counters) 213 213 { 214 214 counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]"); 215 215 counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%"; … … 223 223 for (let t = 0; t < g_MaxTeams; ++t) 224 224 { 225 225 left = 240; 226 for ( varw in counters)226 for (let w in counters) 227 227 { 228 228 counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]"); 229 229 counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%"; … … 253 253 return; 254 254 255 255 var yStart = TEAMS_BOX_Y_START + g_WithoutTeam * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP); 256 for ( vari = 0; i < g_Teams.length; ++i)256 for (let i = 0; i < g_Teams.length; ++i) 257 257 { 258 258 if (!g_Teams[i]) 259 259 continue; -
binaries/data/mods/public/gui/summary/summary.js
52 52 rightSpacer.size = (tabSize.right - 2) + " " + rightSpacer.size.top + " 100%-20 " + rightSpacer.size.bottom; 53 53 } 54 54 55 for ( vari = 0; i < panelNames.length; ++i)55 for (let i = 0; i < panelNames.length; ++i) 56 56 { 57 57 Engine.GetGUIObjectByName(panelNames[i] + 'Button').sprite = "BackgroundTab"; 58 58 } … … 73 73 updateGeneralPanelTeams(); 74 74 75 75 var playerBoxesCounts = [ ]; 76 for ( vari = 0; i < g_PlayerCount; ++i)76 for (let i = 0; i < g_PlayerCount; ++i) 77 77 { 78 78 var playerState = g_GameData.playerStates[i+1]; 79 79 … … 98 98 } 99 99 100 100 var colorString = "color: " 101 102 103 101 + Math.floor(playerState.color.r * 255) + " " 102 + Math.floor(playerState.color.g * 255) + " " 103 + Math.floor(playerState.color.b * 255); 104 104 105 105 var rowPlayerObject = Engine.GetGUIObjectByName(rowPlayer); 106 106 rowPlayerObject.hidden = false; … … 146 146 var mapSizes = initMapSizes(); 147 147 148 148 // retrieve the index of the map size 149 for ( varmapSizeIndex in mapSizes.tiles)149 for (let mapSizeIndex in mapSizes.tiles) 150 150 { 151 151 if (mapSizes.tiles[mapSizeIndex] == data.mapSettings.Size) 152 152 { … … 164 164 if (data.mapSettings.LockTeams) // teams ARE locked 165 165 { 166 166 // Count teams 167 for( vart = 0; t < g_PlayerCount; ++t)167 for(let t = 0; t < g_PlayerCount; ++t) 168 168 { 169 169 let playerTeam = data.playerStates[t+1].team; 170 170 if (g_Teams[playerTeam]) … … 182 182 // Erase teams data if teams are not displayed 183 183 if (!g_Teams) 184 184 { 185 for( varp = 0; p < g_PlayerCount; ++p)185 for(let p = 0; p < g_PlayerCount; ++p) 186 186 data.playerStates[p+1].team = -1; 187 187 } 188 188 … … 190 190 if (g_Teams) 191 191 { 192 192 // Count players without team (or all if teams are not displayed) 193 for ( vari = 0; i < g_Teams.length; ++i)193 for (let i = 0; i < g_Teams.length; ++i) 194 194 g_WithoutTeam -= g_Teams[i] ? g_Teams[i] : 0; 195 195 }