From 438c1cbe86f4443624cededdec158560e1c8e572 Mon Sep 17 00:00:00 2001 From: Enf0 <825808+Enf0@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:42:24 +0100 Subject: [PATCH] feat(options): add health gradient color mode for missing health bar Add "Health Gradient" as a third Color Mode for missing health, with gradient preview bar and per-stop color/weight controls. Reorganize Health Bar options page into collapsible sections (Health Bar, Missing Health) to keep both sets of gradient controls visually grouped. --- Config.lua | 20 ++++++++++ ExportCategories.lua | 10 +++++ Frames/Colors.lua | 45 +++++++++++----------- Frames/Core.lua | 33 ++++++++++++---- GUI/GUI.lua | 13 ++++--- Options/Options.lua | 88 +++++++++++++++++++++++++++++++++++-------- TestMode/TestMode.lua | 18 ++++++++- 7 files changed, 176 insertions(+), 51 deletions(-) diff --git a/Config.lua b/Config.lua index 9d4da5aca..eac451486 100644 --- a/Config.lua +++ b/Config.lua @@ -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 @@ -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 diff --git a/ExportCategories.lua b/ExportCategories.lua index 1200b8afb..ee9c62770 100644 --- a/ExportCategories.lua +++ b/ExportCategories.lua @@ -115,7 +115,17 @@ DF.ExportCategories = { -- Missing Health Background "missingHealthColor", + "missingHealthColorHigh", + "missingHealthColorHighUseClass", + "missingHealthColorHighWeight", + "missingHealthColorLow", + "missingHealthColorLowUseClass", + "missingHealthColorLowWeight", + "missingHealthColorMedium", + "missingHealthColorMediumUseClass", + "missingHealthColorMediumWeight", "missingHealthColorMode", + "missingHealthGradientAlpha", "missingHealthTexture", "missingHealthClassAlpha", diff --git a/Frames/Colors.lua b/Frames/Colors.lua index fd1628d10..4900164c4 100644 --- a/Frames/Colors.lua +++ b/Frames/Colors.lua @@ -106,13 +106,18 @@ 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 @@ -120,8 +125,7 @@ function DF:GetCurveForUnit(unit, db) 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 @@ -129,19 +133,19 @@ function DF:GetCurveForUnit(unit, db) 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") @@ -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") diff --git a/Frames/Core.lua b/Frames/Core.lua index 60c98061b..7f31eb871 100644 --- a/Frames/Core.lua +++ b/Frames/Core.lua @@ -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 @@ -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) @@ -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 diff --git a/GUI/GUI.lua b/GUI/GUI.lua index f7c8cef03..6168a661d 100644 --- a/GUI/GUI.lua +++ b/GUI/GUI.lua @@ -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) @@ -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 @@ -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 diff --git a/Options/Options.lua b/Options/Options.lua index 98ff6ecdb..0a66895b6 100644 --- a/Options/Options.lua +++ b/Options/Options.lua @@ -2645,11 +2645,22 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) local pageHealthBar = CreateSubTab("bars", "bars_health", "Health Bar") BuildPage(pageHealthBar, function(self, db, Add, AddSpace, AddSyncPoint) -- Copy button at top - Add(CreateCopyButton(self.child, {"health", "classColor", "smoothBars"}, "Health Bar", "bars_health"), 25, 2) + Add(CreateCopyButton(self.child, {"health", "classColor", "smoothBars", "background", "missingHealth"}, "Health Bar", "bars_health"), 25, 2) + + local currentSection = nil + local function AddToSection(widget, height, col) + Add(widget, height, col) + if currentSection then currentSection:RegisterChild(widget) end + return widget + end + + -- ===== HEALTH BAR SECTION ===== + local healthBarSection = Add(GUI:CreateCollapsibleSection(self.child, "Health Bar", true), 36, "both") + currentSection = healthBarSection -- ===== COLOR GROUP (Column 1) ===== local colorGroup = GUI:CreateSettingsGroup(self.child, 280) - colorGroup:AddWidget(GUI:CreateHeader(self.child, "Health Bar Color"), 40) + colorGroup:AddWidget(GUI:CreateHeader(self.child, "Color"), 40) local colorModes = { CLASS = "Class Color", CUSTOM = "Custom Color", PERCENT = "Health Gradient" } colorGroup:AddWidget(GUI:CreateDropdown(self.child, "Color Mode", colorModes, db, "healthColorMode", function() @@ -2665,11 +2676,11 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) local customColor = colorGroup:AddWidget(GUI:CreateColorPicker(self.child, "Custom Health Color", db, "healthColor", true, nil, function() DF:LightweightUpdateHealthColor() end, true), 35) customColor.hideOn = function(d) return d.healthColorMode ~= "CUSTOM" end - Add(colorGroup, nil, 1) + AddToSection(colorGroup, nil, 1) -- ===== TEXTURE GROUP (Column 2) ===== local textureGroup = GUI:CreateSettingsGroup(self.child, 280) - textureGroup:AddWidget(GUI:CreateHeader(self.child, "Health Bar Texture"), 40) + textureGroup:AddWidget(GUI:CreateHeader(self.child, "Texture"), 40) textureGroup:AddWidget(GUI:CreateTextureDropdown(self.child, "Texture", db, "healthTexture"), 55) local orientOptions = { @@ -2679,13 +2690,13 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) textureGroup:AddWidget(GUI:CreateDropdown(self.child, "Fill Direction", orientOptions, db, "healthOrientation", function() DF:UpdateAllFrames() end), 55) textureGroup:AddWidget(GUI:CreateCheckbox(self.child, "Smooth Bar Animation", db, "smoothBars", function() DF:UpdateAllFrames() end), 30) - Add(textureGroup, nil, 2) + AddToSection(textureGroup, nil, 2) -- ===== GRADIENT PREVIEW (full width, conditional) ===== - local gradHeader = Add(GUI:CreateHeader(self.child, "Gradient Colors"), 40, "both") + local gradHeader = AddToSection(GUI:CreateHeader(self.child, "Gradient"), 40, "both") gradHeader.hideOn = function(d) return d.healthColorMode ~= "PERCENT" end - local gradBar = Add(GUI:CreateGradientBar(self.child, 550, 24, db), 35, "both") + local gradBar = AddToSection(GUI:CreateGradientBar(self.child, 550, 24, db), 35, "both") gradBar.hideOn = function(d) return d.healthColorMode ~= "PERCENT" end -- ===== HIGH HEALTH GROUP (Column 1, conditional) ===== @@ -2695,7 +2706,7 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) highGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "healthColorHighUseClass", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) highGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "healthColorHighWeight", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if gradBar.UpdatePreview then gradBar.UpdatePreview() end end, true), 55) highGroup.hideOn = function(d) return d.healthColorMode ~= "PERCENT" end - Add(highGroup, nil, 1) + AddToSection(highGroup, nil, 1) -- ===== MEDIUM HEALTH GROUP (Column 2, conditional) ===== local medGroup = GUI:CreateSettingsGroup(self.child, 280) @@ -2704,7 +2715,7 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) medGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "healthColorMediumUseClass", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) medGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "healthColorMediumWeight", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if gradBar.UpdatePreview then gradBar.UpdatePreview() end end, true), 55) medGroup.hideOn = function(d) return d.healthColorMode ~= "PERCENT" end - Add(medGroup, nil, 2) + AddToSection(medGroup, nil, 2) -- ===== LOW HEALTH GROUP (Column 1, conditional) ===== local lowGroup = GUI:CreateSettingsGroup(self.child, 280) @@ -2713,7 +2724,7 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) lowGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "healthColorLowUseClass", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) lowGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "healthColorLowWeight", function() if gradBar.UpdatePreview then gradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if gradBar.UpdatePreview then gradBar.UpdatePreview() end end, true), 55) lowGroup.hideOn = function(d) return d.healthColorMode ~= "PERCENT" end - Add(lowGroup, nil, 1) + AddToSection(lowGroup, nil, 1) -- ===== BACKGROUND GROUP (Column 1) ===== local bgGroup = GUI:CreateSettingsGroup(self.child, 280) @@ -2736,11 +2747,18 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) local bgClassAlpha = bgGroup:AddWidget(GUI:CreateSlider(self.child, "Background Alpha", 0, 1, 0.05, db, "backgroundClassAlpha", nil, function() DF:LightweightUpdateBackgroundColor() end, true), 55) bgClassAlpha.hideOn = function(d) return d.backgroundColorMode ~= "CLASS" end - Add(bgGroup, nil, 1) + AddToSection(bgGroup, nil, 1) - -- ===== MISSING HEALTH GROUP (Column 2) ===== + currentSection = nil + AddSpace(10, "both") + + -- ===== MISSING HEALTH SECTION ===== + local missingSection = Add(GUI:CreateCollapsibleSection(self.child, "Missing Health", true), 36, "both") + currentSection = missingSection + + -- ===== MISSING HEALTH GROUP (Column 1) ===== local missingGroup = GUI:CreateSettingsGroup(self.child, 280) - missingGroup:AddWidget(GUI:CreateHeader(self.child, "Missing Health"), 40) + missingGroup:AddWidget(GUI:CreateHeader(self.child, "Settings"), 40) local bgFillModes = { BACKGROUND = "Background Only", MISSING_HEALTH = "Missing Health Only", BOTH = "Both" } local bgFillMode = missingGroup:AddWidget(GUI:CreateDropdown(self.child, "Background Fill", bgFillModes, db, "backgroundMode", function() @@ -2755,9 +2773,10 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) end, missingHealthTextureOptions), 55) missingHealthTexture.hideOn = function(d) return d.backgroundMode == "BACKGROUND" end - local missingHealthColorModes = { CUSTOM = "Custom Color", CLASS = "Class Color" } + local missingHealthColorModes = { CUSTOM = "Custom Color", CLASS = "Class Color", PERCENT = "Health Gradient" } local missingHealthColorMode = missingGroup:AddWidget(GUI:CreateDropdown(self.child, "Color Mode", missingHealthColorModes, db, "missingHealthColorMode", function() self:RefreshStates() + DF:UpdateColorCurve() DF:UpdateAllFrames() end), 55) missingHealthColorMode.hideOn = function(d) return d.backgroundMode == "BACKGROUND" end @@ -2768,7 +2787,46 @@ function DF:SetupGUIPages(GUI, CreateCategory, CreateSubTab, BuildPage) local missingHealthClassAlpha = missingGroup:AddWidget(GUI:CreateSlider(self.child, "Class Color Alpha", 0, 1, 0.05, db, "missingHealthClassAlpha", nil, function() DF:UpdateAllFrames() end, true), 55) missingHealthClassAlpha.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "CLASS" end - Add(missingGroup, nil, 2) + local missingHealthGradientAlpha = missingGroup:AddWidget(GUI:CreateSlider(self.child, "Gradient Color Alpha", 0, 1, 0.05, db, "missingHealthGradientAlpha", nil, function() DF:RefreshAllVisibleFrames() end, true), 55) + missingHealthGradientAlpha.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + + AddToSection(missingGroup, nil, 1) + + -- ===== MISSING HEALTH GRADIENT PREVIEW (full width, conditional) ===== + local mhGradHeader = AddToSection(GUI:CreateHeader(self.child, "Gradient"), 40, "both") + mhGradHeader.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + + local mhGradBar = AddToSection(GUI:CreateGradientBar(self.child, 550, 24, db, "missingHealthColor"), 35, "both") + mhGradBar.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + + -- ===== MISSING HEALTH HIGH GROUP (Column 1, conditional) ===== + local mhHighGroup = GUI:CreateSettingsGroup(self.child, 280) + mhHighGroup:AddWidget(GUI:CreateHeader(self.child, "High Health (100%)"), 40) + mhHighGroup:AddWidget(GUI:CreateColorPicker(self.child, "Color", db, "missingHealthColorHigh", false, function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 35) + mhHighGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "missingHealthColorHighUseClass", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) + mhHighGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "missingHealthColorHighWeight", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 55) + mhHighGroup.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + AddToSection(mhHighGroup, nil, 1) + + -- ===== MISSING HEALTH MEDIUM GROUP (Column 2, conditional) ===== + local mhMedGroup = GUI:CreateSettingsGroup(self.child, 280) + mhMedGroup:AddWidget(GUI:CreateHeader(self.child, "Medium Health (50%)"), 40) + mhMedGroup:AddWidget(GUI:CreateColorPicker(self.child, "Color", db, "missingHealthColorMedium", false, function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 35) + mhMedGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "missingHealthColorMediumUseClass", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) + mhMedGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "missingHealthColorMediumWeight", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 55) + mhMedGroup.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + AddToSection(mhMedGroup, nil, 2) + + -- ===== MISSING HEALTH LOW GROUP (Column 1, conditional) ===== + local mhLowGroup = GUI:CreateSettingsGroup(self.child, 280) + mhLowGroup:AddWidget(GUI:CreateHeader(self.child, "Low Health (0%)"), 40) + mhLowGroup:AddWidget(GUI:CreateColorPicker(self.child, "Color", db, "missingHealthColorLow", false, function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 35) + mhLowGroup:AddWidget(GUI:CreateCheckbox(self.child, "Use Class Color", db, "missingHealthColorLowUseClass", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end), 30) + mhLowGroup:AddWidget(GUI:CreateSlider(self.child, "Weight", 1, 5, 1, db, "missingHealthColorLowWeight", function() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() end, function() DF:UpdateColorCurve() DF:RefreshAllVisibleFrames() if mhGradBar.UpdatePreview then mhGradBar.UpdatePreview() end end, true), 55) + mhLowGroup.hideOn = function(d) return d.backgroundMode == "BACKGROUND" or d.missingHealthColorMode ~= "PERCENT" end + AddToSection(mhLowGroup, nil, 1) + + currentSection = nil -- See Also links AddSpace(20, "both") diff --git a/TestMode/TestMode.lua b/TestMode/TestMode.lua index cf450696d..4d17b6766 100644 --- a/TestMode/TestMode.lua +++ b/TestMode/TestMode.lua @@ -374,7 +374,15 @@ function DF:UpdateTestFrameHealthOnly(frame, index) -- Handle color mode local colorMode = db.missingHealthColorMode or "CUSTOM" local r, g, b, a - if colorMode == "CLASS" and testData.class then + if colorMode == "PERCENT" then + local color = DF:GetHealthGradientColor(health, db, testData.class, "missingHealthColor") + if color then + r, g, b = color.r, color.g, color.b + else + r, g, b = 0.5, 0, 0 + end + a = db.missingHealthGradientAlpha or 0.8 + elseif colorMode == "CLASS" and testData.class then local classColor = DF:GetClassColor(testData.class) if classColor then r, g, b = classColor.r, classColor.g, classColor.b @@ -533,6 +541,14 @@ function DF:UpdateTestFrame(frame, index, applyLayout) 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" then + local color = DF:GetHealthGradientColor(healthValue, db, testData.class, "missingHealthColor") + if color then + r, g, b = color.r, color.g, color.b + else + r, g, b = 0.5, 0, 0 + end + a = db.missingHealthGradientAlpha or 0.8 elseif colorMode == "CLASS" and testData.class then local classColor = DF:GetClassColor(testData.class) if classColor then