refactor of iteration for WorldFrame child frames

This commit is contained in:
Bunny67
2020-07-05 01:08:06 +03:00
parent 1d0aeb765b
commit ef8d4a658a
+16 -10
View File
@@ -3184,7 +3184,8 @@ do
local WorldGetChildren = WorldFrame.GetChildren local WorldGetChildren = WorldFrame.GetChildren
local WorldGetNumChildren = WorldFrame.GetNumChildren local WorldGetNumChildren = WorldFrame.GetNumChildren
local numChildren = 0 local lastUpdate = 0
local lastChildern, numChildren = 0, 0
local nameplateList = {} local nameplateList = {}
local visibleNameplates = {} local visibleNameplates = {}
@@ -3206,10 +3207,9 @@ do
WeakAuras.StopProfileSystem("nameplatetrigger") WeakAuras.StopProfileSystem("nameplatetrigger")
end end
local function findNewPlate(num) function findNewPlate(...)
if num == numChildren then return end for i = lastChildern + 1, numChildren do
for i = numChildren + 1, num do local frame = select(i, ...)
local frame = select(i, WorldGetChildren(WorldFrame))
local region, _, _, _, _, _, nameText = frame:GetRegions() local region, _, _, _, _, _, nameText = frame:GetRegions()
if (frame.UnitFrame or (region and region:GetObjectType() == "Texture" and region:GetTexture() == OVERLAY)) and not nameplateList[frame] then if (frame.UnitFrame or (region and region:GetObjectType() == "Texture" and region:GetTexture() == OVERLAY)) and not nameplateList[frame] then
frame.nameText = nameText frame.nameText = nameText
@@ -3218,13 +3218,19 @@ do
nameplateShow(frame) nameplateShow(frame)
end end
end end
numChildren = num
end end
local function nameplatesUpdate() function nameplatesUpdate(_, elaps)
WeakAuras.StartProfileSystem("nameplatetrigger") lastUpdate = lastUpdate + elaps
findNewPlate(WorldGetNumChildren(WorldFrame)) if lastUpdate < 1 then return end
WeakAuras.StopProfileSystem("nameplatetrigger") numChildren = WorldGetNumChildren(WorldFrame)
if lastChildern ~= numChildren then
WeakAuras.StartProfileSystem("nameplatetrigger")
findNewPlate(WorldGetChildren(WorldFrame))
WeakAuras.StopProfileSystem("nameplatetrigger")
lastChildern = numChildren
end
lastUpdate = 0
end end
function WeakAuras.GetUnitNameplate(name) function WeakAuras.GetUnitNameplate(name)