From ab3d853f02a76100cbaa47f63e84f01e2a5624ee Mon Sep 17 00:00:00 2001 From: shagu Date: Mon, 18 Jan 2021 16:15:45 +0100 Subject: [PATCH] unitframes: add support for focus target frames --- api/config.lua | 12 +++++++++++- api/unitframes.lua | 19 ++++++++++++++----- modules/focus.lua | 6 ++++++ modules/gui.lua | 9 +++++---- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/api/config.lua b/api/config.lua index b2aa5916..2646b512 100644 --- a/api/config.lua +++ b/api/config.lua @@ -247,6 +247,16 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "focus", "buffsize", "12") pfUI:UpdateConfig("unitframes", "focus", "debuffsize", "12") + pfUI:UpdateConfig("unitframes", "focustarget", "visible", "0") + pfUI:UpdateConfig("unitframes", "focustarget", "width", "80") + pfUI:UpdateConfig("unitframes", "focustarget", "height", "12") + pfUI:UpdateConfig("unitframes", "focustarget", "pheight", "-1") + pfUI:UpdateConfig("unitframes", "focustarget", "buffs", "off") + pfUI:UpdateConfig("unitframes", "focustarget", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "focustarget", "txthpleft", "none") + pfUI:UpdateConfig("unitframes", "focustarget", "txthpcenter", "name") + pfUI:UpdateConfig("unitframes", "focustarget", "txthpright", "none") + pfUI:UpdateConfig("unitframes", "group", "portrait", "off") pfUI:UpdateConfig("unitframes", "group", "width", "164") pfUI:UpdateConfig("unitframes", "group", "height", "32") @@ -357,7 +367,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "ptarget", "txthpright", "none") pfUI:UpdateConfig("unitframes", "ptarget", "overhealperc", "10") - local ufs = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback", "tttarget" } + local ufs = { "player", "target", "focus", "focustarget", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback", "tttarget" } for _, unit in pairs(ufs) do pfUI:UpdateConfig("unitframes", unit, "visible", "1") pfUI:UpdateConfig("unitframes", unit, "showPVP", "0") diff --git a/api/unitframes.lua b/api/unitframes.lua index fa6dfbe0..ce3efba8 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -295,7 +295,7 @@ function pfUI.uf:UpdateVisibility() end -- vanilla visibility - if self.unitname and self.unitname ~= "focus" then + if self.unitname and self.unitname ~= "focus" and self.unitname ~= "focustarget" then self:Show() elseif visibility == "hide" then self:Hide() @@ -840,14 +840,23 @@ function pfUI.uf.OnUpdate() this.fullupdate = nil end - -- early return on unset focus frames - if this.unitname then + if this == pfFocus then -- handle pseudo focus frames local unitname = ( this.label and UnitName(this.label) ) or "" - if this.unitname == "focus" then - return + if pfFocusTarget then -- update focus target + pfFocusTarget.label = this.label and this.label .. "target" or nil + local focustargetname = pfFocusTarget.label and UnitName(pfFocusTarget.label) or nil + + if pfFocusTarget.lastUnit ~= focustargetname then + pfFocusTarget.lastUnit = focustargetname + pfFocusTarget.instantRefresh = true + pfUI.uf:RefreshUnit(pfFocusTarget, "all") + end end + -- break here on unset focus frames + if not this.unitname or this.unitname == "focus" then return end + -- focus unit detection if this.unitname ~= strlower(unitname) then -- invalid focus frame diff --git a/modules/focus.lua b/modules/focus.lua index 984ea21e..e4b9f1b4 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -7,6 +7,12 @@ pfUI:RegisterModule("focus", "vanilla:tbc", function () pfUI.uf.focus:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 220, 220) UpdateMovable(pfUI.uf.focus) pfUI.uf.focus:Hide() + + pfUI.uf.focustarget = pfUI.uf:CreateUnitFrame("FocusTarget", nil, C.unitframes.focustarget, .2) + pfUI.uf.focustarget:UpdateFrameSize() + pfUI.uf.focustarget:SetPoint("BOTTOMLEFT", pfUI.uf.focus, "TOP", 0, 10) + UpdateMovable(pfUI.uf.focustarget) + pfUI.uf.focustarget:Hide() end) -- register focus emulation commands for vanilla diff --git a/modules/gui.lua b/modules/gui.lua index 67fdefb6..a8ec6211 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1595,10 +1595,11 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () [5] = { "pet", T["Pet"] }, [6] = { "ptarget", T["Pet-Target"]}, [7] = { "focus", T["Focus"] }, - [8] = { "group", T["Group"] }, - [9] = { "grouptarget", T["Group-Target"]}, - [10] = { "grouppet", T["Group-Pet"] }, - [11] = { "raid", T["Raid"] }, + [8] = { "focustarget", T["Focus-Target"] }, + [9] = { "group", T["Group"] }, + [10] = { "grouptarget", T["Group-Target"]}, + [11] = { "grouppet", T["Group-Pet"] }, + [12] = { "raid", T["Raid"] }, } CreateGUIEntry(T["Unit Frames"], T["Click Casting"], function()