Skip to content

Commit 0f13c1d

Browse files
Krathe82mergetest
authored andcommitted
Bars: write class/custom health colour to the texture vertex directly
ApplyHealthColors used two different channels per mode: PERCENT paints the status bar texture's vertex colour directly (gradient curve), while CLASS/CUSTOM went through StatusBar:SetStatusBarColor. The StatusBar caches its colour, so after a PERCENT render stained the texture, switching to CLASS could call SetStatusBarColor with values equal to the cached colour and no-op - leaving the last gradient colour (green at full health) visible on every frame until reload. Reports: "class coloured healthbars stuck green", profile data verified healthy (healthColorMode=CLASS, correct classColors) via decoded export. Write the same rgb through tex:SetVertexColor as well, matching the channel UpdateHealthBarAppearance (ElementAppearance) already uses for every mode, so the two colour appliers can no longer disagree and the visible state is guaranteed regardless of the StatusBar's cache. Dead-fade is unaffected: it rides alpha (fadeDeadHealthBar), and the alpha guard is preserved.
1 parent a83594d commit 0f13c1d

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# DandersFrames Changelog
22

3+
## [4.7.3]
4+
5+
### Bug Fixes
6+
7+
* (Bars) Fixed class-coloured health bars staying stuck on the gradient colour (usually green) after using or switching away from the Percent colour mode — the class/custom colour is now written directly to the bar texture, so it can no longer be masked by a leftover gradient tint. (by Krathe)
8+
39
## [4.7.2]
410

511
### Bug Fixes

Frames/Colors.lua

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,31 @@ function DF:ApplyHealthColors(frame)
287287
end
288288
end
289289
frame.healthBar:SetStatusBarColor(r, g, b)
290-
-- Apply alpha separately so range/dead fade can control it
291-
if not deadFadeActive then
292-
local tex = frame.healthBar:GetStatusBarTexture()
293-
if tex then tex:SetAlpha(classColorAlpha) end
290+
local tex = frame.healthBar:GetStatusBarTexture()
291+
if tex then
292+
-- ALSO write the colour to the texture's vertex directly (the same
293+
-- channel PERCENT mode and ElementAppearance use). Without this,
294+
-- switching from Percent to Class can leave the last gradient
295+
-- colour visible: PERCENT painted the texture directly, so the
296+
-- StatusBar's own cached colour may already equal the class colour
297+
-- and SetStatusBarColor above no-ops, leaving the gradient stain
298+
-- (typically green at full health) until /reload. Writing the same
299+
-- rgb through the vertex guarantees the visible state either way,
300+
-- and matches UpdateHealthBarAppearance's channel so the two
301+
-- appliers can't fight.
302+
tex:SetVertexColor(r, g, b)
303+
-- Apply alpha separately so range/dead fade can control it
304+
if not deadFadeActive then
305+
tex:SetAlpha(classColorAlpha)
306+
end
294307
end
295308
else
296309
-- Custom color mode - use RGBA
297310
local c = db.healthColor
298311
frame.healthBar:SetStatusBarColor(c.r, c.g, c.b, c.a or 1)
312+
-- Same direct vertex write as the CLASS branch above (gradient-stain fix).
313+
local tex = frame.healthBar:GetStatusBarTexture()
314+
if tex then tex:SetVertexColor(c.r, c.g, c.b) end
299315
end
300316

301317
-- Skip background color if dead fade with custom color is active

0 commit comments

Comments
 (0)