Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,17 @@ DF.PartyDefaults = {
backgroundTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",
missingHealthClassAlpha = 0.8,
missingHealthColor = {r = 0.5, g = 0, b = 0, a = 0.8},
missingHealthColorHigh = {r = 0.05098039656877518, g = 1, b = 0, a = 1},
missingHealthColorHighUseClass = false,
missingHealthColorHighWeight = 1,
missingHealthColorLow = {r = 1, g = 0, b = 0, a = 1},
missingHealthColorLowUseClass = false,
missingHealthColorLowWeight = 2,
missingHealthColorMedium = {r = 1, g = 1, b = 0, a = 1},
missingHealthColorMediumUseClass = false,
missingHealthColorMediumWeight = 2,
missingHealthColorMode = "CUSTOM",
missingHealthGradientAlpha = 0.8,
missingHealthTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",

-- Border
Expand Down Expand Up @@ -1863,7 +1873,17 @@ DF.RaidDefaults = {
backgroundTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",
missingHealthClassAlpha = 0.8,
missingHealthColor = {r = 0.5, g = 0, b = 0, a = 0.8},
missingHealthColorHigh = {r = 0.05098039656877518, g = 1, b = 0, a = 1},
missingHealthColorHighUseClass = false,
missingHealthColorHighWeight = 1,
missingHealthColorLow = {r = 1, g = 0, b = 0, a = 1},
missingHealthColorLowUseClass = false,
missingHealthColorLowWeight = 2,
missingHealthColorMedium = {r = 1, g = 1, b = 0, a = 1},
missingHealthColorMediumUseClass = false,
missingHealthColorMediumWeight = 2,
missingHealthColorMode = "CUSTOM",
missingHealthGradientAlpha = 0.8,
missingHealthTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",

-- Border
Expand Down
10 changes: 10 additions & 0 deletions ExportCategories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,17 @@ DF.ExportCategories = {

-- Missing Health Background
"missingHealthColor",
"missingHealthColorHigh",
"missingHealthColorHighUseClass",
"missingHealthColorHighWeight",
"missingHealthColorLow",
"missingHealthColorLowUseClass",
"missingHealthColorLowWeight",
"missingHealthColorMedium",
"missingHealthColorMediumUseClass",
"missingHealthColorMediumWeight",
"missingHealthColorMode",
"missingHealthGradientAlpha",
"missingHealthTexture",
"missingHealthClassAlpha",

Expand Down
45 changes: 23 additions & 22 deletions Frames/Colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,42 +106,46 @@ DF.SetBarValue = SetBarValue

function DF:UpdateColorCurve()
DF.CurveCache = {}
DF.MissingHealthCurveCache = {}
end

-- Get a color curve for gradient mode
function DF:GetCurveForUnit(unit, db)
-- prefix: db key prefix ("healthColor" or "missingHealthColor")
-- cache: cache table to use (DF.CurveCache or DF.MissingHealthCurveCache)
function DF:GetCurveForUnit(unit, db, prefix, cache)
if not unit then return nil end
prefix = prefix or "healthColor"
cache = cache or DF.CurveCache

local useClass = db.healthColorLowUseClass or db.healthColorMediumUseClass or db.healthColorHighUseClass
local useClass = db[prefix .. "LowUseClass"] or db[prefix .. "MediumUseClass"] or db[prefix .. "HighUseClass"]
local class = "DEFAULT"

if useClass then
_, class = UnitClass(unit)
if not class then class = "DEFAULT" end
end

if not DF.CurveCache then DF.CurveCache = {} end
if DF.CurveCache[class] then return DF.CurveCache[class] end
if cache[class] then return cache[class] end

if not C_CurveUtil or not C_CurveUtil.CreateColorCurve then return nil end

local curve = C_CurveUtil.CreateColorCurve()
curve:SetType(Enum.LuaCurveType.Linear)

local function GetStageColor(stage)
if db["healthColor" .. stage .. "UseClass"] and class ~= "DEFAULT" then
if db[prefix .. stage .. "UseClass"] and class ~= "DEFAULT" then
local c = DF:GetClassColor(class)
if c then return c.r, c.g, c.b, 1.0 end
return 0.5, 0.5, 0.5, 1.0
else
local c = db["healthColor" .. stage]
local c = db[prefix .. stage]
return c.r, c.g, c.b, c.a or 1
end
end

local lowW = math.max(1, math.floor(db.healthColorLowWeight or 1))
local medW = math.max(1, math.floor(db.healthColorMediumWeight or 1))
local highW = math.max(1, math.floor(db.healthColorHighWeight or 1))
local lowW = math.max(1, math.floor(db[prefix .. "LowWeight"] or 1))
local medW = math.max(1, math.floor(db[prefix .. "MediumWeight"] or 1))
local highW = math.max(1, math.floor(db[prefix .. "HighWeight"] or 1))

local lr, lg, lb, la = GetStageColor("Low")
local mr, mg, mb, ma = GetStageColor("Medium")
Expand All @@ -164,29 +168,26 @@ function DF:GetCurveForUnit(unit, db)
curve:AddPoint(position, col)
end

DF.CurveCache[class] = curve
cache[class] = curve
return curve
end

-- Get gradient color for a health percentage using actual db settings
-- This replicates the curve logic for test mode where we don't have a real unit
function DF:GetHealthGradientColor(percent, db, testClass)
-- Get weights
local lowW = math.max(1, math.floor(db.healthColorLowWeight or 1))
local medW = math.max(1, math.floor(db.healthColorMediumWeight or 1))
local highW = math.max(1, math.floor(db.healthColorHighWeight or 1))
-- prefix: db key prefix ("healthColor" or "missingHealthColor")
function DF:GetHealthGradientColor(percent, db, testClass, prefix)
prefix = prefix or "healthColor"

local lowW = math.max(1, math.floor(db[prefix .. "LowWeight"] or 1))
local medW = math.max(1, math.floor(db[prefix .. "MediumWeight"] or 1))
local highW = math.max(1, math.floor(db[prefix .. "HighWeight"] or 1))

-- Helper to get stage color (respects "use class color" option)
local function GetStageColor(stage)
local useClassKey = "healthColor" .. stage .. "UseClass"
local colorKey = "healthColor" .. stage

if db[useClassKey] and testClass then
if db[prefix .. stage .. "UseClass"] and testClass then
local c = DF:GetClassColor(testClass)
if c then return {r = c.r, g = c.g, b = c.b} end
end

return db[colorKey] or {r = 0.5, g = 0.5, b = 0.5}
return db[prefix .. stage] or {r = 0.5, g = 0.5, b = 0.5}
end

local lowColor = GetStageColor("Low")
Expand Down
33 changes: 26 additions & 7 deletions Frames/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ local function SetMissingHealthBarValue(bar, unit, frame)
bar:SetValue(missingHealth)
end

-- Update texture before color (SetStatusBarTexture resets vertex color)
local texture = db and db.missingHealthTexture
if not texture or texture == "" then
texture = db and db.healthTexture or "Interface\\TargetingFrame\\UI-StatusBar"
end
bar:SetStatusBarTexture(texture)

-- Update color based on color mode
local colorMode = db and db.missingHealthColorMode or "CUSTOM"
local r, g, b, a
Expand All @@ -181,6 +188,23 @@ local function SetMissingHealthBarValue(bar, unit, frame)
local c = db.fadeDeadBackgroundColor or {r = 0.3, g = 0, b = 0}
r, g, b = c.r, c.g, c.b
a = db.fadeDeadBackground or 0.4
elseif colorMode == "PERCENT" and unit and UnitExists(unit) then
-- Use health gradient curve
local applied = false
local curve = DF:GetCurveForUnit(unit, db, "missingHealthColor", DF.MissingHealthCurveCache)
if curve and UnitHealthPercent then
local color = UnitHealthPercent(unit, true, curve)
local tex = bar:GetStatusBarTexture()
if color and tex then
tex:SetVertexColor(color:GetRGB())
tex:SetAlpha(db.missingHealthGradientAlpha or 0.8)
applied = true
end
end
if not applied then
r, g, b = 0.5, 0, 0
a = db.missingHealthGradientAlpha or 0.8
end
elseif colorMode == "CLASS" and unit and UnitExists(unit) then
-- Use class color
local _, class = UnitClass(unit)
Expand All @@ -196,14 +220,9 @@ local function SetMissingHealthBarValue(bar, unit, frame)
local missingColor = db and db.missingHealthColor or {r = 0.5, g = 0, b = 0, a = 0.8}
r, g, b, a = missingColor.r, missingColor.g, missingColor.b, missingColor.a or 0.8
end
bar:SetStatusBarColor(r, g, b, a)

-- Update texture - use missingHealthTexture if set, otherwise fall back to healthTexture
local texture = db and db.missingHealthTexture
if not texture or texture == "" then
texture = db and db.healthTexture or "Interface\\TargetingFrame\\UI-StatusBar"
if r then
bar:SetStatusBarColor(r, g, b, a)
end
bar:SetStatusBarTexture(texture)

bar:Show()
end
Expand Down
13 changes: 7 additions & 6 deletions GUI/GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4251,7 +4251,8 @@ function GUI:CreateHighlightRosterWidget(parent, getPlayersFunc, setPlayersFunc,
end

-- Gradient Preview Bar
function GUI:CreateGradientBar(parent, width, height, db)
function GUI:CreateGradientBar(parent, width, height, db, prefix)
prefix = prefix or "healthColor"
local f = CreateFrame("Frame", nil, parent, "BackdropTemplate")
f:SetSize(width or 360, height or 24)
CreateElementBackdrop(f)
Expand All @@ -4277,10 +4278,10 @@ function GUI:CreateGradientBar(parent, width, height, db)
local classCol = DF:GetClassColor(pClass)

local function GetC(stage)
if db["healthColor" .. stage .. "UseClass"] then
if db[prefix .. stage .. "UseClass"] then
return CreateColor(classCol.r, classCol.g, classCol.b, 1)
end
local c = db["healthColor" .. stage]
local c = db[prefix .. stage]
if not c or not c.r then return CreateColor(1, 1, 1, 1) end
return CreateColor(c.r, c.g, c.b, 1)
end
Expand All @@ -4289,9 +4290,9 @@ function GUI:CreateGradientBar(parent, width, height, db)
local mCol = GetC("Medium")
local hCol = GetC("High")

local lowW = math.max(1, math.floor(db.healthColorLowWeight or 1))
local medW = math.max(1, math.floor(db.healthColorMediumWeight or 1))
local highW = math.max(1, math.floor(db.healthColorHighWeight or 1))
local lowW = math.max(1, math.floor(db[prefix .. "LowWeight"] or 1))
local medW = math.max(1, math.floor(db[prefix .. "MediumWeight"] or 1))
local highW = math.max(1, math.floor(db[prefix .. "HighWeight"] or 1))

local points = {}
for i = 1, lowW do table.insert(points, lCol) end
Expand Down
Loading