Thread Tools Display Modes
07-09-12, 10:09 AM   #1
vimat270
A Murloc Raider
Join Date: Mar 2011
Posts: 4
element castbar color

hi,

is there an easy way to classcolor the castbar?

just like colorClass = true for health and power bars.


cheers vimat
  Reply With Quote
07-09-12, 11:57 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Define that a bit more. Should all castbars be in classcolor of the player or should all castbars be in classcolor referencing the corresponding unit? What is if the unit has no class?

Either way there is no solution where you just add one attribute. So the answer is probably no.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

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

Last edited by zork : 07-09-12 at 11:59 AM.
  Reply With Quote
07-09-12, 01:32 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by vimat270 View Post
is there an easy way to classcolor the castbar?
As easy as "bar.colorClass = true"? No. Easy? Yes; feel free to borrow the code from oUF_Phanx. Specifically, you'll want to look at the code in the PostCastStart and PostChannelStart functions in Core.lua.
__________________
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
07-09-12, 04:31 PM   #4
vimat270
A Murloc Raider
Join Date: Mar 2011
Posts: 4
wow that was much easier than expected

Lua Code:
  1. ...
  2. func.PostCastStart = function(self, unit, name, rank, text)
  3.     local r , g , b = unpack(oUF.colors.class[select(2, UnitClass(unit))])
  4.     self:SetStatusBarColor(r, g, b)
  5. ...

nearly as short as colorClass = true...

thx 4 help

cheers vimat
  Reply With Quote
07-09-12, 05:50 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Don't forget PostChannelStart, or your bar won't be colored for channeled spells.

Also, if you're using that code on castbars for units like "target" or "focus" don't forget that the unit won't always be a player, so you should include some kind of fallback color for non-player units. In oUF_Phanx, I fall back to reaction colors (red for enemy, green for friendly, yellow for neutral) if the unit isn't a player.
__________________
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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » element castbar color


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