Quantcast
What's the proper way to update color of last class power bar? - WoWInterface
 
Thread Tools Display Modes
01-13-21, 01:49 AM   #1
devilArt
A Wyrmkin Dreamwalker
 
devilArt's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 51
What's the proper way to update color of last class power bar?

This is my PostUpdate code for classpower

lua Code:
  1. local function PostUpdateClassPower(element, cur, max, hasMaxChanged, powerType)
  2.     local style = element.__owner.unitStyle
  3.     local gap = 3
  4.     local maxWidth
  5.  
  6.     if style == 'player' then
  7.         maxWidth = C.DB.unitframe.player_width
  8.     else
  9.         maxWidth = C.DB.nameplate.pp_width
  10.     end
  11.  
  12.     if hasMaxChanged then
  13.         for i = 1, max do
  14.             element[i]:SetWidth((maxWidth - (max - 1) * gap) / max)
  15.         end
  16.  
  17.         element[max]:SetStatusBarColor(unpack(lastBarColors[C.MyClass]))
  18.     end
  19. end

When I log into the game for the first time


After /reload it returns to normal


Dose anyone konw the reason?
  Reply With Quote
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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » What's the proper way to update color of last class power bar?

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