Skip to content

Commit

Permalink
Add a ReadyCheck element which mostly uses Blizzard's functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
haste committed Oct 3, 2010
1 parent 18d9d58 commit d3e885b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions elements/readycheck.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
local parent, ns = ...
local oUF = ns.oUF

local Update = function(self, event)
local unit = self.unit
local readyCheck = self.ReadyCheck

if(event == 'READY_CHECK_FINISHED') then
if(GetPartyMember(self:GetID())) then
ReadyCheck_Finish(readyCheck)
end
else
local status = GetReadyCheckStatus(unit)
if(UnitExists(unit) and UnitIsConnected(unit) and status) then
if(status == 'ready') then
ReadyCheck_Confirm(readyCheck, 1)
elseif(status == 'notready') then
ReadyCheck_Confirm(readyCheck, 0)
else
ReadyCheck_Start(readyCheck)
end
else
readyCheck:Hide()
end
end
end

local Path = function(self, ...)
return (self.ReadyCheck.Override or Update) (self, ...)
end

local ForceUpdate = function(element)
return Path(element.__owner, 'ForceUpdate')
end

local Enable = function(self, unit)
local readyCheck = self.ReadyCheck
if(readyCheck) then
readyCheck.__owner = self
readyCheck.ForceUpdate = ForceUpdate

self:RegisterEvent('READY_CHECK', Path)
self:RegisterEvent('READY_CHECK_CONFIRM', Path)
self:RegisterEvent('READY_CHECK_FINISHED', Path)

return true
end
end

local Disable = function(self)
local readyCheck = self.ReadyCheck
if(readyCheck) then
self:UnregisterEvent('READY_CHECK', Path)
self:UnregisterEvent('READY_CHECK_CONFIRM', Path)
self:UnregisterEvent('READY_CHECK_FINISHED', Path)
end
end

oUF:AddElement('ReadyCheck', Path, Enable, Disable)
1 change: 1 addition & 0 deletions oUF.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Script file='elements\holypower.lua' />
<Script file='elements\soulshards.lua' />
<Script file='elements\picon.lua' />
<Script file='elements\readycheck.lua' />

<!--
This template requires the layout to set the anchoring positions from the
Expand Down

0 comments on commit d3e885b

Please sign in to comment.