Quantcast

Resurrection status icon

F. Dekker [10-31-14 - 17:13]
Resurrection status icon
Filename
PerfectRaid.toc
PerfectRaid_Resurrection.lua
diff --git a/PerfectRaid.toc b/PerfectRaid.toc
index 33a2238..b36bfb5 100644
--- a/PerfectRaid.toc
+++ b/PerfectRaid.toc
@@ -1,4 +1,4 @@
-## Interface: 50001
+## Interface: 60000
 ## Title: PerfectRaid
 ## Version: @project-version@
 ## Author: Cladhaire
@@ -28,3 +28,4 @@ PerfectRaid_Range.lua
 PerfectRaid_Highlight.lua
 PerfectRaid_Config.lua
 PerfectRaid_RaidIcons.lua
+PerfectRaid_Resurrection.lua
diff --git a/PerfectRaid_Resurrection.lua b/PerfectRaid_Resurrection.lua
new file mode 100644
index 0000000..e4d6035
--- /dev/null
+++ b/PerfectRaid_Resurrection.lua
@@ -0,0 +1,76 @@
+--[[-------------------------------------------------------------------------
+  *
+  * RaidIcons module for PerfectRaid addon.
+  *
+  * Written by: Panoramix
+  * Version: 1.0
+  *
+---------------------------------------------------------------------------]]
+
+local Resurrection = PerfectRaid:NewModule("PerfectRaid-Resurrection")
+local L = PerfectRaidLocals
+local utils, frames
+
+function Resurrection:Initialize()
+	frames = PerfectRaid.frames
+	utils = PerfectRaid.utils
+end
+
+-- Update Raid Icons when addon is enabled
+function Resurrection:Enable()
+	self:ShowResurrection()
+end
+
+-- Show/Hide raid icons depending on value
+function Resurrection:ShowResurrection(value)
+	self:RegisterEvent("INCOMING_RESURRECT_CHANGED", "UpdateAllUnits")
+	self:RegisterEvent("UNIT_OTHER_PARTY_CHANGED", "UpdateAllUnits")
+	self:RegisterMessage("PERFECTRAID_FRAME_LAYOUT_CHANGED", "UpdateAllUnits")
+	self:UpdateAllUnits()
+end
+
+-- Request full update for all units
+function Resurrection:FullUpdate()
+	self:UpdateAllUnits()
+end
+
+function Resurrection:UpdateAllUnits()
+
+    for unit, tbl in pairs(frames) do
+
+		local resurrecting = UnitHasIncomingResurrection(unit)
+
+		if (resurrecting and frames and frames[unit]) then
+
+			for frame in pairs(frames[unit]) do
+				-- create indicator and texture
+				if (not frame.resurrect) then
+					frame.resurrect = CreateFrame("Frame", nil, frame.healthbar)
+					frame.resurrect:SetHeight(frame:GetHeight())
+					frame.resurrect:SetWidth(frame:GetHeight( ))
+					frame.resurrect:SetFrameLevel(frame.leftbox:GetFrameLevel()+1)
+
+					frame.resurrecticon = frame.resurrect:CreateTexture(nil, "OVERLAY")
+					frame.resurrecticon:SetAllPoints()
+					frame.resurrecticon:SetTexture("Interface\\RaidFrame\\Raid-Icon-Rez")
+				end
+
+				-- resize the texture and show it
+				frame.resurrect:ClearAllPoints()
+				frame.resurrect:SetParent(frame.healthbar)
+				frame.resurrect:SetPoint("RIGHT", 0, 0)
+				frame.resurrect:Show()
+				frame.resurrecticon:Show()
+			end
+		end
+
+		-- unit doesn't have resurrection, hide it
+		if (not resurrecting and frames and frames[unit]) then
+			for frame in pairs(frames[unit]) do
+				if (frame.resurrecticon) then
+					frame.resurrecticon:Hide()
+				end
+			end
+		end
+	end
+end