Ticket #2268: 0ad_show_team_score.diff

File 0ad_show_team_score.diff, 6.2 KB (added by José Manuel Santamaría Lema, 10 years ago)
  • binaries/data/mods/public/gui/summary/summary.js

    diff --git a/binaries/data/mods/public/gui/summary/.summary.js.swp b/binaries/data/mods/public/gui/summary/.summary.js.swp
    new file mode 100644
    index 0000000..0ae8bf3
    Binary files /dev/null and b/binaries/data/mods/public/gui/summary/.summary.js.swp differ
    diff --git a/binaries/data/mods/public/gui/summary/summary.js b/binaries/data/mods/public/gui/summary/summary.js
    index 186d371..0d9ee5b 100644
    a b function init(data)  
    9191    getGUIObjectByName("militaryScoreHeading").size = left +  " 16 " + (left + width) + " 100%"; left += width;
    9292    getGUIObjectByName("explorationScoreHeading").size = left +  " 16 " + (left + width) + " 100%"; left += width;
    9393    getGUIObjectByName("totalScoreHeading").size = left +  " 16 " + (left + width) + " 100%"; left += width;
     94    getGUIObjectByName("teamHeading").size = left +  " 16 " + (left + width) + " 100%"; left += width;
     95    getGUIObjectByName("teamScoreHeading").size = left +  " 16 " + (left + width) + " 100%"; left += width;
    9496   
    9597    left = 50;
    9698    getGUIObjectByName("playerName1Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
    function init(data)  
    127129    getGUIObjectByName("barterEfficiencyHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    128130    getGUIObjectByName("tradeIncomeHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    129131
     132    //Calculate player scores and team scores.
     133    //playerScoresWhatever[i] stores the scores for the player i.
     134    var playerScoreValueEconomy = new Array();
     135    var playerScoreValueMilitary = new Array();
     136    var playerScoreValueExploration = new Array();
     137    var playerScoreValueTotal = new Array();
     138    var teamScoreValue = new Array();
     139    for (var i = 0; i < maxPlayers; ++i)
     140    {
     141        teamScoreValue[i] = 0;
     142    }
     143    for (var i = 0; i < maxPlayers; ++i)
     144    {
     145        var playerState = data.playerStates[i+1];
     146        playerScoreValueEconomy[i] = Math.round((playerState.statistics.resourcesGathered.food
     147            + playerState.statistics.resourcesGathered.wood +
     148            playerState.statistics.resourcesGathered.stone +
     149            playerState.statistics.resourcesGathered.metal) / 10);
     150        playerScoreValueMilitary[i] = Math.round((playerState.statistics.enemyUnitsKilledValue
     151            + playerState.statistics.enemyBuildingsDestroyedValue) / 10);
     152        playerScoreValueExploration[i] = playerState.statistics.percentMapExplored * 10;
     153        playerScoreValueTotal[i] = playerScoreValueEconomy[i] + playerScoreValueMilitary[i] + playerScoreValueExploration[i];
     154        if (playerState.team != -1)
     155        {
     156            teamScoreValue[playerState.team] += playerScoreValueTotal[i] + playerState.statistics.tradeIncome;
     157        }
     158    }
     159
    130160    // Show counters
    131161    for (var i = 0; i < MAX_SLOTS; ++i)
    132162    {
    function init(data)  
    160190            var militaryScore = getGUIObjectByName("militaryScore["+i+"]");
    161191            var explorationScore = getGUIObjectByName("explorationScore["+i+"]");
    162192            var totalScore = getGUIObjectByName("totalScore["+i+"]");
     193            var team = getGUIObjectByName("team["+i+"]");
     194            var teamScore = getGUIObjectByName("teamScore["+i+"]");
    163195
    164196            var unitsTrained = getGUIObjectByName("unitsTrained["+i+"]");
    165197            var unitsLost = getGUIObjectByName("unitsLost["+i+"]");
    function init(data)  
    195227            militaryScore.size = left + " 2 " + (left + width) + " 100%"; left += width;
    196228            explorationScore.size = left + " 2 " + (left + width) + " 100%"; left += width;
    197229            totalScore.size = left + " 2 " + (left + width) + " 100%"; left += width;
     230            team.size = left + " 2 " + (left + width) + " 100%"; left += width;
     231            teamScore.size = left + " 2 " + (left + width) + " 100%"; left += width;
    198232            var size = getGUIObjectByName("playerBox0["+i+"]").size;
    199233            size.right = left + 10;
    200234            getGUIObjectByName("playerBox0["+i+"]").size = size;
    function init(data)  
    242276            getGUIObjectByName("playerBox4["+i+"]").size = size;
    243277
    244278            // display counters
    245             economyScore.caption = Math.round((playerState.statistics.resourcesGathered.food + playerState.statistics.resourcesGathered.wood +
    246                 playerState.statistics.resourcesGathered.stone + playerState.statistics.resourcesGathered.metal) / 10);
    247             militaryScore.caption = Math.round((playerState.statistics.enemyUnitsKilledValue + playerState.statistics.enemyBuildingsDestroyedValue) / 10);
    248             explorationScore.caption = playerState.statistics.percentMapExplored * 10;
    249             totalScore.caption = Number(economyScore.caption) + Number(militaryScore.caption) + Number(explorationScore.caption);
     279            economyScore.caption = playerScoreValueEconomy[i];
     280            militaryScore.caption = playerScoreValueMilitary[i];
     281            explorationScore.caption = playerScoreValueExploration[i];
     282            totalScore.caption = playerScoreValueTotal[i];
     283            if (playerState.team == -1) {
     284                team.caption = 'None'
     285                teamScore.caption = totalScore.caption;
     286            } else {
     287                team.caption = playerState.team + 1;
     288                teamScore.caption = teamScoreValue[playerState.team];
     289            }
    250290           
    251291            unitsTrained.caption = playerState.statistics.unitsTrained;
    252292            unitsLost.caption = playerState.statistics.unitsLost;
  • binaries/data/mods/public/gui/summary/summary.xml

    diff --git a/binaries/data/mods/public/gui/summary/summary.xml b/binaries/data/mods/public/gui/summary/summary.xml
    index 718d1ff..0cbc70d 100644
    a b  
    100100                <object name="totalScoreHeading" type="text" style="CenteredTabLabelText">
    101101                    Total&#10;score
    102102                </object>
     103                <object name="teamHeading" type="text" style="CenteredTabLabelText">
     104                    Team
     105                </object>
     106                <object name="teamScoreHeading" type="text" style="CenteredTabLabelText">
     107                    Team&#10;score
     108                </object>
    103109            </object>
    104110
    105111            <object size="0 65 100% 100%-50">
     
    112118                        <object name="militaryScore[n]"             type="text" style="CenteredLabelText"/>
    113119                        <object name="explorationScore[n]"          type="text" style="CenteredLabelText"/>
    114120                        <object name="totalScore[n]"                type="text" style="CenteredLabelText"/>
     121                        <object name="team[n]"              type="text" style="CenteredLabelText"/>
     122                        <object name="teamScore[n]"                 type="text" style="CenteredLabelText"/>
    115123                    </object>
    116124                </repeat>
    117125            </object>