Ticket #4033: siege-units-summary.3.patch

File siege-units-summary.3.patch, 14.0 KB (added by Mate-86, 8 years ago)
  • binaries/data/mods/public/gui/credits/texts/programming.json

     
    122122            {"nick": "MarkT", "name": "Mark Thompson"},
    123123            {"nick": "Markus"},
    124124            {"nick": "Matei", "name": "Matei Zaharia"},
     125            {"nick": "Mate-86", "name": "Mate Kovacs"},
    125126            {"nick": "MattDoerksen", "name": "Matt Doerksen"},
    126127            {"nick": "mattlott", "name": "Matt Lott"},
    127128            {"nick": "maveric", "name": "Anton Protko"},
  • binaries/data/mods/public/gui/session/session.js

     
    11431143        "Cavalry",
    11441144        "Champion",
    11451145        "Hero",
     1146        "Siege",
    11461147        "Ship",
    11471148        "Trader"
    11481149    ];
  • binaries/data/mods/public/gui/summary/counters.js

     
    55    g_TeamHelperData = [];
    66}
    77
    8 function formatTrained(trained, lost, killed)
     8function formatTrained(trained, killed, lost)
    99{
    1010    return g_TrainedColor + trained + '[/color] / ' +
    11         g_LostColor + lost + '[/color] / ' +
    12         g_KilledColor + killed + '[/color]';
     11        g_KilledColor + killed + '[/color] / ' +
     12        g_LostColor + lost + '[/color]';
    1313}
    1414
    1515function formatCaptured(constructed, destroyed, captured, lost)
     
    2020        g_LostColor + lost + '[/color]\n';
    2121}
    2222
     23function formatCapturedUnit(trained, killed, captured, lost)
     24{
     25    return g_TrainedColor + trained + '[/color] / ' +
     26        g_KilledColor + killed + '[/color] / ' +
     27        g_CapturedColor + captured + '[/color] / ' +
     28        g_LostColor + lost + '[/color]';
     29}
     30
    2331function formatIncome(income, outcome)
    2432{
    2533    return g_IncomeColor + income + '[/color] / ' +
     
    217225
    218226        for (let w in counters)
    219227        {
    220             let total = {
    221                 "constructed": 0,
    222                 "lost": 0,
    223                 "destroyed": 0
     228            let total =
     229            {
     230                "trained": 0,
     231                "killed": 0,
     232                "captured" : 0,
     233                "lost": 0
    224234            };
    225 
     235           
     236               
    226237            for (let p = 0; p < g_Teams[t]; ++p)
    227238            {
    228239                let splitCaption = cleanGUICaption(t, p, w).split("/");
    229 
    230                 total.constructed += +splitCaption[0];
    231                 total.lost += +splitCaption[1];
    232                 total.destroyed += +splitCaption[2];
     240               
     241                total.trained += +splitCaption[0];
     242                total.killed += +splitCaption[1];
     243               
     244                if (w == 0 || w == 6)
     245                {
     246                    total.captured += +splitCaption[2];
     247                    total.lost += +splitCaption[3];
     248                }
     249                else
     250                    total.lost += +splitCaption[2];
    233251            }
    234 
    235             Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption =
    236                 formatTrained(total.constructed, total.lost, total.destroyed);
     252           
     253            let formattedCaption = "";
     254           
     255            if (w == 0 || w == 6)
     256                formattedCaption = formatCapturedUnit(total.trained, total.killed, total.captured, total.lost);
     257            else
     258                formattedCaption = formatTrained(total.trained, total.killed, total.lost);
     259   
     260            Engine.GetGUIObjectByName("valueDataTeam[" + t + "][" + w + "]").caption = formattedCaption;
    237261        }
    238262    }
    239263}
    240264
     265function calculateUnitsWithCaptured(playerState, position)
     266{
     267    let type = g_UnitsTypes[position];
     268
     269    return formatCapturedUnit(
     270        playerState.statistics.unitsTrained[type],
     271        playerState.statistics.enemyUnitsKilled[type],
     272        playerState.statistics.unitsCaptured[type],
     273        playerState.statistics.unitsLost[type]);
     274}
     275
    241276function calculateUnits(playerState, position)
    242277{
    243278    let type = g_UnitsTypes[position];
     
    244279
    245280    return formatTrained(
    246281        playerState.statistics.unitsTrained[type],
    247         playerState.statistics.unitsLost[type],
    248         playerState.statistics.enemyUnitsKilled[type]);
     282        playerState.statistics.enemyUnitsKilled[type],
     283        playerState.statistics.unitsLost[type]);
    249284}
    250285
    251286function calculateResources(playerState, position)
  • binaries/data/mods/public/gui/summary/layout.js

     
    5656    "units": {
    5757        "headings": [
    5858            { "caption": translate("Player name"), "yStart": 26, "width": 200 },
    59             { "caption": translate("Total"), "yStart": 34, "width": 120 },
    60             { "caption": translate("Infantry"), "yStart": 34, "width": 100 },
    61             { "caption": translate("Worker"), "yStart": 34, "width": 100 },
    62             { "caption": translate("Cavalry"), "yStart": 34, "width": 100 },
    63             { "caption": translate("Champion"), "yStart": 34, "width": 100 },
    64             { "caption": translate("Heroes"), "yStart": 34, "width": 100 },
    65             { "caption": translate("Navy"), "yStart": 34, "width": 100 },
    66             { "caption": translate("Traders"), "yStart": 34, "width": 100 }
     59            { "caption": translate("Total"), "yStart": 34, "width": 105 },
     60            { "caption": translate("Infantry"), "yStart": 34, "width": 85 },
     61            { "caption": translate("Worker"), "yStart": 34, "width": 85 },
     62            { "caption": translate("Cavalry"), "yStart": 34, "width": 85 },
     63            { "caption": translate("Champion"), "yStart": 34, "width": 85 },
     64            { "caption": translate("Heroes"), "yStart": 34, "width": 85 },
     65            { "caption": translate("Siege"), "yStart": 34, "width": 95 },
     66            { "caption": translate("Navy"), "yStart": 34, "width": 85 },
     67            { "caption": translate("Traders"), "yStart": 34, "width": 85 }
    6768        ],
    6869        "titleHeadings": [
    6970            {
    70                 "caption": sprintf(translate("Units Statistics (%(trained)s / %(lost)s / %(killed)s)"),
     71                "caption": sprintf(translate("Units Statistics (%(trained)s / %(killed)s / %(captured)s / %(lost)s)"),
    7172                    {
    7273                        "trained": g_TrainedColor + translate("Trained") + '[/color]',
    73                         "lost": g_LostColor + translate("Lost") + '[/color]',
    74                         "killed": g_KilledColor + translate("Killed") + '[/color]'
     74                        "killed": g_KilledColor + translate("Killed") + '[/color]',
     75                        "captured": g_CapturedColor + translate("Captured") + '[/color]',
     76                        "lost": g_LostColor + translate("Lost") + '[/color]'
    7577                    }),
    7678                "yStart": 16,
    7779                "width": (100 * 7 + 120)
     
    7880            },  // width = 820
    7981        ],
    8082        "counters": [
    81             { "width": 120, "fn": calculateUnits, "verticalOffset": 12 },
    82             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    83             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    84             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    85             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    86             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    87             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 },
    88             { "width": 100, "fn": calculateUnits, "verticalOffset": 12 }
     83            { "width": 105, "fn": calculateUnitsWithCaptured, "verticalOffset": 12 },
     84            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     85            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     86            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     87            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     88            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     89            { "width": 105, "fn": calculateUnitsWithCaptured, "verticalOffset": 12 },
     90            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 },
     91            { "width": 85, "fn": calculateUnits, "verticalOffset": 12 }
    8992        ],
    9093        "teamCounterFn": calculateUnitsTeam
    9194    },
  • binaries/data/mods/public/gui/summary/summary.js

     
    1 const g_MaxHeadingTitle= 8;
     1const g_MaxHeadingTitle= 9;
    22
    33// const for filtering long collective headings
    44const g_LongHeadingWidth = 250;
     
    1616const g_CapturedColor = '[color="255 255 157"]';
    1717
    1818const g_BuildingsTypes = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
    19 const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
     19const g_UnitsTypes = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Siege", "Ship", "Trader" ];
    2020const g_ResourcesTypes = [ "food", "wood", "stone", "metal" ];
    2121
    2222// Colors used for gathered and traded resources
  • binaries/data/mods/public/gui/summary/summary.xml

     
    103103                <object name="playerNameHeading" type="text" style="ModernLeftTabLabelText">
    104104                    <translatableAttribute id="caption">Player name</translatableAttribute>
    105105                </object>
    106                 <repeat var="x" count="8">
     106                <repeat var="x" count="9">
    107107                    <object name="titleHeading[x]" type="text" style="ModernTabLabelText">
    108108                    </object>
    109109                </repeat>
    110                 <repeat var="x" count="8">
     110                <repeat var="x" count="9">
    111111                    <object name="Heading[x]" type="text" style="ModernTabLabelText">
    112112                    </object>
    113113                </repeat>
     
    124124                                </object>
    125125                                <object name="playerNamet[i][n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText"/>
    126126                                <object name="civIcont[i][n]" type="image" size="208 5 240 37" />
    127                                 <repeat var="x" count="8">
     127                                <repeat var="x" count="9">
    128128                                    <object name="valueDataTeam[i][n][x]" type="text" style="ModernTabLabelText">
    129129                                    </object>
    130130                                </repeat>
     
    132132                        </repeat>
    133133                    </object>
    134134                    <object name="teamHeadingt[i]" type="text" style="ModernLeftTabLabelText"/>
    135                     <repeat var="x" count="8">
     135                    <repeat var="x" count="9">
    136136                        <object name="valueDataTeam[i][x]" type="text" style="ModernTabLabelText">
    137137                        </object>
    138138                    </repeat>
     
    147147                        </object>
    148148                        <object name="playerName[n]" type="text" size="40 2 208 100%" style="ModernLeftLabelText"/>
    149149                        <object name="civIcon[n]" type="image" size="208 5 240 37"/>
    150                         <repeat var="x" count="8">
     150                        <repeat var="x" count="9">
    151151                            <object name="valueData[n][x]" type="text" style="ModernTabLabelText">
    152152                            </object>
    153153                        </repeat>
  • binaries/data/mods/public/simulation/components/Capturable.js

     
    159159
    160160    let cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
    161161    if (cmpCapturedPlayerStatisticsTracker)
    162         cmpCapturedPlayerStatisticsTracker.CapturedBuilding(this.entity);
     162        cmpCapturedPlayerStatisticsTracker.CapturedEntity(this.entity);
    163163};
    164164
    165165Capturable.prototype.GetRegenRate = function()
  • binaries/data/mods/public/simulation/components/StatisticsTracker.js

     
    1212        "Cavalry",
    1313        "Champion",
    1414        "Hero",
     15        "Siege",
    1516        "Ship",
    1617        "Trader"
    1718    ];
     
    2223        "Cavalry": 0,
    2324        "Champion": 0,
    2425        "Hero": 0,
     26        "Siege": 0,
    2527        "Ship": 0,
    2628        "Trader": 0,
    2729        "total": 0
     
    3335        "Cavalry": 0,
    3436        "Champion": 0,
    3537        "Hero": 0,
     38        "Siege": 0,
    3639        "Ship": 0,
    3740        "Trader": 0,
    3841        "total": 0
     
    4548        "Cavalry": 0,
    4649        "Champion": 0,
    4750        "Hero": 0,
     51        "Siege": 0,
    4852        "Ship": 0,
    4953        "Trader": 0,
    5054        "total": 0
    5155    };
    5256    this.enemyUnitsKilledValue = 0;
     57    this.unitsCaptured = {
     58        "Infantry": 0,
     59        "Worker": 0,
     60        "Female": 0,
     61        "Cavalry": 0,
     62        "Champion": 0,
     63        "Hero": 0,
     64        "Siege": 0,
     65        "Ship": 0,
     66        "Trader": 0,
     67        "total": 0
     68    };
     69    this.unitsCapturedValue = 0;
    5370
    5471    this.buildingsClasses = [
    5572        "House",
     
    163180        "unitsLostValue": this.unitsLostValue,
    164181        "enemyUnitsKilled": this.enemyUnitsKilled,
    165182        "enemyUnitsKilledValue": this.enemyUnitsKilledValue,
     183        "unitsCaptured": this.unitsCaptured,
     184        "unitsCapturedValue": this.unitsCapturedValue,
    166185        "buildingsConstructed": this.buildingsConstructed,
    167186        "buildingsLost": this.buildingsLost,
    168187        "buildingsLostValue": this.buildingsLostValue,
     
    308327    }
    309328};
    310329
    311 StatisticsTracker.prototype.CapturedBuilding = function(capturedBuilding)
     330StatisticsTracker.prototype.CapturedEntity = function(capturedEntity)
    312331{
    313     let cmpCapturedBuildingIdentity = Engine.QueryInterface(capturedBuilding, IID_Identity);
    314     if (!cmpCapturedBuildingIdentity)
     332    let cmpCapturedEntityIdentity = Engine.QueryInterface(capturedEntity, IID_Identity);
     333    if (!cmpCapturedEntityIdentity)
    315334        return;
    316335
    317     for (let type of this.buildingsClasses)
    318         this.CounterIncrement(cmpCapturedBuildingIdentity, "buildingsCaptured", type);
     336    if (cmpCapturedEntityIdentity.HasClass("Unit"))
     337    {
     338        for (let type of this.unitsClasses)
     339            this.CounterIncrement(cmpCapturedEntityIdentity, "unitsCaptured", type);
    319340
    320     ++this.buildingsCaptured.total;
     341        ++this.unitsCaptured.total;
    321342
    322     let cmpCost = Engine.QueryInterface(capturedBuilding, IID_Cost);
    323     if (!cmpCost)
    324         return;
     343        let cmpCost = Engine.QueryInterface(capturedEntity, IID_Cost);
     344        if (!cmpCost)
     345            return;
    325346
    326     let costs = cmpCost.GetResourceCosts();
    327     for (let type in costs)
    328         this.buildingsCapturedValue += costs[type];
     347        let costs = cmpCost.GetResourceCosts();
     348        for (let type in costs)
     349            this.unitsCapturedValue += costs[type];
     350    }
     351   
     352    if (cmpCapturedEntityIdentity.HasClass("Structure"))
     353    {
     354        for (let type of this.buildingsClasses)
     355        this.CounterIncrement(cmpCapturedEntityIdentity, "buildingsCaptured", type);
     356
     357        ++this.buildingsCaptured.total;
     358
     359        let cmpCost = Engine.QueryInterface(capturedEntity, IID_Cost);
     360        if (!cmpCost)
     361            return;
     362
     363        let costs = cmpCost.GetResourceCosts();
     364        for (let type in costs)
     365            this.buildingsCapturedValue += costs[type];
     366    }
    329367};
    330368
    331369/**