Skip to content

Commit affd97c

Browse files
authored
Merge pull request #232 from JerichoR/CharacterDataText
Color gradient for durability
2 parents 22aaf42 + c12bf9b commit affd97c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Tukui/Modules/DataTexts/Elements/Character.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
local T, C, L = unpack((select(2, ...)))
22

33
local DataText = T["DataTexts"]
4-
local format = format
54
local ClassColor = T.RGBToHex(unpack(T.Colors.class[T.MyClass]))
65

76
local Update = function(self)
@@ -21,8 +20,10 @@ local Update = function(self)
2120
end
2221

2322
table.sort(L.DataText.Slots, function(a, b) return a[3] < b[3] end)
23+
local durability = floor(L.DataText.Slots[1][3] * 100)
24+
local r, g, b = T.ColorGradient(durability, 100, 0.8, 0, 0, 0.8, 0.8, 0, 0, 0.8, 0)
2425

25-
self.Text:SetText(ClassColor..T.MyName.."|r".." ("..floor(L.DataText.Slots[1][3] * 100).."%)")
26+
self.Text:SetFormattedText("%s%s|r (|cff%02x%02x%02x%s%%|r)", ClassColor, T.MyName, r * 255, g * 255, b * 255, durability)
2627
end
2728

2829
local OnEnter = function(self)
@@ -49,7 +50,7 @@ local OnEnter = function(self)
4950
if T.Classic then
5051
GameTooltip:AddDoubleLine(ClassColor..T.MyName.."|r "..UnitLevel("player"), T.MyRealm)
5152
GameTooltip:AddLine(" ")
52-
53+
5354
if CharacterStatFrame then
5455
for _, Frame in pairs(CharacterStatFrame) do
5556
local Name = _G[Frame.."Label"]

0 commit comments

Comments
 (0)