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
-14
View File
@@ -59,20 +59,6 @@ function pfUI.api.GetUnitDistance(unit1, unit2)
return nil
end
-- [ UnitInLineOfSight ]
-- Returns true if unit1 has line of sight to unit2
-- Requires UnitXP_SP3
function pfUI.api.UnitInLineOfSight(unit1, unit2)
if not pfUI.api.HasUnitXP() then return nil end
if not unit2 then
unit2 = unit1
unit1 = "player"
end
local success, inSight = pcall(UnitXP, "inSight", unit1, unit2)
if success then return inSight end
return nil
end
-- [ UnitIsBehind ]
-- Returns true if unit1 is behind unit2
-- Requires UnitXP_SP3
+4 -2
View File
@@ -286,9 +286,11 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", nil, "reactive_size", "28")
pfUI:UpdateConfig("unitframes", nil, "damage_tracking", "0")
-- UnitXP Settings
pfUI:UpdateConfig("unitframes", nil, "unitxp_font_size", "13")
-- Target Indicators
pfUI:UpdateConfig("unitframes", nil, "indicator_font_size", "13")
pfUI:UpdateConfig("unitframes", nil, "los_indicator", "0")
-- UnitXP Settings
pfUI:UpdateConfig("unitframes", nil, "behind_indicator", "0")
pfUI:UpdateConfig("unitframes", nil, "hide_distance_yd", "0")
pfUI:UpdateConfig("unitframes", nil, "unitxp_notify", "0")
+4 -2
View File
@@ -2134,6 +2134,10 @@ pfUI:RegisterModule("gui", function ()
CreateConfig(nil, T["Druid Mana Bar Texture"], C.unitframes, "druidmanatexture", "dropdown", pfUI.gui.dropdowns.uf_bartexture, nil, nil, nil)
CreateConfig(nil, T["Target Indicators"], nil, nil, "header")
CreateConfig(nil, T["Target Indicator Font Size"], C.unitframes, "indicator_font_size", nil, nil, nil, nil, nil)
CreateConfig(nil, T["Show Line of Sight Indicator"], C.unitframes, "los_indicator", "checkbox", nil, nil, nil, nil)
CreateConfig(nil, T["SuperWoW Settings"], nil, nil, "header")
CreateConfig(nil, T["Track Group on Minimap"], C.unitframes, "track_group", "checkbox", nil, nil, nil, nil)
@@ -2144,8 +2148,6 @@ pfUI:RegisterModule("gui", function ()
CreateConfig(nil, T["Reactive Indicator Size"], C.unitframes, "reactive_size", nil, nil, nil, nil, nil)
CreateConfig(nil, T["UnitXP Settings"], nil, nil, "header")
CreateConfig(nil, T["Font Size for all UnitXP texts"], C.unitframes, "unitxp_font_size", nil, nil, nil, nil, nil)
CreateConfig(nil, T["Show Line of Sight Indicator"], C.unitframes, "los_indicator", "checkbox", nil, nil, nil, nil)
CreateConfig(nil, T["Show Behind Indicator"], C.unitframes, "behind_indicator", "checkbox", nil, nil, nil, nil)
CreateConfig(nil, T["Show Distance of Target"], C.unitframes, "distance_indicator", "checkbox", nil, nil, nil, nil)
CreateConfig(nil, T["Hide yd characters"], C.unitframes, "hide_distance_yd", "checkbox", nil, nil, nil, nil)
+23
View File
@@ -10,4 +10,27 @@ pfUI:RegisterModule("target", function ()
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)
+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