Quantcast
WoWInterface - View Single Post - Cooldown animation on buttons.
View Single Post
11-29-05, 09:31 AM   #2
Gello
A Firelord
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 492
It takes some getting used to but the cooldown spinner is just an animated model you can start at will and leave alone and it will handle spinning once and hiding itself when the cooldown is done. When you want to show the cooldown again you start another spin.

First off you need the buttons to inherit ActionButtonTemplate, or at least include the cooldown model in your frames. We'll use MultiBarBottomLeftButton12 as an example. This button is in the "bottom left" extra bar in the default UI. The cooldown model (under the <Frames> section of the template) is MultiBarBottomLeftButton12Cooldown.

You start the timer with CooldownFrame_SetTimer which takes at four arguments: frame of the cooldown model, start time, duration, enable. The latter three are exactly the results of every GetsomethingCooldown function:

frame: MultiBarBottomLeftButton12Cooldown <- change to whatever your cooldown model is
start: if there is a cooldown, this is the current GetTime(), 0 if none
duration: time (in seconds) to spin, 0 if none
enable: just needs to be over 0 to get a spinner going. Not sure why this is necessary.

So you can type this in manually:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, GetTime(), 10, 1)

and it will start a spinner starting now for 10 seconds. Or:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, GetTime()-5, 10, 1)

will show a spinner that started 5 seconds ago with a duration of 10 seconds, so it will start halfway done. Or:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, 0, 0, 0)

which will show a finished cooldown. If you want to reflect the cooldown of an item in bags, you can get the 3 arguments with GetContainerItemCooldown:

/script local start, duration, enable = GetContainerItemCooldown(0,1) CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, start, duration, enable)

It's important to note that the cooldown won't automatically start the next time the button is used. You need to get the cooldown and start the spinner every time the item is used.
  Reply With Quote