Ticket #3113: total_carried_resources_v1.4.1.patch

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

Updated to the new revision

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

     
    341341    let maxCapturePoints = 0;
    342342    let capturePoints = (new Array(9)).fill(0);
    343343    let playerID = 0;
     344    let totalResourcesCarried;
    344345
    345346    for (let i = 0; i < selection.length; i++)
    346347    {
     
    358359            maxCapturePoints += entState.maxCapturePoints;
    359360            capturePoints = entState.capturePoints.map((v, i) => v + capturePoints[i]);
    360361        }
     362
     363        if (entState.resourceCarrying && entState.resourceCarrying.length !== 0)
     364        {
     365            if (!totalResourcesCarried)
     366                totalResourcesCarried = {};
     367
     368            let carrying = entState.resourceCarrying[0];
     369            if (totalResourcesCarried[carrying.type])
     370                totalResourcesCarried[carrying.type] += carrying.amount;
     371            else
     372                totalResourcesCarried[carrying.type] = carrying.amount;
     373        }
    361374    }
    362375
    363376    Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0;
     
    407420        });
    408421    }
    409422
    410     Engine.GetGUIObjectByName("numberOfUnits").caption = selection.length;
     423    let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits");
     424    numberOfUnits.caption = selection.length;
     425    let str = "";
     426    if (totalResourcesCarried)
     427        for (let res of RESOURCES)
     428            if (totalResourcesCarried[res])
     429            {
     430                str += getCostComponentDisplayName(res) + totalResourcesCarried[res] + " ";
     431            }
     432    numberOfUnits.tooltip = str.substr(0, str.length - 1);
    411433
    412434    // Unhide Details Area
    413435    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 -->