PHP код:
local addon, ns = ...
local event = CreateFrame'frame'
local sight = CreateFrame('statusbar', nil, UIParent)
sight:SetSize(120, 20)
sight:SetPoint("CENTER", UIParent, 100, -100)
local OnArenaUpdate = function(self)
local curTime = GetTime()
if self.OnArena then
local inArena = curTime - self.enterTime
if curTime - self.sightSwichTimmer > 90 then
self.sightSwichTimmer = GetTime()
else
sight:SetValue(curTime - self.sightSwichTimmer)
end
end
return OnWorldUpdate(self, elapsed, curTime)
-- print(curTime - self.enterTime)
end
function event:UPDATE_BATTLEFIELD_SCORE(event, ...)
self.sightSwichTimmer = GetTime()
sight:Show()
self:SetScript("OnUpdate", OnArenaUpdate)
self:UnregisterEvent("UPDATE_BATTLEFIELD_SCORE")
end
do
local instanceType
function event:PLAYER_ENTERING_WORLD()
local type = select(2, IsInInstance())
if (type == "arena")
self.OnArena = true
self:RegisterEvent("UPDATE_BATTLEFIELD_SCORE")
elseif (type ~= "arena" and instanceType == "arena") then
self:SetScript("OnUpdate", OnWorldUpdate)
self:UnregisterEvent("UPDATE_BATTLEFIELD_SCORE")
self.OnArena = nil
sight:Hide()
end
instanceType = type
end
end
event:SetScript("OnEvent", function(self, event, ...)
return self[event](self, event, ...)
end)
event:SetScript("OnUpdate", OnWorldUpdate)
event:RegisterEvent("PLAYER_ENTERING_WORLD")
sight.icon = sight:CreateTexture(nil, "BORDER")
sight.icon:SetSize(sight:GetHeight(), sight:GetHeight())
sight.icon:SetPoint("RIGHT", sight, "LEFT", 0, 0)
sight.icon:SetTexture(select(3, GetSpellInfo(34709)))
sight.backdrop = sight:CreateTexture(nil, "BACKGROUND")
sight.backdrop:SetAllPoints()
sight.backdrop:SetTexture(0, 0, 0)
sight:SetStatusBarTexture()
sight:SetMinMaxValues(0, 60)
sight:SetStatusBarColor(0, .33, .66)
sight.text = sight:CreateFontString(nil, "ARTWORK")
sight.text:SetFont("Fonts/FRIZQT__.ttf", 12)
sight.text:SetPoint("CENTER")
sight.text:SetText(select(1, GetSpellInfo(34709)))
sight:Hide()
-- event:UPDATE_BATTLEFIELD_SCORE()