Ticket #3518: ticket3518_summarystyle_2.diff

File ticket3518_summarystyle_2.diff, 22.9 KB (added by bb, 8 years ago)

New version: changed global params into g_GlobalSomething

  • 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);
     
    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;
     
    6260
    6361function calculateBuildings(playerState, position)
    6462{
    65     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]';
     63    var type = g_BuildingsTypes[position];
     64    return g_TrainedColor + playerState.statistics.buildingsConstructed[type] + '[/color] / ' +
     65        g_LostColor + playerState.statistics.buildingsLost[type] + '[/color] / ' +
     66        g_KilledColor + 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
     
    9492                total.l += (+splitCaption[1]);
    9593                total.d += (+splitCaption[2]);
    9694            }
    97             var teamTotal = TRAINED_COLOR + total.c + '[/color] / ' +
    98             LOST_COLOR + total.l + '[/color] / ' + KILLED_COLOR + total.d + '[/color]';
     95            var teamTotal = g_Trained_Color + total.c + '[/color] / ' +
     96            g_Lost_Color + total.l + '[/color] / ' + g_Killed_Color + total.d + '[/color]';
    9997
    10098            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
    10199        }
     
    104102
    105103function calculateUnits(playerState, position)
    106104{
    107     var type = UNITS_TYPES[position];
    108     return TRAINED_COLOR + playerState.statistics.unitsTrained[type] + '[/color] / ' +
    109     LOST_COLOR + playerState.statistics.unitsLost[type] + '[/color] / ' +
    110     KILLED_COLOR + playerState.statistics.enemyUnitsKilled[type] + '[/color]';
     105    var type = g_UnitsTypes[position];
     106    return g_TrainedColor + playerState.statistics.unitsTrained[type] + '[/color] / ' +
     107        g_LostColor + playerState.statistics.unitsLost[type] + '[/color] / ' +
     108        g_KilledColor + playerState.statistics.enemyUnitsKilled[type] + '[/color]';
    111109}
    112110
    113111function calculateResources(playerState, position)
    114112{
    115     var type = RESOURCES_TYPES[position];
    116     return INCOME_COLOR + playerState.statistics.resourcesGathered[type] + '[/color] / ' +
    117     OUTCOME_COLOR + (playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type]) + '[/color]';
     113    var type = g_ResourcesTypes[position];
     114    return g_IncomeColor + playerState.statistics.resourcesGathered[type] + '[/color] / ' +
     115        g_OutcomeColor + (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 g_ResourcesTypes)
    126124    {
    127125        totalGathered += playerState.statistics.resourcesGathered[type];
    128126        totalUsed += playerState.statistics.resourcesUsed[type] - playerState.statistics.resourcesSold[type];
    129127    }
    130128
    131     return INCOME_COLOR + totalGathered + '[/color] / ' + OUTCOME_COLOR + totalUsed + '[/color]';
     129    return g_IncomeColor + totalGathered + '[/color] / ' + g_OutcomeColor + totalUsed + '[/color]';
    132130}
    133131
    134132function calculateTreasureCollected(playerState, position)
     
    143141
    144142function calculateTributeSent(playerState, position)
    145143{
    146     return INCOME_COLOR + playerState.statistics.tributesSent + "[/color] / " + OUTCOME_COLOR + playerState.statistics.tributesReceived + "[/color]";
     144    return g_IncomeColor + playerState.statistics.tributesSent + "[/color] / " +
     145           g_OutcomeColor + 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
     
    181180            if (w >= 6)
    182181                teamTotal = total.i;
    183182            else
    184                 teamTotal = INCOME_COLOR + total.i + "[/color] / " + OUTCOME_COLOR + total.o + "[/color]";
     183                teamTotal = g_IncomeColor + total.i + "[/color] / " + g_OutcomeColor + total.o + "[/color]";
    185184
    186185            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
    187186        }
     
    190189
    191190function calculateResourceExchanged(playerState, position)
    192191{
    193     var type = RESOURCES_TYPES[position];
    194     return INCOME_COLOR + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' +
    195         OUTCOME_COLOR + '-' + playerState.statistics.resourcesSold[type] + '[/color]';
     192    var type = g_ResourcesTypes[position];
     193    return g_IncomeColor + '+' + playerState.statistics.resourcesBought[type] + '[/color] ' +
     194        g_OutcomeColor + '-' + 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
     
    246245            if (w >= 4)
    247246                teamTotal = total.i +(w == 4 ? "%" : "");
    248247            else
    249                 teamTotal = INCOME_COLOR + '+' + total.i + '[/color] ' + OUTCOME_COLOR + '-' + total.o + '[/color]';
     248                teamTotal = g_IncomeColor + '+' + total.i + '[/color] ' + g_IncomeColor + '-' + total.o + '[/color]';
    250249
    251250            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
    252251        }
     
    298297    teamMiscHelperData[playerState.team][position].unitsLost = playerState.statistics.unitsLost.total;
    299298
    300299    if (!playerState.statistics.enemyUnitsKilled.total)
    301         return DEFAULT_DECIMAL;
     300        return g_DefaultDecimal
    302301    if (!playerState.statistics.unitsLost.total)    // and enemyUnitsKilled.total > 0
    303         return INFINITE_SYMBOL; // infinity symbol
     302        return g_InfiniteSymbol; // infinity symbol
    304303
    305304    return Math.round((playerState.statistics.enemyUnitsKilled.total / playerState.statistics.unitsLost.total)*100)/100;
    306305}
     
    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
     
    350349            else if (w == 2)
    351350            {
    352351                if (!teamMiscHelperData[t][w].enemyUnitsKilled)
    353                     teamTotal = DEFAULT_DECIMAL;
     352                    teamTotal = g_DefaultDecimal;
    354353                else if (!teamMiscHelperData[t][w].unitsLost)   // and enemyUnitsKilled.total > 0
    355                     teamTotal = INFINITE_SYMBOL; // infinity symbol
     354                    teamTotal = g_InfiniteSymbol; // infinity symbol
    356355                else
    357356                    teamTotal = Math.round((teamMiscHelperData[t][w].enemyUnitsKilled / teamMiscHelperData[t][w].unitsLost)*100)/100;
    358357            }
  • 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 (var h = 0; h < g_MaxHeadingTitle; ++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)
     
    175175        headerGUI.size = left + " " + headings[h].yStart + " " + (left + headings[h].width) + " 100%";
    176176        headerGUI.hidden = false;
    177177
    178         if (headings[h].width < LONG_HEADING_WIDTH)
     178        if (headings[h].width < g_LongHeadingWidth)
    179179            left += headings[h].width;
    180180    }
    181181}
     
    183183function updateGeneralPanelTitles(titleHeadings)
    184184{
    185185    var left = 250;
    186     for (var th in titleHeadings)
     186    for (let th in titleHeadings)
    187187    {
    188         if (th >= MAX_HEADINGTITLE)
     188        if (th >= g_MaxHeadingTitle)
    189189            break;
    190190
    191191        if (titleHeadings[th].xOffset)
     
    196196        headerGUI.size = left + " " + titleHeadings[th].yStart + " " + (left + titleHeadings[th].width) + " 100%";
    197197        headerGUI.hidden = false;
    198198
    199         if (titleHeadings[th].width < LONG_HEADING_WIDTH)
     199        if (titleHeadings[th].width < g_LongHeadingWidth)
    200200            left += titleHeadings[th].width;
    201201    }
    202202}
     
    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%";
     
    231231
    232232                if (g_Teams[t])
    233233                {
    234                     var yStart = 30 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
     234                    var yStart = 30 + g_Teams[t] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;
    235235                    counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]");
    236236                    counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%";
    237237                    counterTotalObject.hidden = false;
     
    252252    if (!g_Teams)
    253253        return;
    254254
    255     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)
     255    var yStart = g_TeamsBoxYStart + g_WithoutTeam * (g_PlayerBoxYSize + g_PlayerBoxGap);
     256    for (let i = 0; i < g_Teams.length; ++i)
    257257    {
    258258        if (!g_Teams[i])
    259259            continue;
     
    264264        teamBoxSize.top = yStart;
    265265        teamBox.size = teamBoxSize;
    266266
    267         yStart += 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 32;
     267        yStart += 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 32;
    268268
    269269        Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1);
    270270
    271271        var teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]");
    272         var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
     272        var yStartTotal = 30 + g_Teams[i] * (g_PlayerBoxYSize + g_PlayerBoxGap) + 2;
    273273        teamHeading.size = "50 "+yStartTotal+" 100% "+(yStartTotal+20);
    274274        teamHeading.caption = translate("Team total");
    275275    }
     
    284284    {
    285285        var playerBox = Engine.GetGUIObjectByName("playerBox[" + h + "]");
    286286        var boxSize = playerBox.size;
    287         boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
    288         boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
     287        boxSize.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
     288        boxSize.bottom = boxSize.top + g_PlayerBoxYSize;
    289289        playerBox.size = boxSize;
    290290
    291291        for (let i = 0; i < g_MaxTeams; ++i)
     
    292292        {
    293293            var playerBoxt = Engine.GetGUIObjectByName("playerBoxt[" + i + "][" + h + "]");
    294294            boxSize = playerBoxt.size;
    295             boxSize.top += h * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP);
    296             boxSize.bottom = boxSize.top + PLAYER_BOX_Y_SIZE;
     295            boxSize.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
     296            boxSize.bottom = boxSize.top + g_PlayerBoxYSize;
    297297            playerBoxt.size = boxSize;
    298298        }
    299299    }
  • binaries/data/mods/public/gui/summary/summary.js

     
    1 const MAX_HEADINGTITLE = 8;
     1const g_MaxHeadingTitle= 8;
    22
    33// const for filtering long collective headings
    4 const LONG_HEADING_WIDTH = 250;
     4const g_LongHeadingWidth = 250;
    55// Vertical size of player box
    6 const PLAYER_BOX_Y_SIZE = 30;
     6const g_PlayerBoxYSize = 30;
    77// Gap between players boxes
    8 const PLAYER_BOX_GAP = 2;
     8const g_PlayerBoxGap = 2;
    99// Alpha for player box
    10 const PLAYER_BOX_ALPHA = " 32";
     10const g_PlayerBoxAlpha = " 32";
    1111// Alpha for player color box
    12 const PLAYER_COLOR_BOX_ALPHA = " 255";
     12const g_PlayerColorBoxAlpha = " 255";
    1313// yStart value for spacing teams boxes (and noTeamsBox)
    14 const TEAMS_BOX_Y_START = 65;
     14const g_TeamsBoxYStart = 65;
    1515// Colors used for units and buildings
    16 const TRAINED_COLOR = '[color="201 255 200"]';
    17 const LOST_COLOR = '[color="255 213 213"]';
    18 const KILLED_COLOR = '[color="196 198 255"]';
     16const g_TrainedColor = '[color="201 255 200"]';
     17const g_LostColor = '[color="255 213 213"]';
     18const g_KilledColor = '[color="196 198 255"]';
    1919
    20 const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    21 const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
    22 const RESOURCES_TYPES = [ "food", "wood", "stone", "metal" ];
     20const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
     21const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
     22const g_ResourcesTypes = [ "food", "wood", "stone", "metal" ];
    2323
    2424// Colors used for gathered and traded resources
    25 const INCOME_COLOR = '[color="201 255 200"]';
    26 const OUTCOME_COLOR = '[color="255 213 213"]';
     25const g_IncomeColor = '[color="201 255 200"]';
     26const g_OutcomeColor = '[color="255 213 213"]';
    2727
    28 const DEFAULT_DECIMAL = "0.00";
    29 const INFINITE_SYMBOL = "\u221E";
     28const g_DefaultDecimal = "0.00";
     29const g_InfiniteSymbol = "\u221E";
    3030// Load data
    3131var g_CivData = loadCivData();
    3232var g_Teams = [];
     
    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
     
    104104
    105105        var rowPlayerObject = Engine.GetGUIObjectByName(rowPlayer);
    106106        rowPlayerObject.hidden = false;
    107         rowPlayerObject.sprite = colorString + PLAYER_BOX_ALPHA;
     107        rowPlayerObject.sprite = colorString + g_PlayerBoxAlpha;
    108108        var boxSize = rowPlayerObject.size;
    109109        boxSize.right = rowPlayerObjectWidth;
    110110        rowPlayerObject.size = boxSize;
    111111
    112112        var playerColorBox = Engine.GetGUIObjectByName(playerColorBoxColumn);
    113         playerColorBox.sprite = colorString + PLAYER_COLOR_BOX_ALPHA;
     113        playerColorBox.sprite = colorString + g_PlayerColorBoxAlpha;
    114114
    115115        Engine.GetGUIObjectByName(playerNameColumn).caption = g_GameData.players[i+1].name;
    116116
     
    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    }