Ticket #3180: auravisualisation.diff
File auravisualisation.diff, 9.0 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Auras.js
47 47 "<text/>" + 48 48 "</element>" + 49 49 "</optional>" + 50 "<optional>" + 51 "<element name='OverlayIcon' a:help='Icon will be displayed on the affected units'>" + 52 "<text/>" + 53 "</element>" + 54 "</optional>" + 50 55 "<element name='Affects' a:help='Affected classes'>" + 51 56 "<text/>" + 52 57 "</element>" + … … 103 108 return Object.keys(this.template); 104 109 }; 105 110 111 Auras.prototype.GetOverlayIcon = function(name) 112 { 113 return this.template[name].OverlayIcon || ""; 114 }; 115 106 116 Auras.prototype.GetRange = function(name) 107 117 { 108 118 if (!this.IsRangeAura(name)) … … 122 132 return this.auras[name].modifications; 123 133 }; 124 134 135 Auras.prototype.GetAffectedEntities = function(name) 136 { 137 return this[name].targetUnits; 138 }; 139 125 140 Auras.prototype.GetAffectedPlayers = function(name) 126 141 { 127 142 return this.affectedPlayers[name]; -
binaries/data/mods/public/simulation/components/GuiInterface.js
26 26 this.timeNotificationID = 1; 27 27 this.timeNotifications = []; 28 28 this.entsRallyPointsDisplayed = []; 29 this.entsWithStatusBars = new Set(); 29 30 }; 30 31 31 32 /* … … 859 860 } 860 861 }; 861 862 863 GuiInterface.prototype.GetEntsWithStatusBars = function() 864 { 865 return [...this.entsWithStatusBars]; 866 }; 867 862 868 GuiInterface.prototype.SetStatusBars = function(player, cmd) 863 869 { 864 for each (var ent incmd.entities)870 for (let ent of cmd.entities) 865 871 { 866 872 var cmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars); 867 873 if (cmpStatusBars) 868 874 cmpStatusBars.SetEnabled(cmd.enabled); 875 if (cmd.enabled) 876 this.entsWithStatusBars.add(ent); 877 else 878 this.entsWithStatusBars.delete(ent); 879 880 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 881 if (!cmpAuras) 882 continue; 883 884 var affectedEntities = []; 885 var auraNames = cmpAuras.GetAuraNames(); 886 for (let name of auraNames) 887 if (cmpAuras.GetOverlayIcon(name)) 888 affectedEntities.push(...cmpAuras.GetAffectedEntities(name)); 889 890 for (let affectedEnt of affectedEntities) 891 { 892 var cmpStatusBars = Engine.QueryInterface(affectedEnt, IID_StatusBars); 893 if (!cmpStatusBars) 894 continue 895 if (cmd.enabled) 896 cmpStatusBars.AddAuraSource(ent); 897 else 898 cmpStatusBars.RemoveAuraSource(ent); 899 } 869 900 } 901 870 902 }; 871 903 872 904 GuiInterface.prototype.GetPlayerEntities = function(player) -
binaries/data/mods/public/simulation/components/StatusBars.js
14 14 StatusBars.prototype.Init = function() 15 15 { 16 16 this.enabled = false; 17 this.auraSource = []; // entity ids of the aura sources 17 18 }; 18 19 19 20 // Because this is enabled directly by the GUI and is not … … 37 38 38 39 this.enabled = enabled; 39 40 40 if (enabled )41 if (enabled || this.auraSource.length) 41 42 this.RegenerateSprites(); 42 43 else 43 44 this.ResetSprites(); 44 45 }; 45 46 47 StatusBars.prototype.AddAuraSource = function(ent) 48 { 49 if (this.auraSource.indexOf(ent) > -1) 50 return; 51 52 this.auraSource.push(ent); 53 this.RegenerateSprites(); 54 }; 55 56 StatusBars.prototype.RemoveAuraSource = function(ent) 57 { 58 var idx = this.auraSource.indexOf(ent); 59 if (idx == -1) 60 return; 61 this.auraSource.splice(idx, 1); 62 if (this.enabled || this.auraSource.length) 63 this.RegenerateSprites(); 64 else 65 this.ResetSprites(); 66 }; 67 46 68 StatusBars.prototype.OnHealthChanged = function(msg) 47 69 { 48 70 if (this.enabled) … … 61 83 this.RegenerateSprites(); 62 84 }; 63 85 86 StatusBars.prototype.OnValueModification = function(msg) 87 { 88 // rebuild the aura sources list for this ent 89 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 90 this.auraSource = []; 91 var entsWithStatusBars = cmpGuiInterface.GetEntsWithStatusBars(); 92 for (let ent of entsWithStatusBars) 93 { 94 if (this.auraSource.indexOf(ent) != -1) 95 continue; 96 97 let cmpAuras = Engine.QueryInterface(ent, IID_Auras); 98 if (!cmpAuras) 99 continue; 100 101 let auraNames = cmpAuras.GetAuraNames(); 102 let affected = false; 103 for (let name of auraNames) 104 { 105 if (!cmpAuras.GetOverlayIcon(name)) 106 continue; 107 if (cmpAuras.GetAffectedEntities(name).indexOf(this.entity) != -1) 108 affected = true; 109 } 110 if (affected) 111 this.auraSource.push(ent); 112 } 113 this.RegenerateSprites(); 114 }; 115 64 116 StatusBars.prototype.ResetSprites = function() 65 117 { 66 118 var cmpOverlayRenderer = Engine.QueryInterface(this.entity, IID_OverlayRenderer); … … 82 134 // Billboard offset of next bar 83 135 var yoffset = 0; 84 136 137 var iconList = [] 138 for (let ent of this.auraSource) 139 { 140 let cmpAuras = Engine.QueryInterface(ent, IID_Auras); 141 if (!cmpAuras) // probably the ent just died 142 return; 143 let auraNames = cmpAuras.GetAuraNames(); 144 for (let name of auraNames) 145 { 146 if (cmpAuras.GetAffectedEntities(name).indexOf(this.entity) == -1) 147 continue; 148 let icon = cmpAuras.GetOverlayIcon(name); 149 if (icon && iconList.indexOf(icon) == -1) 150 iconList.push(icon); 151 } 152 } 153 154 var iconSize = width/2; 155 for (let icon of iconList) 156 { 157 cmpOverlayRenderer.AddSprite( 158 icon, 159 { "x": -iconSize/2, "y": yoffset - iconSize/2 }, 160 { "x": iconSize/2, "y": yoffset + iconSize/2 }, 161 offset 162 ); 163 yoffset += iconSize * 1.2; 164 } 165 166 if (iconList.length) 167 yoffset -= iconSize * 0.6; 168 85 169 var AddBar = function(type, amount) 86 170 { 87 171 cmpOverlayRenderer.AddSprite( 88 172 "art/textures/ui/session/icons/"+type+"_bg.png", 89 { "x": -width/2, "y": -height/2 + yoffset},90 { "x": width/2, "y": height/2 + yoffset},173 { "x": -width/2, "y": yoffset - height/2}, 174 { "x": width/2, "y": yoffset + height/2 }, 91 175 offset 92 176 ); 93 177 94 178 cmpOverlayRenderer.AddSprite( 95 179 "art/textures/ui/session/icons/"+type+"_fg.png", 96 { "x": -width/2, "y": -height/2 + yoffset},97 { "x": width*(amount - 0.5), "y": height/2 + yoffset},180 { "x": -width/2, "y": yoffset - height/2 }, 181 { "x": width*(amount - 0.5), "y": yoffset + height/2 }, 98 182 offset 99 183 ); 100 184 101 yoffset -= height * 1.2;185 yoffset += height * 1.2; 102 186 }; 103 187 104 var cmpMirage = Engine.QueryInterface(this.entity, IID_Mirage); 188 if (this.enabled) 189 { 190 var cmpMirage = Engine.QueryInterface(this.entity, IID_Mirage); 191 var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); 192 if (cmpPack && cmpPack.IsPacking()) 193 AddBar("pack", cmpPack.GetProgress()); 105 194 106 var cmpPack = Engine.QueryInterface(this.entity, IID_Pack); 107 if (cmpPack && cmpPack.IsPacking()) 108 AddBar("pack", cmpPack.GetProgress()); 195 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 196 if (cmpHealth && cmpHealth.GetHitpoints() > 0) 197 AddBar("health", cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints()); 198 else if (cmpMirage && cmpMirage.Health()) 199 AddBar("health", cmpMirage.GetHitpoints() / cmpMirage.GetMaxHitpoints()); 109 200 110 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 111 if (cmpHealth && cmpHealth.GetHitpoints() > 0) 112 AddBar("health", cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints()); 113 else if (cmpMirage && cmpMirage.Health()) 114 AddBar("health", cmpMirage.GetHitpoints() / cmpMirage.GetMaxHitpoints()); 115 116 var cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); 117 if (cmpResourceSupply) 118 AddBar("supply", cmpResourceSupply.IsInfinite() ? 1 : cmpResourceSupply.GetCurrentAmount() / cmpResourceSupply.GetMaxAmount()); 119 else if (cmpMirage && cmpMirage.ResourceSupply()) 120 AddBar("supply", cmpMirage.IsInfinite() ? 1 : cmpMirage.GetAmount() / cmpMirage.GetMaxAmount()); 121 122 /* 201 var cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); 202 if (cmpResourceSupply) 203 AddBar("supply", cmpResourceSupply.IsInfinite() ? 1 : cmpResourceSupply.GetCurrentAmount() / cmpResourceSupply.GetMaxAmount()); 204 else if (cmpMirage && cmpMirage.ResourceSupply()) 205 AddBar("supply", cmpMirage.IsInfinite() ? 1 : cmpMirage.GetAmount() / cmpMirage.GetMaxAmount()); 206 } /* 123 207 // Rank icon disabled for now - see discussion around 124 208 // http://www.wildfiregames.com/forum/index.php?s=&showtopic=13608&view=findpost&p=212154 125 209 -
binaries/data/mods/public/simulation/templates/template_structure_civic_temple.xml
10 10 </Modifications> 11 11 <AuraName>Healing Aura</AuraName> 12 12 <AuraDescription>Heals nearby units at 1 HP per second.</AuraDescription> 13 <OverlayIcon>art/textures/ui/session/auras/heal.png</OverlayIcon> 13 14 </heal> 14 15 </Auras> 15 16 <BuildRestrictions>