Quantcast

Handle the EclipseBar ourselves on WoD until oUF gets updated

Adrian L Lange [08-31-14 - 15:48]
Handle the EclipseBar ourselves on WoD until oUF gets updated
Filename
oUF_P3lim.lua
diff --git a/oUF_P3lim.lua b/oUF_P3lim.lua
index de8c156..c51b8e5 100644
--- a/oUF_P3lim.lua
+++ b/oUF_P3lim.lua
@@ -87,6 +87,40 @@ local function PostUpdateResurrect(element)
 	end
 end

+local function UpdateEclipse(self, event, unit, powerType)
+	if(self.unit ~= unit or (event == 'UNIT_POWER' and powerType ~= 'ECLIPSE')) then return end
+	local element = self.EclipseBar
+
+	local max = UnitPowerMax('player', SPELL_POWER_ECLIPSE)
+	element.LunarBar:SetMinMaxValues(-max, max)
+	element.LunarBar:SetValue(UnitPower('player', SPELL_POWER_ECLIPSE))
+end
+
+local function UpdateEclipseVisibility(self)
+	local element = self.EclipseBar
+
+	local showBar
+	local form = GetShapeshiftFormID()
+	if(not form) then
+		local specialization = GetSpecialization()
+		if(specialization and specialization == 1) then
+			showBar = true
+		end
+	elseif(form == MOONKIN_FORM) then
+		showBar = true
+	end
+
+	if(UnitHasVehicleUI('player')) then
+		showBar = false
+	end
+
+	if(showBar) then
+		element:Show()
+	else
+		element:Hide()
+	end
+end
+
 local function UpdateThreat(self, event, unit)
 	if(unit ~= self.unit) then
 		return
@@ -305,6 +339,14 @@ local UnitSpecific = {
 			local SolarBar = EclipseBar:CreateTexture(nil, 'BORDER')
 			SolarBar:SetAllPoints()
 			SolarBar:SetTexture(1/4, 2/5, 5/6)
+
+			if(WoD) then
+				self:RegisterEvent('PLAYER_TALENT_UPDATE', UpdateEclipseVisibility, true)
+				self:RegisterEvent('UPDATE_SHAPESHIFT_FORM', UpdateEclipseVisibility, true)
+				self:RegisterEvent('UNIT_POWER', UpdateEclipse)
+			else
+				self.EclipseBar = EclipseBar
+			end
 		elseif(playerClass == 'WARLOCK') then
 			local BurningEmbers = {}
 			for index = 1, 4 do