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.
This commit is contained in:
Brues
2026-10-31 15:41:15 -05:00
parent 217b00e9a4
commit 3b64bfa98b
5 changed files with 34 additions and 65 deletions
+3 -47
View File
@@ -1,5 +1,5 @@
-- UnitXP_SP3 integration module
-- Provides Line of Sight indicator, OS notifications, and enhanced targeting
-- Provides behind and distance indicators, OS notifications, and enhanced targeting
-- Requires UnitXP_SP3 DLL: https://github.com/allfoxwy/UnitXP_SP3
pfUI:RegisterModule("unitxp", function ()
@@ -15,7 +15,7 @@ pfUI:RegisterModule("unitxp", function ()
local h = pfUI.uf.target:GetHeight() or 30
local slot = h / 3 -- divide frame into thirds
local fontSize = tonumber(C.unitframes.unitxp_font_size) or (C.global.font_size + 2)
local fontSize = tonumber(C.unitframes.indicator_font_size) or (C.global.font_size + 2)
local suffix = (C.unitframes.hide_distance_yd == "1") and "" or " yd"
-- Behind Indicator for all units (MIDDLE)
@@ -48,36 +48,6 @@ pfUI:RegisterModule("unitxp", function ()
pfUI.uf.target.behindIndicator = behindFrame
end
-- Line of Sight Indicator on Target Frame (BELOW BEHIND)
if C.unitframes.los_indicator == "1" and not pfUI.uf.target.losIndicator then
local losFrame = CreateFrame("Frame", "pfLoSIndicator", pfUI.uf.target)
losFrame:SetAllPoints(pfUI.uf.target)
losFrame:SetFrameLevel(pfUI.uf.target:GetFrameLevel() + 10)
losFrame.text = losFrame:CreateFontString(nil, "OVERLAY")
losFrame.text:SetFont(pfUI.font_default, fontSize, "OUTLINE")
losFrame.text:SetPoint("RIGHT", losFrame, "RIGHT", -1, -slot)
losFrame.text:SetTextColor(1, 0.3, 0.3, 1)
losFrame.text:SetText(T["NO LOS"])
losFrame.text:Hide()
local lastCheck = 0
losFrame:SetScript("OnUpdate", function()
if GetTime() - lastCheck < 0.2 then return end
lastCheck = GetTime()
if not UnitExists("target") then
this.text:Hide()
return
end
local success, inSight = pcall(UnitXP, "inSight", "player", "target")
this.text:SetShown(success and inSight == false)
end)
pfUI.uf.target.losIndicator = losFrame
end
-- Distance Indicator
if C.unitframes.distance_indicator == "1" and not pfUI.uf.target.distanceIndicator then
if C.unitframes.distance_hook_portrait == "1" then
@@ -185,9 +155,7 @@ pfUI:RegisterModule("unitxp", function ()
return
end
local successL, inSight = pcall(UnitXP, "inSight", "player", "target")
local alpha = (successL and inSight == false) and 0.5 or 1.0
f.text:SetAlpha(alpha)
f.text:SetAlpha(UnitInLineOfSight("target") == false and 0.5 or 1.0)
local r, g, b = 1.0, 0.2, 0.2
for i = 1, table.getn(thresholds) do
@@ -225,9 +193,6 @@ pfUI:RegisterModule("unitxp", function ()
if pfUI.uf.target.behindIndicator then
pfUI.uf.target.behindIndicator:SetScript("OnUpdate", nil)
end
if pfUI.uf.target.losIndicator then
pfUI.uf.target.losIndicator:SetScript("OnUpdate", nil)
end
if pfUI.uf.target.distanceIndicator then
pfUI.uf.target.distanceIndicator:SetScript("OnUpdate", nil)
end
@@ -337,10 +302,6 @@ pfUI:RegisterModule("unitxp", function ()
local successB, behind = pcall(UnitXP, "behind", "player", "target")
chat:AddMessage(" Behind check: success=" .. tostring(successB) .. " value=" .. tostring(behind) .. " type=" .. type(behind))
-- Test LOS
local successL, inSight = pcall(UnitXP, "inSight", "player", "target")
chat:AddMessage(" LOS check: success=" .. tostring(successL) .. " value=" .. tostring(inSight) .. " type=" .. type(inSight))
-- Check if indicator frames exist
if pfUI.uf and pfUI.uf.target then
chat:AddMessage(" Target frame: |cff00ff00exists|r")
@@ -349,11 +310,6 @@ pfUI:RegisterModule("unitxp", function ()
else
chat:AddMessage(" Behind indicator: |cffff0000NOT created|r (check settings)")
end
if pfUI.uf.target.losIndicator then
chat:AddMessage(" LOS indicator: |cff00ff00created|r")
else
chat:AddMessage(" LOS indicator: |cffff0000NOT created|r (check settings)")
end
else
chat:AddMessage(" Target frame: |cffff0000NOT found|r")
end