vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function DAB_Main_OnEvent()
2 if (not DAB_INITIALIZED) then return; end
3 if (event == "ACTIONBAR_HIDEGRID") then
4 DiscordActionBarsFrame.updatenewactions = .1;
5 elseif (event == "ACTIONBAR_SHOWGRID") then
6 DiscordActionBarsFrame.updatenewactions = nil;
7 DAB_SHOWING_EMPTY = true;
8 for i=1,10 do
9 if (DAB_Settings[DAB_INDEX].Bar[i].hideEmpty) then
10 DAB_Bar_Update(i);
11 end
12 if (DAB_Settings[DAB_INDEX].Bar[i].expandHidden) then
13 local bar = getglobal("DAB_ActionBar_"..i);
14 DAB_Bar_FauxShow(i);
15 bar:Show();
16 bar.activeConditions = {};
17 local page = DAB_Settings[DAB_INDEX].Bar[i].page;
18 if (bar.pagemap[page]) then
19 page = bar.pagemap[page];
20 end
21 for b=1,120 do
22 if (DAB_Settings[DAB_INDEX].Buttons[b].Bar == i) then
23 local button = getglobal("DAB_ActionButton_"..b);
24 DAB_ActionButton_FauxShow(b);
25 DAB_ActionButton_Show(b);
26 button.activeConditions = {};
27 end
28 end
29 end
30 for b in DAB_Settings[DAB_INDEX].Floaters do
31 if (DAB_Settings[DAB_INDEX].Floaters[b].expandHidden) then
32 local button = getglobal("DAB_ActionButton_"..b);
33 DAB_ActionButton_FauxShow(b);
34 DAB_ActionButton_Show(b);
35 button.activeConditions = {};
36 end
37 end
38 end
39 --elseif (event == "ACTIONBAR_SLOT_CHANGED") then
40 --DiscordActionBarsFrame.updateactionlist = .5;
41 elseif (event == "DISPLAY_SIZE_CHANGED") then
42 DL_Debug("Size changed. Updating DAB settings.");
43 DAB_Initialize_Everything();
44 elseif (event == "UPDATE_SHAPESHIFT_FORMS") then
45 DAB_OTHER_BAR[12][0].numButtons = GetNumShapeshiftForms();
46 DAB_OtherBar_Initialize(12);
47 DL_Update_Forms();
48 elseif (event == "UNIT_PET" and arg1 == "player") then
49 if (PetHasActionBar()) then
50 DAB_OtherBar_Pet.nopet = nil;
51 DAB_OtherBar_Pet:Show();
52 DAB_OtherBar_Pet.mouseover = 1;
53 else
54 DAB_OtherBar_Pet.nopet = true;
55 DAB_OtherBar_Pet:Hide();
56 end
57 --elseif (event == "PLAYER_AURAS_CHANGED") then
58 --DiscordActionBarsFrame.updateactionlist = nil;
59 end
60 end
61  
62 function DAB_Main_OnLoad()
63 DiscordLib_RegisterInitFunc(DAB_Initialize);
64  
65 SlashCmdList["DAB"] = DAB_Slash_Handler;
66 SLASH_DAB1 = "/dab";
67 SLASH_DAB2 = "/discordactionbars";
68  
69 this:RegisterEvent("ACTIONBAR_HIDEGRID");
70 this:RegisterEvent("ACTIONBAR_SHOWGRID");
71 --this:RegisterEvent("ACTIONBAR_SLOT_CHANGED");
72 this:RegisterEvent("DISPLAY_SIZE_CHANGED");
73 this:RegisterEvent("UPDATE_SHAPESHIFT_FORMS");
74 this:RegisterEvent("UNIT_PET");
75 --this:RegisterEvent("PLAYER_AURAS_CHANGED");
76 --this:RegisterEvent("");
77 end
78  
79 function DAB_Add_AutoCast(actionID, unit)
80 if (not DAB_AUTOCAST_QUEUE) then
81 DAB_AUTOCAST_QUEUE = {};
82 end
83 for i in DAB_AUTOCAST_QUEUE do
84 if (DAB_AUTOCAST_QUEUE[i].a == actionID and DAB_AUTOCAST_QUEUE[i].u == unit) then
85 return;
86 end
87 end
88 tinsert(DAB_AUTOCAST_QUEUE, {a=actionID, u=unit});
89 end
90  
91 function DAB_AutoCast()
92 if (DAB_AUTOCAST_QUEUE and DAB_AUTOCAST_QUEUE[1]) then
93 local max = table.getn(DAB_AUTOCAST_QUEUE);
94 local usableAction;
95 for i=1, max do
96 if (DL_ActionUsable(DAB_AUTOCAST_QUEUE[i].a)) then
97 usableAction = i;
98 break;
99 end
100 end
101 if (not usableAction) then return; end
102 local hadTarget;
103 if ( (not UnitCanAttack("player", "target")) and UnitName("target") ) then
104 hadTarget = true;
105 TargetUnit(DAB_AUTOCAST_QUEUE[usableAction].u);
106 end
107 UseAction(DAB_AUTOCAST_QUEUE[usableAction].a);
108 if (hadTarget) then
109 TargetLastTarget();
110 elseif (DAB_AUTOCAST_QUEUE[usableAction].u) then
111 SpellTargetUnit(DAB_AUTOCAST_QUEUE[usableAction].u);
112 end
113 tremove(DAB_AUTOCAST_QUEUE, usableAction);
114 end
115 end
116  
117 function DAB_BonusCooldown_OnUpdate(elapsed)
118 if (this.cooldowncount) then
119 this.cooldowncount = this.cooldowncount - elapsed;
120 if (this.cooldowncount <= 0) then
121 this.cooldowncount = nil;
122 getglobal(this:GetName().."_Text"):SetText("");
123 else
124 local count = math.ceil(this.cooldowncount);
125 if (DAB_Settings[DAB_INDEX].CDFormat == 1) then
126 if (count < 60) then
127 getglobal(this:GetName().."_Text"):SetText(count);
128 else
129 count = math.ceil(count / 60);
130 getglobal(this:GetName().."_Text"):SetText(count.."m");
131 end
132 elseif (DAB_Settings[DAB_INDEX].CDFormat == 2) then
133 getglobal(this:GetName().."_Text"):SetText(count);
134 else
135 local min = math.floor(count / 60);
136 local sec = count - min * 60;
137 if (min < 10) then
138 min = "0"..min;
139 end
140 if (sec < 10) then
141 sec = "0"..sec;
142 end
143 getglobal(this:GetName().."_Text"):SetText(min..":"..sec);
144 end
145 end
146 end
147 end
148  
149 function DAB_Check_ModifierKey(index)
150 if (index == 0) then
151 return;
152 elseif (index == 1) then
153 return IsAltKeyDown();
154 elseif (index == 2) then
155 return IsControlKeyDown();
156 else
157 return IsShiftKeyDown();
158 end
159 end
160  
161 function DAB_EventMacro_Compile()
162 for _, v in DAB_EVENTS do
163 DAB_EventMacroFrame:UnregisterEvent(v.value);
164 end
165 for event, script in DAB_Settings[DAB_INDEX].EventMacros do
166 setglobal("DAB_EventMacros_"..event, nil);
167 if (script and script ~= "") then
168 DAB_EventMacroFrame:RegisterEvent(event);
169 RunScript("function DAB_EventMacros_"..event.."(arg1, arg2, arg3, arg4, arg5)\n"..script.."\nend");
170 elseif (script == "") then
171 DAB_Settings[DAB_INDEX].EventMacros[event] = nil;
172 end
173 end
174 if (DAB_VL_CHANGED) then
175 DAB_VL_CHANGED = nil;
176 if (DAB_EventMacros_VARIABLES_LOADED) then
177 DAB_EventMacros_VARIABLES_LOADED();
178 end
179 end
180 end
181  
182 function DAB_EventMacro_OnEvent(event)
183 if (not DAB_INITIALIZED) then return; end
184 if (DAB_EDITTING_MACRO) then return; end
185 if (getglobal("DAB_EventMacros_"..event)) then
186 getglobal("DAB_EventMacros_"..event)(arg1, arg2, arg3, arg4, arg5);
187 end
188 end
189  
190 function DAB_EventMacro_Update()
191 if (DAB_MACRO_EVENT) then
192 DAB_Settings[DAB_INDEX].EventMacros[DAB_MACRO_EVENT] = DAB_OnEventMacros_EditBox_Text:GetText();
193 DAB_Update_EventList();
194 end
195 if (DAB_MACRO_EVENT == "VARIABLES_LOADED") then
196 DAB_VL_CHANGED = true;
197 end
198 end
199  
200 function DAB_EventMacro_OnUpdate(elapsed)
201 if (not DAB_INITIALIZED) then return; end
202 if (DAB_EDITTING_MACRO) then return; end
203 if (not DAB_EventMacros_OnUpdate) then return; end
204 if (not this.timer) then
205 this.timer = DAB_UPDATE_SPEED;
206 this.lasttime = GetTime();
207 end
208 this.timer = this.timer - elapsed;
209 if (this.timer < 0) then
210 this.timer = DAB_UPDATE_SPEED;
211 local time = GetTime();
212 local trueelapsed = time - this.lasttime;
213 this.lasttime = time;
214 DAB_EventMacros_OnUpdate(trueelapsed);
215 end
216 end
217  
218 function DAB_Get_ActionName(id)
219 if (not id) then return ""; end
220 if (not HasAction(id)) then return ""; end
221 DiscordLib_Tooltip:SetAction(id);
222 local name, rank = "", "";
223 if (DiscordLib_TooltipTextLeft1:IsShown()) then
224 name = DiscordLib_TooltipTextLeft1:GetText();
225 end
226 if (DiscordLib_TooltipTextRight1:IsShown()) then
227 rank = DiscordLib_TooltipTextRight1:GetText();
228 end
229 if (rank == "") then
230 return name;
231 else
232 return name.." ("..rank..")";
233 end
234 end
235  
236 function DAB_Get_BarButtonID(bar, page, loc)
237 local count = 0;
238 for i=1,120 do
239 if (DAB_Settings[DAB_INDEX].Buttons[i].Bar == bar) then
240 count = count + 1;
241 if (count == loc) then
242 return i;
243 end
244 end
245 end
246 end
247  
248 function DAB_Get_MatchingButton(bar, button, bar2)
249 if (bar == bar2) then return button; end
250 local count = 0;
251 for i=1,120 do
252 if (DAB_Settings[DAB_INDEX].Buttons[i].Bar == bar) then
253 count = count + 1;
254 if (i == button) then break; end
255 end
256 end
257 local count2 = 0
258 for i=1,120 do
259 if (DAB_Settings[DAB_INDEX].Buttons[i].Bar == bar2) then
260 count2 = count2 + 1;
261 if (count2 == count) then return i; end
262 end
263 end
264 return getglobal("DAB_ActionButton_"..button):GetID();
265 end
266  
267 function DAB_Global_Response(response, values)
268 if (response == 100) then
269 DL_Feedback(values.rtext);
270 elseif (response == 101) then
271 UIErrorsFrame:AddMessage(values.rtext, 1.0, 1.0, 0.0, 1.0, UIERRORS_HOLD_TIME);
272 elseif (response == 102) then
273 DAB_Bar_FauxHide(values.rnumber);
274 elseif (response == 103) then
275 DAB_Bar_FauxShow(values.rnumber);
276 DAB_Bar_Show(values.rnumber);
277 elseif (response == 104) then
278 DAB_ControlBox_Hide(values.rnumber);
279 elseif (response == 105) then
280 DAB_ControlBox_Show(values.rnumber);
281 elseif (response == 106) then
282 DAB_ActionButton_FauxHide(values.rnumber);
283 elseif (response == 107) then
284 DAB_ActionButton_FauxShow(values.rnumber);
285 DAB_Floater_Show(values.rnumber);
286 elseif (response == 108) then
287 setglobal(values.rtext, false);
288 elseif (response == 109) then
289 setglobal(values.rtext, true);
290 elseif (response == 110) then
291 DAB_Add_AutoCast(values.raction, values.runit);
292 elseif (response == 111) then
293 for index, value in DAB_AUTOCAST_QUEUE do
294 if (DAB_AUTOCAST_QUEUE.a == values.raction) then
295 tremove(DAB_AUTOCAST_QUEUE, index);
296 end
297 end
298 elseif (response == 112) then
299 SpellStopCasting();
300 elseif (response == 113) then
301 DL_Set_Timer(values.rtext, values.rnumber);
302 elseif (response == 114) then
303 PlaySoundFile(values.rtext);
304 elseif (response == 115) then
305 RunScript(values.rtext);
306 end
307 end
308  
309 function DAB_Hide_Group(group)
310 for i=1,10 do
311 if (DAB_Settings[DAB_INDEX].Bar[i].cbgroup == group) then
312 DAB_Bar_Hide(i);
313 end
314 if (DAB_Settings[DAB_INDEX].ControlBox[i].cbgroup == group) then
315 DAB_ControlBox_Hide(i);
316 end
317 end
318 for i=11,14 do
319 if (DAB_Settings[DAB_INDEX].OtherBar[i].cbgroup == group) then
320 DAB_OtherBar_Hide(i);
321 end
322 end
323 for b in DAB_Settings[DAB_INDEX].Floaters do
324 if (DAB_Settings[DAB_INDEX].Floaters[b].cbgroup == group) then
325 DAB_Floater_Hide(b);
326 end
327 end
328 end
329  
330 function DAB_KeybindingDown(id)
331 if (not DAB_INITIALIZED) then return; end
332 local kb = DAB_Settings[DAB_INDEX].Keybindings[id];
333 if (not kb.down) then return; end
334 if (kb.option == 0) then return; end
335 if (kb.option == 1 or kb.option == 10) then
336 local button = DAB_Get_BarButtonID(kb.suboption, page, kb.suboption2);
337 if (button) then
338 local selfcast;
339 if (kb.option == 10) then
340 selfcast = 1;
341 end
342 DAB_Run_Script("OnKeybindingDownBefore", "Bar", kb.suboption, button);
343 DAB_ActionButton_OnClick(button, "LeftButton", 1, selfcast);
344 DAB_Run_Script("OnKeybindingDownAfter", "Bar", kb.suboption, button);
345 end
346 elseif (kb.option == 2) then
347 if (not DAB_Settings[DAB_INDEX].KBGroups[kb.suboption]) then return; end
348 local bar = DAB_Settings[DAB_INDEX].KBGroups[kb.suboption];
349 local button = DAB_Get_BarButtonID(bar, page, kb.suboption2);
350 if (button) then
351 DAB_Run_Script("OnKeybindingDownBefore", "Bar", bar, button);
352 DAB_ActionButton_OnClick(button, "LeftButton", 1);
353 DAB_Run_Script("OnKeybindingDownAfter", "Bar", bar, button);
354 end
355 elseif (kb.option == 3 or kb.option == 11) then
356 local selfcast;
357 if (kb.option == 11) then
358 selfcast = 1;
359 end
360 DAB_Run_Script("OnKeybindingDownBefore", "Floaters", kb.suboption);
361 DAB_ActionButton_OnClick(kb.suboption, "LeftButton", 1, selfcast);
362 DAB_Run_Script("OnKeybindingDownAfter", "Floaters", kb.suboption);
363 elseif (kb.option == 4) then
364 DAB_Run_Script("OnKeybindingDownBefore", "ControlBox", kb.suboption);
365 DAB_ControlBox_KeybindingDown(kb.suboption);
366 DAB_Run_Script("OnKeybindingDownAfter", "ControlBox", kb.suboption);
367 elseif (kb.option == 5) then
368 DAB_Set_KeybindingGroup(kb.suboption, kb.suboption2);
369 elseif (kb.option == 6) then
370 DAB_Bar_SetPage(kb.suboption, kb.suboption2);
371 elseif (kb.option == 7) then
372 DAB_Bar_PageUp(kb.suboption);
373 elseif (kb.option == 8) then
374 DAB_Bar_PageDown(kb.suboption);
375 elseif (kb.option == 9) then
376 DAB_VariableKeybinding_Down(kb.suboption);
377 elseif (kb.option == 12) then
378 local _, _, bar, page = string.find(kb.suboption, "(%d*)_(%d*)");
379 bar = tonumber(bar);
380 page = tonumber(page);
381 page = DAB_Bar_GetRealPage(bar, page);
382 local button = DAB_Get_BarButtonID(bar, page, kb.suboption2);
383 if (button) then
384 local action = DAB_Settings[DAB_INDEX].Bar[bar].pages[page][kb.suboption2];
385 DAB_Run_Script("OnKeybindingDownBefore", "Bar", bar, button);
386 DAB_ActionButton_OnClick(button, "LeftButton", 1, nil, action);
387 DAB_Run_Script("OnKeybindingDownAfter", "Bar", bar, button);
388 end
389 elseif (kb.option == 13) then
390 UseAction(kb.suboption);
391 elseif (kb.option == 14) then
392 local retarget;
393 if (UnitName("target") and (not UnitCanAttack("player", "target")) and (not UnitIsUnit("player", "target"))) then
394 retarget = 1;
395 TargetUnit("player");
396 end
397 UseAction(kb.suboption);
398 if (SpellIsTargeting()) then
399 SpellTargetUnit("player");
400 elseif (retarget) then
401 TargetLastTarget();
402 end
403 end
404 end
405  
406 function DAB_KeybindingUp(id)
407 if (not DAB_INITIALIZED) then return; end
408 local kb = DAB_Settings[DAB_INDEX].Keybindings[id];
409 if (not kb.up) then return; end
410 if (kb.option == 0) then return; end
411 if (kb.option == 1 or kb.option == 10) then
412 local selfcast;
413 if (kb.option == 10) then
414 selfcast = 1;
415 end
416 local button = DAB_Get_BarButtonID(kb.suboption, page, kb.suboption2);
417 if (button) then
418 DAB_Run_Script("OnKeybindingUpBefore", "Bar", kb.suboption, button);
419 DAB_ActionButton_OnClick(button, "LeftButton", 2, selfcast);
420 DAB_Run_Script("OnKeybindingUpAfter", "Bar", kb.suboption, button);
421 end
422 elseif (kb.option == 2) then
423 if (not DAB_Settings[DAB_INDEX].KBGroups[kb.suboption]) then return; end
424 local bar = DAB_Settings[DAB_INDEX].KBGroups[kb.suboption];
425 local button = DAB_Get_BarButtonID(bar, page, kb.suboption2);
426 if (button) then
427 DAB_Run_Script("OnKeybindingUpBefore", "Bar", bar, button);
428 DAB_ActionButton_OnClick(button, "LeftButton", 2);
429 DAB_Run_Script("OnKeybindingUpAfter", "Bar", bar, button);
430 end
431 elseif (kb.option == 3 or kb.option == 11) then
432 local selfcast;
433 if (kb.option == 11) then
434 selfcast = 1;
435 end
436 DAB_Run_Script("OnKeybindingUpBefore", "Floaters", kb.suboption);
437 DAB_ActionButton_OnClick(kb.suboption, "LeftButton", 2, selfcast);
438 DAB_Run_Script("OnKeybindingUpAfter", "Floaters", kb.suboption);
439 elseif (kb.option == 4) then
440 DAB_Run_Script("OnKeybindingUpBefore", "ControlBox", kb.suboption);
441 DAB_ControlBox_KeybindingDown(kb.suboption);
442 DAB_Run_Script("OnKeybindingUpAfter", "ControlBox", kb.suboption);
443 elseif (kb.option == 5) then
444 DAB_Set_KeybindingGroup(kb.suboption, kb.suboption2);
445 elseif (kb.option == 6) then
446 DAB_Bar_SetPage(kb.suboption, kb.suboption2);
447 elseif (kb.option == 7) then
448 DAB_Bar_PageUp(kb.suboption);
449 elseif (kb.option == 8) then
450 DAB_Bar_PageDown(kb.suboption);
451 elseif (kb.option == 9) then
452 DAB_VariableKeybinding_Up(kb.suboption);
453 elseif (kb.option == 12) then
454 local _, _, bar, page = string.find(kb.suboption, "(%d*)_(%d*)");
455 bar = tonumber(bar);
456 page = tonumber(page);
457 page = DAB_Bar_GetRealPage(bar, page);
458 local button = DAB_Get_BarButtonID(bar, page, kb.suboption2);
459 if (button) then
460 local action = DAB_Settings[DAB_INDEX].Bar[bar].pages[page][kb.suboption2];
461 DAB_Run_Script("OnKeybindingUpBefore", "Bar", bar, button);
462 DAB_ActionButton_OnClick(button, "LeftButton", 2);
463 DAB_Run_Script("OnKeybindingUpAfter", "Bar", bar, button);
464 end
465 elseif (kb.option == 13) then
466 UseAction(kb.suboption);
467 elseif (kb.option == 14) then
468 local retarget;
469 if (UnitName("target") and (not UnitCanAttack("player", "target")) and (not UnitIsUnit("player", "target"))) then
470 retarget = 1;
471 TargetUnit("player");
472 end
473 UseAction(kb.suboption);
474 if (SpellIsTargeting()) then
475 SpellTargetUnit("player");
476 elseif (retarget) then
477 TargetLastTarget();
478 end
479 end
480 end
481  
482 function DAB_PetCooldown_OnEvent()
483 if (not DAB_INITIALIZED) then return; end
484  
485 local id = this:GetID();
486 local start, duration, enable = GetPetActionCooldown(id);
487 local cdcount = DAB_Settings[DAB_INDEX].OtherBar[11].cooldownCount;
488 local hideGlobal = DAB_Settings[DAB_INDEX].OtherBar[11].hideGlobalCD;
489 if (cdcount and getglobal(this:GetParent():GetName().."Cooldown"):IsShown()) then
490 if (start and start > 0) then
491 local timeRemaining = duration - (GetTime() - start);
492 if (((not this.cooldowncount) or this.cooldowncount == 0) and timeRemaining <= 2.5 and hideGlobal) then
493 this.cooldowncount = 0;
494 else
495 this.cooldowncount = timeRemaining;
496 end
497 else
498 this.cooldowncount = 0;
499 end
500 end
501 end
502  
503 function DAB_Run_Script(script, object, index, param)
504 if (getglobal("DAB_"..object.."_"..index.."_"..script)) then
505 getglobal("DAB_"..object.."_"..index.."_"..script)(param);
506 end
507 end
508  
509 function DAB_Save_Keybindings()
510 if (not DAB_INITIALIZED) then return; end
511 for i=1,120 do
512 local key1, key2 = GetBindingKey("DAB_"..i);
513 DAB_Settings[DAB_INDEX].Keybindings[i].key1 = key1;
514 DAB_Settings[DAB_INDEX].Keybindings[i].key2 = key2;
515 end
516 end
517  
518 function DAB_Set_KeybindingGroup(group, bar)
519 local oldBar = DAB_Settings[DAB_INDEX].KBGroups[group];
520 if (bar == oldBar) then return; end
521 DAB_Unset_KeybindingGroup(group);
522 for k=1,120 do
523 local option = DAB_Settings[DAB_INDEX].Keybindings[k].option;
524 local kbgroup = DAB_Settings[DAB_INDEX].Keybindings[k].suboption;
525 local buttonLoc = DAB_Settings[DAB_INDEX].Keybindings[k].suboption2;
526 if (option == 2 and kbgroup == group) then
527 local kbtext = DL_Get_KeybindingText("DAB_"..k, nil, 1);
528 for page=1, DAB_Settings[DAB_INDEX].Bar[bar].numBars do
529 local realPage = DAB_Bar_GetRealPage(bar, page);
530 local button = DAB_Get_BarButtonID(bar, realPage, buttonLoc);
531 if (button) then
532 if (kbtext == "" or (not kbtext)) then
533 kbtext = getglobal("DAB_ActionButton_"..button).basekb;
534 end
535 getglobal("DAB_ActionButton_"..button.."_HotKey"):SetText(kbtext);
536 end
537 end
538 end
539 end
540 DAB_Settings[DAB_INDEX].KBGroups[group] = bar;
541 end
542  
543 function DAB_ShapeshiftCooldown_OnEvent()
544 if (not DAB_INITIALIZED) then return; end
545  
546 local id = this:GetID();
547 local start, duration, enable = GetShapeshiftFormCooldown(id);
548 local cdcount = DAB_Settings[DAB_INDEX].OtherBar[12].cooldownCount;
549 local hideGlobal = DAB_Settings[DAB_INDEX].OtherBar[12].hideGlobalCD;
550 if (cdcount and getglobal(this:GetParent():GetName().."Cooldown"):IsShown()) then
551 if (start and start > 0) then
552 local timeRemaining = duration - (GetTime() - start);
553 if (((not this.cooldowncount) or this.cooldowncount == 0) and timeRemaining <= 2.5 and hideGlobal) then
554 this.cooldowncount = 0;
555 else
556 this.cooldowncount = timeRemaining;
557 end
558 else
559 this.cooldowncount = 0;
560 end
561 end
562 end
563  
564 function DAB_Show_Group(group)
565 for i=1,10 do
566 if (DAB_Settings[DAB_INDEX].Bar[i].cbgroup == group) then
567 DAB_Bar_Show(i);
568 DAB_Bar_FauxShow(i);
569 end
570 if (DAB_Settings[DAB_INDEX].ControlBox[i].cbgroup == group) then
571 DAB_ControlBox_Show(i);
572 end
573 end
574 for i=11,14 do
575 if (DAB_Settings[DAB_INDEX].OtherBar[i].cbgroup == group) then
576 DAB_OtherBar_Show(i);
577 end
578 end
579 for b in DAB_Settings[DAB_INDEX].Floaters do
580 if (DAB_Settings[DAB_INDEX].Floaters[b].cbgroup == group) then
581 DAB_Floater_Show(b);
582 DAB_ActionButton_FauxShow(b);
583 end
584 end
585 end
586  
587 function DAB_Slash_Handler(msg)
588 local command, param;
589 local index = string.find(msg, " ");
590  
591 if( index) then
592 command = string.sub(msg, 1, (index - 1));
593 param = string.sub(msg, (index + 1) );
594 else
595 command = msg;
596 end
597  
598 if ( command == "" ) then
599 DAB_Toggle_Options();
600 elseif (command == "clearbar") then
601 bar = tonumber(param);
602 if (bar) then
603 for page=1, DAB_Settings[DAB_INDEX].Bar[bar].numBars do
604 for button=1, DAB_Settings[DAB_INDEX].Bar[bar].numButtons do
605 local action = DAB_Settings[DAB_INDEX].Bar[bar].pages[page][button];
606 PickupAction(action);
607 PickupSpell(999, BOOKTYPE_SPELL);
608 end
609 end
610 end
611 elseif (command == "barhide") then
612 local bar = tonumber(param);
613 if (bar and DAB_Settings[DAB_INDEX].Bar[bar]) then
614 DAB_Bar_Hide(bar);
615 elseif (param == "pet" ) then
616 DAB_OtherBar_Hide(11);
617 elseif (param == "shapeshift" ) then
618 DAB_OtherBar_Hide(12);
619 elseif (param == "bag" ) then
620 DAB_OtherBar_Hide(13);
621 elseif (param == "menu" ) then
622 DAB_OtherBar_Hide(14);
623 end
624 elseif (command == "barpage") then
625 local _,_,bar, page = string.find(param, '(%d*) (%d*)');
626 page = tonumber(page);
627 bar = tonumber(bar);
628 if (bar and page) then
629 DAB_Bar_SetPage(bar, page);
630 end
631 elseif (command == "barshow") then
632 local bar = tonumber(param);
633 if (bar and DAB_Settings[DAB_INDEX].Bar[bar]) then
634 DAB_Bar_Show(bar);
635 elseif (param == "pet" ) then
636 DAB_OtherBar_Show(11);
637 elseif (param == "shapeshift" ) then
638 DAB_OtherBar_Show(12);
639 elseif (param == "bag" ) then
640 DAB_OtherBar_Show(13);
641 elseif (param == "menu" ) then
642 DAB_OtherBar_Show(14);
643 end
644 elseif (command == "bartoggle") then
645 local bar = tonumber(param);
646 if (bar and DAB_Settings[DAB_INDEX].Bar[bar]) then
647 DAB_Bar_Toggle(bar);
648 elseif (param == "pet" ) then
649 DAB_OtherBar_Toggle(11);
650 elseif (param == "shapeshift" ) then
651 DAB_OtherBar_Toggle(12);
652 elseif (param == "bag" ) then
653 DAB_OtherBar_Toggle(13);
654 elseif (param == "menu" ) then
655 DAB_OtherBar_Toggle(14);
656 end
657 elseif (command == "hideallbars") then
658 for i=1,10 do
659 DAB_Bar_Hide(i);
660 end
661 elseif (command == "showallbars") then
662 for i=1,10 do
663 DAB_Bar_Show(i);
664 end
665 elseif (command == "floaterhide") then
666 local bar = tonumber(param);
667 if (bar and DAB_Settings[DAB_INDEX].Floaters[bar]) then
668 DAB_Floater_Hide(bar);
669 end
670 elseif (command == "floatershow") then
671 local bar = tonumber(param);
672 if (bar and DAB_Settings[DAB_INDEX].Floaters[bar]) then
673 DAB_Floater_Show(bar);
674 end
675 elseif (command == "floatertoggle") then
676 local bar = tonumber(param);
677 if (bar and DAB_Settings[DAB_INDEX].Floaters[bar]) then
678 DAB_Floater_Toggle(bar);
679 end
680 elseif (command == "setkeygroup") then
681 local _,_,group, bar = string.find(param, '(%d*) (%d*)');
682 group = tonumber(group);
683 bar = tonumber(bar);
684 if (group and bar) then
685 DAB_Set_KeybindingGroup(group, bar);
686 end
687 elseif (command == "groupshow") then
688 local group = tonumber(param);
689 if (group) then
690 DAB_Show_Group(group);
691 end
692 elseif (command == "grouphide") then
693 local group = tonumber(param);
694 if (group) then
695 DAB_Hide_Group(group);
696 end
697 elseif (command == "grouptoggle") then
698 local group = tonumber(param);
699 if (group) then
700 DAB_Toggle_Group(group);
701 end
702 elseif (command == "drag") then
703 DAB_Toggle_Dragging();
704 elseif (command == "ids") then
705 DAB_Toggle_IDs();
706 elseif (command == "actions") then
707 DAB_Toggle_ActionIDs();
708 elseif (command == "buttonlock") then
709 DAB_Toggle_ButtonLock();
710 elseif (command == "load") then
711 DAB_Load_Profile(param);
712 else
713 for _, line in DAB_HELP_TEXT do
714 DL_Feedback(line);
715 end
716 end
717 end
718  
719 function DAB_Toggle_ActionIDs()
720 if (DAB_SHOWING_IDS) then
721 DAB_SHOWING_IDS = nil;
722 DAB_SHOWING_ACTIONIDS = nil;
723 if (DAB_Options) then
724 DAB_Options_ActionIDToggle:SetText(DAB_TEXT.ShowActionIDs);
725 DAB_Options_IDToggle:SetText(DAB_TEXT.ShowButtonIDs);
726 end
727 else
728 DAB_SHOWING_IDS = true;
729 DAB_SHOWING_ACTIONIDS = true;
730 if (DAB_Options) then
731 DAB_Options_ActionIDToggle:SetText(DAB_TEXT.HideActionIDs);
732 end
733 end
734 for i=1,120 do
735 DAB_ActionButton_Update(i);
736 end
737 end
738  
739 function DAB_Toggle_ButtonLock()
740 for bar=1,10 do
741 if (DAB_Settings[DAB_INDEX].Bar[bar].buttonsLocked) then
742 DAB_Settings[DAB_INDEX].Bar[bar].buttonsLocked = nil;
743 else
744 DAB_Settings[DAB_INDEX].Bar[bar].buttonsLocked = 1;
745 end
746 end
747 for floater in DAB_Settings[DAB_INDEX].Floaters do
748 if (DAB_Settings[DAB_INDEX].Floaters[floater].buttonLocked) then
749 DAB_Settings[DAB_INDEX].Floaters[floater].buttonLocked = nil;
750 else
751 DAB_Settings[DAB_INDEX].Floaters[floater].buttonLocked = 1;
752 end
753 end
754 end
755  
756 function DAB_Toggle_Dragging()
757 if (DAB_DRAGGING_UNLOCKED) then
758 DAB_DRAGGING_UNLOCKED = nil;
759 if (DAB_Options) then
760 DAB_Options_DraggingToggle:SetText(DAB_TEXT.UnlockDragging);
761 end
762 DAB_XPBar:EnableMouse(false);
763 DAB_LatencyBar:EnableMouse(false);
764 DAB_KeyringBox:EnableMouse(false);
765 for i=11,14 do
766 for b=1, DAB_OTHER_BAR[i][0].numButtons do
767 getglobal(DAB_OTHER_BAR[i][b]):EnableMouse(1);
768 end
769 end
770 else
771 DAB_DRAGGING_UNLOCKED = true;
772 if (DAB_Options) then
773 DAB_Options_DraggingToggle:SetText(DAB_TEXT.LockDragging);
774 end
775 DAB_XPBar:EnableMouse(1);
776 DAB_LatencyBar:EnableMouse(1);
777 DAB_KeyringBox:EnableMouse(1);
778 for i=11,14 do
779 for b=1, DAB_OTHER_BAR[i][0].numButtons do
780 getglobal(DAB_OTHER_BAR[i][b]):EnableMouse(false);
781 end
782 end
783 end
784 end
785  
786 function DAB_Toggle_Group(group)
787 for i=1,10 do
788 if (DAB_Settings[DAB_INDEX].Bar[i].cbgroup == group) then
789 DAB_Bar_Toggle(i);
790 end
791 if (DAB_Settings[DAB_INDEX].ControlBox[i].cbgroup == group) then
792 DAB_ControlBox_Toggle(i);
793 end
794 end
795 for i=11,14 do
796 if (DAB_Settings[DAB_INDEX].OtherBar[i].cbgroup == group) then
797 DAB_OtherBar_Toggle(i);
798 end
799 end
800 for b in DAB_Settings[DAB_INDEX].Floaters do
801 if (DAB_Settings[DAB_INDEX].Floaters[b].cbgroup == group) then
802 DAB_Floater_Toggle(b);
803 end
804 end
805 end
806  
807 function DAB_Toggle_IDs()
808 if (DAB_SHOWING_IDS) then
809 DAB_SHOWING_IDS = nil;
810 DAB_SHOWING_ACTIONIDS = nil;
811 if (DAB_Options) then
812 DAB_Options_ActionIDToggle:SetText(DAB_TEXT.ShowActionIDs);
813 DAB_Options_IDToggle:SetText(DAB_TEXT.ShowButtonIDs);
814 end
815 else
816 DAB_SHOWING_IDS = true;
817 if (DAB_Options) then
818 DAB_Options_IDToggle:SetText(DAB_TEXT.HideButtonIDs);
819 end
820 end
821 for i=1,120 do
822 DAB_ActionButton_Update(i);
823 end
824 end
825  
826 function DAB_Toggle_Options()
827 if (not DAB_Options) then
828 DAB_Load_Options();
829 elseif (DAB_Options:IsVisible()) then
830 DAB_Options:Hide();
831 else
832 DAB_Options:Show();
833 end
834 end
835  
836 function DAB_Unset_KeybindingGroup(group)
837 local oldBar = DAB_Settings[DAB_INDEX].KBGroups[group];
838 if (oldBar) then
839 for i=1,120 do
840 if (DAB_Settings[DAB_INDEX].Buttons[i].Bar == oldBar) then
841 getglobal("DAB_ActionButton_"..i.."_HotKey"):SetText(getglobal("DAB_ActionButton_"..i).basekb);
842 end
843 end
844 end
845 DAB_Settings[DAB_INDEX].KBGroups[group] = nil;
846 end
847  
848 function DAB_Update_Location(frame, base, point, to)
849 this:StopMovingOrSizing();
850 local x, y = DL_Get_Offsets(frame, base, point, to);
851 this:ClearAllPoints();
852 this:SetPoint(point, base, to, x, y);
853 DAB_Settings[DAB_INDEX].FrameLocs[frame:GetName()] = {
854 point = point,
855 to = to,
856 frame = base:GetName(),
857 x = x,
858 y = y
859 };
860 end
861  
862 function DAB_Update_NewActions(elapsed)
863 if (DiscordActionBarsFrame.updateactionlist) then
864 DiscordActionBarsFrame.updateactionlist = DiscordActionBarsFrame.updateactionlist - elapsed;
865 if (DiscordActionBarsFrame.updateactionlist < 0) then
866 DAB_Update_ActionList();
867 DiscordActionBarsFrame.updateactionlist = nil;
868 end
869 end
870 if (CursorHasItem() or CursorHasSpell()) then
871 DiscordActionBarsFrame.updatenewactions = nil;
872 end
873 if (not DiscordActionBarsFrame.updatenewactions) then return; end
874 DiscordActionBarsFrame.updatenewactions = DiscordActionBarsFrame.updatenewactions - elapsed;
875 if (DiscordActionBarsFrame.updatenewactions < 0) then
876 DiscordActionBarsFrame.updatenewactions = nil;
877 DAB_SHOWING_EMPTY = nil;
878 for i=1,10 do
879 if (DAB_Settings[DAB_INDEX].Bar[i].hide) then
880 getglobal("DAB_ActionBar_"..i):Hide();
881 end
882 if (DAB_Settings[DAB_INDEX].Bar[i].hideEmpty) then
883 DAB_Bar_Update(i);
884 end
885 end
886 for b in DAB_Settings[DAB_INDEX].Floaters do
887 if (DAB_Settings[DAB_INDEX].Floaters[b].hide) then
888 getglobal("DAB_ActionButton_"..b):Hide();
889 end
890 end
891 end
892 end
893  
894 function DAB_VariableKeybinding_Down(number)
895 DAB_VARIABLE_KEYBINDINGS[number] = 1;
896 if (DAB_EventMacros_VariableKeybinding) then
897 DAB_EventMacros_VariableKeybinding(number, 1);
898 end
899 end
900  
901 function DAB_VariableKeybinding_Up(number)
902 DAB_VARIABLE_KEYBINDINGS[number] = 2;
903 if (DAB_EventMacros_VariableKeybinding) then
904 DAB_EventMacros_VariableKeybinding(number, 2);
905 end
906 end