health-color: make health color a seperate option

This commit is contained in:
shagu
2021-10-10 14:33:53 +02:00
parent 8671435c78
commit 10c69d1a8a
4 changed files with 50 additions and 20 deletions
+1
View File
@@ -52,6 +52,7 @@ mods\social-colors.lua
mods\item-colors.lua
mods\chat-links.lua
mods\health-numbers.lua
mods\health-color.lua
mods\auto-dismount.lua
mods\auto-stance.lua
mods\tooltip-details.lua
+1
View File
@@ -52,6 +52,7 @@ mods\social-colors.lua
mods\item-colors.lua
mods\chat-links.lua
mods\health-numbers.lua
mods\health-color.lua
mods\auto-dismount.lua
mods\auto-stance.lua
mods\tooltip-details.lua
+46
View File
@@ -0,0 +1,46 @@
local _G = _G or getfenv(0)
local Abbreviate = ShaguTweaks.Abbreviate
local GetColorGradient = ShaguTweaks.GetColorGradient
local vanilla = ShaguTweaks.GetExpansion() == "vanilla" or nil
local module = ShaguTweaks:register({
title = "Unit Frame Health Colors",
description = "Change health text color based on its value.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
category = "Unit Frames",
enabled = nil,
})
module.enable = function(self)
local HookUnitFrame_UpdateManaType = UnitFrame_UpdateManaType
function UnitFrame_UpdateManaType(uf)
HookUnitFrame_UpdateManaType(uf)
if not uf then uf = this end
local string = uf.manabar and uf.manabar.TextString
if not string then return end
if not strfind(uf.manabar:GetName(), "Health") then
local r, g, b = uf.manabar:GetStatusBarColor()
string:SetTextColor((r + 2) / 3, (g + 2) / 3, (b + 2) / 3, 1)
end
end
local HookTextStatusBar_UpdateTextString = TextStatusBar_UpdateTextString
function TextStatusBar_UpdateTextString(sb)
if not sb then sb = this end
HookTextStatusBar_UpdateTextString(sb)
local string = sb.TextString
if string and sb.unit then
local min, max = sb:GetMinMaxValues()
local cur = sb:GetValue()
local percent = max > 0 and floor(cur/max*100) or 0
if strfind(sb:GetName(), "Health") then
local r, g, b = GetColorGradient(percent/100)
string:SetTextColor((r + 1) / 2, (g + 1) / 2, (b + 1) / 2, .75)
end
end
end
end
+2 -20
View File
@@ -25,31 +25,18 @@ module.enable = function(self)
PetFrameManaBar.TextString:SetPoint("CENTER", PetFrameManaBar, "CENTER", -2, -2)
for _, frame in pairs( { TargetFrameHealthBar, TargetFrameManaBar, PlayerFrameHealthBar, PlayerFrameManaBar }) do
frame.TextString:SetFontObject("GameFontNormal")
frame.TextString:SetFontObject("GameFontWhite")
frame.TextString:SetFont(STANDARD_TEXT_FONT, 10, "OUTLINE")
frame.TextString:SetHeight(32)
end
for _, frame in pairs( { PetFrameHealthBar, PetFrameManaBar }) do
frame.TextString:SetFontObject("GameFontNormal")
frame.TextString:SetFontObject("GameFontWhite")
frame.TextString:SetFont(STANDARD_TEXT_FONT, 9, "OUTLINE")
frame.TextString:SetHeight(32)
frame.TextString:SetJustifyH("LEFT")
end
local HookUnitFrame_UpdateManaType = UnitFrame_UpdateManaType
function UnitFrame_UpdateManaType(uf)
HookUnitFrame_UpdateManaType(uf)
if not uf then uf = this end
local string = uf.manabar and uf.manabar.TextString
if not string then return end
if not strfind(uf.manabar:GetName(), "Health") then
local r, g, b = uf.manabar:GetStatusBarColor()
string:SetTextColor((r + 2) / 3, (g + 2) / 3, (b + 2) / 3, 1)
end
end
local HookTextStatusBar_UpdateTextString = TextStatusBar_UpdateTextString
function TextStatusBar_UpdateTextString(sb)
if not sb then sb = this end
@@ -82,11 +69,6 @@ module.enable = function(self)
string:SetText(Abbreviate(cur))
end
if strfind(sb:GetName(), "Health") then
local r, g, b = GetColorGradient(percent/100)
string:SetTextColor((r + 1) / 2, (g + 1) / 2, (b + 1) / 2, .75)
end
if max == 0 then
string:Hide()
string:SetText("")