Ticket #3518: ticket3518_summarystyle.diff

File ticket3518_summarystyle.diff, 15.7 KB (added by bb, 9 years ago)

Some spaces and let to var changes

  • binaries/data/mods/public/gui/summary/counters.js

     
    22var teamMiscHelperData = [];
    33
    44function resetDataHelpers()
    5 {
    65    teamMiscHelperData = [];
    7 }
    86
    97function updateCountersPlayer(playerState, counters, idGUI)
    108{
    11     for (var w in counters)
     9    for (let w in counters)
    1210    {
    1311        var fn = counters[w].fn;
    1412        Engine.GetGUIObjectByName(idGUI + "[" + w + "]").caption = fn && fn(playerState, w);
     
    1816function calculateEconomyScore(playerState, position)
    1917{
    2018    let total = 0;
    21     for each (var res in playerState.statistics.resourcesGathered)
     19    for each (let res in playerState.statistics.resourcesGathered)
    2220        total += res;
    2321
    2422    return Math.round(total / 10);
     
    2624
    2725function calculateMilitaryScore(playerState, position)
    2826{
    29     return Math.round((playerState.statistics.enemyUnitsKilledValue +
    30         playerState.statistics.enemyBuildingsDestroyedValue) / 10);
     27    return Math.round((playerState.statistics.enemyUnitsKilledValue + 
     28           playerState.statistics.enemyBuildingsDestroyedValue) / 10);
    3129}
    3230
    3331function calculateExplorationScore(playerState, position)
     
    3836function calculateScoreTotal(playerState, position)
    3937{
    4038    return calculateEconomyScore(playerState) +
    41         calculateMilitaryScore(playerState) +
    42         calculateExplorationScore(playerState);
     39           calculateMilitaryScore(playerState) +
     40           calculateExplorationScore(playerState);
    4341}
    4442
    4543function calculateScoreTeam(counters)
    4644{
    47     for (var t in g_Teams)
     45    for (let t in g_Teams)
    4846    {
    4947        if (t == -1)
    5048            continue;
    5149
    52         for (var w in counters)
     50        for (let w in counters)
    5351        {
    5452            var total = 0;
    55             for (var p = 0; p < g_Teams[t]; ++p)
     53            for (let p = 0; p < g_Teams[t]; ++p)
    5654                total += (+Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption);
    5755
    5856            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = total;
     
    6462{
    6563    var type = BUILDINGS_TYPES[position];
    6664    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]';
    6967}
    7068
    7169function calculateColorsTeam(counters)
    7270{
    73     for (var t in g_Teams)
     71    for (let t in g_Teams)
    7472    {
    7573        if (t == -1)
    7674            continue;
    7775
    78         for (var w in counters)
     76        for (let w in counters)
    7977        {
    8078            var total = {
    8179                c : 0,
     
    8280                l : 0,
    8381                d : 0
    8482            };
    85             for (var p = 0; p < g_Teams[t]; ++p)
     83            for (let p = 0; p < g_Teams[t]; ++p)
    8684            {
    8785                var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    8886                // clean [Color=""], [/Color] and white space for make the sum more easy
     
    106104{
    107105    var type = UNITS_TYPES[position];
    108106    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]';
    111109}
    112110
    113111function calculateResources(playerState, position)
     
    114112{
    115113    var type = RESOURCES_TYPES[position];
    116114    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]';
    118116}
    119117
    120118function calculateTotalResources(playerState, position)
     
    122120    var totalGathered = 0;
    123121    var totalUsed = 0;
    124122
    125     for each (var type in RESOURCES_TYPES)
     123    for each (let type in RESOURCES_TYPES)
    126124    {
    127125        totalGathered += playerState.statistics.resourcesGathered[type];
    128126        totalUsed += playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type];
     
    143141
    144142function calculateTributeSent(playerState, position)
    145143{
    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]";
    147146}
    148147
    149148function calculateResourcesTeam(counters)
    150149{
    151     for (var t in g_Teams)
     150    for (let t in g_Teams)
    152151    {
    153152        if (t == -1)
    154153            continue;
    155154
    156         for (var w in counters)
     155        for (let w in counters)
    157156        {
    158157            var teamTotal = "undefined";
    159158
     
    161160                i : 0,
    162161                o : 0
    163162            };
    164             for (var p = 0; p < g_Teams[t]; ++p)
     163            for (let p = 0; p < g_Teams[t]; ++p)
    165164            {
    166165                var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    167166                // clean [Color=""], [/Color] and white space for make the sum more easy
     
    192191{
    193192    var type = RESOURCES_TYPES[position];
    194193    return INCOME_COLOR + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' +
    195         OUTCOME_COLOR + '-' + playerState.statistics.resourcesSold[type] + '[/color]';
     194           OUTCOME_COLOR + '-' + playerState.statistics.resourcesSold[type] + '[/color]';
    196195}
    197196
    198197function calculateBatteryEfficiency(playerState, position)
    199198{
    200199    var totalBought = 0;
    201     for each (var boughtAmount in playerState.statistics.resourcesBought)
     200    for each (let boughtAmount in playerState.statistics.resourcesBought)
    202201        totalBought += boughtAmount;
    203202    var totalSold = 0;
    204     for each (var soldAmount in playerState.statistics.resourcesSold)
     203    for each (let soldAmount in playerState.statistics.resourcesSold)
    205204        totalSold += soldAmount;
    206205
    207206    return Math.floor(totalSold > 0 ? (totalBought / totalSold) * 100 : 0) + "%";
     
    214213
    215214function calculateMarketTeam(counters)
    216215{
    217     for (var t in g_Teams)
     216    for (let t in g_Teams)
    218217    {
    219218        if (t == -1)
    220219            continue;
    221220
    222         for (var w in counters)
     221        for (let w in counters)
    223222        {
    224223            var teamTotal = "undefined";
    225224
     
    227226                i : 0,
    228227                o : 0
    229228            };
    230             for (var p = 0; p < g_Teams[t]; ++p)
     229            for (let p = 0; p < g_Teams[t]; ++p)
    231230            {
    232231                var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
    233232                // clean [Color=""], [/Color], white space, + and % for make the sum more easy
     
    334333
    335334function calculateMiscellaneous(counters)
    336335{
    337     for (var t in g_Teams)
     336    for (let t in g_Teams)
    338337    {
    339338        if (t == -1)
    340339            continue;
    341340
    342         for (var w in counters)
     341        for (let w in counters)
    343342        {
    344343            var teamTotal = "undefined";
    345344
  • binaries/data/mods/public/gui/summary/layout.js

     
    1616        ],
    1717        "teamCounterFn": calculateScoreTeam
    1818    },
    19     {   // buildings panel
     19    {   // buildings panel
    2020        "headings": [   // headings on buildings panel
    2121            { "caption": translate("Player name"), "yStart": 26, "width": 200 },
    2222            { "caption": translate("Total"), "yStart": 34, "width": 105 },
     
    3232            { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) },   // width = 700
    3333        ],
    3434        "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 }
    4343        ],
    4444        "teamCounterFn": calculateColorsTeam
    4545    },
     
    5959            { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820
    6060        ],
    6161        "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 }
    7070        ],
    7171        "teamCounterFn": calculateColorsTeam
    7272    },
     
    8686            { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510
    8787        ],
    8888        "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 }
    9797        ],
    9898        "teamCounterFn": calculateResourcesTeam
    9999    },
     
    109109        ],
    110110        "titleHeadings": [],
    111111        "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 }
    118118        ],
    119119        "teamCounterFn": calculateMarketTeam
    120120    },
     
    132132            { "caption": translate("Map control"), "xOffset": 400, "yStart": 16, "width": 200 }
    133133        ],
    134134        "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 }
    141141        ],
    142142        "teamCounterFn": calculateMiscellaneous
    143143    }
     
    145145
    146146function resetGeneralPanel()
    147147{
    148     for (var h = 0; h < MAX_HEADINGTITLE; ++h)
     148    for (let h = 0; h < MAX_HEADINGTITLE; ++h)
    149149    {
    150150        Engine.GetGUIObjectByName("titleHeading["+ h +"]").hidden = true;
    151151        Engine.GetGUIObjectByName("Heading[" + h + "]").hidden = true;
     
    164164function updateGeneralPanelHeadings(headings)
    165165{
    166166    var left = 50;
    167     for (var h in headings)
     167    for (let h in headings)
    168168    {
    169169        var headerGUIName = "playerNameHeading";
    170170        if (h > 0)
     
    183183function updateGeneralPanelTitles(titleHeadings)
    184184{
    185185    var left = 250;
    186     for (var th in titleHeadings)
     186    for (let th in titleHeadings)
    187187    {
    188188        if (th >= MAX_HEADINGTITLE)
    189189            break;
     
    209209    {
    210210        left = 240;
    211211        var counterObject;
    212         for (var w in counters)
     212        for (let w in counters)
    213213        {
    214214            counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]");
    215215            counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     
    223223        for (let t = 0; t < g_MaxTeams; ++t)
    224224        {
    225225            left = 240;
    226             for (var w in counters)
     226            for (let w in counters)
    227227            {
    228228                counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]");
    229229                counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     
    253253        return;
    254254
    255255    var yStart = TEAMS_BOX_Y_START + g_WithoutTeam * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
    256     for (var i = 0; i < g_Teams.length; ++i)
     256    for (let i = 0; i < g_Teams.length; ++i)
    257257    {
    258258        if (!g_Teams[i])
    259259            continue;
  • binaries/data/mods/public/gui/summary/summary.js

     
    5252        rightSpacer.size = (tabSize.right - 2) + " " + rightSpacer.size.top + " 100%-20 " + rightSpacer.size.bottom;
    5353    }
    5454
    55     for (var i = 0; i < panelNames.length; ++i)
     55    for (let i = 0; i < panelNames.length; ++i)
    5656    {
    5757        Engine.GetGUIObjectByName(panelNames[i] + 'Button').sprite = "BackgroundTab";
    5858    }
     
    7373    updateGeneralPanelTeams();
    7474
    7575    var playerBoxesCounts = [ ];
    76     for (var i = 0; i < g_PlayerCount; ++i)
     76    for (let i = 0; i < g_PlayerCount; ++i)
    7777    {
    7878        var playerState = g_GameData.playerStates[i+1];
    7979
     
    9898        }
    9999
    100100        var colorString = "color: "
    101                 + Math.floor(playerState.color.r * 255) + " "
    102                 + Math.floor(playerState.color.g * 255) + " "
    103                 + Math.floor(playerState.color.b * 255);
     101                        + Math.floor(playerState.color.r * 255) + " "
     102                        + Math.floor(playerState.color.g * 255) + " "
     103                        + Math.floor(playerState.color.b * 255);
    104104
    105105        var rowPlayerObject = Engine.GetGUIObjectByName(rowPlayer);
    106106        rowPlayerObject.hidden = false;
     
    146146        var mapSizes = initMapSizes();
    147147
    148148        // retrieve the index of the map size
    149         for (var mapSizeIndex in mapSizes.tiles)
     149        for (let mapSizeIndex in mapSizes.tiles)
    150150        {
    151151            if (mapSizes.tiles[mapSizeIndex] == data.mapSettings.Size)
    152152            {
     
    164164    if (data.mapSettings.LockTeams) // teams ARE locked
    165165    {
    166166        // Count teams
    167         for(var t = 0; t < g_PlayerCount; ++t)
     167        for(let t = 0; t < g_PlayerCount; ++t)
    168168        {
    169169            let playerTeam = data.playerStates[t+1].team;
    170170            if (g_Teams[playerTeam])
     
    182182    // Erase teams data if teams are not displayed
    183183    if (!g_Teams)
    184184    {
    185         for(var p = 0; p < g_PlayerCount; ++p)
     185        for(let p = 0; p < g_PlayerCount; ++p)
    186186            data.playerStates[p+1].team = -1;
    187187    }
    188188
     
    190190    if (g_Teams)
    191191    {
    192192        // Count players without team (or all if teams are not displayed)
    193         for (var i = 0; i < g_Teams.length; ++i)
     193        for (let i = 0; i < g_Teams.length; ++i)
    194194            g_WithoutTeam -= g_Teams[i] ? g_Teams[i] : 0;
    195195    }