Ticket #3189: guiinterface_mirage_cleanup.diff
File guiinterface_mirage_cleanup.diff, 6.1 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/session/unit_actions.js
222 222 return false; 223 223 if (getActionInfo("repair", target).possible) 224 224 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}; 226 226 }, 227 227 "actionCheck": function(target) 228 228 { … … 295 295 { 296 296 "execute": function(target, action, selection, queued) 297 297 { 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}); 299 299 Engine.GuiInterfaceCall("PlaySound", { "name": "order_trade", "entity": selection[0] }); 300 300 return true; 301 301 }, … … 390 390 var actionInfo = getActionInfo("garrison", target); 391 391 if (actionInfo.possible) 392 392 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}; 394 394 }, 395 395 "hotkeyActionCheck": function(target) 396 396 { … … 428 428 return false; 429 429 if (getActionInfo("guard", target).possible) 430 430 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}; 432 432 }, 433 433 "hotkeyActionCheck": function(target) 434 434 { -
binaries/data/mods/public/simulation/components/GuiInterface.js
267 267 ret.needsRepair = cmpMirage.NeedsRepair(); 268 268 } 269 269 270 var cmpCapturable = Engine.QueryInterface(ent, IID_Capturable);270 var cmpCapturable = QueryMiragedInterface(ent, IID_Capturable); 271 271 if (cmpCapturable) 272 272 { 273 273 ret.capturePoints = cmpCapturable.GetCapturePoints(); 274 274 ret.maxCapturePoints = cmpCapturable.GetMaxCapturePoints(); 275 275 } 276 if (cmpMirage && cmpMirage.Capturable())277 {278 ret.capturePoints = cmpMirage.GetCapturePoints();279 ret.maxCapturePoints = cmpMirage.GetMaxCapturePoints();280 }281 276 282 277 var cmpBuilder = Engine.QueryInterface(ent, IID_Builder); 283 278 if (cmpBuilder) … … 1716 1711 1717 1712 var owner = QueryOwnerInterface(data.entity).GetPlayerID(); 1718 1713 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); 1725 1715 if (cmp && cmp.CanCapture(owner) && cmpAttack.GetAttackTypes().indexOf("Capture") != -1) 1726 1716 return cmpAttack.CanAttack(data.target); 1727 1717 -
binaries/data/mods/public/simulation/components/Mirage.js
47 47 this.player = player; 48 48 }; 49 49 50 Mirage.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 50 67 // ============================ 51 68 // Parent entity data 52 69 … … 58 75 this.buildPercentage = buildPercentage; 59 76 }; 60 77 61 Mirage.prototype.Foundation = function()62 {63 return this.foundation;64 };65 66 78 Mirage.prototype.GetBuildPercentage = function() 67 79 { 68 80 return this.buildPercentage; … … 78 90 this.needsRepair = needsRepair; 79 91 }; 80 92 81 Mirage.prototype.Health = function()82 {83 return this.health;84 };85 86 93 Mirage.prototype.GetMaxHitpoints = function() 87 94 { 88 95 return this.maxHitpoints; … … 107 114 this.maxCapturePoints = maxCapturePoints; 108 115 }; 109 116 110 Mirage.prototype.Capturable = function()111 {112 return this.capturable;113 };114 115 117 Mirage.prototype.GetMaxCapturePoints = function() 116 118 { 117 119 return this.maxCapturePoints; … … 135 137 this.isInfinite = isInfinite; 136 138 }; 137 139 138 Mirage.prototype.ResourceSupply = function()139 {140 return this.resourceSupply;141 };142 143 140 Mirage.prototype.GetMaxAmount = function() 144 141 { 145 142 return this.maxAmount; -
binaries/data/mods/public/simulation/helpers/Player.js
223 223 } 224 224 225 225 /** 226 * Similar to Engine.QueryInterface but first checks if the entity 227 * mirages the interface. 228 */ 229 function 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 /** 226 241 * Returns true if the entity 'target' is owned by an ally of 227 242 * the owner of 'entity'. 228 243 */ … … 379 394 Engine.RegisterGlobal("LoadPlayerSettings", LoadPlayerSettings); 380 395 Engine.RegisterGlobal("QueryOwnerInterface", QueryOwnerInterface); 381 396 Engine.RegisterGlobal("QueryPlayerIDInterface", QueryPlayerIDInterface); 397 Engine.RegisterGlobal("QueryMiragedInterface", QueryMiragedInterface); 382 398 Engine.RegisterGlobal("IsOwnedByAllyOfEntity", IsOwnedByAllyOfEntity); 383 399 Engine.RegisterGlobal("IsOwnedByMutualAllyOfEntity", IsOwnedByMutualAllyOfEntity); 384 400 Engine.RegisterGlobal("IsOwnedByPlayer", IsOwnedByPlayer);