Quantcast

NEW procs

Steven Jackson [03-20-15 - 00:50]
NEW procs
Filename
SVUI_!Core/libs/_SVUI_Lib/Animate.lua
SVUI_!Core/system/api.lua
SVUI_!Options/SVUI_!Options.lua
SVUI_Auras/Loader.lua
SVUI_Auras/components/procs.lua
diff --git a/SVUI_!Core/libs/_SVUI_Lib/Animate.lua b/SVUI_!Core/libs/_SVUI_Lib/Animate.lua
index 97fbcf8..1801d5a 100644
--- a/SVUI_!Core/libs/_SVUI_Lib/Animate.lua
+++ b/SVUI_!Core/libs/_SVUI_Lib/Animate.lua
@@ -47,9 +47,10 @@ local MANAGED_ANIMATIONS = {
 --[[ LOCAL FUNCTIONS ]]--

 local Anim_OnShow = function(self)
-    if not self.anim:IsPlaying() then
-        self.anim:Play()
+    if self.anim:IsPlaying() then
+        self.anim:Finish()
     end
+    self.anim:Play()
 end

 local Anim_OnHide = function(self)
@@ -139,29 +140,31 @@ local Pulse_OnUpdate2 = function(self)
     parent:SetScale(1 + (1.05 * (1 - step)))
 end

-local Kapow_OnPlay = function(self)
+local Kapow_OnUpdate1 = function(self)
     local parent = self.parent
+    local step = self:GetProgress()
     if(not parent.startscale) then
         parent.startscale = parent:GetScale()
     end
+    local scale = parent.startscale
     parent:SetAlpha(1)
-    parent:SetScale(parent.startscale or 1)
+    parent:SetScale(scale + (1.05 * step))
 end

-local Kapow_OnUpdate1 = function(self)
+local Kapow_OnUpdate2 = function(self)
     local parent = self.parent
     local step = self:GetProgress()
-    local scale = 1
-    if(parent.startscale) then
-        scale = scale * parent.startscale
-    end
-    parent:SetScale(scale + (1.05 * step))
+    UIFrameFadeOut(parent, 0.3, 1, 0)
 end

-local Kapow_OnUpdate2 = function(self)
+local Kapow_OnUpdate2Special = function(self)
     local parent = self.parent
     local step = self:GetProgress()
-    UIFrameFadeOut(parent, 0.3, 1, 0)
+    local scale = 1
+    if(parent.startscale) then
+        scale = scale * parent.startscale
+    end
+    parent:SetScale(scale + (1.05 * (scale - step)))
 end

 local Slide_OnUpdate = function(self)
@@ -203,9 +206,13 @@ local function AnimationTemplate(frame, animType, hideOnFinished, speed, special
     frame.anim.hideOnFinished = hideOnFinished

     if(MANAGED_ANIMATIONS[animType]) then
-        frame.anim:SetScript("OnPlay", Anim_OnPlay)
-        frame.anim:SetScript("OnFinished", Anim_OnFinished)
-        frame.anim:SetScript("OnStop", Anim_OnStop)
+        if(animType ~= 'Pulse' and animType ~= 'Kapow') then
+            frame.anim:SetScript("OnPlay", Anim_OnPlay)
+        end
+        if(animType ~= 'Kapow' or (animType == 'Kapow' and (not special))) then
+            frame.anim:SetScript("OnFinished", Anim_OnFinished)
+            frame.anim:SetScript("OnStop", Anim_OnStop)
+        end
     end

     if(not noShowHide) then
@@ -345,7 +352,7 @@ local function AnimationTemplate(frame, animType, hideOnFinished, speed, special
         frame.anim[2]:SetOrder(2)
         frame.anim[2]:SetScript("OnUpdate", Pulse_OnUpdate2)
     elseif(animType == 'Kapow') then
-        frame.anim:SetScript("OnPlay", Kapow_OnPlay)
+        --frame.anim:SetScript("OnPlay", Kapow_OnPlay)

         frame.anim.startscale = frame:GetScale()

@@ -358,7 +365,12 @@ local function AnimationTemplate(frame, animType, hideOnFinished, speed, special
         frame.anim[2] = SetNewAnimation(frame.anim)
         frame.anim[2]:SetDuration(0.3)
         frame.anim[2]:SetOrder(2)
-        frame.anim[2]:SetScript("OnUpdate", Kapow_OnUpdate2)
+
+        if(not special) then
+            frame.anim[2]:SetScript("OnUpdate", Kapow_OnUpdate2)
+        else
+            frame.anim[2]:SetScript("OnUpdate", Kapow_OnUpdate2Special)
+        end
     end
 end

@@ -375,9 +387,9 @@ function lib:Pulse(frame, hideOnFinished)
     AnimationTemplate(frame, 'Pulse', hideOnFinished)
 end

-function lib:Kapow(frame, hideOnFinished, noShowHide)
+function lib:Kapow(frame, hideOnFinished, noShowHide, noHide)
     if not frame then return end
-    AnimationTemplate(frame, 'Kapow', hideOnFinished, nil, nil, nil, noShowHide)
+    AnimationTemplate(frame, 'Kapow', hideOnFinished, nil, noHide, nil, noShowHide)
 end

 --[[ ANIMATED SPRITES ]]--
diff --git a/SVUI_!Core/system/api.lua b/SVUI_!Core/system/api.lua
index 4527bfc..a7c1522 100644
--- a/SVUI_!Core/system/api.lua
+++ b/SVUI_!Core/system/api.lua
@@ -553,7 +553,11 @@ end

 local Cooldown_StopTimer = function(self)
     self.enable = nil;
-    self:Hide()
+    if(self.parent and self.parent.HideAfterCooldown) then
+        self.parent:Hide();
+    else
+        self:Hide();
+    end
 end

 local Cooldown_OnUpdate = function(self, elapsed)
@@ -629,6 +633,7 @@ end

 local CreateCooldownTimer = function(self)
     local timer = CreateFrame('Frame', nil, self)
+    timer.parent = self:GetParent()
     timer:SetAllPoints()
     timer:SetScript('OnUpdate', Cooldown_OnUpdate)

diff --git a/SVUI_!Options/SVUI_!Options.lua b/SVUI_!Options/SVUI_!Options.lua
index bb38533..12e852f 100644
--- a/SVUI_!Options/SVUI_!Options.lua
+++ b/SVUI_!Options/SVUI_!Options.lua
@@ -263,13 +263,13 @@ end
 local function GetAllFilterList()
 	wipe(allFilterTable);
 	allFilterTable[""] = NONE;
-	allFilterTable["BlackList"] = "Blacklist";
-	allFilterTable["WhiteList"] = "Whitelist";
-	allFilterTable["Raid"] = "Consolidated";
-	allFilterTable["AuraBars"] = "AuraBars";
-	allFilterTable["Player"] = "Player";
-	allFilterTable["BuffWatch"] = "AuraWatch";
-	allFilterTable["PetBuffWatch"] = "PetAuraWatch";
+	for filter in pairs(SV.db.Filters) do
+		if(filter == 'Raid') then
+			allFilterTable[filter] = "Consolidated"
+		elseif(filter ~= 'Custom') then
+			allFilterTable[filter] = filter
+		end
+	end
 	for filter in pairs(SV.db.Filters.Custom) do
 		allFilterTable[filter] = filter
 	end
diff --git a/SVUI_Auras/Loader.lua b/SVUI_Auras/Loader.lua
index 28269ed..149950d 100644
--- a/SVUI_Auras/Loader.lua
+++ b/SVUI_Auras/Loader.lua
@@ -227,8 +227,15 @@ function MOD:LoadOptions()
 				get = function(a)return SV.db[Schema].hyperBuffsFiltered end,
 				set = function(a,b)SV.db[Schema].hyperBuffsFiltered = b;SV:StaticPopup_Show("RL_CLIENT")end
 			},
-			auraGroups = {
+			procsEnabled = {
 				order = 5,
+				type = "toggle",
+				name = L["Proc Watch Enabled"],
+				get = function(a) return SV.db[Schema].procsEnabled end,
+				set = function(a,b)SV.db[Schema].procsEnabled = b;SV:StaticPopup_Show("RL_CLIENT") end
+			},
+			auraGroups = {
+				order = 6,
 				type = "group",
 				name = L["Options"],
 				childGroups = "tree",
diff --git a/SVUI_Auras/components/procs.lua b/SVUI_Auras/components/procs.lua
index 00756c3..f66ee83 100644
--- a/SVUI_Auras/components/procs.lua
+++ b/SVUI_Auras/components/procs.lua
@@ -66,30 +66,24 @@ if(not MOD) then return end;
 LOCAL VARS
 ##########################################################
 ]]--
-local GUIDs = {};
 local ProcWatch = CreateFrame('Frame', 'SVUI_ProcWatch', UIParent);

+local OnCooldDownExpired = function(self)
+	self.timeLeft = nil;
+	self:FadeOut(0.2, 1, 0, true)
+end
+
 local function CreateProcIcon()
 	local proc = CreateFrame("Frame", nil, ProcWatch)
-	proc:SetBackdrop({
-		bgFile = [[Interface\BUTTONS\WHITE8X8]],
-		tile = false,
-		tileSize = 0,
-		edgeFile = [[Interface\BUTTONS\WHITE8X8]],
-		edgeSize = 2,
-		insets = {
-			left = 0,
-			right = 0,
-			top = 0,
-			bottom = 0
-		}
-	 })
- 	proc:SetBackdropColor(0, 0, 0)
- 	proc:SetBackdropBorderColor(0, 0, 0)
+
+ 	local bg = proc:CreateTexture(nil, "BACKGROUND")
+	bg:SetAllPoints()
+	bg:SetTexture(0,0,0,0.5)

 	proc.icon = proc:CreateTexture(nil, "BORDER")
 	proc.icon:InsetPoints(proc, 2, 2)
 	proc.icon:SetTexCoord(unpack(_G.SVUI_ICON_COORDS))
+	proc.icon:SetVertexColor(1,1,1,0.6)

 	proc.count = proc:CreateFontString(nil, "ARTWORK")
 	proc.count:SetPoint("BOTTOMRIGHT", (-1 + SV.db.Auras.countOffsetH), (1 + SV.db.Auras.countOffsetV))
@@ -98,7 +92,7 @@ local function CreateProcIcon()
 	proc.time = proc:CreateFontString(nil, "ARTWORK")
 	proc.time:SetPoint("TOP", proc, "BOTTOM", 1 + SV.db.Auras.timeOffsetH, 0 + SV.db.Auras.timeOffsetV)
 	proc.time:SetFontObject(SVUI_Font_Aura)
-
+	proc.HideAfterCooldown = true
 	proc.cd = SV.API:CD(proc);

 	proc.highlight = proc:CreateTexture(nil, "HIGHLIGHT")
@@ -106,7 +100,7 @@ local function CreateProcIcon()
 	proc.highlight:SetVertexColor(1, 1, 1, 0.45)
 	proc.highlight:InsetPoints(proc, 2, 2)

-	SV.Animate:Flash(proc)
+	SV.Animate:Kapow(proc, false, true, true)

 	return proc;
 end
@@ -115,64 +109,17 @@ end
 CORE FUNCTIONS
 ##########################################################
 ]]--
-local setupGUID
-do
-	local cache = setmetatable({}, {__type = "k"})
-
-	local frame = CreateFrame"Frame"
-	frame:SetScript("OnEvent", function(self, event)
-		for k,t in pairs(GUIDs) do
-			GUIDs[k] = nil
-			for a in pairs(t) do
-				t[a] = nil
-			end
-			cache[t] = true
-		end
-	end)
-	frame:RegisterEvent"PLAYER_REGEN_ENABLED"
-	frame:RegisterEvent"PLAYER_ENTERING_WORLD"
-
-	function setupGUID(unit)
-		if(not unit) then return false end
-		local guid = UnitGUID(unit)
-		if(not guid) then return false end
-		if(not GUIDs[guid]) then
-			local t = next(cache)
-			if t then
-				cache[t] = nil
-			else
-				t = {}
-			end
-			GUIDs[guid] = t
-		end
-		return GUIDs[guid]
-	end
-end
-
-local function SetProcTimer(aura, count, duration, remaining)
-	aura:Show()
-	if duration and duration > 0 then
-		aura.cd:SetCooldown(remaining - duration, duration)
-	end
-	aura.count:SetText((count > 1 and count))
-end
-
 local PROC_UNIT_AURA = function(self, event, unit)
-	local CACHED_AURA = setupGUID(unit);
-	if(not CACHED_AURA) then return end
+	if(not unit) then return end

 	local index = 1
 	local PROCS = self.cache
-	local _, name, texture, count, duration, remaining, caster, key, spellID
-	local filter = "HELPFUL"
+	local _, name, texture, count, duration, expiration, caster, key, spellID
+	local filter = "HELPFUL";
+	local lastProc;

-	for _, icon in pairs(PROCS) do
-		icon:Hide()
-	end
-
-	local x = 1
 	while true do
-		name, _, texture, count, _, duration, remaining, caster, _, _, spellID = UnitAura(unit, index, filter)
+		name, _, texture, count, _, duration, expiration, caster, _, _, spellID = UnitAura(unit, index, filter)
 		if not name then
 			if filter == "HELPFUL" then
 				filter = "HARMFUL"
@@ -181,17 +128,26 @@ local PROC_UNIT_AURA = function(self, event, unit)
 				break
 			end
 		else
-			local aura = PROCS[spellID]
-			if(aura) then
-				aura.timeLeft = remaining;
-				CACHED_AURA[spellID] = true;
+			local procID = tostring(spellID);
+			local aura = PROCS[procID]
+			if(aura and duration and (duration > 0)) then
 				aura:ClearAllPoints()
-				aura:SetPoint('RIGHT', self, 'RIGHT', -((x - 1) * 43), 0)
-				aura:Show()
-
-				if(duration and (duration > 0)) then
-					aura.cd:SetCooldown(remaining - duration, duration)
+				if(not lastProc) then
+					aura:SetPoint('RIGHT', self, 'RIGHT', 0, 0)
+				else
+					aura:SetPoint('RIGHT', lastProc, 'LEFT', -1, 0)
 				end
+				local timeleft = expiration - duration;
+				local lastTimer = aura.LastTimer or 0
+
+				if(lastTimer < expiration) then
+					aura.anim:Stop()
+					aura:Show()
+					aura.anim[2]:SetDuration(duration)
+            		aura.anim:Play()
+            		aura.cd:SetCooldown(timeleft, duration)
+            	end
+            	aura.LastTimer = expiration

 				local textCount = '';
 				if(count and (count > 1)) then
@@ -199,7 +155,7 @@ local PROC_UNIT_AURA = function(self, event, unit)
 				end
 				aura.count:SetText(textCount);

-				x = x + 1
+				lastProc = aura;
 			end
 			index = index + 1
 		end
@@ -207,34 +163,34 @@ local PROC_UNIT_AURA = function(self, event, unit)
 end

 function MOD:UpdateProcWatch()
-	if(not SV.db.Auras.procsEnabled) then return end;
-	local PROCS = ProcWatch.cache;
+	ProcWatch.cache = {}
 	local pwSize = SV.db.Auras.procSize or 40;
-	local CONFIG = SV.db.Filters.BuffWatch;
-	--local CONFIG = SV.db.Filters.Procs
+	local CONFIG = SV.db.Filters.Procs
 	local i = 1;
 	for procID,procData in pairs(CONFIG) do
-		local spellID = tonumber(procID);
-		local spellName,_,spellTexture = GetSpellInfo(spellID)
-		if spellName then
-			local proc = PROCS[procID];
-
-			if(not proc) then
-				proc = CreateProcIcon()
-				PROCS[procID] = proc
-			end;
-
-			proc.name = spellName;
-			proc.index = i;
-			proc.spellID = spellID;
-			proc:SetWidth(pwSize)
-			proc:SetHeight(pwSize)
-			proc:ClearAllPoints()
-			proc:SetPoint('RIGHT', ProcWatch, 'RIGHT', -((i - 1) * 43), 0)
-			proc.icon:SetTexture(spellTexture)
-			proc:Hide();
-
-			i = i + 1
+		if(procData.enable) then
+			local spellID = tonumber(procID);
+			local spellName,_,spellTexture = GetSpellInfo(spellID)
+			if spellName then
+				local proc = ProcWatch.cache[procID];
+
+				if(not proc) then
+					proc = CreateProcIcon()
+					ProcWatch.cache[procID] = proc
+				end;
+
+				proc.name = spellName;
+				proc.index = i;
+				proc.spellID = spellID;
+				proc:SetWidth(pwSize)
+				proc:SetHeight(pwSize)
+				proc:ClearAllPoints()
+				proc:SetPoint('RIGHT', ProcWatch, 'RIGHT', -((i - 1) * 43), 0)
+				proc.icon:SetTexture(spellTexture)
+				proc:Hide();
+
+				i = i + 1
+			end
 		end
 	end;
 end;
@@ -246,8 +202,6 @@ function MOD:InitializeProcWatch()
 		SV.db.Filters.Procs = {}
 	end

-	ProcWatch.cache = {};
-
 	local ProcsAnchor = CreateFrame('Frame', 'SVUI_ProcWatchFrame', SV.Screen)
 	ProcsAnchor:SetSize(172,40)
 	ProcsAnchor:SetPoint("TOPRIGHT", SV.Screen, "CENTER", -50, -50)
@@ -256,10 +210,11 @@ function MOD:InitializeProcWatch()
 	ProcWatch:SetWidth(720)
 	ProcWatch:SetHeight(40)
 	ProcWatch:SetPoint('RIGHT', ProcsAnchor, 'RIGHT', 0, 0)
-	ProcWatch:RegisterUnitEvent('UNIT_AURA', "player")
+	ProcWatch:RegisterUnitEvent("UNIT_AURA", "player")
 	ProcWatch:SetScript('OnEvent', PROC_UNIT_AURA)

 	SV:NewAnchor(ProcsAnchor, L["Procs Frame"])

-	self:UpdateProcWatch()
+	self:UpdateProcWatch();
+	SV.Events:On("AURA_FILTER_OPTIONS_CHANGED", MOD.UpdateProcWatch, true);
 end;