View Single Post
01-16-21, 07:38 AM   #2
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
I'm currently re-writing my layout / UI, but on my old layout, I did this:

https://github.com/greven/oUF_Lumen/...tions.lua#L659

Lua Code:
  1. -- Colorize the last power color element
  2. local function SetMaxClassPowerColor(element, max, powerType)
  3.     if not element or not max then return end
  4.  
  5.     local color = element.__owner.colors.power.max[powerType]
  6.  
  7.     if element[max] and color then
  8.         local r, g, b = color[1], color[2], color[3]
  9.  
  10.         local LastBar = element[max]
  11.         LastBar:SetStatusBarColor(r, g, b)
  12.  
  13.         local bg = LastBar.bg
  14.         if (bg) then
  15.             local mu = bg.multiplier or 1
  16.             bg:SetColorTexture(r * mu, g * mu, b * mu)
  17.         end
  18.     end
  19. end
  20.  
  21. -- Post Update ClassPower
  22. local function PostUpdateClassPower(element, cur, max, diff, powerType)
  23.     local frame = element.__owner.mystyle
  24.  
  25.     if (diff) then
  26.         local maxWidth, gap = cfg.units[frame].width, 6
  27.  
  28.         for i = 1, max do
  29.             local Bar = element[i]
  30.             Bar:SetWidth(((maxWidth / max) - (((max - 1) * gap) / max)))
  31.  
  32.             if (i > 1) then
  33.                 Bar:ClearAllPoints()
  34.                 Bar:SetPoint("LEFT", element[i - 1], "RIGHT", gap, 0)
  35.             end
  36.         end
  37.     end
  38.  
  39.     SetMaxClassPowerColor(element, max, powerType)
  40. end
__________________
My oUF Layout: oUF Lumen
  Reply With Quote