Ticket #4279: vision_range_tooltip.diff

File vision_range_tooltip.diff, 2.5 KB (added by elexis, 8 years ago)

Shows the vision range in the selection details, revealing the bug on ownership change.

  • binaries/data/mods/public/simulation/components/GuiInterface.js

    GuiInterface.prototype.GetEntityState =  
    248248        "trader": null,
    249249        "unitAI": null,
    250250        "visibility": null,
    251251    };
    252252
     253    let cmpVision = Engine.QueryInterface(ent, IID_Vision);
     254    if (cmpVision)
     255        ret.vision = {
     256            "range": cmpVision.GetRange()
     257        };
     258
    253259    let cmpMirage = Engine.QueryInterface(ent, IID_Mirage);
    254260    if (cmpMirage)
    255261        ret.mirage = true;
    256262
    257263    let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
  • binaries/data/mods/public/gui/session/selection_details.js

    function displaySingle(entState)  
    281281
    282282    // TODO: we should require all entities to have icons
    283283    Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack";
    284284
    285285    Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = [
     286        getVisionTooltip,
    286287        getAttackTooltip,
    287288        getSplashDamageTooltip,
    288289        getHealerTooltip,
    289290        getArmorTooltip,
    290291        getRepairRateTooltip,
  • binaries/data/mods/public/gui/common/tooltips.js

    function damageTypesToText(dmg)  
    130130            "damage": dmg[dmgType].toFixed(1),
    131131            "damageType": unitFont(g_DamageTypes[dmgType])
    132132        })).join(commaFont(translate(", ")));
    133133}
    134134
     135function getVisionTooltip(template)
     136{
     137    if (!template.vision)
     138        return "";
     139
     140    let range = template.vision.range;
     141
     142    return sprintf(translate("%(label)s %(details)s"), {
     143        "label": translate("Vision Range"),
     144        "details": sprintf(translatePlural("%(range)s %(meters)s", "%(range)s %(meters)s", range), {
     145            "range": range,
     146            "meters": unitFont(translatePlural("meter", "meters", range))
     147        })
     148    });
     149}
     150
    135151// TODO: should also show minRange
    136152function getAttackTooltip(template)
    137153{
    138154    if (!template.attack)
    139155        return "";