Reply
Thread Tools Display Modes
Unread 02-08-13, 07:05 AM   #1
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Coloring auras by their buff/debuff type

Good morrow,

I wanted to inquire about coloring the borders of my buffs and debuffs by their color type. I am aware that enabling showType, showBuffType, or showDebuffType will overlay the appropriate aura with a texture, colored by said aura's type, but is there any way to simply color the 1px by 1px border that already surrounds the aura?

Thank you very much.
Clamsoda is offline   Reply With Quote
Unread 02-08-13, 07:41 AM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
Just add a PostCreateIcon function to your layout's Auras/Buffs/Debuffs element that modifies the button.overlay texture object's texture, points, texCoords, etc.

I'm not sure what "1px by 1px border" you're talking about, as oUF doesn't add any such texture to aura buttons. If your layout does, it's probably already using a PostCreateIcon function, in which case you should just get rid of the border texture object, and apply those properties to the button's overlay object instead.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-08-13, 08:09 AM   #3
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Thanks for the reply as usual Phanx;

The oUF layout is my own, and I've not created ANY border for the auras, they inherently have a 1px by 1px border around them. As a reference, here is the code I use to produce my buffs and debuffs.

Lua Code:
  1. lib.generate_Buffs = function(f)
  2.     b = CreateFrame("Frame", nil, f)
  3.     b.size = 19
  4.     b.num = 40
  5.     b.spacing = 1
  6.     b.onlyShowPlayer = false
  7.     b:SetHeight((b.size+b.spacing)*4)
  8.     b:SetWidth(f.width / 2)
  9.     b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 1)
  10.     b.initialAnchor = "BOTTOMLEFT"
  11.     b["growth-x"] = "RIGHT"
  12.     b["growth-y"] = "UP"
  13.     b.showType = true
  14.        
  15.     f.Buffs = b
  16. end

There are no hooks or callbacks, so the border is definitely inherent; that being said, I want to set the vertex color of said border, but I am not sure how to reference it.
Clamsoda is offline   Reply With Quote
Unread 02-08-13, 09:42 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,391
Do you define "local b" anywhere? If not please make sure your variables stay local unless they should be applied to the global scope.

I know that because it is my bug.
http://code.google.com/p/rothui/sour...e/core.lua#334
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
zork is offline   Reply With Quote
Unread 02-08-13, 09:59 AM   #5
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Good call Zork ;]
Clamsoda is offline   Reply With Quote
Unread 02-08-13, 09:13 PM   #6
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
I assume you mean just the border of the stock icons (the thing we always want to remove with SetTexCoord(0.1, 0.9, 0.1, 0.9)). If so then there is no way to color just that part of the texture.

@Phanx
oUF does add a border texture to the aura buttons unless the layout provides its own auras.CreateIcon function.

Last edited by Rainrider : 02-08-13 at 09:18 PM.
Rainrider is offline   Reply With Quote
Unread 02-08-13, 11:22 PM   #7
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
Originally Posted by Rainrider View Post
oUF does add a border texture to the aura buttons unless the layout provides its own auras.CreateIcon function.
I'm looking at elements\aura.lua right now, and I see the following objects being created on each aura button:

* cd (cooldown),
* icon (texture),
* count (fontstring),
* overlay (texture), and
* stealable (texture).

None of these appear to be a border. The "overlay" texture is what gets colored by debuff type. Based on the OP's description it is a highlight that covers the whole icon, so if s/he wants it to be a border instead of a highlight, that should be done by changing the texture file and coords, eg:

Code:
self.Buffs.PostCreateIcon = function(element, button)
    button.overlay:SetTexture("Interface\\AddOns\\oUF_MyLayout\\BorderTexture")
    button.overlay:SetTexCoord(0, 1, 0, 1)
end
Maybe you're thinking of the "border" that's built into most of Blizzard's actual icon textures? That is part of the icon texture, and cannot be colored separately from the whole icon. You can get rid of it by "clipping" the texture:

Code:
self.Buffs.PostCreateIcon = function(element, button)
    button.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
end
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-09-13, 12:41 AM   #8
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
You are absolutely correct Phanx, it is the Clean Icons: Thin border. As usual I feel as stupid as is possible.

Your posted code will work perfectly, thank you very much. Sorry about the confusion.
Clamsoda is offline   Reply With Quote
Unread 02-09-13, 10:47 PM   #9
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
Originally Posted by Phanx View Post
I'm looking at elements\aura.lua right now, and I see the following objects being created on each aura button:

* cd (cooldown),
* icon (texture),
* count (fontstring),
* overlay (texture), and
* stealable (texture).

None of these appear to be a border. The "overlay" texture is what gets colored by debuff type. Based on the OP's description it is a highlight that covers the whole icon, so if s/he wants it to be a border instead of a highlight, that should be done by changing the texture file and coords, eg:
You are of course perfectly right. But Interface\\Buttons\\UI-Debuff-Overlays is just what the user sees as a border and that's what I meant.
Rainrider is offline   Reply With Quote
Unread 02-10-13, 04:16 AM   #10
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Is there anyway I can draw the overlay texture above the cooldown model? Currently, the cooldown spiral is drawn above the overlay texture, and makes color recognition difficult.

I have tried changing the Strata(just as a test), and the DrawLayer of the overlay texture and have had no luck.

Thank you everyone for the help thus far!
Clamsoda is offline   Reply With Quote
Unread 02-10-13, 08:59 AM   #11
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
Just anchor the overlay texture so that it expands beyond the edges of the icon.

Code:
self.Buffs.PostCreateIcon = function(element, button)
    button.overlay:ClearAllPoints()
    button.overlay:SetPoint("TOPLEFT", -2, 2)
    button.overlay:SetPoint("BOTTOMRIGHT", 2, -2)
end
Experiment with the values depending on your texture for the overlay. It the texture you use for the overlay is not transparent and covers the icon you could use button.overlay:SetDrawLayer("BORDER").
Rainrider is offline   Reply With Quote
Unread 02-10-13, 09:24 AM   #12
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Thank you for the input Rainrider, but at the moment, it would be a lot more desirable for me to draw the overlay texture above the cooldown model. Have you got any input as to how I may achieve that?
Clamsoda is offline   Reply With Quote
Unread 02-10-13, 09:01 PM   #13
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
The cooldown model is a frame, not a texture, so it sits above the button frame and all the button frame's textures. If you want a texture to be above the cooldown frame, it needs to either be parented to the cooldown frame, or parented to some other frame that's above the cooldown frame.

Most addons solve this problem by parenting the textures to the cooldown frame when it's shown, and then parenting them back to the button frame when the cooldown is hidden.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-12-13, 11:13 AM   #14
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
I experimented with parenting the overlay texture to the CD model if shown, and I found mild success. It works perfect for any aura with a numeric duration, but the overlay texture ceases to show up for auras with unlimited duration (mounts, traditional auras etc.).

My current code is:

Code:
	lib.PostCreateIcon = function(self, button)
		button.overlay:SetTexture("Interface\\AddOns\\oUF_Clamsoda\\media\\aura2")
		button.overlay:SetTexCoord(0, 1, 0, 1)
		button.overlay:ClearAllPoints()
		button.overlay:SetPoint("TOPLEFT", -1, 1)
		button.overlay:SetPoint("BOTTOMRIGHT", 1, -1)
		
		if button.cd:IsVisible() then 
			button.overlay:SetParent(button.cd)
		end
	end
I had an else statement to make sure the aura was anchored to the icon, but that seemed unnecessary considering that is the case my default.

I also opted for IsVisible() because the cooldown frame is anchored to the button, and will respond to IsShown() with respect to the parent, which would always return true.

Also, occasionally the cooldown doesn't update for some auras. For example, I could target someone, and their 1 hour kings buff would have 30 minutes left, but there is no timer, and the cooldown spiral is at full duration. Is this an issue on my side, or with oUF?

Thanks tons.
Clamsoda is offline   Reply With Quote
Unread 02-12-13, 03:52 PM   #15
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
PostCreateIcon only runs once, when the button is created. At that point, all of the button's child frames, textures, and font strings have been created, but nothing has been hidden, colored, or otherwise configured for a specific buff or debuff. Your code will always parent the texture to the cooldown frame, which is why it fails for auras without durations.

Instead, you should remove the red part from your PostCreateIcon function, and add a PostUpdateIcon function; this will run every time the button is updated for a specific buff or debuff.

Code:
		if button.cd:IsShown() then
			button.overlay:SetParent(button.cd)
		else
			button.overlay:SetParent(button)
		end
Without seeing the rest of your code, I couldn't tell you whether your cooldown updating problem is coming from your layout or not, but I've never seen it happen in my own layout, so I'd suspect an issue somewhere in your code.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-13-13, 01:04 PM   #16
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Thanks for the help and explanations thus far Phanx.

Currently your suggested implementation isn't working, and is yielding some strange results. Unit frames display no auras, and are colored completely white. Here is my implementation:

Lua Code:
  1. lib.PostCreateIcon = function(self, button)
  2.         button.overlay:SetTexture("Interface\\AddOns\\oUF_Clamsoda\\media\\aura2")
  3.         button.overlay:SetTexCoord(0, 1, 0, 1)
  4.         button.overlay:ClearAllPoints()
  5.         button.overlay:SetPoint("TOPLEFT", -1, 1)
  6.         button.overlay:SetPoint("BOTTOMRIGHT", 1, -1)
  7.     end
  8.    
  9.     lib.PostUpdateIcon = function(self, button)
  10.         if button.cd:IsShown() then
  11.             button.overlay:SetParent(button.cd)
  12.         else
  13.             button.overlay:SetParent(button)
  14.         end
  15.     end
  16.    
  17.     lib.generate_Buffs = function(f)
  18.         local b = CreateFrame("Frame", nil, f)
  19.         b.size = 19
  20.         b.num = 40
  21.         b.spacing = 1
  22.         b.onlyShowPlayer = false
  23.         b:SetHeight((b.size+b.spacing)*4)
  24.         b:SetWidth(f.width / 2)
  25.         b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 1)
  26.         b.initialAnchor = "BOTTOMLEFT"
  27.         b["growth-x"] = "RIGHT"
  28.         b["growth-y"] = "UP"
  29.         b.showBuffType = true
  30.        
  31.         b.PostCreateIcon = lib.PostCreateIcon
  32.         b.PostUpdateIcon = lib.PostUpdateIcon
  33.        
  34.         f.Buffs = b
  35.     end

By removing the call to the PostUpdateIcon function, frames return to normal. I can't figure out what I am doing wrong >.<

EDIT: Figured it out. I missed an argument before button, and was calling the wrong variable. Got it now, thanks tons for the input!

Last edited by Clamsoda : 02-13-13 at 01:15 PM.
Clamsoda is offline   Reply With Quote
Unread 02-13-13, 09:51 PM   #17
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
Also, whenever you are doing anything with addon code, make sure you have something showing you Lua errors in-game. The problem you described was absolutely raising a Lua error. At the very least, turn on "Display Lua errors" under Interface Options > Help, though I strongly recommend using BugSack, as the default error display cannot show you errors that are raised during the initial loading process, and BugSack has other advantages as well.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 02-15-13, 09:48 AM   #18
Clamsoda
A Cobalt Mageweaver
Join Date: Nov 2011
Posts: 248
Originally Posted by Phanx View Post
Also, whenever you are doing anything with addon code, make sure you have something showing you Lua errors in-game. The problem you described was absolutely raising a Lua error. At the very least, turn on "Display Lua errors" under Interface Options > Help, though I strongly recommend using BugSack, as the default error display cannot show you errors that are raised during the initial loading process, and BugSack has other advantages as well.
Well, I did have "Display LUA Errors" enabled, and I can confirm that it was enabled at that time, because I had a minor syntax error when I implemented your solution, and it was displayed (extra slash somewhere). I never once got an error for using the wrong argument, just the malformed frames. That being said, perhaps BugSack would have picked it up. I'll grab it. Thanks much!
Clamsoda is offline   Reply With Quote
Reply

Go BackWoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Coloring auras by their buff/debuff type

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