Ticket #3561: t3561_fix_summary_screen_meh_WIP_v0.1.patch

File t3561_fix_summary_screen_meh_WIP_v0.1.patch, 5.9 KB (added by elexis, 8 years ago)

Not finished, but addresses most of the issues partially.

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

    function calculateMarketTeam(counters)  
    241241                    total.i += (+splitCaption[0]);
    242242                    total.o += (+splitCaption[1]);
    243243                }
    244244            }
    245245
    246             if (w >= 4)
    247                 teamTotal = total.i +(w == 4 ? "%" : "");
     246            if (w == 4)
     247                // average barter efficiency
     248                teamTotal = (total.i / g_Teams[t]) + "%";
     249            else if (w > 4)
     250                // trade income
     251                teamTotal = total.i;
    248252            else
     253                // resources exchanges
    249254                teamTotal = INCOME_COLOR + '+' + total.i + '[/color] ' + OUTCOME_COLOR + '-' + total.o + '[/color]';
    250255
    251256            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
    252257        }
    253258    }
    function calculateVegetarianRatio(player  
    265270        teamMiscHelperData[playerState.team][position].food += playerState.statistics.resourcesGathered.food;
    266271        teamMiscHelperData[playerState.team][position].vegetarianFood += playerState.statistics.resourcesGathered.vegetarianFood;
    267272        return Math.floor((playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100) + "%";
    268273    }
    269274    else
    270         return 0 + "%";
     275        return "-";
    271276}
    272277
    273278function calculateFeminization(playerState, position)
    274279{
    275280    if (!teamMiscHelperData[playerState.team])
    function calculateFeminization(playerSta  
    282287        teamMiscHelperData[playerState.team][position].Female = playerState.statistics.unitsTrained.Female;
    283288        teamMiscHelperData[playerState.team][position].Worker = playerState.statistics.unitsTrained.Worker;
    284289        return Math.floor((playerState.statistics.unitsTrained.Female / playerState.statistics.unitsTrained.Worker) * 100) + "%";
    285290    }
    286291    else
    287         return 0 + "%";
     292        return "-";
    288293}
    289294
    290295function calculateKillDeathRatio(playerState, position)
    291296{
    292297    if (!teamMiscHelperData[playerState.team])
    function calculateKillDeathRatio(playerS  
    295300        teamMiscHelperData[playerState.team][position] = {"enemyUnitsKilled": 0, "unitsLost": 0};
    296301
    297302    teamMiscHelperData[playerState.team][position].enemyUnitsKilled = playerState.statistics.enemyUnitsKilled.total;
    298303    teamMiscHelperData[playerState.team][position].unitsLost = playerState.statistics.unitsLost.total;
    299304
    300     if (!playerState.statistics.enemyUnitsKilled.total)
    301         return DEFAULT_DECIMAL;
    302     if (!playerState.statistics.unitsLost.total)    // and enemyUnitsKilled.total > 0
    303         return INFINITE_SYMBOL; // infinity symbol
     305    if (!playerState.statistics.unitsLost.total)
     306        return "-"
    304307
    305308    return Math.round((playerState.statistics.enemyUnitsKilled.total / playerState.statistics.unitsLost.total)*100)/100;
    306309}
    307310
    308311function calculateMapExploration(playerState, position)
    309312{
    310313    if (!teamMiscHelperData[playerState.team])
    311314        teamMiscHelperData[playerState.team] = [];
    312315
    313     teamMiscHelperData[playerState.team][position] = playerState.statistics.teamPercentMapExplored;
     316    teamMiscHelperData[playerState.team][position] = playerState.statistics.percentMapExplored;
    314317    return playerState.statistics.percentMapExplored + "%";
    315318}
    316319
    317320function calculateMapFinalControl(playerState, position)
    318321{
    function calculateMiscellaneous(counters  
    339342        if (t == -1)
    340343            continue;
    341344
    342345        for (var w in counters)
    343346        {
    344             var teamTotal = "undefined";
    345 
    346             if (w == 0)
    347                 teamTotal = (teamMiscHelperData[t][w].food == 0 ? "0" : Math.floor((teamMiscHelperData[t][w].vegetarianFood / teamMiscHelperData[t][w].food) * 100)) + "%";
    348             else if (w == 1)
    349                 teamTotal = (teamMiscHelperData[t][w].Worker == 0 ? "0" : Math.floor((teamMiscHelperData[t][w].Female / teamMiscHelperData[t][w].Worker) * 100)) + "%";
    350             else if (w == 2)
     347            var teamTotal = 0;
     348            for (var p = 0; p < g_Teams[t]; ++p)
    351349            {
    352                 if (!teamMiscHelperData[t][w].enemyUnitsKilled)
    353                     teamTotal = DEFAULT_DECIMAL;
    354                 else if (!teamMiscHelperData[t][w].unitsLost)   // and enemyUnitsKilled.total > 0
    355                     teamTotal = INFINITE_SYMBOL; // infinity symbol
    356                 else
    357                     teamTotal = Math.round((teamMiscHelperData[t][w].enemyUnitsKilled / teamMiscHelperData[t][w].unitsLost)*100)/100;
     350                if (w == 0 && teamMiscHelperData[t][w].food)
     351                    // vegetarian ratio
     352                    teamTotal += Math.floor(teamMiscHelperData[t][w].vegetarianFood / teamMiscHelperData[t][w].food * 100);
     353                else if (w == 1 && teamMiscHelperData[t][w].Worker)
     354                    // feminization
     355                    teamTotal += Math.floor(teamMiscHelperData[t][w].Female / teamMiscHelperData[t][w].Worker * 100);
     356                else if (w == 2 && teamMiscHelperData[t][w].unitsLost)
     357                    // kill death ratio
     358                    teamTotal += Math.round((teamMiscHelperData[t][w].enemyUnitsKilled / teamMiscHelperData[t][w].unitsLost)*100)/100;
     359                else if (w >= 3)
     360                    // map exploration, map control at peak, at finish
     361                    teamTotal += +teamMiscHelperData[t][w];
    358362            }
    359             else if (w >= 3)
    360                 teamTotal = teamMiscHelperData[t][w] + "%";
    361 
    362             Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
     363            // compute average
     364            teamTotal ;
     365           
     366            if (w==2)
     367                teamTotal
     368            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = Math.round(teamTotal /  g_Teams[t]) + (w != 2 ? "%" : "");
    363369        }
    364370    }
    365371}
  • binaries/data/mods/public/gui/summary/summary.js

    const RESOURCES_TYPES = [ "food", "wood"  
    2323
    2424// Colors used for gathered and traded resources
    2525const INCOME_COLOR = '[color="201 255 200"]';
    2626const OUTCOME_COLOR = '[color="255 213 213"]';
    2727
    28 const DEFAULT_DECIMAL = "0.00";
    29 const INFINITE_SYMBOL = "\u221E";
    3028// Load data
    3129var g_CivData = loadCivData();
    3230var g_Teams = [];
    3331// TODO set g_PlayerCount as playerCounters.length
    3432var g_PlayerCount = 0;