Ticket #1605: used.patch

File used.patch, 9.6 KB (added by Deiz, 12 years ago)
  • gui/summary/summary.js

     
    101101
    102102    left = 50;
    103103    getGUIObjectByName("playerName2Heading").size = left + " 26 " + (left + playerNameHeadingWidth) + " 100%"; left += playerNameHeadingWidth;
    104     getGUIObjectByName("foodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
     104    getGUIObjectByName("resourceHeading").size = left + " 16 " + (left + width * 4) + " 100%";
     105    getGUIObjectByName("foodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width;
     106    getGUIObjectByName("woodGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width;
     107    getGUIObjectByName("stoneGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width;
     108    getGUIObjectByName("metalGatheredHeading").size = left + " 34 " + (left + width) + " 100%"; left += width;
    105109    getGUIObjectByName("vegetarianRatioHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    106     getGUIObjectByName("woodGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    107     getGUIObjectByName("stoneGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    108     getGUIObjectByName("metalGatheredHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    109110    getGUIObjectByName("treasuresCollectedHeading").size = left + " 16 " + (left + width) + " 100%"; left += width;
    110111
    111112    left = 50;
     
    158159            var mapExploration = getGUIObjectByName("mapExploration["+i+"]");
    159160
    160161            var foodGathered = getGUIObjectByName("foodGathered["+i+"]");
    161             var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");
    162162            var woodGathered = getGUIObjectByName("woodGathered["+i+"]");
    163163            var stoneGathered = getGUIObjectByName("stoneGathered["+i+"]");
    164164            var metalGathered = getGUIObjectByName("metalGathered["+i+"]");
     165            var vegetarianRatio = getGUIObjectByName("vegetarianRatio["+i+"]");
    165166            var treasuresCollected = getGUIObjectByName("treasuresCollected["+i+"]");
    166167
    167168            var exchangedFood = getGUIObjectByName("exchangedFood["+i+"]");
     
    195196
    196197            left = 240;
    197198            foodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width;
    198             vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width;
    199199            woodGathered.size = left + " 2 " + (left + width) + " 100%"; left += width;
    200200            stoneGathered.size = left + " 2 " + (left + width) + " 100%"; left += width;
    201201            metalGathered.size = left + " 2 " + (left + width) + " 100%"; left += width;
     202            vegetarianRatio.size = left + " 2 " + (left + width) + " 100%"; left += width;
    202203            treasuresCollected.size = left + " 2 " + (left + width) + " 100%"; left += width;
    203204            size = getGUIObjectByName("playerBox2["+i+"]").size;
    204205            size.right = left + 10;
     
    227228            enemyCivCentresDestroyed.caption = playerState.statistics.enemyCivCentresDestroyed;
    228229            mapExploration.caption = playerState.statistics.percentMapExplored + "%";
    229230
    230             foodGathered.caption = playerState.statistics.resourcesGathered.food;
     231            foodGathered.caption = playerState.statistics.resourcesGathered.food + " / " +
     232                (playerState.statistics.resourcesUsed.food - playerState.statistics.resourcesSold.food);
     233            woodGathered.caption = playerState.statistics.resourcesGathered.wood + " / " +
     234                (playerState.statistics.resourcesUsed.wood - playerState.statistics.resourcesSold.wood);
     235            stoneGathered.caption = playerState.statistics.resourcesGathered.stone + " / " +
     236                (playerState.statistics.resourcesUsed.stone - playerState.statistics.resourcesSold.stone);
     237            metalGathered.caption = playerState.statistics.resourcesGathered.metal + " / " +
     238                (playerState.statistics.resourcesUsed.metal - playerState.statistics.resourcesSold.metal);
    231239            vegetarianRatio.caption = Math.floor(playerState.statistics.resourcesGathered.food > 0 ?
    232240                (playerState.statistics.resourcesGathered.vegetarianFood / playerState.statistics.resourcesGathered.food) * 100 : 0) + "%";
    233             woodGathered.caption = playerState.statistics.resourcesGathered.wood;
    234             stoneGathered.caption = playerState.statistics.resourcesGathered.stone;
    235             metalGathered.caption = playerState.statistics.resourcesGathered.metal;
    236241            treasuresCollected.caption = playerState.statistics.treasuresCollected;
    237242
    238243            const SOLD_COLOR = "201 255 200";
  • gui/summary/summary.xml

     
    158158                <object name="playerName2Heading" type="text" style="LeftTabLabelText">
    159159                    Player name
    160160                </object>
     161                <object name="resourceHeading" type="text" style="CenteredTabLabelText">
     162                    Resource Statistics (Gathered / Used)
     163                </object>
    161164                <object name="foodGatheredHeading" type="text" style="CenteredTabLabelText">
    162                     Food&#10;gathered
     165                    Food
    163166                </object>
    164                 <object name="vegetarianRatioHeading" type="text" style="CenteredTabLabelText">
    165                     Vegetarian&#10;ratio
    166                 </object>
    167167                <object name="woodGatheredHeading" type="text" style="CenteredTabLabelText">
    168                     Wood&#10;gathered
     168                    Wood
    169169                </object>
    170170                <object name="stoneGatheredHeading" type="text" style="CenteredTabLabelText">
    171                     Stone&#10;gathered
     171                    Stone
    172172                </object>
    173173                <object name="metalGatheredHeading" type="text" style="CenteredTabLabelText">
    174                     Metal&#10;gathered
     174                    Metal
    175175                </object>
     176                <object name="vegetarianRatioHeading" type="text" style="CenteredTabLabelText">
     177                    Vegetarian&#10;ratio
     178                </object>
    176179                <object name="treasuresCollectedHeading" type="text" style="CenteredTabLabelText">
    177180                    Treasures&#10;collected
    178181                </object>
     
    185188                        <object name="playerName2[n]"           type="text"  style="LeftLabelText" size="40 2 208 100%" />
    186189                        <object name="civIcon2[n]"              type="image" size="208 0 240 32" tooltip_style="sessionToolTip"/>
    187190                        <object name="foodGathered[n]"          type="text" style="CenteredLabelText"/>
    188                         <object name="vegetarianRatio[n]"       type="text" style="CenteredLabelText"/>
    189191                        <object name="woodGathered[n]"          type="text" style="CenteredLabelText"/>
    190192                        <object name="stoneGathered[n]"         type="text" style="CenteredLabelText" />
    191193                        <object name="metalGathered[n]"         type="text" style="CenteredLabelText"/>
     194                        <object name="vegetarianRatio[n]"       type="text" style="CenteredLabelText"/>
    192195                        <object name="treasuresCollected[n]"        type="text" style="CenteredLabelText"/>
    193196                    </object>
    194197                </repeat>
  • simulation/components/Foundation.js

     
    8080    {
    8181        var scaled = Math.floor(this.costs[r] * (1.0 - this.buildProgress));
    8282        if (scaled)
     83        {
    8384            cmpPlayer.AddResource(r, scaled);
     85            var cmpStatisticsTracker = QueryPlayerIDInterface(this.owner, IID_StatisticsTracker);
     86            if (cmpStatisticsTracker)
     87                cmpStatisticsTracker.IncreaseResourceUsedCounter(r, -scaled);
     88        }
    8489    }
    8590
    8691    // Reset the timer
  • simulation/components/Player.js

     
    191191    else
    192192    {
    193193        // Subtract the resources
     194        var cmpStatisticsTracker = QueryPlayerIDInterface(this.playerID, IID_StatisticsTracker);
    194195        for (var type in amounts)
     196        {
    195197            this.resourceCount[type] -= amounts[type];
     198            if (cmpStatisticsTracker)
     199                cmpStatisticsTracker.IncreaseResourceUsedCounter(type, amounts[type]);
     200        }
    196201    }
    197202
    198203    return true;
  • simulation/components/ProductionQueue.js

     
    309309
    310310        // Refund the resource cost for this batch
    311311        var totalCosts = {};
     312        var cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
    312313        for each (var r in ["food", "wood", "stone", "metal"])
     314        {
    313315            totalCosts[r] = Math.floor(item.count * item.resources[r]);
     316            if (cmpStatisticsTracker)
     317                cmpStatisticsTracker.IncreaseResourceUsedCounter(r, -totalCosts[r]);
     318        }
    314319       
    315320        cmpPlayer.AddResources(totalCosts);
    316321       
  • simulation/components/StatisticsTracker.js

     
    2424            "stone": 0,
    2525            "vegetarianFood": 0
    2626    };
     27    this.resourcesUsed = {
     28            "food": 0,
     29            "wood": 0,
     30            "metal": 0,
     31            "stone": 0,
     32    };
    2733    this.resourcesSold = {
    2834            "food": 0,
    2935            "wood": 0,
     
    5258        "civCentresBuilt": this.civCentresBuilt,
    5359        "enemyCivCentresDestroyed": this.enemyCivCentresDestroyed,
    5460        "resourcesGathered": this.resourcesGathered,
     61        "resourcesUsed": this.resourcesUsed,
    5562        "resourcesSold": this.resourcesSold,
    5663        "resourcesBought": this.resourcesBought,
    5764        "tradeIncome": this.tradeIncome,
     
    135142        this.resourcesGathered["vegetarianFood"] += amount;
    136143};
    137144
     145/**
     146 * @param type Generic type of resource (string)
     147 * @param amount Amount of resource which has been used (integer)
     148 */
     149StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount)
     150{
     151    this.resourcesUsed[type] += amount;
     152};
     153
    138154StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
    139155{
    140156    return this.treasuresCollected++;