From 156861c6dd4b4d4f46b7fd6a70e8458e3aa75af6 Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Thu, 7 May 2020 22:54:43 +0300 Subject: [PATCH] Non-raid unit frame fixes --- kehys/events.lua | 28 ++++++++++++++++++++-------- kehys/frame.lua | 1 + kehys/player.lua | 6 ++---- kehys/target.lua | 7 ++++--- kehys/updater.lua | 15 ++++++++++----- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/kehys/events.lua b/kehys/events.lua index ff6c4c9..6a96b3e 100644 --- a/kehys/events.lua +++ b/kehys/events.lua @@ -36,7 +36,7 @@ function addon.RegisterEvents(frame) if frame.unit == "player" then frame:RegisterEvent("PLAYER_ALIVE") end if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end if frame.unit == "target" then frame:RegisterEvent("PLAYER_TARGET_CHANGED") end - if not frame.nonraid then + if frame.raid then frame:RegisterEvent("PLAYER_REGEN_DISABLED"); frame:RegisterEvent("READY_CHECK"); frame:RegisterEvent("READY_CHECK_FINISHED"); @@ -53,10 +53,10 @@ function addon.RegisterUnitEvents(frame) if frame.unit == "focus" or frame.unit == "target" then frame:RegisterUnitEvent("UNIT_TARGETABLE_CHANGED", frame.unit, displayed); end - if not frame.nonraid or frame.unit ~= "player" then + if frame.raid or frame.unit ~= "player" then frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed); end - if not frame.nonraid then + if frame.raid then frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed); frame:RegisterUnitEvent("READY_CHECK_CONFIRM", frame.unit, displayed); end @@ -75,7 +75,17 @@ local function updateName(frame, unit) local _, class = UnitClass(unit); local color = RAID_CLASS_COLORS[class]; - if color then frame.name:SetVertexColor(color.r, color.g, color.b) end + if color then + if not frame.raid then + if UnitIsEnemy("player", unit) then + frame.health:SetVertexColor(1, 0, 0); + else + frame.health:SetVertexColor(color.r, color.g, color.b); + end + else + frame.name:SetVertexColor(color.r, color.g, color.b); + end + end end addon.Events.UpdateName = updateName; @@ -154,7 +164,7 @@ local eventFuncs = { end, ["UNIT_NAME_UPDATE"] = function(frame) updateName(frame, frame.unit); - if not frame.nonraid then + if frame.raid then if frame.guid then guids[frame.guid] = nil; end @@ -174,7 +184,7 @@ local eventFuncs = { updateRaidMarker(frame, frame.displayed); end, ["PLAYER_REGEN_DISABLED"] = function(frame) - if not frame.nonraid then + if frame.raid then -- clear buff status on entering combat, should also use UnitAura to re-fill frame.tankcd = {}; frame.alert = {}; @@ -188,10 +198,10 @@ local eventFuncs = { ["UPDATE_ALL_BARS"] = function(frame) updateVehicle(frame); updateRaidMarker(frame, frame.displayed); - if not frame.nonraid or frame.unit ~= "player" then + if frame.raid or frame.unit ~= "player" then updateName(frame, frame.unit); end - if not frame.nonraid then + if frame.raid then updateRole(frame, frame.unit); updateAggro(frame, frame.displayed); updateReadyCheck(frame, frame.unit); @@ -209,6 +219,8 @@ local eventFuncs = { frame.buff1 = {}; frame.buff2 = {}; addon.SetAuras(frame.unit, frame.guid); + else + frame.prev = {}; end end, }; diff --git a/kehys/frame.lua b/kehys/frame.lua index 84a8c2d..4f1615f 100644 --- a/kehys/frame.lua +++ b/kehys/frame.lua @@ -57,6 +57,7 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes, f.buff1 = {}; -- custom buff indicator 1 f.buff2 = {}; -- custom buff indicator 2 f.incoming = {}; -- incoming ability indicator + f.raid = true; f.rounds = 0; -- set up periodic updates updaters[f] = function() diff --git a/kehys/player.lua b/kehys/player.lua index 20f4c4a..08ea8fe 100644 --- a/kehys/player.lua +++ b/kehys/player.lua @@ -37,7 +37,6 @@ local function initPlayer(parent, width, height, update, event) f.unit = "player"; f.displayed = "player"; f.vehicle = "vehicle" - f.nonraid = true; f.prev = {}; playerUpdate = function() @@ -63,7 +62,7 @@ local function initPlayer(parent, width, height, update, event) f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT"); f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8); f.health:SetTexture(barTexture); - f.health:SetVertexColor(0.8, 0.8, 0.8); + f.health:SetVertexColor(0.7, 0.7, 0.7); f.health:Hide(); f.mana = f:CreateTexture(nil, "BORDER"); f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8); @@ -142,7 +141,6 @@ local function initPet(parent, width, height, update, event) f.unit = "pet"; f.displayed = "pet"; f.vehicle = "player" - f.nonraid = true; f.prev = {}; petUpdate = function() @@ -169,7 +167,7 @@ local function initPet(parent, width, height, update, event) f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT"); f.health:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT"); f.health:SetTexture(barTexture); - f.health:SetVertexColor(0.8, 0.8, 0.8); + f.health:SetVertexColor(0.7, 0.7, 0.7); f.health:Hide(); f.shield = f:CreateTexture(nil, "BORDER"); f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT"); diff --git a/kehys/target.lua b/kehys/target.lua index 342743b..9b98d94 100644 --- a/kehys/target.lua +++ b/kehys/target.lua @@ -20,7 +20,7 @@ local function initTarget(parent, width, height, update, event) local f = CreateFrame("Button", "kehysTarget", parent, "SecureUnitButtonTemplate,SecureHandlerStateTemplate"); f:Hide(); - f:SetPoint("CENTER", parent, "CENTER", 300, -178); + f:SetPoint("CENTER", parent, "CENTER", 290, -178); f:SetWidth(width); f:SetHeight(height); f.barwidth = width - 2; -- 1px padding @@ -28,7 +28,6 @@ local function initTarget(parent, width, height, update, event) f:SetAttribute("displayed", "target"); f.unit = "target"; f.displayed = "target"; - f.nonraid = true; f.prev = {}; targetUpdate = function() @@ -36,6 +35,8 @@ local function initTarget(parent, width, height, update, event) update(f); end f:SetScript("OnEvent", event); + f:SetScript("OnHide", function (frame) frame.prev = {} end); + f:SetScript("OnShow", function (frame) update(frame) end); f:RegisterForClicks("AnyDown"); f:SetAttribute("*type1", "target"); f:SetAttribute("*type2", "togglemenu"); @@ -53,7 +54,7 @@ local function initTarget(parent, width, height, update, event) f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT"); f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8); f.health:SetTexture(barTexture); - f.health:SetVertexColor(0.8, 0.8, 0.8); + f.health:SetVertexColor(0.7, 0.7, 0.7); f.health:Hide(); f.mana = f:CreateTexture(nil, "BORDER"); f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8); diff --git a/kehys/updater.lua b/kehys/updater.lua index 9a673ae..3690953 100644 --- a/kehys/updater.lua +++ b/kehys/updater.lua @@ -27,9 +27,14 @@ local ignoredAuras = { local powerColors = { [Enum.PowerType.Mana] = {0.1, 0.5, 0.9}, [Enum.PowerType.Rage] = {1, 0, 0}, + [Enum.PowerType.Pain] = {1, 0, 0}, [Enum.PowerType.Focus] = {1, 0.5, 0}, [Enum.PowerType.Energy] = {1, 0.8, 0}, + [Enum.PowerType.Fury] = {0.8, 0.3, 0.9}, [Enum.PowerType.RunicPower] = {0.8, 0, 0.2}, + [Enum.PowerType.LunarPower] = {0.3, 0.5, 0.9}, + [Enum.PowerType.Maelstrom] = {0, 0.5, 1}, + [Enum.PowerType.Insanity] = {0.4, 0, 0.8}, }; function addon.FrameUpdate(frame) @@ -78,11 +83,11 @@ function addon.FrameUpdate(frame) if not frame.text:IsShown() then frame.text:Show() end else frame.text.status = false; - if not (frame.nonraid and frame.unit == "target") and frame.text:IsShown() then + if (frame.raid or frame.unit ~= "target") and frame.text:IsShown() then frame.text:Hide(); end end - if frame.nonraid and frame.unit == "player" then + if not frame.raid and frame.unit == "player" then if InCombatLockdown() then frame.status:SetTexCoord(0.5, 1, 0, 0.484375); frame.status:Show(); @@ -93,11 +98,11 @@ function addon.FrameUpdate(frame) frame.status:Hide(); end end - -- TODO incoming res, maybe just with events? -- health local current, hmax = UnitHealth(unit), UnitHealthMax(unit); if frame.prev.health ~= current or frame.prev.hmax ~= hmax then - if frame.nonraid and frame.unit == "target" and frame.prev.htext ~= current then + if not frame.raid and frame.unit == "target" and not frame.text.status + and frame.prev.htext ~= current then frame.prev.htext = current; if current > 1000000000 then -- 1.0B frame.text:SetFormattedText("%.2fB", current / 1000000000); @@ -205,7 +210,7 @@ function addon.FrameUpdate(frame) frame.rounds = 0; end end - if not frame.nonraid then + if frame.raid then -- tank CD marker if next(frame.tankcd) then if not frame.defensive:IsShown() then frame.defensive:Show() end -- 2.39.5