Commit 5c85a7de authored by Benik's avatar Benik

Updated the InfoPanel and Portrait style coloring

parent 4d7c4231
......@@ -31,18 +31,18 @@ end
local function GetClassColor(unit)
local unitReaction = UnitReaction(unit, 'player')
local _, targetClass = UnitClass(unit)
local r, g, b
if (UnitIsPlayer(unit)) then
local classColor = (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[targetClass] or RAID_CLASS_COLORS[targetClass])
if not targetClass then return "" end
r, g, b = classColor.r, classColor.g, classColor.b
local unitPlayer = UnitIsPlayer(unit)
if (unitPlayer) then
local _, unitClass = UnitClass(unit)
local classColor = (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[unitClass] or RAID_CLASS_COLORS[unitClass])
return classColor.r, classColor.g, classColor.b
elseif (unitReaction) then
local reaction = ElvUF.colors.reaction[unitReaction]
r, g, b = reaction[1], reaction[2], reaction[3]
return reaction[1], reaction[2], reaction[3]
else
return 255, 128, 128
end
return r, g, b
end
-- Units
......@@ -164,11 +164,19 @@ function BU:BossInfoPanelColor()
end
end
function BU:InfoPanelColor()
function BU:UpdateUnitInfoPanelColor()
BU:UnitInfoPanelColor()
BU:RaidInfoPanelColor()
BU:Raid40InfoPanelColor()
BU:PartyInfoPanelColor()
BU:ArenaInfoPanelColor()
BU:BossInfoPanelColor()
end
function BU:InfoPanelColor()
--self:UpdateUnitInfoPanelColor()
self:RegisterEvent('UNIT_NAME_UPDATE', BU.UpdateUnitInfoPanelColor)
self:RegisterEvent('UNIT_FACTION', BU.UpdateUnitInfoPanelColor)
self:RegisterEvent('INSTANCE_ENCOUNTER_ENGAGE_UNIT', BU.UpdateUnitInfoPanelColor)
hooksecurefunc(UF, 'Update_TargetFrame', BU.UnitInfoPanelColor)
end
\ No newline at end of file
......@@ -48,77 +48,30 @@ function BU:RecolorTargetDetachedPortraitStyle()
if frame.USE_PORTRAIT and portrait.backdrop.style and E.db.benikui.unitframes.target.portraitStyle then
local maxValue = UnitPowerMax("target")
local _, pToken, altR, altG, altB = UnitPowerType("target")
local _, _, altR, altG, altB = UnitPowerType("target")
local mu = power.BG.multiplier or 1
local color = ElvUF['colors'].power[pToken]
local isPlayer = UnitIsPlayer("target")
local classColor = (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[targetClass] or RAID_CLASS_COLORS[targetClass])
if not power.colorClass then
if maxValue > 0 then
if color then
r, g, b = color[1], color[2], color[3]
else
r, g, b = altR, altG, altB
end
local reaction = UnitReaction('target', 'player')
if maxValue > 0 then
if isPlayer then
r, g, b = classColor.r, classColor.g, classColor.b
else
if color and mu then
r, g, b = color[1] * mu, color[2] * mu, color[3] * mu
if reaction then
local tpet = ElvUF.colors.reaction[reaction]
r, g, b = tpet[1], tpet[2], tpet[3]
end
end
else
local reaction = UnitReaction('target', 'player')
if maxValue > 0 then
if isPlayer then
r, g, b = classColor.r, classColor.g, classColor.b
else
if reaction then
local tpet = ElvUF.colors.reaction[reaction]
r, g, b = tpet[1], tpet[2], tpet[3]
end
end
else
if reaction and mu then
local t = ElvUF.colors.reaction[reaction]
r, g, b = t[1] * mu, t[2] * mu, t[3] * mu
end
if reaction and mu then
local t = ElvUF.colors.reaction[reaction]
r, g, b = t[1] * mu, t[2] * mu, t[3] * mu
end
end
portrait.backdrop.style:SetBackdropColor(r, g, b, (E.db.benikui.colors.styleAlpha or 1))
end
end
end
function BU:RecolorTargetInfoPanel()
local frame = _G["ElvUF_Target"]
if not frame.USE_INFO_PANEL then return end
local targetClass = select(2, UnitClass("target"));
do
local panel = frame.InfoPanel
local isPlayer = UnitIsPlayer("target")
local classColor = (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[targetClass] or RAID_CLASS_COLORS[targetClass])
local reaction = UnitReaction('target', 'player')
local r, g, b
if isPlayer then
if E.db.benikui.unitframes.infoPanel.customColor == 1 then
r, g, b = classColor.r, classColor.g, classColor.b
else
r, g, b = BUI:unpackColor(E.db.benikui.unitframes.infoPanel.color)
end
else
if reaction then
local tpet = ElvUF.colors.reaction[reaction]
if E.db.benikui.unitframes.infoPanel.customColor == 1 then
r, g, b = tpet[1], tpet[2], tpet[3]
else
r, g, b = BUI:unpackColor(E.db.benikui.unitframes.infoPanel.color)
end
end
portrait.backdrop.style:SetBackdropColor(r, g, b, (E.db.benikui.colors.styleAlpha or 1))
end
panel.color:SetVertexColor(r, g, b, (E.db.benikui.colors.styleAlpha or 1))
end
end
......@@ -158,17 +111,17 @@ function BU:ArrangeTarget()
end
function BU:PLAYER_TARGET_CHANGED()
self:RecolorTargetDetachedPortraitStyle()
self:RecolorTargetInfoPanel()
BU:RecolorTargetDetachedPortraitStyle()
BU:UnitInfoPanelColor()
end
function BU:InitTarget()
if not E.db.unitframe.units.target.enable then return end
self:Construct_TargetFrame()
hooksecurefunc(UF, 'Update_TargetFrame', BU.ArrangeTarget)
self:RegisterEvent('PLAYER_TARGET_CHANGED')
hooksecurefunc(UF, 'Update_TargetFrame', BU.RecolorTargetDetachedPortraitStyle)
hooksecurefunc(UF, 'Update_TargetFrame', BU.RecolorTargetInfoPanel)
self:RegisterEvent('PLAYER_TARGET_CHANGED')
-- Needed for some post updates
hooksecurefunc(UF, "Configure_Portrait", function(self, frame)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment