Quantcast SecureAuraHeaderTemplate - WoWInterface
Thread Tools Display Modes
02-15-16, 12:49 PM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
SecureAuraHeaderTemplate

I was experimenting to update secure aura headers without the "UNIT_AURA" event and without updating every auras every time unnecessary.

I came up with this:

Lua Code:
  1. buff:SetScript("OnAttributeChanged", function(self, name, value)
  2.     if name == "index" then
  3.         --print(self:GetName(), name, value)
  4.         if value then
  5.             local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, shouldConsolidate, spellId, canApplyAura, isBossDebuff, isCastByPlayer = UnitAura(self.unit, value, buff.filter)
  6.             if self.index ~= value or self.spellId ~= spellId or self.count ~= count or self.expirationTime ~= expirationTime then
  7.                 if self.index ~= value then
  8.                     print("INDEX", name, self.index, value)
  9.                 elseif self.spellId ~= spellId then
  10.                     print("ID", value, name, self.spellId, spellId)
  11.                 elseif self.count ~= count then
  12.                     print("COUNT", value, name, self.count, count)
  13.                 elseif self.expirationTime ~= expirationTime then
  14.                     print("EXP", value, name, self.expirationTime, expirationTime)
  15.                 end
  16.  
  17.                 if type(module.UpdateBuff) == "function" then
  18.                     module:UpdateBuff(self, value)
  19.                 end
  20.             end
  21.         else
  22.             self.index = nil
  23.             self.spellId = nil
  24.             self.count = nil
  25.             self.expirationTime = nil
  26.         end
  27.     end
  28. end)

With this method only the changed buffs are gonna get updated and it will leave out the ones which did not changed, so you can save a lot of unnecessary calls. You only need to do a full force update when you: on a loading screen, or when the unit attribute changes.

So what do you guys think could this be a valid solution?

Last edited by Resike : 02-16-16 at 05:25 AM.
  Reply With Quote
02-16-16, 03:12 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
What is triggering the index change?
Does this work if you refresh an aura?
Does this work if you refresh an aura and only have one aura active?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
02-16-16, 05:04 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
What is triggering the index change?
Does this work if you refresh an aura?
Does this work if you refresh an aura and only have one aura active?
Well you save the checked values in the UpdateBuff function, or you nil them when the buff fades/expires/not exists.

For some reason by default the aura header template updates every buffs on every attribute chanes unlike the group headers, and thats the real issue here. And the UNIT_AURA event doesn't give any valid information about which buffs you should update, so you are kinda forced to update everything there too.

It works on pretty much any buff changes/refresh because of the index/spellID/expirationTime checker.
Additional checkers can be added too, there are just the basic ones, like unitCaster and isCastByPlayer could be usefull too, if someone cast the same buff on you without expiration time, to the same index.

The good thing about this, it skips any unchanges or static buffs, that you did not changed or refreshed.

Last edited by Resike : 02-16-16 at 05:08 AM.
  Reply With Quote
02-16-16, 07:06 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
That is my point. When using the SecureAuraHeaderTemplate something is triggering an update on any aura attribute for you which makes is possible to have a script for OnAttributeChanged?
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
02-16-16, 07:27 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
That is my point. When using the SecureAuraHeaderTemplate something is triggering an update on any aura attribute for you which makes is possible to have a script for OnAttributeChanged?
I'll give you a more detailed code example.

The attribute is not on the header frame, but on the frame which gets created BY the header frame (SecureActionButtonTemplate), and it has a index and filter attribute changes every time the unit's buffs get updated:

Lua Code:
  1. -- Buffs Header
  2.     frame.buffs = CreateFrame("Frame", "ZPerl2"..name.."BuffFrame", frame, "SecureAuraHeaderTemplate")
  3.     frame.buffs:SetPoint("TopLeft", frame, "BottomLeft", 4, -1)
  4.  
  5.     frame.buffs:SetAttribute("useparent-unit", true)
  6.     frame.buffs:SetAttribute("filter", "HELPFUL")
  7.     frame.buffs:SetAttribute("template", "SecureActionButtonTemplate")
  8.     frame.buffs:SetAttribute("minWidth", 24)
  9.     frame.buffs:SetAttribute("minHeight", 24)
  10.     frame.buffs:SetAttribute("separateOwn", 0)
  11.  
  12.     frame.buffs:SetAttribute("point", "TOPLEFT")
  13.     frame.buffs:SetAttribute("xOffset", 24)
  14.     frame.buffs:SetAttribute("yOffset", 0)
  15.     frame.buffs:SetAttribute("wrapAfter", 8)
  16.     frame.buffs:SetAttribute("wrapXOffset", 0)
  17.     frame.buffs:SetAttribute("wrapYOffset", -24)
  18.     frame.buffs:SetAttribute("maxWraps", 5)
  19.  
  20.     frame.buffs:SetAttribute("sortMethod", "INDEX") -- INDEX or NAME or TIME
  21.     frame.buffs:SetAttribute("sortDir", "+") -- - to reverse
  22.  
  23.     frame.buffs:SetAttribute("style-width", 24)
  24.     frame.buffs:SetAttribute("style-height", 24)
  25.     frame.buffs:SetAttribute("style-scale", 1)
  26.  
  27.     local function CreateBuffFrame(header, frameName)
  28.         local buff = _G[frameName]
  29.  
  30.         buff:RegisterForClicks("RightButtonUp")
  31.         --buff.unit = header:GetParent():GetAttribute("unit") or frame.unit
  32.         --buff.filter = "HELPFUL"
  33.  
  34.         buff.texture = buff:CreateTexture(nil, "Background")
  35.         buff.texture:SetAllPoints(buff)
  36.  
  37.         buff.cooldown = CreateFrame("Cooldown", nil, buff, "CooldownFrameTemplate")
  38.         buff.cooldown:SetReverse(true)
  39.         buff.cooldown:SetDrawEdge(false)
  40.         buff.cooldown:SetDrawBling(false)
  41.         -- Blizzard
  42.         buff.cooldown:SetHideCountdownNumbers(true)
  43.         -- OmniCC
  44.         buff.cooldown.noCooldownCount = true
  45.  
  46.         buff.cooldown:SetAllPoints(buff)
  47.  
  48.         buff.stack = buff:CreateFontString(nil, "Artwork")
  49.         buff.stack:SetFont("Fonts\\ARIALN.TTF", 9, "Outline")
  50.         buff.stack:SetPoint("BottomRight", buff, "BottomRight", 0, 2)
  51.         buff.stack:SetJustifyH("Center")
  52.         buff.stack:SetJustifyV("Center")
  53.         buff.stack:SetWordWrap(false)
  54.  
  55.         buff:SetScript("OnAttributeChanged", function(self, name, value)
  56.             --print(self:GetName(), name, value)
  57.             if name == "index" then
  58.                 --print(self:GetName(), name, value)
  59.                 if value then
  60.                     local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, shouldConsolidate, spellId, canApplyAura, isBossDebuff, isCastByPlayer = UnitAura(header:GetParent():GetAttribute("unit"), header:GetAttribute("filter"))
  61.                     if self.index ~= value or self.spellId ~= spellId or self.count ~= count or self.expirationTime ~= expirationTime then
  62.                         --[[if self.index ~= value then
  63.                             print("INDEX", name, self.index, value)
  64.                         elseif self.spellId ~= spellId then
  65.                             print("ID", value, name, self.spellId, spellId)
  66.                         elseif self.count ~= count then
  67.                             print("COUNT", value, name, self.count, count)
  68.                         elseif self.expirationTime ~= expirationTime then
  69.                             print("EXP", value, name, self.expirationTime, expirationTime)
  70.                         end]]
  71.  
  72.                         if type(module.UpdateBuff) == "function" then
  73.                             module:UpdateBuff(self, value)
  74.                         end
  75.                     end
  76.                 else
  77.                     self.index = nil
  78.                     self.spellId = nil
  79.                     self.count = nil
  80.                     self.expirationTime = nil
  81.                 end
  82.             end
  83.         end)
  84.  
  85.         buff:SetScript("OnEnter", function(self)
  86.             GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT")
  87.             GameTooltip:SetFrameLevel(self:GetFrameLevel() + 2)
  88.             local s = self.slotID or 0
  89.             if s == 16 or s == 17 then
  90.                 GameTooltip:SetInventoryItem(header:GetParent():GetAttribute("unit"), s)
  91.             else
  92.                 GameTooltip:SetUnitAura(header:GetParent():GetAttribute("unit"), self:GetID(), header:GetAttribute("filter"))
  93.             end
  94.  
  95.             self:SetScript("OnUpdate", function(self, elapsed)
  96.                 self.time = (self.time or 0) + elapsed
  97.                 if self.time < 0.5 then
  98.                     return
  99.                 end
  100.                 self.time = 0
  101.  
  102.                 if GameTooltip:IsOwned(self) then
  103.                     local s = self.slotID or 0
  104.                     if s == 16 or s == 17 or s == 18 then
  105.                         GameTooltip:SetInventoryItem(header:GetParent():GetAttribute("unit"), s)
  106.                     else
  107.                         GameTooltip:SetUnitAura(header:GetParent():GetAttribute("unit"), self:GetID(), header:GetAttribute("filter"))
  108.                     end
  109.                 end
  110.             end)
  111.         end)
  112.         buff:SetScript("OnLeave", function(self)
  113.             self:SetScript("OnUpdate", nil)
  114.             GameTooltip:Hide()
  115.         end)
  116.  
  117.         return buff
  118.     end
  119.  
  120.     frame.buffs:SetAttribute("initialConfigFunction", [[
  121.         local header = self:GetParent()
  122.  
  123.         self:SetHeight(header:GetAttribute("style-height"))
  124.         self:SetWidth(header:GetAttribute("style-width"))
  125.         self:SetScale(header:GetAttribute("style-scale"))
  126.  
  127.         self:SetAttribute("type2", "cancelaura")
  128.  
  129.         self:SetAttribute("isHeaderDriven", true)
  130.  
  131.         header:CallMethod("initialConfigFunction", self:GetName())
  132.     ]])
  133.  
  134.     frame.buffs.initialConfigFunction = CreateBuffFrame
  135.  
  136.     frame.buffs:Show()

It looks kinky to create so many functions for every buffs, but even in a 5 man party we are talking about 400 unit and 400 potential pet buffs and god knows how many UNIT_AURA triggers. And for my initial test this method is better performace wise.

Maybe the thread's name is missleading. My bad.

Last edited by Resike : 02-16-16 at 07:42 AM.
  Reply With Quote
02-16-16, 09:36 AM   #6
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
No it is not misleading. I'm just trying to understand what is triggering attribute change. Gonna play around with it myself later.

I think I found what I was looking for:
https://github.com/tekkub/wow-ui-sou...aders.lua#L668

Using the template registers UNIT_AURA.

Have you read this post from sigg?
http://www.wowinterface.com/forums/s...ad.php?t=36117

Btw make sure you implement the cancelaura stuff only for player unit.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 02-16-16 at 09:50 AM.
  Reply With Quote
02-16-16, 05:36 PM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
No it is not misleading. I'm just trying to understand what is triggering attribute change. Gonna play around with it myself later.

I think I found what I was looking for:
https://github.com/tekkub/wow-ui-sou...aders.lua#L668

Using the template registers UNIT_AURA.

Have you read this post from sigg?
http://www.wowinterface.com/forums/s...ad.php?t=36117

Btw make sure you implement the cancelaura stuff only for player unit.
Hmm intresting. But thats pretty dumb that they don't use RegisterUnitEvent when registering.

I don't think cancelaura could cause any issue. And since you can remove buffs from your vehicle/pet it's better to leave it.
And i still can't decide yet, if i want to use secure aura headers or simple textures on the target and focus frames.
  Reply With Quote
02-17-16, 06:51 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
SecureAuraHeader is only useful if you want sorting. Otherwise SecureActionButton should be enough. But the ability to sort auras by own_auras_first is amazing. That is really damn helpful, on any unit. Just think of healers. I do not want to search for my heal over time in 40 auras?! This might make a lot of aura filtering obsolete aswell. One only had to use those because one could not find his own heal over time or debuff.

That being said. There is already a function for OnAttributeChanged. Maybe you can hook it for the desired affect. Currently you use SetScript. Which is bad. If possible always go for HookScript. (Well if the override is not intended of course)

Additionally I'm not sure if Blizzard is changing that part for Legion.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 02-17-16 at 07:07 AM.
  Reply With Quote
02-17-16, 07:36 AM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
SecureAuraHeader is only useful if you want sorting. Otherwise SecureActionButton should be enough. But the ability to sort auras by own_auras_first is amazing. That is really damn helpful, on any unit. Just think of healers. I do not want to search for my heal over time in 40 auras?! This might make a lot of aura filtering obsolete aswell. One only had to use those because one could not find his own heal over time or debuff.

That being said. There is already a function for OnAttributeChanged. Maybe you can hook it for the desired affect. Currently you use SetScript. Which is bad. If possible always go for HookScript. (Well if the override is not intended of course)

Additionally I'm not sure if Blizzard is changing that part for Legion.
The issue with secure stuff is that you won't be able to move/rearrange the buffs in combat like this:



HookScript is not usefull here, since than there would be another attribute funcition ticking in the background pointlessly.

I also have some issues with the temporary enchant frames, for some reason the header is showing 2 tempenchant buffs all the time, no matter if you only have 1 temporary weapon enchants.

Last edited by Resike : 02-17-16 at 07:39 AM.
  Reply With Quote
02-17-16, 11:21 AM   #10
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
Yeah I'm not even sure if tempenchants work properly.

Has 2 entries
https://github.com/tekkub/wow-ui-sou...aders.lua#L724
Loops over 3 entries
https://github.com/tekkub/wow-ui-sou...aders.lua#L795
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
02-17-16, 12:12 PM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
Yeah I'm not even sure if tempenchants work properly.

Has 2 entries
https://github.com/tekkub/wow-ui-sou...aders.lua#L724
Loops over 3 entries
https://github.com/tekkub/wow-ui-sou...aders.lua#L795
I found the problem here:

https://github.com/tekkub/wow-ui-sou...aders.lua#L793

They use the old GetWeaponEnchant() arguments, instead of the live one:

Lua Code:
  1. local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = GetWeaponEnchantInfo()

Somebody poke Blizzard about this, i want a working tempenchant frame.
  Reply With Quote
02-17-16, 12:32 PM   #12
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,739
Maybe you can PM alestane. I'm pretty sure he wrote that part. http://www.wowinterface.com/portal.php?id=353
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW) | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
02-17-16, 01:17 PM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by zork View Post
Maybe you can PM alestane. I'm pretty sure he wrote that part. http://www.wowinterface.com/portal.php?id=353
I made a herp-derp workaround like this:

Lua Code:
  1. local OldGetWeaponEnchantInfo = GetWeaponEnchantInfo
  2.  
  3. GetWeaponEnchantInfo = function(self)
  4.     local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = OldGetWeaponEnchantInfo()
  5.     return hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId
  6. end

And it fixes the issue, so i'm pretty sure that problem is what mentioned above:


However it breaks the functionality of the whole temp enchants frames.

Last edited by Resike : 02-17-16 at 03:27 PM.
  Reply With Quote
02-17-16, 02:40 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,868
It also breaks every other addon that deals with temporary enchants.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-17-16, 03:26 PM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by SDPhantom View Post
It also breaks every other addon that deals with temporary enchants.
Not if you upvalue in time. :P It was only to test the anchoring position of the header frame. Any it worked since it only pushed the buff frame by one only buff, with only 1 temp enchant applied.
  Reply With Quote
02-18-16, 05:24 AM   #16
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
If Blizzard actually used their own code in their own UI they might be more interested in making all the Secure* features work well and have enough functionality to implement a true alternative to Blizzard's UI. Sadly Blizzard just gets to cheat and never worry about whether their new features and UI designs work with secure frames and headers.

It took them more than a year to add ranged weapon enchants to the secure aura headers after they were added to the game. No-one at Blizzard even knew it was broken, because nobody there uses the code they wrote. And not many people reported it because nobody outside Blizzard uses secure aura frames either, due to the fact that it never supported filtering or sorting or anything a real aura addon would need.

And all this because a few druids in tree form were auto-cancelling their tree aura when a warlock tried to banish them. Hey, maybe now that treeform doesn't exist we can get aura cancelling unprotected and do away with the entire secure aura header system? Somehow I don't see it happening any time soon though. Unless Blizzard had to use their own code anyway, in which case it would have happened five years ago.
  Reply With Quote
02-18-16, 09:28 AM   #17
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by Barjack View Post
If Blizzard actually used their own code in their own UI they might be more interested in making all the Secure* features work well and have enough functionality to implement a true alternative to Blizzard's UI. Sadly Blizzard just gets to cheat and never worry about whether their new features and UI designs work with secure frames and headers.

It took them more than a year to add ranged weapon enchants to the secure aura headers after they were added to the game. No-one at Blizzard even knew it was broken, because nobody there uses the code they wrote. And not many people reported it because nobody outside Blizzard uses secure aura frames either, due to the fact that it never supported filtering or sorting or anything a real aura addon would need.

And all this because a few druids in tree form were auto-cancelling their tree aura when a warlock tried to banish them. Hey, maybe now that treeform doesn't exist we can get aura cancelling unprotected and do away with the entire secure aura header system? Somehow I don't see it happening any time soon though. Unless Blizzard had to use their own code anyway, in which case it would have happened five years ago.
I can't agree with you more. While i understand that secure frames are needed, since everyone remebers the uncontrolled and capable for anything macros from the Burning Crusade.
But the main issue is that if somebody wants to cheat they can do it so easily.
Either remove the lua restrictions (And i don't think anyone ever got banned for it.), or recently i reverse engineered an interrupt bot program, which was working with an ingame addon. The addon created a 1x1 pixel texture in the corner of you screen and listened cast releated events and colorded that pixel based on that information. And outside the game another program just checked the color of the pixel and initiated a keydown action directly from windows which was your interrupt keybind.

So my question is that is the secure stuff worth the protection it gives, because i highly don't think so.
If at least we could SetPoint in combat i would be so happy. And would solve 90% of the addon blocked issues.
  Reply With Quote
02-18-16, 09:39 AM   #18
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Back on my issue tho, yesterday i came up with a temporary solution to show the icon of your secodary weapon instead of the blank unclickable frame:

  Reply With Quote
02-18-16, 02:52 PM   #19
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,868
Originally Posted by Resike View Post
Originally Posted by SDPhantom View Post
Originally Posted by Resike View Post
However it breaks the functionality of the whole temp enchants frames.
It also breaks every other addon that deals with temporary enchants.
Not if you upvalue in time.
Relying on people to create local copies of API functions before you trash them isn't good enough reason to do so.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
02-18-16, 03:21 PM   #20
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
Originally Posted by SDPhantom View Post
Relying on people to create local copies of API functions before you trash them isn't good enough reason to do so.
It's not a real code, it was a local test function.
Why would i use a workaround on a buggy frame, which breaks the frame functionalities even more.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SecureAuraHeaderTemplate

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off