Ticket #3113: total_carried_resources_v1.4.patch

File total_carried_resources_v1.4.patch, 2.4 KB (added by Imarok, 8 years ago)

merged line 392 and 393

  • binaries/data/mods/public/gui/session/selection_details.js

     
    303303    let maxCapturePoints = 0;
    304304    let capturePoints = (new Array(9)).fill(0);
    305305    let playerID = 0;
     306    let totalResourcesCarried;
    306307
    307308    for (let i = 0; i < selection.length; i++)
    308309    {
     
    320321            maxCapturePoints += entState.maxCapturePoints;
    321322            capturePoints = entState.capturePoints.map((v, i) => v + capturePoints[i]);
    322323        }
     324
     325        if (entState.resourceCarrying && entState.resourceCarrying.length !== 0)
     326        {
     327            if (!totalResourcesCarried)
     328                totalResourcesCarried = {};
     329
     330            let carrying = entState.resourceCarrying[0];
     331            if (totalResourcesCarried[carrying.type])
     332                totalResourcesCarried[carrying.type] += carrying.amount;
     333            else
     334                totalResourcesCarried[carrying.type] = carrying.amount;
     335        }
    323336    }
    324337
    325338    Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0;
     
    369382        });
    370383    }
    371384
    372     Engine.GetGUIObjectByName("numberOfUnits").caption = selection.length;
     385    let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits");
     386    numberOfUnits.caption = selection.length;
     387    let str = "";
     388    if (totalResourcesCarried)
     389        for (let res of RESOURCES)
     390            if (totalResourcesCarried[res])
     391            {
     392                str += getCostComponentDisplayName(res) + totalResourcesCarried[res] + " ";
     393            }
     394    numberOfUnits.tooltip = str.substr(0, str.length - 1);
    373395
    374396    // Unhide Details Area
    375397    Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false;
  • binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml

     
    1919
    2020    <!-- Total -->
    2121    <object size="100%-42 12 100%-8 46" type="image" sprite="groupsIcon">
    22     <object size="0 0 100% 100%" type="text" style="largeCenteredOutlinedText" name="numberOfUnits"/>
     22    <object size="0 0 100% 100%" type="text" style="largeCenteredOutlinedText" name="numberOfUnits" tooltip_style="sessionToolTipBold"/>
    2323    </object>
    2424
    2525    <!-- Stats Bars -->