vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function DAB_ActionButton_Collapse(button, bar)
2 if (button.collapsed) then return; end
3 if ((not bar) or bar=="F") then return; end
4 if (not DAB_Settings[DAB_INDEX].Bar[bar].collapse) then return; end
5 if (not button:GetParent().initialized) then return; end
6 button.collapsed = true;
7 local loc = button:GetParent().buttonLocation[button:GetID()].loc;
8 local row = button:GetParent().buttonLocation[button:GetID()].row;
9 button:ClearAllPoints();
10 if (loc == 1 and row == 1) then
11 button:SetPoint("TOPRIGHT", button:GetParent(), "TOPLEFT", DAB_Settings[DAB_INDEX].Bar[bar].Background.leftpadding - DAB_Settings[DAB_INDEX].Bar[bar].hspacing, -DAB_Settings[DAB_INDEX].Bar[bar].Background.toppadding);
12 elseif (button.yoffset) then
13 button:SetPoint("TOPRIGHT", button:GetParent(), "TOPLEFT", DAB_Settings[DAB_INDEX].Bar[bar].Background.leftpadding - DAB_Settings[DAB_INDEX].Bar[bar].hspacing, -button.yoffset);
14 elseif (loc > 1) then
15 button:SetPoint("LEFT", "DAB_ActionButton_"..button:GetParent().rows[row][loc - 1], "LEFT", 0, 0);
16 end
17 DAB_Bar_Size(bar);
18 end
19  
20 function DAB_ActionButton_FauxHide(id)
21 local button = getglobal("DAB_ActionButton_"..id);
22 --if (button.fauxhidden) then return; end
23 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
24 button.hidden = true;
25 button.fauxhidden = true;
26 button:SetAlpha(0);
27 button:EnableMouse(false);
28 button:EnableMouseWheel(false);
29 DAB_ActionButton_Collapse(button, bar);
30 end
31  
32 function DAB_ActionButton_FauxShow(id)
33 local button = getglobal("DAB_ActionButton_"..id);
34 --if (not button.fauxhidden) then return; end
35 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
36 button.hidden = nil;
37 button.fauxhidden = nil;
38 if (bar == "F" or (bar ~= "F" and (not getglobal("DAB_ActionBar_"..bar).fauxhidden))) then
39 button:SetAlpha(1);
40 button:EnableMouse(1);
41 button:EnableMouseWheel(1);
42 this = button;
43 DAB_ActionButton_Update();
44 DAB_ActionButton_UpdateState();
45 DAB_ActionButton_UpdateCooldown(id);
46 DAB_ActionButton_RestoreAlpha(id);
47 end
48 DAB_ActionButton_Uncollapse(button, bar);
49 end
50  
51 function DAB_ActionButton_GetColor(id, num, r, g, b, manaRecolor, notEnoughMana, rangeRecolor, outOfRange, unusableRecolor, isUsable)
52 if (this.colorOverride and this.colorOverride[num]) then
53 return this.colorOverride[num].r, this.colorOverride[num].g, this.colorOverride[num].b;
54 elseif (manaRecolor == num and notEnoughMana) then
55 r, g, b = DAB_ActionButton_GetSetting(id, "manacolor", 1);
56 elseif (rangeRecolor == num and outOfRange) then
57 local target = DAB_ActionButton_GetSetting(id, "target");
58 local force = DAB_ActionButton_GetSetting(id, "forceTarget")
59 if (target and force and target ~= "target") then
60 r = 1
61 g = 1
62 b = 1
63 end
64 r, g, b = DAB_ActionButton_GetSetting(id, "rangecolor", 1);
65 elseif (unusableRecolor == num and (not isUsable)) then
66 r, g, b = DAB_ActionButton_GetSetting(id, "unusablecolor", 1);
67 end
68 return r, g, b;
69 end
70  
71 function DAB_ActionButton_GetSetting(id, index, colortoggle, subindex)
72 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
73 if (bar == "F") then
74 if (subindex) then
75 if (colortoggle) then
76 return DAB_Settings[DAB_INDEX].Floaters[id][index][subindex].r, DAB_Settings[DAB_INDEX].Floaters[id][index][subindex].g, DAB_Settings[DAB_INDEX].Floaters[id][index][subindex].b;
77 else
78 return DAB_Settings[DAB_INDEX].Floaters[id][index][subindex];
79 end
80 else
81 if (colortoggle) then
82 return DAB_Settings[DAB_INDEX].Floaters[id][index].r, DAB_Settings[DAB_INDEX].Floaters[id][index].g, DAB_Settings[DAB_INDEX].Floaters[id][index].b;
83 else
84 return DAB_Settings[DAB_INDEX].Floaters[id][index];
85 end
86 end
87 else
88 if (subindex) then
89 if (colortoggle) then
90 return DAB_Settings[DAB_INDEX].Bar[bar][index][subindex].r, DAB_Settings[DAB_INDEX].Bar[bar][index][subindex].g, DAB_Settings[DAB_INDEX].Bar[bar][index][subindex].b;
91 else
92 return DAB_Settings[DAB_INDEX].Bar[bar][index][subindex];
93 end
94 else
95 if (colortoggle) then
96 return DAB_Settings[DAB_INDEX].Bar[bar][index].r, DAB_Settings[DAB_INDEX].Bar[bar][index].g, DAB_Settings[DAB_INDEX].Bar[bar][index].b;
97 else
98 return DAB_Settings[DAB_INDEX].Bar[bar][index];
99 end
100 end
101 end
102 end
103  
104 function DAB_ActionButton_OnClick(id, mousebutton, kboverride, selfCast, actionoverride)
105 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
106 local button = getglobal("DAB_ActionButton_"..id);
107 if (button.disabled) then return; end
108 local action = button:GetActionID();
109  
110 if (button.moving or button:GetParent().moving) then
111 DAB_ActionButton_OnDragStop();
112 end
113  
114 if (not kboverride) then
115 if (bar == "F") then
116 DAB_Run_Script("OnClickBefore", "Floaters", id, mousebutton);
117 else
118 DAB_Run_Script("OnClickBefore", "Bar", bar, mousebutton);
119 end
120 end
121  
122 local rightclick, middleclick, target, hideonclick, autoattack, forcetarget, petattack, hadTarget;
123  
124 if (bar == "F") then
125 target = DAB_Settings[DAB_INDEX].Floaters[id].target;
126 hideonclick = DAB_Settings[DAB_INDEX].Floaters[id].hideonclick;
127 rightclick = DAB_Settings[DAB_INDEX].Floaters[id].rightClick;
128 middleclick = DAB_Settings[DAB_INDEX].Floaters[id].middleClick;
129 autoattack = DAB_Settings[DAB_INDEX].Floaters[id].autoAttack;
130 petattack = DAB_Settings[DAB_INDEX].Floaters[id].petAutoAttack;
131 forcetarget = DAB_Settings[DAB_INDEX].Floaters[id].forceTarget;
132 else
133 if (DAB_Settings[DAB_INDEX].Bar[bar].rightClick > 0) then
134 rightclick = DAB_Get_MatchingButton(bar, id, DAB_Settings[DAB_INDEX].Bar[bar].rightClick);
135 rightclick = DAB_Settings[DAB_INDEX].Buttons[rightclick].action;
136 else
137 rightclick = DAB_Settings[DAB_INDEX].Bar[bar].rightClick;
138 end
139 if (DAB_Settings[DAB_INDEX].Bar[bar].middleClick > 0) then
140 middleclick = DAB_Get_MatchingButton(bar, id, DAB_Settings[DAB_INDEX].Bar[bar].middleClick);
141 middleclick = DAB_Settings[DAB_INDEX].Buttons[middleclick].action;
142 else
143 middleclick = DAB_Settings[DAB_INDEX].Bar[bar].middleClick;
144 end
145 target = DAB_Settings[DAB_INDEX].Bar[bar].target;
146 hideonclick = DAB_Settings[DAB_INDEX].Bar[bar].hideonclick;
147 autoattack = DAB_Settings[DAB_INDEX].Bar[bar].autoAttack;
148 petattack = DAB_Settings[DAB_INDEX].Bar[bar].petAutoAttack;
149 forcetarget = DAB_Settings[DAB_INDEX].Bar[bar].forceTarget;
150 if (getglobal("DAB_ActionBar_"..bar).targetOverride) then
151 target = getglobal("DAB_ActionBar_"..bar).targetOverride;
152 forcetarget = true;
153 end
154 end
155  
156 if ( DAB_Check_ModifierKey(DAB_Settings[DAB_INDEX].ButtonLockOverride) and (not kboverride) ) then
157 PickupAction(action);
158 else
159 if (petattack) then
160 DL_PetAttack();
161 end
162 if ( MacroFrame_SaveMacro ) then
163 MacroFrame_SaveMacro();
164 end
165 if (mousebutton == "RightButton" and rightclick) then
166 if (rightclick == -2) then
167 selfCast = 1;
168 else
169 action = rightclick;
170 end
171 elseif (mousebutton == "MiddleButton" and middleclick) then
172 if (middleclick == -2) then
173 selfCast = 1;
174 else
175 action = middleclick;
176 end
177 end
178 if (actionoverride) then
179 action = actionoverride;
180 end
181  
182 if (not IsAttackAction(action)) then
183 if (autoattack) then
184 DL_AttackTarget();
185 end
186 end
187  
188 if (((not kboverride) and DAB_Check_ModifierKey(DAB_Settings[DAB_INDEX].SelfCast)) or selfCast) then
189 target = "player";
190 forcetarget = true;
191 end
192  
193 if (button.targetOverride) then
194 target = button.targetOverride;
195 forcetarget = true;
196 end
197  
198 if ((not UnitCanAttack("player", "target")) and forcetarget) then
199 hadTarget = true;
200 end
201  
202 if (target and forcetarget and hadTarget) then
203 TargetUnit(target);
204 elseif (target and forcetarget and string.find(DAB_Get_ActionName(action), DAB_DISPELMAGIC)) then
205 hadTarget = true;
206 TargetUnit(target);
207 end
208  
209 if (action > 0) then
210 local checkCursor;
211 if (not kboverride) then checkCursor = 1; end
212 UseAction(action, checkCursor);
213 end
214  
215 if (hadTarget and target and forcetarget) then
216 TargetLastTarget();
217 elseif (SpellIsTargeting() and target) then
218 SpellTargetUnit(target);
219 end
220  
221 if (hideonclick) then
222 if (bar == "F") then
223 DAB_ActionButton_FauxHide(id);
224 else
225 DAB_Bar_FauxHide(bar);
226 end
227 end
228 end
229  
230 if (kboverride == 1) then
231 button.keydown = 1;
232 elseif (kboverride) then
233 button.keydown = nil;
234 end
235 if (not actionoverride) then
236 button:SetChecked(1);
237 button.clicked = .2;
238 end
239  
240 if (not kboverride) then
241 if (bar == "F") then
242 DAB_Run_Script("OnClickAfter", "Floaters", id, mousebutton);
243 else
244 DAB_Run_Script("OnClickAfter", "Bar", bar, mousebutton);
245 end
246 end
247 end
248  
249 function DAB_ActionButton_OnDragStart()
250 local bar = DAB_Settings[DAB_INDEX].Buttons[this:GetID()].Bar;
251 if (DAB_DRAGGING_UNLOCKED or DAB_Check_ModifierKey(DAB_Settings[DAB_INDEX].DragLockOverride)) then
252 if (bar == "F") then
253 this.moving = true;
254 getglobal("DAB_FloaterBox_"..this:GetID()):SetMovable(1);
255 getglobal("DAB_FloaterBox_"..this:GetID()):StartMoving();
256 elseif (bar) then
257 DAB_Bar_OnDragStart(bar);
258 end
259 else
260 if (bar == "F") then
261 if (DAB_Settings[DAB_INDEX].Floaters[this:GetID()].buttonLocked) then return; end
262 else
263 if (DAB_Settings[DAB_INDEX].Bar[bar].buttonsLocked) then return; end
264 end
265 PickupAction(this:GetActionID());
266 end
267 end
268  
269 function DAB_ActionButton_OnDragStop()
270 local id = this:GetID();
271 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
272 if (bar == "F") then
273 this.moving = nil;
274 getglobal("DAB_FloaterBox_"..this:GetID()):StopMovingOrSizing();
275 local settings = DAB_Settings[DAB_INDEX].Floaters[id].Anchor;
276 local x, y = DL_Get_Offsets(getglobal("DAB_FloaterBox_"..this:GetID()), getglobal(settings.frame), settings.point, settings.to);
277 settings.x = x;
278 settings.y = y;
279 DAB_Floater_Location(id);
280 if (DAB_Options and DAB_OBJECT_SUBINDEX == id) then
281 DL_Init_EditBox(DAB_FloaterOptions_Config_XOffset, x);
282 DL_Init_EditBox(DAB_FloaterOptions_Config_YOffset, y);
283 end
284 elseif (bar) then
285 DAB_Bar_OnDragStop(bar);
286 end
287 end
288  
289 function DAB_ActionButton_OnEnter()
290 local button = this;
291 if (not button) then return; end
292 local id = button:GetID();
293 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
294 local action = button:GetActionID();
295 if (bar == "F") then
296 DAB_ControlBox_Delay(DAB_Settings[DAB_INDEX].Floaters[id].cbgroup);
297 elseif (bar) then
298 DAB_ControlBox_Delay(DAB_Settings[DAB_INDEX].Bar[bar].cbgroup);
299 end
300 if (bar == "F") then
301 DAB_Run_Script("OnEnter", "Floaters", id);
302 else
303 DAB_Run_Script("OnEnter", "Bar", bar);
304 end
305 if (bar ~= "F" and DAB_Settings[DAB_INDEX].Bar[bar].disableTooltips) then return; end
306 if (bar == "F" and DAB_Settings[DAB_INDEX].Floaters[id].disableTooltip) then return; end
307 if ( GetCVar("UberTooltips") == "1" ) then
308 GameTooltip_SetDefaultAnchor(GameTooltip, button);
309 else
310 GameTooltip:SetOwner(button, "ANCHOR_RIGHT");
311 end
312  
313 if ( GameTooltip:SetAction(action) ) then
314 button.updateTooltip = TOOLTIP_UPDATE_TIME;
315 else
316 button.updateTooltip = nil;
317 end
318  
319 if (DAB_Settings[DAB_INDEX].ModifyTooltip) then
320 GameTooltip:AddLine(DAB_TEXT.ButtonID..id.." "..DAB_TEXT.ActionID..action, .6, .6, .6, .6, .6, .6);
321 GameTooltip:SetHeight(GameTooltip:GetHeight() + 15);
322 if (GameTooltip:GetWidth() < 200) then
323 GameTooltip:SetWidth(200);
324 end
325 end
326 end
327  
328 function DAB_ActionButton_OnEvent(event)
329 if (DAB_INITIALIZED and DAB_Settings[DAB_INDEX].Buttons[this:GetID()].Bar) then
330 local bar = DAB_Settings[DAB_INDEX].Buttons[this:GetID()].Bar;
331 if (bar == "F") then
332 DAB_Run_Script("OnEvent", "Floaters", this:GetID(), event);
333 elseif (not bar) then
334 return;
335 end
336 else
337 return;
338 end
339  
340 if ( event == "ACTIONBAR_SLOT_CHANGED" ) then
341 if ( arg1 == -1 or arg1 == this:GetActionID() ) then
342 DAB_ActionButton_Update();
343 end
344 elseif ( event == "PLAYER_AURAS_CHANGED" ) then
345 DAB_ActionButton_Update();
346 DAB_ActionButton_UpdateState();
347 return;
348 elseif ( event == "UPDATE_BONUS_ACTIONBAR" ) then
349 DAB_ActionButton_Update();
350 DAB_ActionButton_UpdateState();
351 return;
352 end
353  
354 if ( this.hidden or this.fauxhidden) then return; end
355  
356 if ( event == "UNIT_INVENTORY_CHANGED" ) then
357 if ( arg1 == "player" ) then
358 DAB_ActionButton_Update();
359 end
360 elseif ( event == "ACTIONBAR_UPDATE_STATE" ) then
361 DAB_ActionButton_UpdateState();
362 elseif ( event == "ACTIONBAR_UPDATE_USABLE" or event == "UPDATE_INVENTORY_ALERTS" or event == "ACTIONBAR_UPDATE_COOLDOWN" ) then
363 DAB_ActionButton_UpdateCooldown(this:GetID());
364 elseif ( event == "CRAFT_SHOW" or event == "CRAFT_CLOSE" or event == "TRADE_SKILL_SHOW" or event == "TRADE_SKILL_CLOSE" ) then
365 DAB_ActionButton_UpdateState();
366 elseif ( event == "PLAYER_ENTER_COMBAT" ) then
367 IN_ATTACK_MODE = 1;
368 if ( IsAttackAction(this:GetActionID()) ) then
369 DAB_ActionButton_StartFlash();
370 end
371 elseif ( event == "PLAYER_LEAVE_COMBAT" ) then
372 IN_ATTACK_MODE = nil;
373 if ( IsAttackAction(this:GetActionID()) ) then
374 DAB_ActionButton_StopFlash();
375 end
376 elseif ( event == "START_AUTOREPEAT_SPELL" ) then
377 IN_AUTOREPEAT_MODE = 1;
378 if ( IsAutoRepeatAction(this:GetActionID()) ) then
379 DAB_ActionButton_StartFlash();
380 end
381 elseif ( event == "STOP_AUTOREPEAT_SPELL" ) then
382 IN_AUTOREPEAT_MODE = nil;
383 if ( this.flashing == 1 and (not IsAttackAction(this:GetActionID())) ) then
384 DAB_ActionButton_StopFlash();
385 end
386 end
387 end
388  
389 function DAB_ActionButton_Hide(id)
390 if (not DAB_INITIALIZED) then return; end
391 local button = getglobal("DAB_ActionButton_"..id);
392 button.hidden = true;
393 button:Hide();
394 button.cooldowncount = nil;
395 button.ccountlocked = nil;
396 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
397 if (bar) then
398 DAB_ActionButton_Collapse(button, bar);
399 end
400 end
401  
402 function DAB_ActionButton_OnLeave()
403 this.updateTooltip = nil;
404 GameTooltip:Hide();
405 local bar = DAB_Settings[DAB_INDEX].Buttons[this:GetID()].Bar;
406 if (bar == "F") then
407 DAB_ControlBox_Delay(DAB_Settings[DAB_INDEX].Floaters[this:GetID()].cbgroup, 1);
408 DAB_Run_Script("OnLeave", "Floaters", this:GetID());
409 elseif (bar) then
410 DAB_ControlBox_Delay(DAB_Settings[DAB_INDEX].Bar[bar].cbgroup, 1);
411 DAB_Run_Script("OnLeave", "Bar", bar);
412 end
413 end
414  
415 function DAB_ActionButton_OnLoad()
416 this.flashing = 0;
417 this.flashtime = 0;
418 this:RegisterForDrag("LeftButton", "RightButton");
419 this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up");
420 this:RegisterEvent("ACTIONBAR_SLOT_CHANGED");
421 this:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
422 this:RegisterEvent("ACTIONBAR_UPDATE_STATE");
423 this:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
424 this:RegisterEvent("CRAFT_CLOSE");
425 this:RegisterEvent("CRAFT_SHOW");
426 this:RegisterEvent("PLAYER_AURAS_CHANGED");
427 this:RegisterEvent("PLAYER_ENTER_COMBAT");
428 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
429 this:RegisterEvent("START_AUTOREPEAT_SPELL");
430 this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
431 this:RegisterEvent("TRADE_SKILL_CLOSE");
432 this:RegisterEvent("TRADE_SKILL_SHOW");
433 this:RegisterEvent("UNIT_INVENTORY_CHANGED");
434 this:RegisterEvent("UPDATE_BINDINGS");
435 this:RegisterEvent("UPDATE_BONUS_ACTIONBAR");
436 this:RegisterEvent("UPDATE_INVENTORY_ALERTS");
437 this.activeConditions = {};
438 this.GetActionID = function(frame)
439 return DAB_Settings[DAB_INDEX].Buttons[frame:GetID()].action;
440 end
441 end
442  
443 function DAB_ActionButton_OnMouseWheel(direction)
444 local bar = DAB_Settings[DAB_INDEX].Buttons[this:GetID()].Bar;
445 if (bar == "F") then
446 DAB_Run_Script("OnMouseWheel", "Floaters", this:GetID(), direction);
447 elseif (bar) then
448 DAB_Run_Script("OnMouseWheel", "Bar", bar, direction);
449 end
450 if (bar == "F") then return; end
451 if (DAB_Settings[DAB_INDEX].Bar[bar].disableMW) then return; end
452 local page = DAB_Settings[DAB_INDEX].Bar[bar].page;
453 if (direction > 0) then
454 DAB_Bar_PageDown(bar);
455 else
456 DAB_Bar_PageUp(bar);
457 end
458 end
459  
460 function DAB_ActionButton_OnReceiveDrag()
461 PlaceAction(this:GetActionID());
462 this:SetChecked(0);
463 DAB_ActionButton_UpdateState();
464 end
465  
466 function DAB_ActionButton_SetTarget(buttonID, unit)
467 local button = getglobal("DAB_ActionButton_"..buttonID);
468 if (button) then
469 button.targetOverride = unit;
470 end
471 end
472  
473 function DAB_ActionButton_SetText(buttonID, text)
474 local button = getglobal("DAB_ActionButton_"..buttonID);
475 if (button) then
476 button.textOverride = text;
477 if (text) then
478 getglobal("DAB_ActionButton_"..buttonID.."_Name"):SetText(text);
479 else
480 getglobal("DAB_ActionButton_"..buttonID.."_Name"):SetText(GetActionText(button:GetActionID()));
481 end
482 end
483 end
484  
485 function DAB_ActionButton_Show(id)
486 if (not DAB_INITIALIZED) then return; end
487 local button = getglobal("DAB_ActionButton_"..id);
488 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
489 button.hidden = nil;
490 button:Show();
491 if (bar and bar ~="F") then
492 DAB_ActionButton_Uncollapse(button, bar);
493 end
494 end
495  
496 function DAB_ActionButton_OnUpdate(elapsed)
497 if (not DAB_INITIALIZED) then return; end
498  
499 local id = this:GetID();
500 local action = this:GetActionID();
501 if (this.clicked) then
502 this.clicked = this.clicked - elapsed;
503 if (this.clicked < 0) then
504 this.clicked = nil;
505 DAB_ActionButton_UpdateState();
506 end
507 elseif (this:GetChecked()) then
508 DAB_ActionButton_UpdateState();
509 end
510  
511 if (DAB_SHOWING_EMPTY) then return; end
512  
513 if (not HasAction(action)) then return; end
514 if (not DAB_Settings[DAB_INDEX].Buttons[id].Bar) then return; end
515  
516 if ( this.flashing == 1 and (not this.fauxhidden)) then
517 this.flashtime = this.flashtime - elapsed;
518 if ( this.flashtime <= 0 ) then
519 local overtime = -this.flashtime;
520 if ( overtime >= ATTACK_BUTTON_FLASH_TIME ) then
521 overtime = 0;
522 end
523 this.flashtime = ATTACK_BUTTON_FLASH_TIME - overtime;
524  
525 local flashTexture = getglobal(this:GetName().."_Flash");
526 if ( flashTexture:IsShown() ) then
527 flashTexture:Hide();
528 else
529 flashTexture:Show();
530 end
531 end
532 end
533  
534 if (this.blinking and (not this.fauxhidden)) then
535 this.blinktime = this.blinktime - elapsed;
536 if (this.blinktime < 0) then
537 this.blinktime = .5;
538 if (this.direction) then
539 this.direction = nil;
540 else
541 this.direction = true;
542 end
543 end
544 if (this.direction) then
545 this:SetAlpha(1 - this.blinktime);
546 else
547 this:SetAlpha(this.blinktime + .5);
548 end
549 end
550  
551 if (this.timetohide) then
552 this.timetohide = this.timetohide - elapsed;
553 if (this.timetohide < 0) then
554 this.timetohide = nil;
555 DAB_Floater_Hide(id);
556 end
557 end
558  
559 if ( this.rangeTimer and (not this.fauxhidden)) then
560 if ( this.rangeTimer < 0 ) then
561 local isUsable, notEnoughMana = IsUsableAction(action);
562 local outOfRange;
563 if (IsActionInRange(action) == 0) then
564 outOfRange = true;
565 end
566  
567 local manaRecolor = DAB_ActionButton_GetSetting(id, "manarecolor");
568 local unusableRecolor = DAB_ActionButton_GetSetting(id, "unusablerecolor");
569 local rangeRecolor = DAB_ActionButton_GetSetting(id, "rangerecolor");
570  
571 if (manaRecolor == 1 or unusableRecolor == 1 or rangeRecolor == 1) then
572 local r, g, b = 1, 1, 1;
573 r, g, b = DAB_ActionButton_GetColor(id, 1, r, g, b, manaRecolor, notEnoughMana, rangeRecolor, outOfRange, unusableRecolor, isUsable);
574 getglobal(this:GetName().."_Icon"):SetVertexColor(r, g, b);
575 end
576  
577 if (manaRecolor == 2 or unusableRecolor == 2 or rangeRecolor == 2) then
578 local r, g, b = DAB_ActionButton_GetSetting(this:GetID(), "ButtonBorder", 1, "color");
579 r, g, b = DAB_ActionButton_GetColor(id, 2, r, g, b, manaRecolor, notEnoughMana, rangeRecolor, outOfRange, unusableRecolor, isUsable);
580 getglobal(this:GetName().."_Border"):SetVertexColor(r, g, b);
581 end
582  
583 if (manaRecolor == 3 or unusableRecolor == 3 or rangeRecolor == 3) then
584 local r, g, b = DAB_ActionButton_GetSetting(this:GetID(), "Keybinding", 1, "color");
585 r, g, b = DAB_ActionButton_GetColor(id, 3, r, g, b, manaRecolor, notEnoughMana, rangeRecolor, outOfRange, unusableRecolor, isUsable);
586 getglobal(this:GetName().."_HotKey"):SetTextColor(r, g, b);
587 end
588  
589 this.rangeTimer = TOOLTIP_UPDATE_TIME;
590 if (this.clicked and (not this.keydown)) then
591 if ( (not IsCurrentAction(action)) and (not IsAutoRepeatAction(action)) ) then
592 this:SetChecked(0);
593 this.clicked = nil;
594 end
595 end
596 else
597 this.rangeTimer = this.rangeTimer - elapsed;
598 end
599 end
600  
601 if (this.cooldowncount) then
602 this.cooldowncount = this.cooldowncount - elapsed;
603 if (this.cooldowncount <= 0) then
604 this.cooldowncount = nil;
605 this.clicked = nil;
606 getglobal(this:GetName().."_CooldownCount"):SetText("");
607 getglobal(this:GetName().."_Timer"):SetText("");
608 if (this.ccountlocked) then
609 this.ccountlocked = nil;
610 DAB_ActionButton_UpdateCooldown(id);
611 end
612 else
613 local count = math.ceil(this.cooldowncount);
614 local cctext;
615 if (this.ccountlocked) then
616 cctext = getglobal(this:GetName().."_Timer");
617 getglobal(this:GetName().."_CooldownCount"):SetText("");
618 else
619 cctext = getglobal(this:GetName().."_CooldownCount");
620 getglobal(this:GetName().."_Timer"):SetText("");
621 end
622 if (DAB_Settings[DAB_INDEX].CDFormat == 1) then
623 if (count < 60) then
624 cctext:SetText(count);
625 else
626 count = math.ceil(count / 60);
627 cctext:SetText(count.."m");
628 end
629 elseif (DAB_Settings[DAB_INDEX].CDFormat == 2) then
630 cctext:SetText(count);
631 else
632 local min = math.floor(count / 60);
633 local sec = count - min * 60;
634 if (min < 10) then
635 min = "0"..min;
636 end
637 if (sec < 10) then
638 sec = "0"..sec;
639 end
640 cctext:SetText(min..":"..sec);
641 end
642 end
643 end
644  
645 if (not this.updatetimer) then this.updatetimer = DAB_UPDATE_SPEED; end
646 this.updatetimer = this.updatetimer - elapsed;
647 if (this.updatetimer < 0) then
648 this.updatetimer = DAB_UPDATE_SPEED;
649  
650 if (DAB_Settings[DAB_INDEX].Buttons[id].Bar == "F") then
651 if (not this.lasttime) then this.lasttime = GetTime(); end
652 local timeelapsed = GetTime() - this.lasttime;
653 this.lasttime = GetTime();
654 DAB_Run_Script("OnUpdate", "Floaters", id, timeelapsed);
655 end
656  
657 local condition, response;
658 local conditions;
659 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
660 if (bar == "F") then
661 conditions = DAB_Settings[DAB_INDEX].Buttons[id].Conditions;
662 else
663 local page = DAB_Bar_GetRealPage(bar);
664 conditions = DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][this:GetParent().bttnpos[id]];
665 end
666 for i = 1, table.getn(conditions) do
667 condition = conditions[i].condition;
668 response = conditions[i].response;
669 this = getglobal("DAB_ActionButton_"..id);
670 local active;
671 if (condition == 0) then
672 active = true;
673 this.activeConditions[i] = nil;
674 elseif (condition == 9 or condition == 10) then
675 active = DL_CheckCondition[condition](getglobal("DAB_FloaterBox_"..id));
676 else
677 active = DL_CheckCondition[condition](conditions[i]);
678 end
679 for _,override in conditions[i].overrides do
680 if (this.activeConditions[override]) then
681 active = nil;
682 break;
683 end
684 end
685  
686 if (active and (not this.activeConditions[i]) and response ~= 0) then
687 if (response == 2) then
688 DAB_ActionButton_FauxHide(id);
689 elseif (response == 3) then
690 DAB_ActionButton_FauxShow(id);
691 elseif (response == 4) then
692 this:SetAlpha(conditions[i].alpha);
693 elseif (response == 7) then
694 getglobal(this:GetName().."_Border"):SetAlpha(conditions[i].alpha);
695 elseif (response == 8) then
696 if (not this.colorOverride) then
697 this.colorOverride = {[2] = conditions[i].color};
698 else
699 this.colorOverride[2] = conditions[i].color;
700 end
701 getglobal(this:GetName().."_Border"):SetVertexColor( conditions[i].color.r, conditions[i].color.g, conditions[i].color.b );
702 elseif (response == 11) then
703 DAB_Floater_MoveUp(id, conditions[i].amount);
704 elseif (response == 12) then
705 DAB_Floater_MoveDown(id, conditions[i].amount);
706 elseif (response == 13) then
707 DAB_Floater_MoveLeft(id, conditions[i].amount);
708 elseif (response == 14) then
709 DAB_Floater_MoveRight(id, conditions[i].amount);
710 elseif (response == 19) then
711 DAB_Floater_Size(id, conditions[i].amount);
712 elseif (response == 21) then
713 local x, y = GetCursorPosition();
714 x = x / UIParent:GetScale();
715 y = y / UIParent:GetScale();
716 DAB_Floater_Location(id, x, y, "UIParent", "CENTER", "BOTTOMLEFT");
717 elseif (response == 22) then
718 if (not this.colorOverride) then
719 this.colorOverride = {[1] = conditions[i].color};
720 else
721 this.colorOverride[1] = conditions[i].color;
722 end
723 getglobal(this:GetName().."_Icon"):SetVertexColor( conditions[i].color.r, conditions[i].color.g, conditions[i].color.b );
724 elseif (response == 23) then
725 DAB_Floater_SetKeybinding(id, conditions[i].rnumber);
726 elseif (response == 24) then
727 this.blinking = true;
728 this.blinkdirection = true;
729 this.blinktime = .5;
730 elseif (response == 25) then
731 this.blinking = nil;
732 this:SetAlpha(1);
733 elseif (response == 26) then
734 DAB_ActionButton_StartFlash();
735 this.flashingoverride = 1;
736 elseif (response == 27) then
737 this.flashingoverride = nil;
738 DAB_ActionButton_StopFlash();
739 elseif (response == 28) then
740 this.colorOverride = nil;
741 getglobal(this:GetName().."_Icon"):SetVertexColor( 1, 1, 1 );
742 elseif (response == 29) then
743 DAB_ActionButton_SetAction(this:GetID(), conditions[i].raction);
744 elseif (response == 30) then
745 this.disabled = nil;
746 elseif (response == 31) then
747 this.disabled = true;
748 elseif (response == 33) then
749 DAB_ActionButton_SetTarget(this:GetID(), conditions[i].runit);
750 elseif (response == 34) then
751 DAB_ActionButton_SetTarget(this:GetID());
752 elseif (response == 35) then
753 DAB_Floater_Location(id, conditions[i].rx, conditions[i].ry);
754 else
755 DAB_Global_Response(response, conditions[i]);
756 end
757 end
758  
759 getglobal("DAB_ActionButton_"..id).activeConditions[i] = active;
760 end
761 end
762  
763 if ( not this.updateTooltip ) then return; end
764  
765 this.updateTooltip = this.updateTooltip - elapsed;
766 if ( this.updateTooltip > 0 ) then return; end
767  
768 if ( GameTooltip:IsOwned(this) ) then
769 DAB_ActionButton_OnEnter();
770 else
771 this.updateTooltip = nil;
772 end
773 end
774  
775 function DAB_ActionButton_RestoreAlpha(id)
776 local texture = getglobal("DAB_ActionButton_"..id.."_Icon");
777 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
778 local settings;
779 if (bar == "F") then
780 settings = DAB_Settings[DAB_INDEX].Floaters[id];
781 else
782 settings = DAB_Settings[DAB_INDEX].Bar[bar];
783 end
784 if (settings.ButtonBorder.alpha < 1) then
785 getglobal("DAB_ActionButton_"..id.."_Border"):SetVertexColor(settings.ButtonBorder.color.r, settings.ButtonBorder.color.g, settings.ButtonBorder.color.b, settings.ButtonBorder.alpha);
786 end
787 if (settings.alpha == 1) then return; end
788 getglobal("DAB_ActionButton_"..id.."_Icon"):SetVertexColor(1, 1, 1, settings.alpha);
789 getglobal("DAB_ActionButton_"..id.."_Background"):SetVertexColor(settings.buttonbgcolor.r, settings.buttonbgcolor.g, settings.buttonbgcolor.b, settings.alpha);
790 getglobal("DAB_ActionButton_"..id.."_Checked"):SetVertexColor(settings.checkedcolor.r, settings.checkedcolor.g, settings.checkedcolor.b, settings.alpha);
791 getglobal("DAB_ActionButton_"..id.."_EquippedBorder"):SetVertexColor(settings.ButtonBorder.ecolor.r, settings.ButtonBorder.ecolor.g, settings.ButtonBorder.ecolor.b, settings.alpha);
792 end
793  
794 function DAB_ActionButton_SetAction(id, action)
795 if (DAB_Settings[DAB_INDEX].Buttons[id].action == action) then return; end
796 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
797 DAB_Settings[DAB_INDEX].Buttons[id].action = action;
798 if (bar ~= "F") then
799 local page = DAB_Settings[DAB_INDEX].Bar[bar].page;
800 local loc = getglobal("DAB_ActionBar_"..bar).bttnpos[id];
801 DAB_Settings[DAB_INDEX].Bar[bar].pages[page][loc] = action;
802 end
803 DAB_ActionButton_Update(id);
804 end
805  
806 function DAB_ActionButton_SetTimer(id, cdtime)
807 local button = getglobal("DAB_ActionButton_"..id);
808 getglobal("DAB_ActionButton_"..id.."_CooldownCount"):SetText("");
809 button.cooldowncount = cdtime;
810 button.ccountlocked = true;
811 end
812  
813 function DAB_ActionButton_StartFlash()
814 this.flashing = 1;
815 this.flashtime = 0;
816 DAB_ActionButton_UpdateState();
817 end
818  
819 function DAB_ActionButton_StopFlash()
820 if (this.flashingoverride) then return; end
821 this.flashing = 0;
822 getglobal(this:GetName().."_Flash"):Hide();
823 DAB_ActionButton_UpdateState();
824 end
825  
826 function DAB_ActionButton_Uncollapse(button, bar)
827 if (bar == "F") then return; end
828 if (not button.collapsed) then return; end
829 if (not button:GetParent().initialized) then return; end
830 button.collapsed = nil;
831 local loc = button:GetParent().buttonLocation[button:GetID()].loc;
832 local row = button:GetParent().buttonLocation[button:GetID()].row;
833 button:ClearAllPoints();
834 if (loc == 1 and row == 1) then
835 button:SetPoint("TOPLEFT", button:GetParent(), "TOPLEFT", DAB_Settings[DAB_INDEX].Bar[bar].Background.leftpadding, -DAB_Settings[DAB_INDEX].Bar[bar].Background.toppadding);
836 elseif (button.yoffset) then
837 button:SetPoint("TOPLEFT", button:GetParent(), "TOPLEFT", DAB_Settings[DAB_INDEX].Bar[bar].Background.leftpadding, -button.yoffset);
838 elseif (loc > 1) then
839 button:SetPoint("LEFT", "DAB_ActionButton_"..button:GetParent().rows[row][loc - 1], "RIGHT", DAB_Settings[DAB_INDEX].Bar[bar].hspacing, 0);
840 end
841 button:SetWidth(36);
842 DAB_Bar_Size(bar);
843 end
844  
845 function DAB_ActionButton_Update(id)
846 if (not DAB_INITIALIZED) then return; end
847 local button, buttonName;
848 if (id) then
849 buttonName = "DAB_ActionButton_"..id;
850 button = getglobal(buttonName);
851 else
852 id = this:GetID();
853 button = this;
854 buttonName = this:GetName();
855 end
856  
857 local resetthis
858 if (this:GetName() == "ChatFrameEditBox") then
859 resetthis = 1
860 end
861  
862 local action = button:GetActionID();
863 local icon = getglobal(buttonName.."_Icon");
864 local texture = GetActionTexture(action);
865  
866 this = button;
867 DAB_ActionButton_UpdateCount();
868 if ( HasAction(action) ) then
869 if (texture == "" or (not texture)) then
870 icon:SetTexture("");
871 icon:Hide();
872 else
873 icon:SetTexture(texture);
874 icon:Show();
875 end
876 button.rangeTimer = TOOLTIP_UPDATE_TIME;
877 DAB_ActionButton_UpdateCooldown(id);
878 else
879 icon:SetTexture("");
880 icon:Hide();
881 end
882  
883 local eborder = getglobal(buttonName.."_EquippedBorder");
884 if (IsEquippedAction(action)) then
885 eborder:Show();
886 else
887 eborder:Hide();
888 end
889  
890 if ( IsAttackAction(action) and IsCurrentAction(action) ) then
891 IN_ATTACK_MODE = 1;
892 else
893 IN_ATTACK_MODE = nil;
894 end
895 IN_AUTOREPEAT_MODE = IsAutoRepeatAction(action);
896 if ( IN_ATTACK_MODE or IN_AUTOREPEAT_MODE ) then
897 DAB_ActionButton_StartFlash();
898 else
899 DAB_ActionButton_StopFlash();
900 end
901  
902 if ( GameTooltip:IsOwned(button) ) then
903 DAB_ActionButton_OnEnter();
904 else
905 button.updateTooltip = nil;
906 end
907  
908 if (DAB_SHOWING_IDS) then
909 if (DAB_SHOWING_ACTIONIDS) then
910 getglobal(buttonName.."_Name"):SetText("A "..action);
911 else
912 getglobal(buttonName.."_Name"):SetText(id);
913 end
914 elseif (button.textOverride) then
915 getglobal(buttonName.."_Name"):SetText(button.textOverride);
916 else
917 getglobal(buttonName.."_Name"):SetText(GetActionText(action));
918 end
919  
920 if (not HasAction(action)) then
921 local bar = DAB_Settings[DAB_INDEX].Buttons[id].Bar;
922 if (bar and bar ~= "F") then
923 if (DAB_Settings[DAB_INDEX].Bar[bar].hideEmpty) then
924 if (not DAB_SHOWING_EMPTY) then
925 DAB_ActionButton_Hide(id);
926 else
927 DAB_ActionButton_Show(id);
928 end
929 else
930 DAB_ActionButton_Show(id);
931 end
932 end
933 end
934  
935 this = button;
936 if (resetthis) then
937 this = ChatFrameEditBox
938 end
939 end
940  
941 function DAB_ActionButton_UpdateCooldown(id)
942 if (not DAB_INITIALIZED) then return; end
943 if (not id or id == 0) then return; end
944 if (not DAB_Settings[DAB_INDEX].Buttons[id].Bar) then return; end
945 local button = getglobal("DAB_ActionButton_"..id);
946 local action = button:GetActionID();
947 local cooldown = getglobal(button:GetName().."_Cooldown");
948 local start, duration, enable = GetActionCooldown(action);
949 CooldownFrame_SetTimer(cooldown, start, duration, enable);
950 if (not DAB_SHOWING_IDS) then
951 getglobal(button:GetName().."_CooldownCount"):SetText("");
952 end
953 if (button.ccountlocked) then return; end
954 local cdcount, hideGlobal;
955 if (DAB_Settings[DAB_INDEX].Buttons[id].Bar == "F") then
956 cdcount = DAB_Settings[DAB_INDEX].Floaters[id].cooldownCount;
957 hideGlobal = DAB_Settings[DAB_INDEX].Floaters[id].hideGlobalCD;
958 else
959 cdcount = DAB_Settings[DAB_INDEX].Bar[DAB_Settings[DAB_INDEX].Buttons[id].Bar].cooldownCount;
960 hideGlobal = DAB_Settings[DAB_INDEX].Bar[DAB_Settings[DAB_INDEX].Buttons[id].Bar].hideGlobalCD;
961 end
962 if (cdcount) then
963 if (start and start > 0) then
964 local timeRemaining = duration - (GetTime() - start);
965 if (((not button.cooldowncount) or button.cooldowncount == 0) and timeRemaining <= 2.5 and hideGlobal) then
966 button.cooldowncount = 0;
967 else
968 button.cooldowncount = timeRemaining;
969 end
970 else
971 button.cooldowncount = 0;
972 end
973 end
974 end
975  
976 function DAB_ActionButton_UpdateCount()
977 local text = getglobal(this:GetName().."_Count");
978 local count = GetActionCount(this:GetActionID());
979 if ( IsConsumableAction(this:GetActionID()) ) then
980 text:SetText(count);
981 else
982 text:SetText("");
983 end
984 end
985  
986 function DAB_ActionButton_UpdateState()
987 if (this.clicked) then return; end
988 if ( IsCurrentAction(this:GetActionID()) or IsAutoRepeatAction(this:GetActionID()) ) then
989 this:SetChecked(1);
990 else
991 this:SetChecked(0);
992 end
993 end