Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a ReadyCheck element which mostly uses Blizzard's functions.

  • Loading branch information...
commit d3e885bbdaa5c8b74a903401a74f45353a4aad25 1 parent 18d9d58
@haste authored
Showing with 60 additions and 0 deletions.
  1. +59 −0 elements/readycheck.lua
  2. +1 −0  oUF.xml
View
59 elements/readycheck.lua
@@ -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)
View
1  oUF.xml
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.