Skip to content
This repository
Browse code

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

  • Loading branch information...
commit d3e885bbdaa5c8b74a903401a74f45353a4aad25 1 parent 18d9d58
Trond A Ekseth authored October 03, 2010
59  elements/readycheck.lua
... ...
@@ -0,0 +1,59 @@
  1
+local parent, ns = ...
  2
+local oUF = ns.oUF
  3
+
  4
+local Update = function(self, event)
  5
+	local unit = self.unit
  6
+	local readyCheck = self.ReadyCheck
  7
+
  8
+	if(event == 'READY_CHECK_FINISHED') then
  9
+		if(GetPartyMember(self:GetID())) then
  10
+			ReadyCheck_Finish(readyCheck)
  11
+		end
  12
+	else
  13
+		local status = GetReadyCheckStatus(unit)
  14
+		if(UnitExists(unit) and UnitIsConnected(unit) and status) then
  15
+			if(status == 'ready') then
  16
+				ReadyCheck_Confirm(readyCheck, 1)
  17
+			elseif(status == 'notready') then
  18
+				ReadyCheck_Confirm(readyCheck, 0)
  19
+			else
  20
+				ReadyCheck_Start(readyCheck)
  21
+			end
  22
+		else
  23
+			readyCheck:Hide()
  24
+		end
  25
+	end
  26
+end
  27
+
  28
+local Path = function(self, ...)
  29
+	return (self.ReadyCheck.Override or Update) (self, ...)
  30
+end
  31
+
  32
+local ForceUpdate = function(element)
  33
+	return Path(element.__owner, 'ForceUpdate')
  34
+end
  35
+
  36
+local Enable = function(self, unit)
  37
+	local readyCheck = self.ReadyCheck
  38
+	if(readyCheck) then
  39
+		readyCheck.__owner = self
  40
+		readyCheck.ForceUpdate = ForceUpdate
  41
+
  42
+		self:RegisterEvent('READY_CHECK', Path)
  43
+		self:RegisterEvent('READY_CHECK_CONFIRM', Path)
  44
+		self:RegisterEvent('READY_CHECK_FINISHED', Path)
  45
+
  46
+		return true
  47
+	end
  48
+end
  49
+
  50
+local Disable = function(self)
  51
+	local readyCheck = self.ReadyCheck
  52
+	if(readyCheck) then
  53
+		self:UnregisterEvent('READY_CHECK', Path)
  54
+		self:UnregisterEvent('READY_CHECK_CONFIRM', Path)
  55
+		self:UnregisterEvent('READY_CHECK_FINISHED', Path)
  56
+	end
  57
+end
  58
+
  59
+oUF:AddElement('ReadyCheck', Path, Enable, Disable)
1  oUF.xml
@@ -25,6 +25,7 @@
25 25
 	<Script file='elements\holypower.lua' />
26 26
 	<Script file='elements\soulshards.lua' />
27 27
 	<Script file='elements\picon.lua' />
  28
+	<Script file='elements\readycheck.lua' />
28 29
 
29 30
 	<!--
30 31
 		This template requires the layout to set the anchoring positions from the

0 notes on commit d3e885b

Please sign in to comment.
Something went wrong with that request. Please try again.