第一次发版v0.1.0

This commit is contained in:
rucky
2026-03-20 10:20:05 +08:00
commit 017e37a365
17 changed files with 6166 additions and 0 deletions

63
Scanner.lua Normal file
View File

@@ -0,0 +1,63 @@
NanamiPlates_Scanner = {}
local initializedChildren = 0
local cachedWorldChildren = {}
local function CheckRegionForBorder(r)
if r and r.GetObjectType and r:GetObjectType() == "Texture" and r.GetTexture then
return r:GetTexture() == "Interface\\Tooltips\\Nameplate-Border"
end
return false
end
function NanamiPlates_Scanner.IsNamePlate(frame)
if not frame then return nil end
local objType = frame:GetObjectType()
if objType ~= "Frame" and objType ~= "Button" then return nil end
local r1, r2, r3, r4, r5, r6 = frame:GetRegions()
if CheckRegionForBorder(r1) then return true end
if CheckRegionForBorder(r2) then return true end
if CheckRegionForBorder(r3) then return true end
if CheckRegionForBorder(r4) then return true end
if CheckRegionForBorder(r5) then return true end
if CheckRegionForBorder(r6) then return true end
return nil
end
function NanamiPlates_Scanner.ScanForNewNameplates(registry, callback)
local parentcount = WorldFrame:GetNumChildren()
if initializedChildren >= parentcount then
return false
end
cachedWorldChildren = { WorldFrame:GetChildren() }
local foundNew = false
for i = initializedChildren + 1, parentcount do
local plate = cachedWorldChildren[i]
if plate and not registry[plate] then
if NanamiPlates_Scanner.IsNamePlate(plate) then
callback(plate)
foundNew = true
end
end
end
initializedChildren = parentcount
return foundNew
end
function NanamiPlates_Scanner.Reset()
initializedChildren = 0
for k in pairs(cachedWorldChildren) do
cachedWorldChildren[k] = nil
end
end
function NanamiPlates_Scanner.GetInitializedCount()
return initializedChildren
end
NanamiPlates.Scanner = NanamiPlates_Scanner