Skip to content

Commit

Permalink
refactor: define 'InvertedHealthColor' variable for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Jun 17, 2022
1 parent a497e68 commit d2b746d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ C.CharacterSettings = {
Smooth = true,
Portrait = true,
HealthColor = { r = 0.82, g = 0.8, b = 0.77 },
InvertedHealthColor = { r = 0.1, g = 0.1, b = 0.1 },
InvertedHealthAlpha = 0.8,
FrequentHealth = false,
HealthFrequency = 0.2,

Expand Down
1 change: 1 addition & 0 deletions modules/unitframe/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ colors.reaction = {
}

colors.smooth = { 1, 0, 0, 1, 1, 0, 0, 1, 0 }
colors.disconnected = { 0.5, 0.5, 0.5 }
10 changes: 8 additions & 2 deletions modules/unitframe/elements/health.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local F, C = unpack(select(2, ...))
local UNITFRAME = F:GetModule('UnitFrame')
local oUF = F.Libs.oUF

UNITFRAME.UnitFrames = {
['player'] = true,
Expand Down Expand Up @@ -107,11 +108,16 @@ local function PostUpdateColor(self, unit)
local parent = self.__owner
local inverted = C.DB.Unitframe.InvertedColorMode
local isOffline = not UnitIsConnected(unit)

if inverted then
local color = C.DB.Unitframe.InvertedHealthColor
local alpha = C.DB.Unitframe.InvertedHealthAlpha

if isOffline then
parent.backdrop:SetBackdropColor(0.5, 0.5, 0.5, 0.8)
local r, g, b = unpack(oUF.colors.disconnected)
parent.backdrop:SetBackdropColor(r, g, b, alpha)
else
parent.backdrop:SetBackdropColor(0.1, 0.1, 0.1, 0.8)
parent.backdrop:SetBackdropColor(color.r, color.g, color.b, alpha)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions modules/unitframe/unitframe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ function UNITFRAME:CreateBackdrop(self, onKeyDown)

self.backdrop = F.SetBD(self, 0)
if C.DB.Unitframe.InvertedColorMode then
self.backdrop:SetBackdropColor(0.1, 0.1, 0.1, 0.8)
local color = C.DB.Unitframe.InvertedHealthColor
local alpha = C.DB.Unitframe.InvertedHealthAlpha
self.backdrop:SetBackdropColor(color.r, color.g, color.b, alpha)
else
self.backdrop:SetBackdropColor(0.1, 0.1, 0.1, 0)
self.backdrop:SetBackdropColor(0, 0, 0, 0)
end
self.backdrop:SetBackdropBorderColor(0, 0, 0, 1)
self.backdrop:SetFrameStrata('BACKGROUND')
Expand Down

0 comments on commit d2b746d

Please sign in to comment.