Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -168,7 +168,7 @@ session.highlightguarding = PgDn ; Toggle highlight of guarding units session.highlightguarded = PgUp ; Toggle highlight of guarded units session.toggleattackrange = "Alt+C" ; Toggle display of attack range overlays of selected defensive structures -session.toggleaurarange = "Alt+V" ; Toggle display of aura range overlays of selected units and structures +session.toggleaurasrange = "Alt+V" ; Toggle display of aura range overlays of selected units and structures session.togglehealrange = "Alt+B" ; Toggle display of heal range overlays of selected units ; > HOTKEYS ONLY @@ -348,7 +348,7 @@ timeelapsedcounter = false ; Show the game duration in the top right corner batchtrainingsize = 5 ; Number of units to be trained per batch (when pressing the hotkey) attackrange = true ; Display attack range overlays of selected defensive structures -aurarange = true ; Display aura range overlays of selected units and structures +aurasrange = true ; Display aura range overlays of selected units and structures healrange = true ; Display heal range overlays of selected units [gui.session.minimap] Index: ps/trunk/binaries/data/mods/public/gui/session/hotkeys/misc.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/hotkeys/misc.xml +++ ps/trunk/binaries/data/mods/public/gui/session/hotkeys/misc.xml @@ -101,8 +101,8 @@ toggleRangeOverlay("Attack"); - - toggleRangeOverlay("Aura"); + + toggleRangeOverlay("Auras"); Index: ps/trunk/binaries/data/mods/public/gui/session/session.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.js +++ ps/trunk/binaries/data/mods/public/gui/session/session.js @@ -797,7 +797,7 @@ handleNotifications(); updateGUIObjects(); - for (let type of ["Attack", "Aura", "Heal"]) + for (let type of ["Attack", "Auras", "Heal"]) Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", { "type": type, "enabled": Engine.ConfigDB_GetValue("user", "gui.session." + type.toLowerCase() + "range") == "true" @@ -1280,7 +1280,7 @@ /** * Toggles the display of range overlays of selected entities for the given range type. - * @param {string} type - for example "Aura" + * @param {string} type - for example "Auras" */ function toggleRangeOverlay(type) { Index: ps/trunk/binaries/data/mods/public/simulation/components/Auras.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Auras.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Auras.js @@ -66,29 +66,6 @@ return undefined; }; -/** - * Return the names of any range auras - used to render their ranges. - */ -Auras.prototype.GetVisualAuraRangeNames = function() -{ - return this.GetAuraNames().filter(auraName => this.IsRangeAura(auraName) && this[auraName].isApplied); -}; - -Auras.prototype.GetLineTexture = function(name) -{ - return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTexture : "outline_border.png"; -}; - -Auras.prototype.GetLineTextureMask = function(name) -{ - return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineTextureMask : "outline_border_mask.png"; -}; - -Auras.prototype.GetLineThickness = function(name) -{ - return this.auras[name].rangeOverlay ? this.auras[name].rangeOverlay.lineThickness : 0.2; -}; - Auras.prototype.GetClasses = function(name) { return this.auras[name].affects; @@ -104,6 +81,35 @@ return this.affectedPlayers[name]; }; +Auras.prototype.GetRangeOverlays = function() +{ + let rangeOverlays = []; + + for (let name of this.GetAuraNames()) + { + if (!this.IsRangeAura(name) || !this[name].isApplied) + continue; + + rangeOverlays.push( + this.auras[name].rangeOverlay ? + { + "radius": this.GetRange(name), + "texture": this.auras[name].rangeOverlay.lineTexture, + "textureMask": this.auras[name].rangeOverlay.lineTextureMask, + "thickness": this.auras[name].rangeOverlay.lineThickness + } : + // Specify default in order not to specify it in about 40 auras + { + "radius": this.GetRange(name), + "texture": "outline_border.png", + "textureMask": "outline_border_mask.png", + "thickness": 0.2 + }); + } + + return rangeOverlays; +}; + Auras.prototype.CalculateAffectedPlayers = function(name) { var affectedPlayers = this.auras[name].affectedPlayers || ["Player"]; @@ -278,7 +284,7 @@ let cmpRangeVisualization = Engine.QueryInterface(this.entity, IID_RangeVisualization); if (cmpRangeVisualization) { - cmpRangeVisualization.UpdateVisualAuraRanges(); + cmpRangeVisualization.UpdateRangeOverlays("Auras"); cmpRangeVisualization.RegenerateRangeVisualizations(false); } } Index: ps/trunk/binaries/data/mods/public/simulation/components/Heal.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Heal.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Heal.js @@ -87,19 +87,17 @@ return this.template.HealableClasses._string || ""; }; -Heal.prototype.GetLineTexture = function() +Heal.prototype.GetRangeOverlays = function() { - return this.template.RangeOverlay ? this.template.RangeOverlay.LineTexture : "heal_overlay_range.png"; -}; + if (!this.template.RangeOverlay) + return []; -Heal.prototype.GetLineTextureMask = function() -{ - return this.template.RangeOverlay ? this.template.RangeOverlay.LineTextureMask : "heal_overlay_range_mask.png"; -}; - -Heal.prototype.GetLineThickness = function() -{ - return this.template.RangeOverlay ? +this.template.RangeOverlay.LineThickness : 0.35; + return [{ + "radius": this.GetRange().max, + "texture": this.template.RangeOverlay.LineTexture, + "textureMask": this.template.RangeOverlay.LineTextureMask, + "thickness": +this.template.RangeOverlay.LineThickness + }] }; /** Index: ps/trunk/binaries/data/mods/public/simulation/components/RangeVisualization.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/RangeVisualization.js +++ ps/trunk/binaries/data/mods/public/simulation/components/RangeVisualization.js @@ -7,7 +7,7 @@ this.enabled = false; this.enabledRangeTypes = { "Attack": false, - "Aura": false, + "Auras": false, "Heal": false }; @@ -22,42 +22,11 @@ this.Init(); }; -RangeVisualization.prototype.UpdateVisualAttackRanges = function() +RangeVisualization.prototype.UpdateRangeOverlays = function(componentName) { - let cmpAttack = Engine.QueryInterface(this.entity, IID_Attack); - if (cmpAttack) - this.rangeVisualizations.set("Attack", cmpAttack.GetRangeOverlays()); -}; - -RangeVisualization.prototype.UpdateVisualAuraRanges = function() -{ - let cmpAuras = Engine.QueryInterface(this.entity, IID_Auras); - if (!cmpAuras) - return; - - this.rangeVisualizations.set("Aura", []); - - for (let auraName of cmpAuras.GetVisualAuraRangeNames()) - this.rangeVisualizations.get("Aura").push({ - "radius": cmpAuras.GetRange(auraName), - "texture": cmpAuras.GetLineTexture(auraName), - "textureMask": cmpAuras.GetLineTextureMask(auraName), - "thickness": cmpAuras.GetLineThickness(auraName), - }); -}; - -RangeVisualization.prototype.UpdateVisualHealRanges = function() -{ - let cmpHeal = Engine.QueryInterface(this.entity, IID_Heal); - if (!cmpHeal) - return; - - this.rangeVisualizations.set("Heal", [{ - "radius": cmpHeal.GetRange().max, - "texture": cmpHeal.GetLineTexture(), - "textureMask": cmpHeal.GetLineTextureMask(), - "thickness": cmpHeal.GetLineThickness(), - }]); + let cmp = Engine.QueryInterface(this.entity, global["IID_" + componentName]); + if (cmp) + this.rangeVisualizations.set(componentName, cmp.GetRangeOverlays()); }; RangeVisualization.prototype.SetEnabled = function(enabled, enabledRangeTypes, forceUpdate) @@ -95,7 +64,8 @@ if (msg.to == -1) return; for (let type in this.enabledRangeTypes) - this["UpdateVisual" + type + "Ranges"](); + this.UpdateRangeOverlays(type); + this.RegenerateRangeVisualizations(false); }; @@ -106,7 +76,7 @@ msg.valueNames.indexOf("Attack/Ranged/MaxRange") == -1) return; - this["UpdateVisual" + msg.component + "Ranges"](); + this.UpdateRangeOverlays(msg.component); this.RegenerateRangeVisualizations(false); }; @@ -116,7 +86,7 @@ RangeVisualization.prototype.OnDeserialized = function(msg) { for (let type in this.enabledRangeTypes) - this["UpdateVisual" + type + "Ranges"](); + this.UpdateRangeOverlays(type); }; Engine.RegisterComponentType(IID_RangeVisualization, "RangeVisualization", RangeVisualization); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Heal.js @@ -53,11 +53,12 @@ TS_ASSERT_EQUALS(cmpHeal.GetUnhealableClasses(), "Cavalry"); -TS_ASSERT_EQUALS(cmpHeal.GetLineTexture(), "heal_overlay_range.png"); - -TS_ASSERT_EQUALS(cmpHeal.GetLineTextureMask(), "heal_overlay_range_mask.png"); - -TS_ASSERT_EQUALS(cmpHeal.GetLineThickness(), 0.35); +TS_ASSERT_UNEVAL_EQUALS(cmpHeal.GetRangeOverlays(), [{ + "radius": 20 + 300, + "texture": "heal_overlay_range.png", + "textureMask": "heal_overlay_range_mask.png", + "thickness": 0.35 +}]); // Test PerformHeal let target = 70; Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_hero_healer.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_hero_healer.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_hero_healer.xml @@ -19,6 +19,11 @@ 2000 Human + + heal_overlay_range.png + heal_overlay_range_mask.png + 0.35 + 1000 Index: ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_healer.xml =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_healer.xml +++ ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support_healer.xml @@ -11,6 +11,11 @@ 2000 Human + + heal_overlay_range.png + heal_overlay_range_mask.png + 0.35 + 85