Ticket #4026: healertooltip.4.diff

File healertooltip.4.diff, 7.6 KB (added by elexis, 8 years ago)

Moved tooltip above the armor tooltip, uses toFixed() and variables in tooltip.js, removes one less newline in load.js. The patch is completely broken as it doesn't change all occurances of entState.healer

  • binaries/data/mods/public/globalscripts/Templates.js

    function GetTemplateDataHelper(template,  
    222222        ret.garrisonHolder = {};
    223223        if (template.GarrisonHolder.Max)
    224224            ret.garrisonHolder.max = getEntityValue("GarrisonHolder/Max");
    225225    }
    226226
     227    if (template.Heal)
     228    {
     229        ret.heal = {};
     230        if (template.Heal.HP)
     231            ret.heal.hp = getEntityValue("Heal/HP");
     232        if (template.Heal.Range)
     233            ret.heal.range = getEntityValue("Heal/Range");
     234        if (template.Heal.Rate)
     235            ret.heal.rate = getEntityValue("Heal/Rate");
     236    }
     237
    227238    if (template.Obstruction)
    228239    {
    229240        ret.obstruction = {
    230241            "active": ("" + template.Obstruction.Active == "true"),
    231242            "blockMovement": ("" + template.Obstruction.BlockMovement == "true"),
  • binaries/data/mods/public/gui/common/tooltips.js

    function getSpeedTooltip(template)  
    458458    });
    459459}
    460460
    461461function getHealerTooltip(template)
    462462{
    463     if (!template.healer)
     463    if (!template.heal)
    464464        return "";
    465465
     466    let hp = template.heal.hp.toFixed(1);
     467    let range = template.heal.range.toFixed(1);
     468    let rate = (template.heal.rate / 1000).toFixed(1);
     469
    466470    return [
    467         sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", template.healer.HP), {
     471        sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", hp), {
    468472            "label": headerFont(translate("Heal:")),
    469             "val": template.healer.HP,
     473            "val": hp,
    470474            // Translation: Short for hit points (or health points) that are healed in one healing action
    471             "unit": unitFont(translatePlural("HP", "HP", template.healer.HP))
     475            "unit": unitFont(translatePlural("HP", "HP", hp))
    472476        }),
    473         sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", template.healer.Range), {
     477        sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", range), {
    474478            "label": headerFont(translate("Range:")),
    475             "val": template.healer.Range,
    476             "unit": unitFont(translatePlural("meter", "meters", template.healer.Range))
     479            "val": range,
     480            "unit": unitFont(translatePlural("meter", "meters", range))
    477481        }),
    478         sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", template.healer.Rate/1000), {
     482        sprintf(translatePlural("%(label)s %(val)s %(unit)s", "%(label)s %(val)s %(unit)s", rate), {
    479483            "label": headerFont(translate("Rate:")),
    480             "val": template.healer.Rate/1000,
    481             "unit": unitFont(translatePlural("second", "seconds", template.healer.Rate / 1000))
     484            "val": rate,
     485            "unit": unitFont(translatePlural("second", "seconds", rate))
    482486        })
    483487    ].join(translate(", "));
    484488}
    485489
    486490function getAurasTooltip(template)
  • binaries/data/mods/public/gui/session/selection_details.js

    function displaySingle(entState)  
    282282    // TODO: we should require all entities to have icons
    283283    Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "bkFillBlack";
    284284
    285285    Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = [
    286286        getAttackTooltip,
     287        getHealerTooltip,
    287288        getArmorTooltip,
    288289        getRepairRateTooltip,
    289290        getBuildRateTooltip,
    290291        getGarrisonTooltip,
    291292        getProjectilesTooltip
  • binaries/data/mods/public/gui/session/selection_panels.js

    g_SelectionPanels.Training = {  
    10041004
    10051005        if (Engine.ConfigDB_GetValue("user", "showdetailedtooltips") === "true")
    10061006            tooltips.push(
    10071007                getHealthTooltip(template),
    10081008                getAttackTooltip(template),
     1009                getHealerTooltip(template),
    10091010                getArmorTooltip(template),
    10101011                getGarrisonTooltip(template),
    10111012                getProjectilesTooltip(template),
    10121013                getSpeedTooltip(template)
    10131014            );
  • binaries/data/mods/public/gui/structree/load.js

    function loadUnit(templateName)  
    7878                    g_Lists.techs.push(research);
    7979            }
    8080        }
    8181    }
    8282
    83     if (template.Heal)
    84         unit.healer = {
    85             "Range": +template.Heal.Range || 0,
    86             "HP": +template.Heal.HP || 0,
    87             "Rate": +template.Heal.Rate || 0
    88         };
    89 
    9083    if (template.Builder && template.Builder.Entities._string)
    9184        for (let build of template.Builder.Entities._string.split(" "))
    9285        {
    9386            build = build.replace("{civ}", g_SelectedCiv);
    9487            if (g_Lists.structures.indexOf(build) < 0)
  • binaries/data/mods/public/simulation/components/GuiInterface.js

    GuiInterface.prototype.GetExtendedEntity  
    543543        ret.barterMarket = { "prices": cmpBarter.GetPrices() };
    544544    }
    545545
    546546    let cmpHeal = Engine.QueryInterface(ent, IID_Heal);
    547547    if (cmpHeal)
    548         ret.healer = {
     548        ret.heal = {
     549            "hp": cmpHeal.GetHP(),
     550            "range": cmpHeal.GetRange().max,
     551            "rate": cmpHeal.GetRate(),
    549552            "unhealableClasses": cmpHeal.GetUnhealableClasses(),
    550553            "healableClasses": cmpHeal.GetHealableClasses(),
    551554        };
    552555
    553556    return ret;
  • binaries/data/mods/public/simulation/components/Heal.js

    Heal.prototype.GetTimers = function()  
    4545    repeat = ApplyValueModificationsToEntity("Heal/Rate", repeat, this.entity);
    4646   
    4747    return { "prepare": prepare, "repeat": repeat };
    4848};
    4949
     50Heal.prototype.GetHP = function()
     51{
     52    return ApplyValueModificationsToEntity("Heal/Range", +this.template.HP, this.entity);
     53};
     54
     55Heal.prototype.GetRate = function()
     56{
     57    return ApplyValueModificationsToEntity("Heal/Rate", +this.template.Rate, this.entity);
     58};
     59
    5060Heal.prototype.GetRange = function()
    5161{
    5262    var min = 0;
    5363    var max = +this.template.Range;
    5464   
  • binaries/data/mods/public/simulation/templates/units/maur_hero_chanakya.xml

     
    2929    <Classes datatype="tokens">Human Organic Support</Classes>
    3030    <VisibleClasses datatype="tokens">Hero Healer</VisibleClasses>
    3131    <GenericName>Acharya Chanakya</GenericName>
    3232    <SpecificName>Acharya Chāṇakya</SpecificName>
    3333    <Icon>units/maur_hero_chanakya.png</Icon>
    34     <Tooltip>Hero Special: "Healer" - Heal units at an accelerated rate.
    35 Hero Special: "Philosopher" - Research 4 special technologies only available to Chanakya.</Tooltip>
    3634    <RequiredTechnology>phase_city</RequiredTechnology>
    3735  </Identity>
    3836  <Minimap>
    3937    <Type>hero</Type>
    4038  </Minimap>