From f2bb49433c3e5edfc81625f21c91557a841ef64e Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Sun, 28 Jan 2018 13:35:16 +0200 Subject: [PATCH] Change to coloring health bar instead of name in UF --- OmaRF/Settings.lua | 2 +- OmaUF/Events.lua | 26 ++++++++++++++++++++++---- OmaUF/Settings.lua | 8 ++++---- OmaUF/UnitFrames.lua | 6 +++--- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/OmaRF/Settings.lua b/OmaRF/Settings.lua index 225f433..80a3e41 100644 --- a/OmaRF/Settings.lua +++ b/OmaRF/Settings.lua @@ -98,7 +98,7 @@ local settings = { [PowerTypeRage] = {1, 0, 0}, [PowerTypeFocus] = {1, 0.5, 0}, [PowerTypeEnergy] = {1, 0.8, 0}, - [PowerTypeRunic] = {0.9, 0, 0.1}, + [PowerTypeRunic] = {0.8, 0, 0.2}, }, MajorAuras = { -- Antorus diff --git a/OmaUF/Events.lua b/OmaUF/Events.lua index 0e63e9c..d68affe 100644 --- a/OmaUF/Events.lua +++ b/OmaUF/Events.lua @@ -22,6 +22,7 @@ local updateAuraFrames = OmaUFAuras.UpdateAuras; local Settings = OmaUFSettings; local baseColor = Settings.BaseColor; +local healthColor = Settings.HealthColor; local overlayColorDispel = Settings.OverlayColorDispel; local overlayColorCharm = Settings.OverlayColorCharm; local overlayColorAlert = Settings.OverlayColorAlert; @@ -146,10 +147,6 @@ local function updateName(frame, unit) local name = UnitName(unit); if not name then return end frame.name:SetText(ssub(name, 1, 10)); - - local _, class = UnitClass(unit); - local color = RAID_CLASS_COLORS[class]; - if color then frame.name:SetVertexColor(color.r, color.g, color.b) end end local function updateHealPred(frame, unit) @@ -347,6 +344,24 @@ local function updateLeaderIcon(frame, unit) end end +local function updateHealthColor(frame, unit) + if not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) then + frame.health:SetVertexColor(0.5, 0.5, 0.5); + elseif UnitIsPlayer(unit) then + local _, class = UnitClass(unit); + local color = RAID_CLASS_COLORS[class]; + if color then + frame.health:SetVertexColor(color.r, color.g, color.b) + else + frame.health:SetVertexColor(unpack(healthColor)) + end + elseif UnitPlayerControlled(unit) then + frame.health:SetVertexColor(0, 1, 0); + else + frame.health:SetVertexColor(UnitSelectionColor(unit)); + end +end + local eventFuncs = { ["UNIT_HEALTH"] = function(frame) updateHealth(frame, frame.displayed); @@ -391,6 +406,7 @@ local eventFuncs = { end, ["UNIT_NAME_UPDATE"] = function(frame) updateName(frame, frame.displayed); + updateHealthColor(frame, frame.unit); end, ["UNIT_CONNECTION"] = function(frame) updateHealthText(frame, frame.displayed); @@ -418,6 +434,7 @@ local eventFuncs = { end, ["UNIT_FACTION"] = function(frame) updatePVP(frame, frame.unit); + updateHealthColor(frame, frame.unit); end, ["PARTY_LEADER_CHANGED"] = function(frame) updateLeaderIcon(frame, frame.unit); @@ -442,6 +459,7 @@ local eventFuncs = { updateStatus(frame, frame.unit); updatePVP(frame, frame.unit); updateLeaderIcon(frame, frame.unit); + updateHealthColor(frame, frame.unit); end, }; eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"]; diff --git a/OmaUF/Settings.lua b/OmaUF/Settings.lua index c2dca70..a73a9e7 100644 --- a/OmaUF/Settings.lua +++ b/OmaUF/Settings.lua @@ -67,9 +67,9 @@ local chars = { -- account-wide settings local settings = { - BaseColor = {0, 0, 0}, - BgColor = {0.9, 0.9, 0.9}, - HealthColor = {0.3, 0.3, 0.3}, + BaseColor = {0, 0, 0, 0.5}, + BgColor = {0.1, 0.1, 0.1, 0.4}, + HealthColor = {0.5, 0.5, 0.5}, ShieldColor = {0.1, 0.8, 1}, ShieldhlColor = {0.5, 0.8, 1}, HealpredColor = {0.5, 0.6, 0.5}, @@ -82,7 +82,7 @@ local settings = { [PowerTypeRage] = {1, 0, 0}, [PowerTypeFocus] = {1, 0.5, 0}, [PowerTypeEnergy] = {1, 0.8, 0}, - [PowerTypeRunic] = {0.9, 0, 0.1}, + [PowerTypeRunic] = {0.8, 0, 0.2}, }, MajorAuras = { -- Antorus diff --git a/OmaUF/UnitFrames.lua b/OmaUF/UnitFrames.lua index d2e5fcc..c0fe00c 100644 --- a/OmaUF/UnitFrames.lua +++ b/OmaUF/UnitFrames.lua @@ -176,9 +176,6 @@ local function setupFrame(frame, secure, unit) frame:SetScript("OnShow", frameShow); frame:SetScript("OnHide", frameHide); frame:SetScript("OnEvent", unitEvent); - -- let other addons hook these to anchor tooltip elsewhere - GameTooltip = _G["GameTooltip"]; - GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; secure:SetScript("OnEnter", showTooltip); secure:SetScript("OnLeave", hideTooltip); -- set attributes @@ -244,6 +241,9 @@ end local function initialize() loadCharSettings(); + -- let other addons hook these to anchor tooltip elsewhere + GameTooltip = _G["GameTooltip"]; + GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; initializePlayer(UIParent); initializeTarget(UIParent); -- TODO boss frames, pet frame, (arena frames) -- 2.39.5