vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | BuffTimers: Mini timers for the top right buff icons |
||
4 | copyright 2004 by Telo |
||
5 | |||
6 | - Displays small timer text below each of the top right buff and debuff icons |
||
7 | |||
8 | ]] |
||
9 | |||
10 | -------------------------------------------------------------------------------------------------- |
||
11 | -- Local variables |
||
12 | -------------------------------------------------------------------------------------------------- |
||
13 | |||
14 | -- Function hooks |
||
15 | local lOriginal_BuffButton_Update; |
||
16 | local lOriginal_BuffButton_OnUpdate; |
||
17 | |||
18 | -- Track whether we've moved the buff buttons yet or not |
||
19 | local lMovedButtons; |
||
20 | |||
21 | -------------------------------------------------------------------------------------------------- |
||
22 | -- Internal functions |
||
23 | -------------------------------------------------------------------------------------------------- |
||
24 | |||
25 | local function lSetTimeText(button, time) |
||
26 | local d, h, m, s; |
||
27 | local text; |
||
28 | |||
29 | if( time <= 0 ) then |
||
30 | text = ""; |
||
31 | elseif( time < 3600 ) then |
||
32 | d, h, m, s = ChatFrame_TimeBreakDown(time); |
||
33 | text = format("%02d:%02d", m, s); |
||
34 | else |
||
35 | text = "1 hr+"; |
||
36 | end |
||
37 | |||
38 | button:SetText(text); |
||
39 | end |
||
40 | |||
41 | local function lGetField(name) |
||
42 | local s, e, number = string.find(name, "BuffButton(%d+)"); |
||
43 | return getglobal("BuffTimer"..number.."Time"); |
||
44 | end |
||
45 | |||
46 | -------------------------------------------------------------------------------------------------- |
||
47 | -- OnFoo functions |
||
48 | -------------------------------------------------------------------------------------------------- |
||
49 | |||
50 | function BuffTimers_OnLoad() |
||
51 | -- Hook the button functions we need to override |
||
52 | lOriginal_BuffButton_Update = BuffButton_Update; |
||
53 | BuffButton_Update = BuffTimers_BuffButton_Update; |
||
54 | lOriginal_BuffButton_OnUpdate = BuffButton_OnUpdate; |
||
55 | BuffButton_OnUpdate = BuffTimers_BuffButton_OnUpdate; |
||
56 | |||
57 | if( DEFAULT_CHAT_FRAME ) then |
||
58 | DEFAULT_CHAT_FRAME:AddMessage("Telo's BuffTimers AddOn loaded"); |
||
59 | end |
||
60 | UIErrorsFrame:AddMessage("Telo's BuffTimers AddOn loaded", 1.0, 1.0, 1.0, 1.0, UIERRORS_HOLD_TIME); |
||
61 | end |
||
62 | |||
63 | function BuffTimers_OnShow() |
||
64 | -- Move the buff buttons slightly to accomodate our timer text |
||
65 | if( not lMovedButtons ) then |
||
66 | local iButton; |
||
67 | |||
68 | getglobal("BuffButton8"):SetPoint("TOP", "BuffButton0", "BOTTOM", 0, -11); |
||
69 | for iButton = 9, 15 do |
||
70 | getglobal("BuffButton"..iButton):SetPoint("RIGHT", "BuffButton"..(iButton - 1), "LEFT", -5, 0); |
||
71 | end |
||
72 | getglobal("BuffButton16"):SetPoint("TOP", "BuffButton8", "BOTTOM", 0, -11); |
||
73 | for iButton = 17, 23 do |
||
74 | getglobal("BuffButton"..iButton):SetPoint("RIGHT", "BuffButton"..(iButton - 1), "LEFT", -5, 0); |
||
75 | end |
||
76 | |||
77 | lMovedButtons = 1; |
||
78 | end |
||
79 | end |
||
80 | |||
81 | function BuffTimers_BuffButton_Update() |
||
82 | lOriginal_BuffButton_Update(); |
||
83 | |||
84 | if( this.untilCancelled ) then |
||
85 | lGetField(this:GetName()):SetText(""); |
||
86 | end |
||
87 | end |
||
88 | |||
89 | function BuffTimers_BuffButton_OnUpdate() |
||
90 | lOriginal_BuffButton_OnUpdate(); |
||
91 | |||
92 | if( BuffFrameUpdateTime <= 0 ) then |
||
93 | lSetTimeText(lGetField(this:GetName()), GetPlayerBuffTimeLeft(this.buffIndex)); |
||
94 | end |
||
95 | end |