Ticket #3216: 3216.7.patch

File 3216.7.patch, 16.6 KB (added by maveric, 9 years ago)
  • binaries/data/mods/public/gui/summary/counters.js

     
    2727function calculateMilitaryScore(playerState, position)
    2828{
    2929    return Math.round((playerState.statistics.enemyUnitsKilledValue +
    30         playerState.statistics.enemyBuildingsDestroyedValue) / 10);
     30        playerState.statistics.enemyBuildingsDestroyedValue +
     31        playerState.statistics.buildingsCapturedValue) / 10);
    3132}
    3233
    3334function calculateExplorationScore(playerState, position)
     
    6364function calculateBuildings(playerState, position)
    6465{
    6566    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]';
     67    return '   ' + TRAINED_COLOR + playerState.statistics.buildingsConstructed[type] + '[/color] / ' +
     68    KILLED_COLOR + playerState.statistics.enemyBuildingsDestroyed[type] + '[/color]\n' +
     69    CAPTURED_COLOR + playerState.statistics.buildingsCaptured[type] + '[/color] / ' +
     70    LOST_COLOR + playerState.statistics.buildingsLost[type] + '[/color]';
    6971}
    7072
    71 function calculateColorsTeam(counters)
     73function calculateBuildingsTeam(counters)
    7274{
    7375    for (var t in g_Teams)
    7476    {
     
    7880        for (var w in counters)
    7981        {
    8082            var total = {
     83                constructed : 0,
     84                destroyed : 0,
     85                captured : 0,   
     86                lost : 0
     87            };
     88            for (var p = 0; p < g_Teams[t]; ++p)
     89            {
     90                var caption = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]").caption;
     91                // clean [Color=""], [/Color] and white space for make the sum more easy
     92                caption = caption.replace(/\[([\w\' \\\"\/\=]*)\]|[\t\r \f]/g, "");
     93
     94                var splitCaption = caption.split("\n");
     95                var first = splitCaption[0].split("/");
     96                var second = splitCaption[1].split("/");
     97
     98                total.constructed += (+first[0]);
     99                total.destroyed += (+first[1]);
     100                total.captured += (+second[0]);
     101                total.lost += (+second[1]);
     102            }
     103            var teamTotal = '   ' + TRAINED_COLOR + total.constructed + '[/color] / ' +
     104                    KILLED_COLOR + total.destroyed + '[/color]\n' +
     105                    CAPTURED_COLOR + total.captured + '[/color] / ' +
     106                    LOST_COLOR + total.lost + '[/color]';
     107
     108            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = teamTotal;
     109        }
     110    }
     111}
     112
     113function calculateUnitsTeam(counters)
     114{
     115    for (var t in g_Teams)
     116    {
     117        if (t == -1)
     118            continue;
     119
     120        for (var w in counters)
     121        {
     122            var total = {
    81123                c : 0,
    82124                l : 0,
    83125                d : 0
  • binaries/data/mods/public/gui/summary/layout.js

     
    99        ],
    1010        "titleHeadings": [],
    1111        "counters": [   // counters on score panel
    12             { "width": 100, "fn": calculateEconomyScore },
    13             { "width": 100, "fn": calculateMilitaryScore },
    14             { "width": 100, "fn": calculateExplorationScore },
    15             { "width": 100, "fn": calculateScoreTotal}
     12            { "width": 100, "fn": calculateEconomyScore, "verticalOffset": 12 },
     13            { "width": 100, "fn": calculateMilitaryScore, "verticalOffset": 12 },
     14            { "width": 100, "fn": calculateExplorationScore, "verticalOffset": 12 },
     15            { "width": 100, "fn": calculateScoreTotal, "verticalOffset": 12 }
    1616        ],
    1717        "teamCounterFn": calculateScoreTeam
    1818    },
     
    2929            { "caption": translate("Wonders"), "yStart": 34, "width": 85 }
    3030        ],
    3131        "titleHeadings": [
    32             { "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) },   // width = 735
     32            { "caption": translate("Buildings Statistics (Constructed / Destroyed / Captured / Lost)"),
     33             "yStart": 16, "width": (85 * 7 + 105)
     34            },  // width = 735
    3335        ],
    3436        "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}
     37            {"width": 105, "fn": calculateBuildings, "verticalOffset": 3},
     38            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     39            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     40            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     41            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     42            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     43            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3},
     44            {"width": 85, "fn": calculateBuildings, "verticalOffset": 3}
    4345        ],
    44         "teamCounterFn": calculateColorsTeam
     46        "teamCounterFn": calculateBuildingsTeam
    4547    },
    4648    {   // units panel
    4749        "headings": [   // headings on units panel
     
    5860            { "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 6 + 120) }, // width = 720
    5961        ],
    6062        "counters": [   // counters on units panel
    61             {"width": 120, "fn": calculateUnits},
    62             {"width": 100, "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}
     63            {"width": 120, "fn": calculateUnits, "verticalOffset": 12},
     64            {"width": 100, "fn": calculateUnits, "verticalOffset": 12},
     65            {"width": 100, "fn": calculateUnits, "verticalOffset": 12},
     66            {"width": 100, "fn": calculateUnits, "verticalOffset": 12},
     67            {"width": 100, "fn": calculateUnits, "verticalOffset": 12},
     68            {"width": 100, "fn": calculateUnits, "verticalOffset": 12},
     69            {"width": 100, "fn": calculateUnits, "verticalOffset": 12}
    6870        ],
    69         "teamCounterFn": calculateColorsTeam
     71        "teamCounterFn": calculateUnitsTeam
    7072    },
    7173    {   // resources panel
    7274        "headings": [   // headings on resources panel
     
    8385            { "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510
    8486        ],
    8587        "counters": [   // counters on resources panel
    86             {"width": 100, "fn": calculateResources},
    87             {"width": 100, "fn": calculateResources},
    88             {"width": 100, "fn": calculateResources},
    89             {"width": 100, "fn": calculateResources},
    90             {"width": 110, "fn": calculateTotalResources},
    91             {"width": 100, "fn": calculateTreasureCollected},
    92             {"width": 121, "fn": calculateTributeSent}
     88            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     89            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     90            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     91            {"width": 100, "fn": calculateResources, "verticalOffset": 12},
     92            {"width": 110, "fn": calculateTotalResources, "verticalOffset": 12},
     93            {"width": 100, "fn": calculateTreasureCollected, "verticalOffset": 12},
     94            {"width": 121, "fn": calculateTributeSent, "verticalOffset": 12}
    9395        ],
    9496        "teamCounterFn": calculateResourcesTeam
    9597    },
     
    105107        ],
    106108        "titleHeadings": [],
    107109        "counters": [   // counters on market panel
    108             {"width": 100, "fn": calculateResourceExchanged},
    109             {"width": 100, "fn": calculateResourceExchanged},
    110             {"width": 100, "fn": calculateResourceExchanged},
    111             {"width": 100, "fn": calculateResourceExchanged},
    112             {"width": 100, "fn": calculateBatteryEfficiency},
    113             {"width": 100, "fn": calculateTradeIncome}
     110            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     111            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     112            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     113            {"width": 100, "fn": calculateResourceExchanged, "verticalOffset": 12},
     114            {"width": 100, "fn": calculateBatteryEfficiency, "verticalOffset": 12},
     115            {"width": 100, "fn": calculateTradeIncome, "verticalOffset": 12}
    114116        ],
    115117        "teamCounterFn": calculateMarketTeam
    116118    },
     
    124126        ],
    125127        "titleHeadings": [],
    126128        "counters": [   // counters on miscellaneous panel
    127             {"width": 100, "fn": calculateVegetarianRatio},
    128             {"width": 100, "fn": calculateFeminisation},
    129             {"width": 100, "fn": calculateKillDeathRatio},
    130             {"width": 100, "fn": calculateMapExploration}
     129            {"width": 100, "fn": calculateVegetarianRatio, "verticalOffset": 12},
     130            {"width": 100, "fn": calculateFeminisation, "verticalOffset": 12},
     131            {"width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12},
     132            {"width": 100, "fn": calculateMapExploration, "verticalOffset": 12}
    131133        ],
    132134        "teamCounterFn": calculateMiscellaneous
    133135    }
     
    189191{
    190192    var rowPlayerObjectWidth = 0;
    191193    var left = 0;
     194       
    192195    for (var p = 0; p < MAX_SLOTS; ++p)
    193196    {
    194197        left = 240;
     
    196199        for (var w in counters)
    197200        {
    198201            counterObject = Engine.GetGUIObjectByName("valueData[" + p + "][" + w + "]");
    199             counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     202            counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    200203            counterObject.hidden = false;
    201204            left += counters[w].width;
    202205        }
     
    210213            for (var w in counters)
    211214            {
    212215                counterObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + p + "][" + w + "]");
    213                 counterObject.size = left + " 6 " + (left + counters[w].width) + " 100%";
     216                counterObject.size = left + " " + counters[w].verticalOffset + " " + (left + counters[w].width) + " 100%";
    214217                counterObject.hidden = false;
    215218
    216219                if (g_Teams[t])
    217220                {
    218                     var yStart = 30 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
     221                    var yStart = 25 + g_Teams[t] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 3 + counters[w].verticalOffset;
    219222                    counterTotalObject = Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]");
    220223                    counterTotalObject.size = (left + 20) + " " + yStart + " " + (left + counters[w].width) + " 100%";
    221224                    counterTotalObject.hidden = false;
     
    250253        Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team "+(i+1);
    251254
    252255        var teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]");
    253         var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 2;
    254         teamHeading.size = "50 "+yStartTotal+" 100% "+(yStartTotal+20);
     256        var yStartTotal = 30 + g_Teams[i] * (PLAYER_BOX_Y_SIZE + PLAYER_BOX_GAP) + 10;
     257        teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20);
    255258        teamHeading.caption = translate("Team total");
    256259    }
    257260    // If there are no players without team, hide "player name" heading
  • binaries/data/mods/public/gui/summary/summary.js

     
    66// const for filtering long collective headings
    77const LONG_HEADING_WIDTH = 250;
    88// vertical size of player box
    9 const PLAYER_BOX_Y_SIZE = 30;
     9const PLAYER_BOX_Y_SIZE = 40;
    1010// gap between players boxes
    1111const PLAYER_BOX_GAP = 2;
    1212// alpha for player box
     
    1414// alpha for player color box
    1515const PLAYER_COLOR_BOX_ALPHA = " 255";
    1616// yStart value for spacing teams boxes (and noTeamsBox)
    17 const TEAMS_BOX_Y_START = 65;
     17const TEAMS_BOX_Y_START = 40;
    1818// colors used for units and buildings
    1919const TRAINED_COLOR = '[color="201 255 200"]';
    2020const LOST_COLOR = '[color="255 213 213"]';
    2121const KILLED_COLOR = '[color="196 198 255"]';
     22const CAPTURED_COLOR = '[color="255 255 157"]';
    2223
    2324const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    2425const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship" ];
  • binaries/data/mods/public/gui/summary/summary.xml

     
    119119                    <object size="0 30 100% 100%">
    120120                        <repeat count="8" var="n">
    121121                            <object type="image" name="playerBoxt[i][n]" size="10 0 10 30" hidden="true">
    122                                 <object name="playerColorBoxt[i][n]" type="image" size="10 4 30 24"/>
     122                                <object name="playerColorBoxt[i][n]" type="image" size="10 9 34 33"/>
    123123                                <object name="playerNamet[i][n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText" />
    124                                 <object name="civIcont[i][n]" type="image" size="208 0 240 32"  tooltip_style="sessionToolTip"/>
     124                                <object name="civIcont[i][n]" type="image" size="208 5 240 37"  tooltip_style="sessionToolTip"/>
    125125                                <repeat var="x" count="8">
    126126                                    <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText">
    127127                                    </object>
     
    140140            <object type="image" name="noTeamsBox" size="0 65 100% 100%-50" hidden="true">
    141141                <repeat count="8">
    142142                    <object type="image" name="playerBox[n]" size="10 0 10 30" hidden="true">
    143                         <object type="image" sprite="ForegroundBox" size="10 4 34 28">
     143                        <object type="image" sprite="ForegroundBox" size="10 9 34 33">
    144144                            <object name="playerColorBox[n]" type="image" size="2 2 22 22"/>
    145145                        </object>
    146146                        <object name="playerName[n]" type="text"  size="40 2 208 100%" style="ModernLeftLabelText"/>
    147                         <object name="civIcon[n]" type="image" size="208 0 240 32"/>
     147                        <object name="civIcon[n]" type="image" size="208 5 240 37"/>
    148148                        <repeat var="x" count="8">
    149149                            <object name="valueData[n][x]" type="text" style="ModernTabLabelText">
    150150                            </object>
  • binaries/data/mods/public/simulation/components/Capturable.js

     
    103103    for (let i in this.cp)
    104104        if (this.cp[i] >= this.cp[bestPlayer])
    105105            bestPlayer = +i;
     106   
     107    var cmpLostPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     108    if (cmpLostPlayerStatisticsTracker)
     109        cmpLostPlayerStatisticsTracker.LostEntity(this.entity);
    106110
    107111    cmpOwnership.SetOwner(bestPlayer);
    108 
     112   
     113    var cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     114    if (cmpCapturedPlayerStatisticsTracker)
     115        cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity);
     116   
    109117    return takenCp;
    110118};
    111119
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     
    7676        "CivCentre": 0,
    7777        "Wonder": 0,
    7878        "total": 0
    79         };
     79    };
    8080    this.buildingsLostValue = 0;
    8181    this.enemyBuildingsDestroyed = {
    8282        "House": 0,
     
    8787        "CivCentre": 0,
    8888        "Wonder": 0,
    8989        "total": 0
    90         };
    91     this.enemyBuildingsDestroyedValue = 0;
     90    };
     91    this.enemyBuildingsDestroyedValue = 0;
     92    this.buildingsCaptured = {
     93        "House": 0,
     94        "Economic": 0,
     95        "Outpost": 0,
     96        "Military": 0,
     97        "Fortress": 0,
     98        "CivCentre": 0,
     99        "Wonder": 0,
     100        "total": 0
     101    };
     102    this.buildingsCapturedValue = 0;
    92103    // resources
    93104    this.resourcesGathered = {
    94105        "food": 0,
     
    149160        "buildingsLost": this.buildingsLost,
    150161        "buildingsLostValue": this.buildingsLostValue,
    151162        "enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
    152         "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
     163        "enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
     164        "buildingsCaptured": this.buildingsCaptured,
     165        "buildingsCapturedValue": this.buildingsCapturedValue,
    153166        "resourcesGathered": this.resourcesGathered,
    154167        "resourcesUsed": this.resourcesUsed,
    155168        "resourcesSold": this.resourcesSold,
     
    292305        for each (var cost in costs)
    293306            this.buildingsLostValue += cost;
    294307    }
     308};
     309
     310StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding)
     311{
     312    var cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity);
     313    var cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost);
     314    var costs = cmpCost.GetResourceCosts();
     315
     316    for each (var type in this.buildingsClasses)
     317        this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type);
     318   
     319    this.buildingsCaptured.total++;
     320   
     321    for each (var cost in costs)
     322        this.buildingsCapturedValue += cost;
    295323};
    296324
    297325/**