Files
pfUI/modules/target.lua
T
Brues 3b64bfa98b Show the target LoS indicator through ClassicAPI's UnitInLineOfSight
The indicator moves from the unitxp module to the target frame, so it no
longer needs UnitXP_SP3. Its checkbox and the shared font size move to a
Target Indicators header; unitxp_font_size becomes indicator_font_size.
The unused pfUI.api.UnitInLineOfSight wrapper, which shadowed the
ClassicAPI global inside the pfUI environment, is removed.
2026-10-31 15:41:15 -05:00

37 lines
1.4 KiB
Lua

pfUI:RegisterModule("target", function ()
-- do not go further on disabled UFs
if C.unitframes.disable == "1" then return end
-- Hide Blizzard target frame and unregister all events to prevent it from popping up again
TargetFrame:Hide()
TargetFrame:UnregisterAllEvents()
pfUI.uf.target = pfUI.uf:CreateUnitFrame("Target", nil, C.unitframes.target)
pfUI.uf.target:UpdateFrameSize()
pfUI.uf.target:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 75, 125)
UpdateMovable(pfUI.uf.target)
-- "NO LOS" in the bottom third of the frame, below unitxp's behind indicator
if C.unitframes.los_indicator == "1" then
local los = CreateFrame("Frame", "pfLoSIndicator", pfUI.uf.target)
los:SetAllPoints(pfUI.uf.target)
los:SetFrameLevel(pfUI.uf.target:GetFrameLevel() + 10)
los.text = los:CreateFontString(nil, "OVERLAY")
los.text:SetFont(pfUI.font_default, tonumber(C.unitframes.indicator_font_size) or (C.global.font_size + 2), "OUTLINE")
los.text:SetPoint("RIGHT", los, "RIGHT", -1, -pfUI.uf.target:GetHeight() / 3)
los.text:SetTextColor(1, 0.3, 0.3, 1)
los.text:SetText(T["NO LOS"])
los.text:Hide()
local lastCheck = 0
los:SetScript("OnUpdate", function()
if GetTime() - lastCheck < 0.2 then return end
lastCheck = GetTime()
-- nil without a target
this.text:SetShown(UnitInLineOfSight("target") == false)
end)
end
end)