Minimap - Show Who Pinged - fix

Adjusted position, fixed hiding frame
This commit is contained in:
Sattva
2024-12-31 23:05:28 +03:00
parent 3c2b80e7ac
commit 9e755a3cd2
+12 -15
View File
@@ -4758,9 +4758,9 @@ function LeaPlusLC:Player()
-- Set position -- Set position
if LeaPlusLC["SquareMinimap"] == "On" then if LeaPlusLC["SquareMinimap"] == "On" then
pFrame:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 0, -3) pFrame:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 0, -3) -- Move to the left
else else
pFrame:SetPoint("BOTTOM", Minimap, "BOTTOM", 0, 2) pFrame:SetPoint("BOTTOM", Minimap, "BOTTOM", -50, 2) -- Slightly offset to the left
end end
-- Set backdrop -- Set backdrop
@@ -4786,37 +4786,34 @@ function LeaPlusLC:Player()
local lastUnit, lastX, lastY = "player", 0, 0 local lastUnit, lastX, lastY = "player", 0, 0
-- Show who pinged -- Show who pinged
pFrame:SetScript("OnEvent", function(void, void, unit, x, y) pFrame:SetScript("OnEvent", function(_, _, unit, x, y)
-- Ignore if the ping is from the player or the same unit at the same location
-- Do nothing if unit has not changed if UnitIsUnit(unit, "player") or (UnitIsUnit(unit, lastUnit) and x == lastX and y == lastY) then
if UnitIsUnit(unit, "player") or UnitIsUnit(unit, lastUnit) and x == lastX and y == lastY then
return return
end end
-- if UnitIsUnit(unit, lastUnit) and x == lastX and y == lastY then print("end") return end
lastUnit, lastX, lastY = unit, x, y lastUnit, lastX, lastY = unit, x, y
-- Show name in class color -- Show name in class color
local void, class = UnitClass(unit) local _, class = UnitClass(unit)
if class then if class then
local color = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class] local color = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
if color then if color then
-- Set frame details -- Set frame details
pFrame.f:SetFormattedText("|cff%02x%02x%02x%s|r", color.r * 255, color.g * 255, color.b * 255, UnitName(unit)) pFrame.f:SetFormattedText("|cff%02x%02x%02x%s|r", color.r * 255, color.g * 255, color.b * 255, UnitName(unit))
pFrame:SetSize(pFrame.f:GetStringWidth() + 12, 20) pFrame:SetSize(pFrame.f:GetStringWidth() + 12, 20)
-- Hide frame after 5 seconds -- Show frame
pFrame:Show() pFrame:Show()
pingTime = GetTime()
LibCompat.After(5, function() -- Hide frame after 3 second
if GetTime() - pingTime >= 5 then LibCompat.After(3, function()
-- Only hide if the last ping matches the current state
if UnitIsUnit(unit, lastUnit) and x == lastX and y == lastY then
pFrame:Hide() pFrame:Hide()
end end
end) end)
end end
end end
end) end)
-- Set event when option is clicked and on startup -- Set event when option is clicked and on startup