• 0

    posted a message on CooldownTimers2 - Official Thread
    Quote from Sorren »

    @TheBlinkingMan
    Looking over the code, it's totally borrowed from JIM's CooldownPulse. I've spoken to JIM before and didn't want to 'assimilate' his AddOn, so to speak. I haven't heard from him lately, but I don't know how I feel about borrowing his code like that.


    Yeah meant to mention that, guess I just stuck it in a comment. The comments in his code say he's ok with people using his code.


    If you see code you like, go ahead and copy it.
    Yes, that's right. I'm cool with "sharing".


    Sorry about that confusion, but yeah some of the constants and the loop in the animation function is almost exactly from his code. I understand if you don't want to assimilate that feature. This was more if anyone wanted to patch the stuff in themselves instead of using JIM's mod.

    There isn't really a way to turn it off in game, so I don't know if just committing it would be a good idea.
    Posted in: General AddOns
  • 0

    posted a message on CooldownTimers2 - Official Thread
    Quote from Sorren »

    @TheBlinkingMan

    I'd like to see this diff, if you please ;)

    My first attempt at programming lua so you might want to clean it up if you want to.

    Ok big post inc:

    Index: CooldownTimers2.lua
    ===================================================================
    --- CooldownTimers2.lua	(revision 55047)
    +++ CooldownTimers2.lua	(working copy)
    @@ -59,6 +59,34 @@
     if AceLibrary:HasInstance("Waterfall-1.0") then
     	waterfall = AceLibrary("Waterfall-1.0")
     end
    +
    +--[[
    +-- Simple queue implemntation: push pop isempty
    +--]]
    +local Queue = {}
    +function Queue.new()
    +  return {first = 0, last = -1}
    +end
    +
    +function Queue.push(queue, icon)
    +  local last = queue.last + 1
    +  queue.last = last
    +  queue[last] = icon
    +end
    +
    +function Queue.pop(queue)
    +  local first = queue.first
    +  if first > queue.last then error("Queue is empty") end
    +  local value = queue[first]
    +  queue[first] = nil
    +  queue.first = first + 1
    +  return value
    +end
    +
    +function Queue.isEmpty(queue)
    +  return (queue.first > queue.last)
    +end
    +
     CooldownTimers = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0",
     												"AceEvent-2.0",
     												"AceDB-2.0",
    @@ -562,6 +590,25 @@
     		self.announce.anchor:Hide()
     		self.announce.frame:Hide()
     	end
    +
    +    --[[
    +    -- Sets up the pulse location
    +    --]]
    +    self.pulse = {}
    +    self.pulse = CreateFrame("Button","CDTPulseImage",UIParent)
    +	self.pulse:ClearAllPoints()
    +	self.pulse:SetPoint("TOP", self.announce.anchor, "CENTER", 0,0)
    +    self.pulse:SetHeight(170)
    +    self.pulse:SetWidth(170)
    +    self.pulse:SetAlpha(0)
    +    self.pulse:EnableMouse(false)
    +    self.pulse.animating = false
    +    self.pulseQueue = Queue.new()
    +    self.pulse:SetScript("OnUpdate", function()
    +      --if self.announce.anchor:IsShown() then
    +        self:AnimatePulse()
    +      --end
    +    end)
     end
     
     function CooldownTimers:LockAnchor(group)
    @@ -961,5 +1008,68 @@
     	self.announce.last = GetTime()
     	self.announce.alpha = 1
     	self.announce.frame:Show()
    +    
    +    --self:Print(icon)
    +    Queue.push(self.pulseQueue, icon)
    +    --self:Print("Added pulse to queue")
     end
     
    +-- Some of this is so stolen from Jim's Cooldown Pulse. Thanks JIM!
    +
    +--[[
    +-- Flash each icon in the queue of cooldown that are compleate
    +-- Animates a puluse by quickly fading a spell or ablity image in and out
    +-- All ablities in the queue should need their ablity flashed as soon as possible
    +--]]
    +
    +-- Hard coded for now
    +local Pulse_maxAlpha		= 0.5	-- How solid should the pulsing images be when fully visible? 1 = completely solid
    +local Pulse_lubTime		= 0.25	-- animation time of pulse fade in
    +local Pulse_dubTime		= 1.00	-- animation time of pulse fade out
    +local Pulse_minDubTime	= 0.75	-- shortest delay before one pulse cuts another pulse short; also, time between beginning of pulses
    +
    +
    +function CooldownTimers:AnimatePulse()
    +  local now = GetTime()
    +  local anim = self.pulse.animating and (now - self.pulse.pulsedAt)
    +  --self:Print("AnimatePulse called")
    +  --Need to loop though the queue here and set the icon of the self.pulse.frame
    +  
    +  if ( anim ) then
    +    --self:Print("Animating")
    +	--[[ Animation progress: anim records not the current time,
    +	but the progress of the animation in seconds.
    +	Based on this value, the effect's "alpha" can be set so that its image
    +	appears to be pulsing to the sound of a heartbeat.
    +	
    +	This entire function is called however often your Frames Per Second permit,
    +	so computers with more memory and faster video cards will get smoother animations!
    +	I say that like it's a good thing, but really I should tone down the frequency of this function.
    +	--]]
    +    self.pulse:SetAlpha(
    +	  ( anim < Pulse_lubTime )	-- pulse fade in
    +		and anim * Pulse_maxAlpha / Pulse_lubTime
    +	  or	( anim < Pulse_dubTime )	-- pulse fade out
    +		and ( Pulse_dubTime - anim ) * Pulse_maxAlpha / ( Pulse_dubTime - Pulse_lubTime )
    +      or	0	-- animation over
    +	)
    +
    +    if ( anim >= Pulse_dubTime ) then
    +	  self.pulse.pulsedAt= nil
    +	  self.pulse.animating= false
    +      --self:Print("Ending animation")
    +	end
    +  else
    +    if Queue.isEmpty(self.pulseQueue) then
    +      return
    +    else
    +      --self:Print("Starting Animation")
    +      self.pulse.animating = true
    +      self.pulse.pulsedAt = now
    +      self.pulse:SetNormalTexture(Queue.pop(self.pulseQueue))
    +      
    +    end
    +  end
    +
    +end
    +
    Posted in: General AddOns
  • 0

    posted a message on CooldownTimers2 - Official Thread
    I have been using this mod to keep track of my cooldowns for a while, but I've always wanted a JIM's cooldown pulse type icon flash to go with the announcement since that is much easier to absorb during combat. So I wrote a quick hack to this mod that pulses the icon of a cooldown every time a bar finishes.



    The pulse frame is attached to the bottom of the announce frame and uses a queue to hold each icon so that it can pulse each icon in order if there are several expiring cooldowns happening near to each other.

    It works for me, but i haven't tested it more than just playing the game with it. If anyone is interested I can post a diff of my code and the current svn trunk.
    Posted in: General AddOns
  • To post a comment, please or register a new account.