Thread Tools Display Modes
08-22-12, 04:12 PM   #1
grimgaw
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
Auras.gap bugging out?

When gap is enabled I get overlay/background still displaying on that invisible icon.
Here's relevant part of code i'm working with:
Code:
local function PostCreateIcon(f, button)
	f.disableCooldown = true
	
	button.icon:SetTexCoord(.1, .9, .1, .9)
	
	button.time = createFS(button, 14, 'OUTLINE')
	button.time:SetPoint("BOTTOM", button, 2, -6)
	button.time:SetJustifyH('CENTER')
	
	button.count = createFS(button, 15, 'OUTLINE')
	button.count:ClearAllPoints()
	button.count:SetPoint("TOPRIGHT", button, 4, 4)
	button.count:SetJustifyH('RIGHT')
	
	button.overlay:SetTexture(NORMAL)
	button.overlay:SetTexCoord(0,1,0,1)
	button.overlay:SetPoint("TOPLEFT", -2, 2)
	button.overlay:SetPoint("BOTTOMRIGHT", 2, -2)
	button.overlay:SetVertexColor(0.37, 0.3, 0.3)
	button.overlay:Show()
	button.overlay.Hide = function() end
	
	createShadow(button, 7)
end
local function PostUpdateIcon(f, unit, icon, index, offset)
	local _, _, _, _, _, duration, expirationTime, caster = UnitAura(unit, index, icon.filter)
	
	if duration and duration > 0 then
		icon.time:Show()
		icon.timeLeft = expirationTime
		icon:SetScript("OnUpdate", createBuffTimer)	
	else
		icon.time:Hide()
		icon.timeLeft = math.huge
		icon:SetScript("OnUpdate", nil)
	end

	if icon.isDebuff and unit == 'target' then
		if playerUnits[caster] then
			icon.icon:SetDesaturated(false)
		else
			icon.icon:SetDesaturated(true)
		end
	end
	icon:SetScript('OnMouseUp', function(self, mouseButton)
		if mouseButton == 'RightButton' then
			CancelUnitBuff('player', index)
		end
	end)
	
	icon.first = true
end
And a screenie of the problem:

I'm still an lua newbie, so please explain accordingly.
  Reply With Quote
08-22-12, 05:03 PM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
This looks pretty much like oUF_Caellian code with the exception of
Code:
	button.overlay.Hide = function() end
	
	createShadow(button, 7)
From oUF's aura element:
lua Code:
  1. local hasGap
  2.         if(visibleBuffs ~= 0 and auras.gap) then
  3.             hasGap = true
  4.             visibleBuffs = visibleBuffs + 1
  5.  
  6.             local icon = auras[visibleBuffs] or (auras.CreateIcon or createAuraIcon) (auras, visibleBuffs)
  7.  
  8.             -- Prevent the icon from displaying anything.
  9.             if(icon.cd) then icon.cd:Hide() end
  10.             icon:EnableMouse(false)
  11.             icon.icon:SetTexture()
  12.             icon.overlay:Hide()
  13.             icon.stealable:Hide()
  14.             icon.count:SetText()
  15.             icon:Show()

So just remove "button.overlay.Hide = function() end" from your code. The "button.overlay:Show()" part is also not needed, oUF takes care of this.

Also:
lua Code:
  1. icon:SetScript('OnMouseUp', function(self, mouseButton)
  2.     if mouseButton == 'RightButton' then
  3.         CancelUnitBuff('player', index)
  4.     end
  5. end)
won't function in combat, leading to an error message and the option to either disable oUF or ignore the error. This is because oUF does not implement the secure aura header.
  Reply With Quote
08-22-12, 05:34 PM   #3
grimgaw
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
Removing
Code:
button.overlay.Hide = function() end
makes my borders disappear.
Code:
createShadow
is just a backdrop function, removing it and function above leaves me with just plain icons. I guess that solves the problem however I'd really like to have the icons with borders and shadow.
  Reply With Quote
08-22-12, 05:45 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Post the contents of your createShadow function. I add custom borders to aura icons in my oUF layout and have never seen a problem like the one you're seeing. I'd guess you're not actually parenting the custom textures to the aura icon frame; otherwise they'd get hidden along with the icon.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-22-12, 06:20 PM   #5
grimgaw
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
Code:
local function createBackrop(f, inset)
	f:SetBackdrop({
		bgFile = BG,
		edgeFile = OUTERSHADOW,
		tile = false,
		tileSize = 0,
		edgeSize = 7,
		insets = {
			left = inset,
			right = inset,
			top = inset,
			bottom = inset
		}
	})
	f:SetBackdropColor(0,0,0,.8)
	f:SetBackdropBorderColor(0,0,0,.8)
end

local function createShadow(f, offset)
	local s = CreateFrame("Frame", nil, f)
	s:SetFrameLevel(0)
	s:SetPoint("TOPLEFT", -(offset), offset)
	s:SetPoint("BOTTOMRIGHT", offset, -(offset))
	createBackrop(s, 7)
end
I can work around shadows and make them hide with PostUpdateGapIcon but the button.overlay keeps displaying on 'gap button'.
  Reply With Quote
08-22-12, 07:08 PM   #6
grimgaw
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
After much tinkering, I 'think' I found the problem in oUF's aura element:
Code:
-- Prevent the icon from displaying anything.
if(icon.cd) then icon.cd:Hide() end
icon:EnableMouse(false)
icon.icon:SetTexture()
icon.overlay:Hide()
icon.stealable:Hide()
icon.count:SetText()
icon:Show() --This line should be icon:Hide()
Edit: That is the latest version from GitHub

Last edited by grimgaw : 08-22-12 at 07:11 PM.
  Reply With Quote
08-22-12, 10:11 PM   #7
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
That :Show() is very much intended. In 1.6.x, oUF creates a hidden icon for the gap.

You need to make your overlay.Hide handle showing and hiding of your custom border.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-23-12, 03:15 AM   #8
grimgaw
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 5
Oh, I see. For now changing it to Hide fixes all my problems,
however as I understand it's used for custom filters,
and those would break with it on Hide. Could anyone more experienced,
give me a hint where to go from my code to implement what Haste said?
  Reply With Quote
08-24-12, 09:52 AM   #9
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
oUF creates a button widget for every buff/debuff so that it can accept mouse clicks (which is currently broken because of lack of SecureAuraHeader support). This button is basically a lua table and oUF adds some fields to it as:
icon (which holds the aura texture)
overlay (which is the aura border that most of us use to color based on aura type)
cd (holding the cooldown spiral)
count (holding a font object to represent the number of applications)
stealable (a texture to inform whether the aura is stealable or purgeable)

In order to make a gap aura, oUF does not hide the button but rather sets the icon texture to nil and hides all the other fields (overlay, cd, count and stealable).

You create a shadow effect around the button by parenting another frame to the button and setting a backdrop to that frame. In WoW the visibility of something depends on the visibility of its parent, so that if a parent is hidden, so are its children. But oUF does not hide the button itself, so your childframe and its backdrop remain visible too.

To work around this, you could create your backdrop based on the return of button.icon:GetTexture(). If this returns nil, then it is the gap aura and you don't create the backdrop. With your current code, you have to do this from within your createShadow function.
lua Code:
  1. if not f.icon:GetTexture() then return end

You don't have to create another frame just for the shadow effect. You could apply your backdrop to the aura button, because it is a frame itself.

Take a look at https://github.com/haste/oUF/blob/ma...s/aura.lua#L83
  Reply With Quote
08-24-12, 06:57 PM   #10
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Rainrider View Post
oUF creates a button widget for every buff/debuff so that it can accept mouse clicks (which is currently broken because of lack of SecureAuraHeader support).
1) Mouse support is also required for tooltips on mouseover.

2) SecureAuraHeader is pathetically limited, with very limited sorting features and no useful filtering features. There is no way to support it in oUF (or any other addon) without losing all filtering features and most sorting features. Also, you can't show buffs and debuffs with a single SecureAuraHeader, so the entire Auras element would have to go, and you'd only be able to use the separate Buffs and Debuffs element.

Originally Posted by Rainrider View Post
To work around this, you could create your backdrop based on the return of button.icon:GetTexture(). If this returns nil, then it is the gap aura and you don't create the backdrop. With your current code, you have to do this from within your createShadow function.
lua Code:
  1. if not f.icon:GetTexture() then return end
The bolded, italicized portion of what you posted is wrong. If you do it that way, then any button which is first displayed without an icon will not get a shadow, ever. For example, if you get a debuff, Icon #1 will show the debuff icon and get a shadow. If you get another debuff, Icon #2 will show the second debuff and get a shadow. If you then get a buff, Icon #3 will be an invisible spacer, and will not get a shadow; Icon #4 will show the buff and get a shadow. Then the first debuff expires, so Icon #1 is now the second debuff with a shadow, #2 is now the spacer but still has a shadow, and #3 is now the buff but does not have a shadow.

Instead, you need to dynamically hide or show your shadow. A simple way to do that would be to hook the icon texture's SetTexture method:

Code:
hooksecurefunc(icon.icon, "SetTexture", function(self, texture)
    if texture and strlen(texture) > 0 then
        shadow:Show()
    else
        shadow:Hide()
    end
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-25-12, 04:48 AM   #11
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
I just emphasized on the lack of SecureAuraHeader support because grimgaw had code calling CancelUnitBuff, which is now protected. You are right about the limitations of the SecureAuraHeader.

Thank you for the corrections, I didn't realize it works like that. So oUF reuses already created buttons for new auras, right?
  Reply With Quote
08-25-12, 05:08 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
CancelUnitBuff is only protected while in combat. Out of combat, you can cancel buffs as insecurely as you want. The only caveat is that shapeshift forms cannot be cancelled insecurely, and will silently fail (ie. no error message).

To your other question, yes; buttons get reused. If you have 2 buffs when your layout loads, oUF creates 2 buttons. If you gain 1 more buff, oUF creates a third button. If you lose 2 buffs, there are still 3 buttons, but 2 of them are hidden. If you then gain 1 buff, you still have created only 3 buttons; 2 of them are visible, and 1 of them is hidden. Creating a new button every time you gained an aura would be an incredibly huge waste of memory, as there is no way to unload or destroy frame objects.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 08-25-12 at 05:11 AM.
  Reply With Quote
08-25-12, 04:35 PM   #13
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
http://www.wowhead.com/item=19250 my apologies to grimgaw for the wrong tips. Thanks a lot Phanx for the clarification and for correcting me.
  Reply With Quote
08-27-12, 03:58 AM   #14
Paopao001
A Fallenroot Satyr
 
Paopao001's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 20
I met this problem, too. And I solved it this way.
In my layout, the aura icon got two more things on it, a shadow border and a timer. I prevent the gap icon from showing this two things by PostUpdateGapIcon. However, I need to force the border showing in PostUpdateIcon, or it might kill other real aura icons' borders.

Code related to create the two more things and hide them in gap.
Lua Code:
  1. --=============================================--
  2. --[[                   Auras                 ]]--
  3. --=============================================--
  4. local PostCreateIcon = function(auras, icon)
  5.     icon.icon:SetTexCoord(.07, .93, .07, .93)
  6.  
  7.     icon.count:ClearAllPoints()
  8.     icon.count:SetPoint('BOTTOMRIGHT', 3, -3)
  9.     icon.count:SetFontObject(nil)
  10.     icon.count:SetFont(cfg.font, 9, cfg.fontflag)
  11.     icon.count:SetTextColor(.9, .9, .1)
  12.  
  13. icon.overlay:SetTexture(cfg.texture)
  14. icon.overlay:SetDrawLayer('BACKGROUND')
  15.     icon.overlay:SetPoint('TOPLEFT', icon, 'TOPLEFT', -1, 1)
  16.     icon.overlay:SetPoint('BOTTOMRIGHT', icon, 'BOTTOMRIGHT', 1, -1)
  17.  
  18. icon.bd = createBackdrop(icon, icon, 0)
  19.  
  20. icon.remaining = createFont(icon, 'OVERLAY', cfg.font, 9, 'OUTLINE', 1, 1, 1)
  21.     icon.remaining:SetPoint('TOPLEFT', -3, 2)
  22.  
  23.     if cfg.auraborders then
  24.         auras.showDebuffType = true
  25. end
  26. end
  27.  
  28. local CreateAuraTimer = function(self, elapsed)
  29.     self.elapsed = (self.elapsed or 0) + elapsed
  30.  
  31.     if self.elapsed < .2 then return end
  32.     self.elapsed = 0
  33.  
  34.     local timeLeft = self.expires - GetTime()
  35.     if timeLeft <= 0 then
  36.         self.remaining:SetText(nil)
  37.     else
  38.         self.remaining:SetText(FormatTime(timeLeft))
  39.     end
  40. end
  41.  
  42. local PostUpdateIcon = function(icons, unit, icon, index, offset)
  43. local name, _, _, _, _, duration, expirationTime = UnitAura(unit, index, icon.filter)
  44.  
  45. if icon.isPlayer or UnitIsFriend('player', unit) or not icon.isDebuff then
  46. icon.icon:SetDesaturated(false)
  47. if duration and duration > 0 then
  48. icon.remaining:Show()
  49. else
  50. icon.remaining:Hide()
  51. end
  52. else
  53. icon.icon:SetDesaturated(true) -- grey other's debuff casted on enemy.
  54. icon.overlay:Hide()
  55. icon.remaining:Hide()
  56. icon.count:Hide()
  57. end
  58.  
  59. if duration then
  60. icon.bd:Show() -- if the aura is not a gap icon show it's bd
  61. end
  62.  
  63. icon.expires = expirationTime
  64. icon:SetScript('OnUpdate', CreateAuraTimer)
  65. end
  66.  
  67. local PostUpdateGapIcon = function(auras, unit, icon, visibleBuffs)
  68. icon.bd:Hide()
  69. icon.remaining:Hide()
  70. end
__________________

I hope you could understand my broken English.
If I offended you it was unwitting.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Auras.gap bugging out?


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