nameplates: increase scan performance

This commit is contained in:
shagu
2017-05-28 20:28:51 +02:00
parent 83bb05f616
commit 848c20e26c
+16 -9
View File
@@ -5,16 +5,23 @@ pfUI:RegisterModule("nameplates", function ()
-- catch all nameplates
pfUI.nameplates.scanner = CreateFrame("Frame", "pfNameplateScanner", UIParent)
pfUI.nameplates.scanner.parentCount = 0
pfUI.nameplates.scanner:SetScript("OnUpdate", function()
for _, nameplate in ipairs({WorldFrame:GetChildren()}) do
if not nameplate.done and nameplate:GetObjectType() == "Button" then
local regions = nameplate:GetRegions()
if regions and regions:GetObjectType() == "Texture" and regions:GetTexture() == "Interface\\Tooltips\\Nameplate-Border" then
nameplate:Hide()
nameplate:SetScript("OnShow", function() pfUI.nameplates:CreateNameplate() end)
nameplate:SetScript("OnUpdate", function() pfUI.nameplates:UpdateNameplate() end)
nameplate:Show()
nameplate.done = true
local parentCount = WorldFrame:GetNumChildren()
if pfUI.nameplates.scanner.parentCount < parentCount then
pfUI.nameplates.scanner.parentCount = parentCount
for _, nameplate in ipairs({WorldFrame:GetChildren()}) do
if not nameplate.done and nameplate:GetObjectType() == "Button" then
local regions = nameplate:GetRegions()
if regions and regions:GetObjectType() == "Texture" and regions:GetTexture() == "Interface\\Tooltips\\Nameplate-Border" then
nameplate:Hide()
nameplate:SetScript("OnShow", pfUI.nameplates.CreateNameplate)
nameplate:SetScript("OnUpdate", pfUI.nameplates.UpdateNameplate)
nameplate:Show()
nameplate.done = true
end
end
end
end