Quantcast WoWInterface - View Single Post - Set PowerBarColor without taint?
View Single Post
08-08-16, 05:04 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You will most likely have to use secure hooks. For an example, here is the function I use in !ClassColors to apply custom class colors to the health bars of the default raid frames:

lua Code:
  1. hooksecurefunc("CompactUnitFrame_UpdateHealthColor", function(frame)
  2.     if frame.optionTable.useClassColors and UnitIsConnected(frame.unit) then
  3.         local _, class = UnitClass(frame.unit)
  4.         if class then
  5.             local color = CUSTOM_CLASS_COLORS[class]
  6.             if color then
  7.                 frame.healthBar:SetStatusBarColor(color.r, color.g, color.b)
  8.             end
  9.         end
  10.     end
  11. end)

You'll need to change the function, object, and table names, but otherwise it should be pretty similar. You can't modify the original table at all, so you'll need to add a bunch more hooks to apply your custom colors to power bars in other parts of the UI as well.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, 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!
  Reply With Quote