PHP код:
local function healthbar_valuechanged_cb(self,value)
self.text:SetText(value)
end
local function healthbar_show_cb(self)
self.text:SetText(self:GetValue())
end
local function nameplate_update_cb(self)
self:SetAlpha(1)
end
local function InitNamePlate(frame)
local healthbar = frame:GetChildren()
healthbar.text = healthbar:CreateFontString(nil,"ARTWORK")
healthbar.text:SetFont("Fonts\\FRIZQT__.TTF",11,"OUTLINE")
healthbar.text:SetPoint("CENTER")
healthbar_show_cb(healthbar)
healthbar:SetScript("OnValueChanged",healthbar_valuechanged_cb)
healthbar:SetScript("OnShow",healthbar_show_cb)
frame:SetScript("OnUpdate",nameplate_update_cb)
end
local function IdentifyFrame(self)
if self:GetName() then return end
if self.GetRegions then
local region = self:GetRegions()
if region.GetTexture then
local texturePath = region:GetTexture()
if texturePath == "Interface\\TargetingFrame\\UI-TargetingFrame-Flash" then
return "NamePlate"
elseif texturePath == "Interface\\Tooltips\\ChatBubble-Background" then
return "ChatBubble"
end
end
end
end
local function iterateChildrens(object,...)
if not object then return end
local type = IdentifyFrame(object)
if type == "NamePlate" then
InitNamePlate(object)
elseif type == "ChatBubble" then
--InitChatBubble(object)
end
return iterateChildrens(...)
end
local select,WorldFrame = select,WorldFrame
local lastWorldFrameChildsCount = 0
CreateFrame("frame"):SetScript("OnUpdate",function()
local worldFrameChildsCount = WorldFrame:GetNumChildren()
if worldFrameChildsCount ~= lastWorldFrameChildsCount then
iterateChildrens(select(lastWorldFrameChildsCount+1,WorldFrame:GetChildren()))
lastWorldFrameChildsCount = worldFrameChildsCount
end
end)