Ticket #3189: guiinterface_mirage_cleanup.diff

File guiinterface_mirage_cleanup.diff, 6.1 KB (added by leper, 9 years ago)

wip (as in incomplete); slightly broken (removes Health() and similar though still used (see first point))

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

     
    222222                return false;
    223223            if (getActionInfo("repair", target).possible)
    224224                return {"type": "repair", "cursor": "action-repair", "target": target};
    225             return {"type": "none", "cursor": "action-repair-disabled", "target": undefined};
     225            return {"type": "none", "cursor": "action-repair-disabled", "target": null};
    226226        },
    227227        "actionCheck": function(target)
    228228        {
     
    295295    {
    296296        "execute": function(target, action, selection, queued)
    297297        {
    298             Engine.PostNetworkCommand({"type": "setup-trade-route", "entities": selection, "target": action.target, "source": undefined, "route": undefined, "queued": queued});
     298            Engine.PostNetworkCommand({"type": "setup-trade-route", "entities": selection, "target": action.target, "source": null, "route": null, "queued": queued});
    299299            Engine.GuiInterfaceCall("PlaySound", { "name": "order_trade", "entity": selection[0] });
    300300            return true;
    301301        },
     
    390390            var actionInfo =  getActionInfo("garrison", target);
    391391            if (actionInfo.possible)
    392392                return {"type": "garrison", "cursor": "action-garrison", "tooltip": actionInfo.tooltip, "target": target};
    393             return {"type": "none", "cursor": "action-garrison-disabled", "target": undefined};
     393            return {"type": "none", "cursor": "action-garrison-disabled", "target": null};
    394394        },
    395395        "hotkeyActionCheck": function(target)
    396396        {
     
    428428                return false;
    429429            if (getActionInfo("guard", target).possible)
    430430                return {"type": "guard", "cursor": "action-guard", "target": target};
    431             return {"type": "none", "cursor": "action-guard-disabled", "target": undefined};
     431            return {"type": "none", "cursor": "action-guard-disabled", "target": null};
    432432        },
    433433        "hotkeyActionCheck": function(target)
    434434        {
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    267267        ret.needsRepair = cmpMirage.NeedsRepair();
    268268    }
    269269
    270     var cmpCapturable = Engine.QueryInterface(ent, IID_Capturable);
     270    var cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
    271271    if (cmpCapturable)
    272272    {
    273273        ret.capturePoints = cmpCapturable.GetCapturePoints();
    274274        ret.maxCapturePoints = cmpCapturable.GetMaxCapturePoints();
    275275    }
    276     if (cmpMirage && cmpMirage.Capturable())
    277     {
    278         ret.capturePoints = cmpMirage.GetCapturePoints();
    279         ret.maxCapturePoints = cmpMirage.GetMaxCapturePoints();
    280     }
    281276
    282277    var cmpBuilder = Engine.QueryInterface(ent, IID_Builder);
    283278    if (cmpBuilder)
     
    17161711
    17171712    var owner = QueryOwnerInterface(data.entity).GetPlayerID();
    17181713
    1719     var cmp = Engine.QueryInterface(data.target, IID_Mirage);
    1720     if (cmp && !cmp.Capturable())
    1721         return false
    1722     else if (!cmp)
    1723         var cmp = Engine.QueryInterface(data.target, IID_Capturable);
    1724 
     1714    var cmpCapturale = QueryMiragedInterface(data.target, IID_Capturable);
    17251715    if (cmp && cmp.CanCapture(owner) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1)
    17261716        return cmpAttack.CanAttack(data.target);
    17271717
  • binaries/data/mods/public/simulation/components/Mirage.js

     
    4747    this.player = player;
    4848};
    4949
     50Mirage.prototype.Mirages = function(iid)
     51{
     52    switch (iid)
     53    {
     54    case IID_Foundation:
     55        return this.foundation;
     56    case IID_Health:
     57        return this.health;
     58    case IID_Capturable:
     59        return this.capturable;
     60    case IID_ResourceSupply:
     61        return this.resourceSupply;
     62    default:
     63        return false;
     64    }
     65};
     66
    5067// ============================
    5168// Parent entity data
    5269
     
    5875    this.buildPercentage = buildPercentage;
    5976};
    6077
    61 Mirage.prototype.Foundation = function()
    62 {
    63     return this.foundation;
    64 };
    65 
    6678Mirage.prototype.GetBuildPercentage = function()
    6779{
    6880    return this.buildPercentage;
     
    7890    this.needsRepair = needsRepair;
    7991};
    8092
    81 Mirage.prototype.Health = function()
    82 {
    83     return this.health;
    84 };
    85 
    8693Mirage.prototype.GetMaxHitpoints = function()
    8794{
    8895    return this.maxHitpoints;
     
    107114    this.maxCapturePoints = maxCapturePoints;
    108115};
    109116
    110 Mirage.prototype.Capturable = function()
    111 {
    112     return this.capturable;
    113 };
    114 
    115117Mirage.prototype.GetMaxCapturePoints = function()
    116118{
    117119    return this.maxCapturePoints;
     
    135137    this.isInfinite = isInfinite;
    136138};
    137139
    138 Mirage.prototype.ResourceSupply = function()
    139 {
    140     return this.resourceSupply;
    141 };
    142 
    143140Mirage.prototype.GetMaxAmount = function()
    144141{
    145142    return this.maxAmount;
  • binaries/data/mods/public/simulation/helpers/Player.js

     
    223223}
    224224
    225225/**
     226 * Similar to Engine.QueryInterface but first checks if the entity
     227 * mirages the interface.
     228 */
     229function QueryMiragedInterface(ent, iid)
     230{
     231    var cmp = Engine.QueryInterface(ent, IID_Mirage);
     232    if (cmp && !cmp.Mirages(iid))
     233        return null;
     234    else if (!cmp)
     235        cmp = Engine.QueryInterface(ent, iid);
     236
     237    return cmp;
     238}
     239
     240/**
    226241 * Returns true if the entity 'target' is owned by an ally of
    227242 * the owner of 'entity'.
    228243 */
     
    379394Engine.RegisterGlobal("LoadPlayerSettings", LoadPlayerSettings);
    380395Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface);
    381396Engine.RegisterGlobal("QueryPlayerIDInterface", QueryPlayerIDInterface);
     397Engine.RegisterGlobal("QueryMiragedInterface", QueryMiragedInterface);
    382398Engine.RegisterGlobal("IsOwnedByAllyOfEntity", IsOwnedByAllyOfEntity);
    383399Engine.RegisterGlobal("IsOwnedByMutualAllyOfEntity", IsOwnedByMutualAllyOfEntity);
    384400Engine.RegisterGlobal("IsOwnedByPlayer", IsOwnedByPlayer);