vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function DAB_Add_ButtonOrPage(id)
2 if (not id) then
3 id = this:GetParent():GetID();
4 end
5 local freeButtons = table.getn(DAB_Settings[DAB_INDEX].FreeButtons);
6 if (id < 11) then
7 local needed = 1;
8 if (needed > freeButtons) then
9 DAB_NumButtons_SetWarning(needed - freeButtons);
10 return;
11 end
12 local button = DAB_Get_FreeButton();
13 local action = DAB_Get_UnusedAction();
14 DAB_Settings[DAB_INDEX].Buttons[button].Bar = id;
15 DAB_Settings[DAB_INDEX].Buttons[button].Bar2 = i;
16 DAB_Settings[DAB_INDEX].Buttons[button].action = action;
17 DAB_Settings[DAB_INDEX].Bar[id].numButtons = DAB_Settings[DAB_INDEX].Bar[id].numButtons + 1;
18 for p = 1, DAB_Settings[DAB_INDEX].Bar[id].numBars do
19 DAB_Settings[DAB_INDEX].Bar[id].pages[p][DAB_Settings[DAB_INDEX].Bar[id].numButtons] = action;
20 action = DAB_Get_UnusedAction();
21 DAB_Settings[DAB_INDEX].Bar[id].pageconditions[p][DAB_Settings[DAB_INDEX].Bar[id].numButtons] = {};
22 end
23 else
24 id = id - 10;
25 local needed = DAB_Settings[DAB_INDEX].Bar[id].numButtons;
26 DAB_Settings[DAB_INDEX].Bar[id].numBars = DAB_Settings[DAB_INDEX].Bar[id].numBars + 1;
27 local page = DAB_Settings[DAB_INDEX].Bar[id].numBars;
28 DAB_Settings[DAB_INDEX].Bar[id].pages[page] = {};
29 DAB_Settings[DAB_INDEX].Bar[id].pageconditions[page] = {};
30 for i=1,needed do
31 local action = DAB_Get_UnusedAction();
32 DAB_Settings[DAB_INDEX].Bar[id].pages[page][i] = action;
33 DAB_Settings[DAB_INDEX].Bar[id].pageconditions[page][i] = {};
34 end
35 end
36 DAB_Init_ButtonLayout();
37 DAB_Bar_Initialize(id);
38 DAB_Bar_ButtonTextures(id);
39 DAB_Bar_ButtonText(id);
40 DAB_Bar_ButtonSize(id);
41 DAB_Bar_ButtonAlpha(id);
42 if (DAB_Settings[DAB_INDEX].AutoConfigureKB) then
43 DAB_AutoConfigure_Keybindings();
44 end
45 DAB_Update_Keybindings();
46 end
47  
48 function DAB_Add_Condition()
49 if (not DAB_CONDITION_BUFFER) then return; end
50 local baseOptions;
51 if (DAB_BarOptions_ButtonControl:IsVisible()) then
52 baseOptions = "DAB_BarOptions_ButtonControl_";
53 elseif (DAB_OBJECT_TYPE == "Bar") then
54 baseOptions = "DAB_BarOptions_BarControl_";
55 elseif (DAB_OBJECT_TYPE == "Floaters") then
56 baseOptions = "DAB_FloaterOptions_Control_";
57 end
58  
59 local option = getglobal(baseOptions.."Buff");
60 if (option:IsShown()) then
61 DAB_CONDITION_BUFFER.buff = option:GetText();
62 if (not DAB_CONDITION_BUFFER.buff) then DAB_CONDITION_BUFFER.buff = ""; end
63 end
64 option = getglobal(baseOptions.."Text");
65 if (option:IsShown()) then
66 DAB_CONDITION_BUFFER.text = option:GetText();
67 if (not DAB_CONDITION_BUFFER.text) then DAB_CONDITION_BUFFER.text = ""; end
68 end
69 option = getglobal(baseOptions.."Number");
70 if (option:IsShown()) then
71 DAB_CONDITION_BUFFER.number = option:GetNumber();
72 if (not DAB_CONDITION_BUFFER.number) then DAB_CONDITION_BUFFER.number = 1; end
73 end
74 option = getglobal(baseOptions.."ResponseText");
75 if (option:IsShown()) then
76 DAB_CONDITION_BUFFER.rtext = option:GetText();
77 if (not DAB_CONDITION_BUFFER.rtext) then DAB_CONDITION_BUFFER.rtext = ""; end
78 end
79 option = getglobal(baseOptions.."ResponseNumber");
80 if (option:IsShown()) then
81 DAB_CONDITION_BUFFER.rnumber = option:GetNumber();
82 if (not DAB_CONDITION_BUFFER.rnumber) then DAB_CONDITION_BUFFER.rnumber = 1; end
83 end
84 option = getglobal(baseOptions.."ResponseX");
85 if (option and option:IsShown()) then
86 DAB_CONDITION_BUFFER.rx = option:GetNumber();
87 if (not DAB_CONDITION_BUFFER.rx) then DAB_CONDITION_BUFFER.rx = 0; end
88 end
89 option = getglobal(baseOptions.."ResponseY");
90 if (option and option:IsShown()) then
91 DAB_CONDITION_BUFFER.ry = option:GetNumber();
92 if (not DAB_CONDITION_BUFFER.ry) then DAB_CONDITION_BUFFER.ry = 0; end
93 end
94  
95 local orbox = getglobal(baseOptions.."Overrides");
96 DAB_CONDITION_BUFFER.overrides = orbox:GetText();
97 orbox:SetText("");
98 orbox:ClearFocus();
99 if (DAB_CONDITION_BUFFER.overrides and DAB_CONDITION_BUFFER.overrides ~= "") then
100 local overrides = {};
101 local num = "";
102 local index = 1;
103 local char;
104 for i=1, string.len(DAB_CONDITION_BUFFER.overrides) do
105 char = string.sub(DAB_CONDITION_BUFFER.overrides, i, i);
106 if (char == ",") then
107 num = tonumber(num);
108 if (num) then
109 overrides[index] = num;
110 index = index + 1;
111 end
112 num = "";
113 else
114 num = num..char;
115 end
116 end
117 num = tonumber(num);
118 if (num) then
119 overrides[index] = num;
120 end
121 DAB_CONDITION_BUFFER.overrides = {};
122 DL_Copy_Table(overrides, DAB_CONDITION_BUFFER.overrides);
123 else
124 DAB_CONDITION_BUFFER.overrides = {};
125 end
126 if (DAB_BarOptions_ButtonControl:IsVisible()) then
127 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
128 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
129 local bar = DAB_OBJECT_SUBINDEX;
130 local index = table.getn(DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button]) + 1;
131 if (DAB_CONDITION_EDITTING) then
132 index = DAB_CONDITION_EDITTING;
133 end
134 DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button][index] = {};
135 DL_Copy_Table(DAB_CONDITION_BUFFER, DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button][index]);
136 DAB_BarOptions_ButtonControl_Condition_Setting:SetText("");
137 DAB_BarOptions_ButtonControl_Response_Setting:SetText("");
138 DAB_Reset_Parameters("DAB_BarOptions_ButtonControl");
139 local id = DAB_Get_BarButtonID(bar, page, button);
140 getglobal("DAB_ActionButton_"..id).activeConditions = {};
141 elseif (DAB_OBJECT_TYPE == "Bar") then
142 local index = table.getn(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions) + 1;
143 if (DAB_CONDITION_EDITTING) then
144 index = DAB_CONDITION_EDITTING;
145 end
146 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions[index] = {};
147 DL_Copy_Table(DAB_CONDITION_BUFFER, DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions[index]);
148 DAB_BarOptions_BarControl_Condition_Setting:SetText("");
149 DAB_BarOptions_BarControl_Response_Setting:SetText("");
150 DAB_Reset_Parameters("DAB_BarOptions_BarControl");
151 getglobal("DAB_ActionBar_"..DAB_OBJECT_SUBINDEX).activeConditions = {};
152 elseif (DAB_OBJECT_TYPE == "Floaters") then
153 local index = table.getn(DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions) + 1;
154 if (DAB_CONDITION_EDITTING) then
155 index = DAB_CONDITION_EDITTING;
156 end
157 DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions[index] = {};
158 DL_Copy_Table(DAB_CONDITION_BUFFER, DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions[index]);
159 DAB_FloaterOptions_Control_Condition_Setting:SetText("");
160 DAB_FloaterOptions_Control_Response_Setting:SetText("");
161 DAB_Reset_Parameters("DAB_FloaterOptions_Control");
162 getglobal("DAB_ActionButton_"..DAB_OBJECT_SUBINDEX).activeConditions = {};
163 end
164 DAB_ConditionMenu_Update();
165 DAB_CONDITION_BUFFER = nil;
166 DAB_CONDITION_EDITTING = nil;
167 end
168  
169 function DAB_Add_Event()
170 DAB_NewEvent:Hide();
171 local event = DAB_NewEvent_Event:GetText();
172 local name = DAB_NewEvent_Name:GetText();
173 local desc = DAB_NewEvent_Desc:GetText();
174 DAB_NewEvent_Event:SetText("");
175 DAB_NewEvent_Name:SetText("");
176 DAB_NewEvent_Desc:SetText("");
177 if ((not event) or event == "") then return; end
178 if ((not name) or name == "") then name = event; end
179 if (not desc) then desc = ""; end
180 DAB_Settings[DAB_INDEX].CustomEvents[event] = {text=name, desc=desc};
181 DAB_Update_EventList();
182 end
183  
184 function DAB_Add_Floater()
185 if (table.getn(DAB_Settings[DAB_INDEX].FreeButtons) == 0) then
186 DAB_NumButtons_SetWarning(1);
187 return;
188 end
189 local id = DAB_Get_FreeButton();
190 local action = DAB_Get_UnusedAction();
191 DAB_Floater_SetDefaults(id, action);
192 DAB_Settings[DAB_INDEX].Buttons[id].action = action;
193 DAB_Floater_Initialize(id);
194 DAB_Init_ButtonLayout();
195 DAB_Update_ObjectList();
196 DAB_Update_FloaterList();
197 DAB_Update_AnchorsList();
198 DAB_BarBrowser_Update();
199 if (DAB_Settings[DAB_INDEX].AutoConfigureKB) then
200 DAB_AutoConfigure_Keybindings();
201 end
202 DAB_Update_Keybindings();
203 end
204  
205 function DAB_AddFloater_OnMouseWheel()
206 if (arg1 > 0) then
207 DAB_Add_Floater();
208 end
209 end
210  
211 function DAB_AnchorFrameEditBox_OnEnterPressed()
212 DAB_MenuEditBox_OnEnterPressed();
213 DAB_Update_AnchorsList();
214 end
215  
216 function DAB_Apply_IDRange()
217 DAB_SetActionIDs_Min:ClearFocus();
218 DAB_SetActionIDs_Max:ClearFocus();
219 local min = DAB_SetActionIDs_Min:GetNumber();
220 local max = DAB_SetActionIDs_Max:GetNumber();
221 if (not min) then return; end
222 if (not max or max == 0) then max = 120; end
223 if (min < 1 or min > 120 or max < 1 or max > 120) then
224 DL_Debug("Action IDs can only be a number between 1 and 120.");
225 return;
226 end
227 local step = 1;
228 if (min > max) then
229 step = -1;
230 end
231 local index = 0;
232 for action=min,max,step do
233 index = index + 1;
234 if (DAB_ACTIONIDS_LIST[index]) then
235 local bar = DAB_ACTIONIDS_LIST[index].bar;
236 local button = DAB_ACTIONIDS_LIST[index].button;
237 if (bar == "F") then
238 DAB_Settings[DAB_INDEX].Buttons[button].action = action;
239 DAB_ActionButton_Update(button);
240 else
241 local page = DAB_ACTIONIDS_LIST[index].page;
242 DAB_Settings[DAB_INDEX].Bar[bar].pages[page][button] = action;
243 DAB_Bar_SetPage(bar, DAB_Settings[DAB_INDEX].Bar[bar].page, 1);
244 end
245 DAB_ACTIONIDS_LIST[index].action = action;
246 end
247 end
248 DAB_SetActionIDsMenu_Update();
249 DAB_Update_FloaterList();
250 DAB_Update_ObjectList();
251 DAB_BarBrowser_Update();
252 end
253  
254 function DAB_AutoConfigure_Keybindings()
255 local count = 0;
256 for bar = 1,5 do
257 for button = 1,DAB_Settings[DAB_INDEX].Bar[bar].numButtons do
258 count = count + 1;
259 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
260 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
261 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=1, suboption=bar, suboption2=button, down=1, key1=key1, key2=key2};
262 end
263 end
264 for f=1,120 do
265 if (DAB_Settings[DAB_INDEX].Floaters[f]) then
266 count = count + 1;
267 if (count > 120) then return; end
268 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
269 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
270 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=3, suboption=f, down=1, key1=key1, key2=key2};
271 end
272 end
273 for b=1,10 do
274 count = count + 1;
275 if (count > 120) then return; end
276 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
277 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
278 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=4, suboption=b, down=1, key1=key1, key2=key2};
279 end
280 for bar=1,10 do
281 if (DAB_Settings[DAB_INDEX].Bar[bar].numBars > 1) then
282 count = count + 1;
283 if (count > 120) then return; end
284 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
285 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
286 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=7, suboption=bar, down=1, key1=key1, key2=key2};
287 count = count + 1;
288 if (count > 120) then return; end
289 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
290 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
291 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=8, suboption=bar, down=1, key1=key1, key2=key2};
292 end
293 end
294 for group=1,2 do
295 for button=1,12 do
296 count = count + 1;
297 if (count > 120) then return; end
298 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
299 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
300 DAB_Settings[DAB_INDEX].Keybindings[count] = {option=2, suboption=group, suboption2=button, down=1, key1=key1, key2=key2};
301 end
302 end
303  
304 count = count + 1;
305 for i=count,120 do
306 local key1 = DAB_Settings[DAB_INDEX].Keybindings[count].key1;
307 local key2 = DAB_Settings[DAB_INDEX].Keybindings[count].key2;
308 DAB_Settings[DAB_INDEX].Keybindings[i] = {option=0, down=1, key1=key1, key2=key2};
309 end
310  
311 DAB_Save_Keybindings();
312 end
313  
314 function DAB_BarBrowser_OnClick()
315 this:SetChecked(1);
316 DAB_Show_Window(this.index);
317 DAB_BarBrowser_Update();
318 end
319  
320 function DAB_BarBrowser_Update()
321 local numOptions = table.getn(DAB_BAR_LIST);
322 local offset = FauxScrollFrame_GetOffset(DAB_Options_BarBrowser);
323 if (not offset) then offset = 0; end
324 local index, button;
325  
326 for i=1, 15 do
327 button = getglobal("DAB_Options_BarBrowser_Button"..i);
328 buttontext = getglobal("DAB_Options_BarBrowser_Button"..i.."Text");
329 index = offset + i;
330 button.index = index;
331 if ( DAB_BAR_LIST[index] ) then
332 buttontext:SetText(DAB_BAR_LIST[index].text);
333 buttontext:SetJustifyH("LEFT");
334 button:Enable();
335 button:Show();
336 if (DAB_BAR_LIST[index].header) then
337 button:Disable();
338 buttontext:SetJustifyH("CENTER");
339 button:SetChecked(0);
340 buttontext:SetTextColor(1, .82, 0);
341 buttontext:SetFont("Fonts\\MORPHEUS.ttf", 13);
342 elseif (DAB_OBJECT_INDEX == button.index) then
343 button:SetChecked(1);
344 buttontext:SetTextColor(1, 0, 0);
345 buttontext:SetFont("Fonts\\FRIZQT__.TTF", 12);
346 else
347 button:SetChecked(0);
348 buttontext:SetTextColor(1, 1, 1);
349 buttontext:SetFont("Fonts\\ARIALN.TTF", 12);
350 end
351 else
352 button:Hide();
353 end
354 end
355  
356 FauxScrollFrame_Update(DAB_Options_BarBrowser, numOptions, 15, 20 );
357 end
358  
359 function DAB_BarOptions_OnMouseWheel(direction)
360 if (direction > 0) then
361 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX - 1;
362 elseif (direction < 0) then
363 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX + 1;
364 end
365 if (DAB_OBJECT_INDEX > 11) then
366 DAB_OBJECT_INDEX = 2;
367 elseif (DAB_OBJECT_INDEX < 2) then
368 DAB_OBJECT_INDEX = 11;
369 end
370 DAB_OBJECT_SUBINDEX = DAB_OBJECT_INDEX - 1;
371 DAB_Init_BarOptions();
372 DAB_BarBrowser_Update();
373 end
374  
375 function DAB_BarButtonsMenu_Update()
376 local numOptions = table.getn(DAB_BAR_BUTTONS);
377 local offset = FauxScrollFrame_GetOffset(DAB_BarOptions_ButtonControl_ButtonsMenu);
378 if (not offset) then offset = 0; end
379 local index, button;
380  
381 for i=1, 4 do
382 buttonName = "DAB_BarOptions_ButtonControl_ButtonsMenu_Button"..i;
383 button = getglobal(buttonName);
384 index = offset + i;
385 button.action = nil;
386 if ( DAB_BAR_BUTTONS[index] ) then
387 button:Show();
388 button:SetChecked(0);
389 button.button = DAB_BAR_BUTTONS[index].button;
390 button.page = DAB_BAR_BUTTONS[index].page;
391 button.index = index;
392 local action = DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].pages[button.page][button.button];
393 getglobal(buttonName.."_Icon"):SetTexture(GetActionTexture(action));
394 getglobal(buttonName.."_Button"):SetText(DAB_TEXT.Button..": "..DAB_BAR_BUTTONS[index].page.."/"..DAB_BAR_BUTTONS[index].button);
395 getglobal(buttonName.."_ActionID"):SetText(DAB_TEXT.Action..": "..action);
396 getglobal(buttonName.."_Action"):SetText(DAB_Get_ActionName(action));
397 if (DAB_SELECTED_BARBUTTON == index) then
398 button:SetChecked(1);
399 end
400 else
401 button:Hide();
402 end
403 end
404  
405 FauxScrollFrame_Update(DAB_BarOptions_ButtonControl_ButtonsMenu, numOptions, 4, 20 );
406 DAB_BarOptions_ButtonControl_ButtonsMenu:Show();
407 end
408  
409 function DAB_CBoxOptions_OnMouseWheel(direction)
410 if (direction > 0) then
411 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX - 1;
412 elseif (direction < 0) then
413 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX + 1;
414 end
415 if (DAB_OBJECT_INDEX > 27) then
416 DAB_OBJECT_INDEX = 18;
417 elseif (DAB_OBJECT_INDEX < 18) then
418 DAB_OBJECT_INDEX = 27;
419 end
420 DAB_OBJECT_SUBINDEX = DAB_BAR_LIST[DAB_OBJECT_INDEX].value;
421 DAB_Init_ControlBoxOptions();
422 DAB_BarBrowser_Update();
423 end
424  
425 function DAB_Change_PageControlBar()
426 DAB_CONTROL_PAGES = {};
427 for i=1, DAB_Settings[DAB_INDEX].Bar[this.value].numBars do
428 DAB_CONTROL_PAGES[i] = {text=i, value=i};
429 end
430 if (DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].changePagePage > DAB_Settings[DAB_INDEX].Bar[this.value].numBars) then
431 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].changePagePage = 1;
432 DL_Init_MenuControl(DAB_CBoxOptions_Control_PageControlPage, DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].changePagePage);
433 end
434 DAB_Update_Setting(DAB_DropMenu.settingType, this.value, DAB_DropMenu.index, DAB_DropMenu.subindex, DAB_DropMenu.subindex2);
435 end
436  
437 function DAB_Change_PageControlType()
438 if (this.value == 3) then
439 DAB_CBoxOptions_Control_PageControlPage:Show();
440 else
441 DAB_CBoxOptions_Control_PageControlPage:Hide();
442 end
443 DAB_Update_Setting(DAB_DropMenu.settingType, this.value, DAB_DropMenu.index, DAB_DropMenu.subindex, DAB_DropMenu.subindex2);
444 end
445  
446 function DAB_ChangeActionsMenu_Update()
447 local numOptions = 120;
448 local offset = FauxScrollFrame_GetOffset(DAB_ChangeActions_ScrollMenu);
449 if (not offset) then offset = 0; end
450 local index, button, buttontext, icon, idtext;
451  
452 for i=1, 13 do
453 button = getglobal("DAB_ChangeActions_ScrollMenu_Button"..i);
454 buttontext = getglobal("DAB_ChangeActions_ScrollMenu_Button"..i.."_Text");
455 actionbutton = getglobal("DAB_ChangeActions_ScrollMenu_Button"..i.."_Button");
456 icon = getglobal("DAB_ChangeActions_ScrollMenu_Button"..i.."_Button_Icon");
457 idtext = getglobal("DAB_ChangeActions_ScrollMenu_Button"..i.."_ID");
458 index = offset + i;
459 if ( index <= 120 ) then
460 idtext:SetText(index..":");
461 actionbutton.action = index;
462 if (HasAction(index)) then
463 icon:SetTexture(GetActionTexture(index));
464 else
465 icon:SetTexture("Interface\\AddOns\\DiscordLibrary\\EmptyButton");
466 end
467 buttontext:SetText(DAB_Get_ActionName(index));
468 else
469 button:Hide();
470 end
471 end
472  
473 FauxScrollFrame_Update(DAB_ChangeActions_ScrollMenu, numOptions, 13, 40 );
474 end
475  
476 function DAB_CheckBox_OnClick()
477 local value;
478 if (this:GetChecked()) then
479 value = 1;
480 end
481 DAB_Update_Setting(this.settingType, value, this.index, this.subindex, this.subindex2);
482 end
483  
484 function DAB_ColorPicker_OnClick()
485 local basecolor = DAB_Get_Setting(this.index, this.subindex);
486 local color = {};
487 color.r = basecolor.r;
488 color.g = basecolor.g;
489 color.b = basecolor.b;
490 ColorPickerFrame.hasOpacity = nil;
491 ColorPickerFrame.previousValues = color;
492 ColorPickerFrame.cancelFunc = DAB_ColorPicker_ColorCancelled;
493 ColorPickerFrame.opacityFunc = DAB_ColorPicker_ColorChanged;
494 ColorPickerFrame.func = DAB_ColorPicker_ColorChanged;
495 ColorPickerFrame.colorBox = this:GetName();
496 ColorPickerFrame.index = this.index;
497 ColorPickerFrame.subindex = this.subindex;
498 ColorPickerFrame.settingType = this.settingType;
499 ColorPickerFrame:SetColorRGB(color.r, color.g, color.b);
500 ColorPickerFrame:ClearAllPoints();
501 if (DAB_Options:GetRight() < UIParent:GetWidth() / 2) then
502 ColorPickerFrame:SetPoint("LEFT", "DAB_Options", "RIGHT", 10, 0);
503 else
504 ColorPickerFrame:SetPoint("RIGHT", "DAB_Options", "LEFT", -10, 0);
505 end
506 ColorPickerFrame:Show();
507 end
508  
509 function DAB_ColorPicker_ColorCancelled()
510 local color = ColorPickerFrame.previousValues;
511 getglobal(ColorPickerFrame.colorBox):SetBackdropColor(color.r, color.g, color.b);
512 DAB_Update_Setting(ColorPickerFrame.settingType, color, ColorPickerFrame.index, ColorPickerFrame.subindex);
513 end
514  
515 function DAB_ColorPicker_ColorChanged()
516 local r, g, b = ColorPickerFrame:GetColorRGB();
517 local color = { r=r, g=g, b=b };
518 getglobal(ColorPickerFrame.colorBox):SetBackdropColor(color.r, color.g, color.b);
519 DAB_Update_Setting(ColorPickerFrame.settingType, color, ColorPickerFrame.index, ColorPickerFrame.subindex);
520 end
521  
522 function DAB_Condition_Delete()
523 local list;
524 if (DAB_BarOptions_ButtonControl:IsVisible()) then
525 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
526 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
527 local bar = DAB_OBJECT_SUBINDEX;
528 list = DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button];
529 getglobal("DAB_ActionButton_"..DAB_SELECTED_BARBUTTON).activeConditions = {};
530 elseif (DAB_OBJECT_TYPE == "Bar") then
531 list = DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions;
532 getglobal("DAB_ActionBar_"..DAB_OBJECT_SUBINDEX).activeConditions = {};
533 elseif (DAB_OBJECT_TYPE == "Floaters") then
534 list = DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions;
535 getglobal("DAB_ActionButton_"..DAB_OBJECT_SUBINDEX).activeConditions = {};
536 end
537 for i=1, table.getn(list) do
538 if (i > this:GetParent().index and i > 1) then
539 list[i - 1] = {};
540 DL_Copy_Table(list[i], list[i - 1]);
541 end
542 end
543 list[table.getn(list)] = nil;
544 DAB_ConditionMenu_Update();
545 end
546  
547 function DAB_Condition_Edit()
548 local ci = this:GetParent().index;
549 DAB_Select_Condition(ci, this:GetParent().cboxbase);
550 DAB_Select_Response(DAB_CONDITION_BUFFER.response, this:GetParent().cboxbase);
551 end
552  
553 function DAB_Condition_MoveDown()
554 local list;
555 local index = this:GetParent().index;
556 local newindex = index + 1;
557  
558 if (DAB_BarOptions_ButtonControl:IsVisible()) then
559 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
560 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
561 local bar = DAB_OBJECT_SUBINDEX;
562 list = DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button];
563 elseif (DAB_OBJECT_TYPE == "Bar") then
564 list = DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions;
565 elseif (DAB_OBJECT_TYPE == "Floaters") then
566 list = DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions;
567 end
568 if (newindex > table.getn(list)) then return; end
569  
570 local buffer = {};
571 DL_Copy_Table(list[index], buffer);
572 local buffer2 = {};
573 DL_Copy_Table(list[newindex], buffer2);
574  
575 DL_Copy_Table(buffer2, list[index]);
576 DL_Copy_Table(buffer, list[newindex]);
577 DAB_ConditionMenu_Update();
578 end
579  
580 function DAB_Condition_MoveUp()
581 local list;
582 local index = this:GetParent().index;
583 local newindex = index - 1;
584 if (newindex == 0) then return; end
585  
586 if (DAB_BarOptions_ButtonControl:IsVisible()) then
587 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
588 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
589 local bar = DAB_OBJECT_SUBINDEX;
590 list = DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button];
591 elseif (DAB_OBJECT_TYPE == "Bar") then
592 list = DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions;
593 elseif (DAB_OBJECT_TYPE == "Floaters") then
594 list = DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions;
595 end
596  
597 local buffer = {};
598 DL_Copy_Table(list[index], buffer);
599 local buffer2 = {};
600 DL_Copy_Table(list[newindex], buffer2);
601  
602 DL_Copy_Table(buffer2, list[index]);
603 DL_Copy_Table(buffer, list[newindex]);
604 DAB_ConditionMenu_Update();
605 end
606  
607 function DAB_ConditionMenu_Update()
608 local list, frame, numButtons;
609 if (DAB_BarOptions_ButtonControl:IsVisible()) then
610 local bar = DAB_OBJECT_SUBINDEX;
611 if (DAB_Settings[DAB_INDEX].Bar[bar].numButtons == 0) then return; end
612 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
613 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
614 list = DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button];
615 frame = DAB_BarOptions_ButtonControl_ConditionMenu;
616 numButtons = 2;
617 elseif (DAB_OBJECT_TYPE == "Bar") then
618 list = DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions;
619 frame = DAB_BarOptions_BarControl_ConditionMenu;
620 numButtons = 5;
621 elseif (DAB_OBJECT_TYPE == "Floaters") then
622 list = DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions;
623 frame = DAB_FloaterOptions_Control_ConditionMenu;
624 numButtons = 5;
625 end
626 local numOptions = table.getn(list);
627 local offset = FauxScrollFrame_GetOffset(frame);
628 if (not offset) then offset = 0; end
629 local index, button, text;
630  
631 for i=1, numButtons do
632 button = getglobal(frame:GetName().."_Button"..i);
633 index = offset + i;
634 if ( list[index] ) then
635 button:Disable();
636 button:Show();
637 button.index = index;
638 button.cboxbase = frame:GetName();
639 text = DL_Get_MenuText(DL_CONDITIONS_MENU, list[index].condition);
640 if (not text) then text = ""; end
641 local conditionsIndex;
642 for cindex, value in DL_CONDITIONS_MENU do
643 if (value.value == list[index].condition) then
644 conditionsIndex = cindex;
645 break;
646 end
647 end
648 local params = DL_CONDITIONS_MENU[conditionsIndex].params;
649 if (params == 1 or params == 2) then
650 text = text..": |cFFFFFFFF"..DL_Get_MenuText(DAB_ACTIONS, list[index].action);
651 if (list[index].ignoreGlobal) then
652 text = text..",|cFFCCCCCC "..DAB_TEXT.IgnoreGlobal;
653 end
654 elseif (params == 3) then
655 text = text.." on "..list[index].unit..": |cFFFFFFFF"..list[index].buff;
656 elseif (params == 4) then
657 text = text.." |cFFFFFFFF"..DL_Get_MenuText(DL_COMPARE_MENU, list[index].compare).." "..list[index].number;
658 elseif (params == 5) then
659 text = text..": |cFFFFFFFF"..list[index].unit..", "..list[index].text;
660 elseif (params == 6) then
661 text = text.." Applications "..DL_Get_MenuText(DL_COMPARE_MENU, list[index].compare).." "..list[index].number.." on "..list[index].unit..": |cFFFFFFFF"..list[index].text;
662 elseif (params == 7) then
663 local number = list[index].number;
664 if (number < 1) then
665 number = (number * 100).."%";
666 end
667 text = text.." "..list[index].unit.." "..DL_Get_MenuText(DL_COMPARE_MENU, list[index].compare).." "..number;
668 elseif (params == 8) then
669 local form = DL_Get_MenuText(DL_FORMS, list[index].form);
670 if (form == "") then
671 form = list[index].form;
672 end
673 text = text..": |cFFFFFFFF"..form;
674 elseif (params == 9) then
675 text = text..": |cFFFFFFFF"..DL_Get_MenuText(DL_TARGET_PARAMS, list[index].target);
676 elseif (params == 10) then
677 text = text..": |cFFFFFFFF"..list[index].number;
678 elseif (params == 11) then
679 text = text..": |cFFFFFFFF"..DL_Get_MenuText(DAB_ACTIONS, list[index].action).." "..DL_Get_MenuText(DL_COMPARE_MENU, list[index].compare).." "..list[index].number;
680 elseif (params == 12) then
681 text = text..": |cFFFFFFFF"..list[index].text;
682 elseif (params == 13) then
683 text = text..": |cFFFFFFFF"..list[index].unit;
684 elseif (params == 14) then
685 text = text..": |cFFFFFFFF"..list[index].unit.." and "..list[index].unit2;
686 elseif (params == 200) then
687 text = text..": |cFFFFFFFFBar "..list[index].bar.."'s Page "..DL_Get_MenuText(DL_COMPARE_MENU, list[index].compare).." "..list[index].number;
688 end
689 getglobal(frame:GetName().."_Button"..i.."ConditionText"):SetText(text);
690  
691 text = DAB_TEXT.Response.." |cFFFFFF00"..DL_Get_MenuText(getglobal(frame.responsemenu), list[index].response);
692 if (list[index].response == 1) then
693 text = text.." to "..list[index].page;
694 elseif (list[index].response == 4 or list[index].response == 5 or list[index].response == 7) then
695 text = text.." to "..(list[index].alpha * 100).."%";
696 elseif (list[index].response == 6 or list[index].response == 8 or list[index].response == 20 or (list[index].response == 22 and list[index].color)) then
697 local hex = DL_Get_HexColor(list[index].color.r, list[index].color.g, list[index].color.b);
698 text = text.." to "..hex.."this color";
699 elseif (list[index].response == 19 or (list[index].response > 10 and list[index].response < 19)) then
700 text = text..": |cFFFFFFFF"..list[index].amount;
701 elseif (list[index].response == 100 or list[index].response == 101 or list[index].response == 108 or list[index].response == 109 or list[index].response == 114 or list[index].response == 115) then
702 text = text..": |cFFFFFFFF"..list[index].rtext;
703 elseif (list[index].response == 23 or (list[index].response > 101 and list[index].response < 108)) then
704 text = text..": |cFFFFFFFF"..list[index].rnumber;
705 elseif (list[index].response == 29 or list[index].response == 111) then
706 text = text..": |cFFFFFFFF"..DL_Get_MenuText(DAB_ACTIONS, list[index].raction);
707 elseif (list[index].response == 110) then
708 text = text..": |cFFFFFFFF"..DL_Get_MenuText(DAB_ACTIONS, list[index].raction).." on "..list[index].runit;
709 elseif (list[index].response == 32) then
710 text = text.." "..list[index].page2.." to "..list[index].page;
711 elseif (list[index].response == 33) then
712 text = text..": |cFFFFFFFF"..list[index].runit;
713 elseif (list[index].response == 35) then
714 text = text..": |cFFFFFFFF"..list[index].rx..", "..list[index].ry;
715 elseif (list[index].response == 113) then
716 text = text.." "..list[index].rtext.." for "..list[index].rnumber.." seconds";
717 end
718 getglobal(frame:GetName().."_Button"..i.."ResponseText"):SetText(text);
719  
720 text = DAB_TEXT.Overrides.." |cFFFFFFFF";
721 for i,o in list[index].overrides do
722 if (i == table.getn(list[index].overrides)) then
723 text = text..o;
724 else
725 text = text..o..", ";
726 end
727 end
728 getglobal(frame:GetName().."_Button"..i.."OverrideText"):SetText(text);
729 getglobal(frame:GetName().."_Button"..i.."Index"):SetText(index);
730 else
731 button:Hide();
732 end
733 end
734  
735 FauxScrollFrame_Update(frame, numOptions, numButtons, 40);
736 frame:Show();
737 end
738  
739 function DAB_Copy_ControlSettings()
740 DAB_CONTROL_BUFFER = {};
741 if (DAB_BarOptions_ButtonControl:IsVisible()) then
742 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
743 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
744 local bar = DAB_OBJECT_SUBINDEX;
745 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button], DAB_CONTROL_BUFFER);
746 elseif (DAB_OBJECT_TYPE == "Bar") then
747 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions, DAB_CONTROL_BUFFER);
748 elseif (DAB_OBJECT_TYPE == "Floaters") then
749 DL_Copy_Table(DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions, DAB_CONTROL_BUFFER);
750 end
751 end
752  
753 function DAB_Copy_Settings()
754 DAB_BUFFER = {};
755 if (DAB_OBJECT_TYPE == "Bar") then
756 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX], DAB_BUFFER);
757 DAB_Options_Paste:SetText(DL_PASTETEXT.." (Bar "..DAB_OBJECT_SUBINDEX..")");
758 elseif (DAB_OBJECT_TYPE == "Floaters") then
759 DL_Copy_Table(DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX], DAB_BUFFER);
760 DAB_Options_Paste:SetText(DL_PASTETEXT.." (Floater "..DAB_OBJECT_SUBINDEX..")");
761 elseif (DAB_OBJECT_TYPE == "ControlBox") then
762 DL_Copy_Table(DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX], DAB_BUFFER);
763 DAB_Options_Paste:SetText(DL_PASTETEXT.." (Control Box "..DAB_OBJECT_SUBINDEX..")");
764 elseif (DAB_OBJECT_TYPE == "OtherBar") then
765 DL_Copy_Table(DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX], DAB_BUFFER);
766 DAB_Options_Paste:SetText(DL_PASTETEXT.." Other Bar");
767 end
768 DAB_BUFFER_TYPE = DAB_OBJECT_TYPE;
769 DAB_Options_Paste:Enable();
770 end
771  
772 function DAB_DropMenu_OnClick()
773 getglobal(DAB_DropMenu.controlbox):SetText(getglobal(this:GetName().."_Text"):GetText());
774 DAB_DropMenu:Hide();
775 if (DAB_DropMenu.initFunc) then
776 DAB_DropMenu.initFunc();
777 else
778 DAB_Update_Setting(DAB_DropMenu.settingType, this.value, DAB_DropMenu.index, DAB_DropMenu.subindex, DAB_DropMenu.subindex2);
779 end
780 end
781  
782 function DAB_EditBox_Update()
783 local value = this:GetText();
784 if (not value) then value = ""; end
785 if (this.number) then
786 value = this:GetNumber();
787 if (not value) then
788 value = 0;
789 this:SetText("0");
790 end
791 end
792 this:ClearFocus();
793 this.prevvalue = value;
794 DAB_Update_Setting(this.settingType, value, this.index, this.subindex);
795 end
796  
797 function DAB_Filter_ActionIDs()
798 if (DAB_DropMenu.index == "filter1") then
799 DAB_ACTIONIDS_FILTER1 = this.value;
800 DAB_ACTIONIDS_FILTER2 = 1;
801 if (DAB_ACTIONIDS_FILTER1 > 2) then
802 DAB_ACTIONID_FILTERS2 = { {text="All Pages", value=1} };
803 local bar = this.value - 2;
804 for page=1, DAB_Settings[DAB_INDEX].Bar[bar].numBars do
805 DAB_ACTIONID_FILTERS2[page + 1] = {text="Page "..page, value=page + 1};
806 end
807 DAB_SetActionIDs_FilterMenu2_Setting:SetText("All Pages");
808 else
809 DAB_ACTIONID_FILTERS2 = {};
810 DAB_SetActionIDs_FilterMenu2_Setting:SetText("");
811 end
812 else
813 DAB_ACTIONIDS_FILTER2 = this.value;
814 end
815 DAB_Update_ActionIDsList();
816 end
817  
818 function DAB_FloaterOptions_OnMouseWheel(direction)
819 if (direction > 0) then
820 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX - 1;
821 elseif (direction < 0) then
822 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX + 1;
823 end
824 if (DAB_OBJECT_INDEX > table.getn(DAB_BAR_LIST)) then
825 DAB_OBJECT_INDEX = 29;
826 elseif (DAB_OBJECT_INDEX < 29) then
827 DAB_OBJECT_INDEX = table.getn(DAB_BAR_LIST);
828 end
829 DAB_OBJECT_SUBINDEX = DAB_BAR_LIST[DAB_OBJECT_INDEX].value;
830 DAB_Init_FloaterOptions();
831 DAB_BarBrowser_Update();
832 end
833  
834 function DAB_FontEditBox_OnEnterPressed()
835 DAB_MenuEditBox_OnEnterPressed();
836 DAB_Update_FontList();
837 end
838  
839 function DAB_Get_FreeButton()
840 local low = 999;
841 for i, b in DAB_Settings[DAB_INDEX].FreeButtons do
842 if (b < low) then
843 low = b;
844 end
845 end
846 local oldFree = {};
847 DL_Copy_Table(DAB_Settings[DAB_INDEX].FreeButtons, oldFree);
848 DAB_Settings[DAB_INDEX].FreeButtons = {};
849 local index = 0;
850 for i, b in oldFree do
851 if (b ~= low) then
852 index = index + 1;
853 DAB_Settings[DAB_INDEX].FreeButtons[index] = b;
854 end
855 end
856 return low;
857 end
858  
859 function DAB_Get_Setting(index, subindex, subindex2)
860 if (index == "Misc") then
861 return DAB_Settings[DAB_INDEX][subindex];
862 elseif (index == "CONDITION") then
863 return DAB_CONDITION_BUFFER[subindex];
864 elseif (index == "MainMenuBar") then
865 return DAB_Settings[DAB_INDEX].MainMenuBar[subindex];
866 else
867 if (subindex2) then
868 return DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index][subindex][subindex2];
869 elseif (subindex) then
870 return DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index][subindex];
871 else
872 return DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index];
873 end
874 end
875 end
876  
877 function DAB_Get_UnusedAction()
878 local unusedAction;
879 local usedactions = {};
880 for bar = 1, DAB_NUM_BARS do
881 for page = 1, DAB_Settings[DAB_INDEX].Bar[bar].numBars do
882 if (DAB_Settings[DAB_INDEX].Bar[bar].pages[page]) then
883 for _, pageAction in DAB_Settings[DAB_INDEX].Bar[bar].pages[page] do
884 usedactions[pageAction] = 1;
885 end
886 end
887 end
888 end
889 for button = 1, 120 do
890 if (DAB_Settings[DAB_INDEX].Buttons[button].Bar) then
891 usedactions[DAB_Settings[DAB_INDEX].Buttons[button].action] = 1;
892 end
893 end
894 for i = 1, 120 do
895 if (not usedactions[i]) then
896 unusedAction = i;
897 break;
898 end
899 end
900 if (not unusedAction) then
901 if (DAB_LAST_USED) then
902 DAB_LAST_USED = DAB_LAST_USED + 1;
903 unusedAction = DAB_LAST_USED;
904 else
905 DAB_LAST_USED = 1;
906 unusedAction = 1;
907 end
908 end
909 return unusedAction;
910 end
911  
912 function DAB_GroupEditBox_OnEnterPressed()
913 DAB_MenuEditBox_OnEnterPressed();
914 DAB_Update_GroupList();
915 end
916  
917 function DAB_HideAllOptions()
918 DAB_BarOptions:Hide();
919 DAB_OtherBarOptions:Hide();
920 DAB_ButtonLayout:Hide();
921 DAB_FloaterOptions:Hide();
922 DAB_OnEventMacros:Hide();
923 DAB_MainBarOptions:Hide();
924 DAB_CBoxOptions:Hide();
925 DAB_ScriptOptions:Hide();
926 DAB_KeybindingOptions:Hide();
927 DAB_MiscOptions:Hide();
928 DAB_ChangeActions:Hide();
929 end
930  
931 function DAB_KeybindingBrowser_Update()
932 local numOptions = 120;
933 local offset = FauxScrollFrame_GetOffset(DAB_KeybindingOptions_KeybindingBrowser);
934 local index, button;
935  
936 for i=1, 10 do
937 button = "DAB_KeybindingOptions_KeybindingBrowser_Button"..i;
938 index = offset + i;
939 local option = DAB_Settings[DAB_INDEX].Keybindings[index].option;
940 local suboption = DAB_Settings[DAB_INDEX].Keybindings[index].suboption;
941 local suboption2 = DAB_Settings[DAB_INDEX].Keybindings[index].suboption2;
942 getglobal(button).index = index;
943 getglobal(button.."Index"):SetText(index);
944 DL_Init_MenuControl(getglobal(button.."_Option"), option);
945 setglobal("DAB_KEYBINDING_SUBOPTIONS_"..i, {});
946 setglobal("DAB_KEYBINDING_SUBOPTIONS2_"..i, {});
947 local suboptiontable = getglobal("DAB_KEYBINDING_SUBOPTIONS_"..i);
948 local suboption2table = getglobal("DAB_KEYBINDING_SUBOPTIONS2_"..i);
949  
950 if (option == 0) then
951 getglobal(button.."_Suboption_Label"):SetText("");
952 getglobal(button.."_Suboption2_Label"):SetText("");
953 elseif (option == 1 or option == 10) then
954 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Bar);
955 getglobal(button.."_Suboption2_Label"):SetText(DAB_TEXT.Button);
956 for i=1,10 do
957 suboptiontable[i] = {text=i, value=i};
958 end
959 for i=1,DAB_Settings[DAB_INDEX].Bar[suboption].numButtons do
960 local button = DAB_Settings[DAB_INDEX].Bar[suboption].pages[DAB_Settings[DAB_INDEX].Bar[suboption].page][i];
961 suboption2table[i] = {text="["..i.."] "..DAB_Get_ActionName(button), value=i};
962 end
963 elseif (option == 2) then
964 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Group);
965 getglobal(button.."_Suboption2_Label"):SetText(DAB_TEXT.Button);
966 for i=1,120 do
967 suboptiontable[i] = {text=i, value=i};
968 suboption2table[i] = {text=i, value=i};
969 end
970 elseif (option == 3 or option == 11) then
971 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Floater);
972 getglobal(button.."_Suboption2_Label"):SetText("");
973 local count = 0;
974 for i in DAB_Settings[DAB_INDEX].Floaters do
975 count = count + 1;
976 suboptiontable[count] = {text="["..i.."] "..DAB_Get_ActionName(DAB_Settings[DAB_INDEX].Buttons[i].action), value=i};
977 end
978 elseif (option == 4) then
979 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.CtrlBox);
980 getglobal(button.."_Suboption2_Label"):SetText("");
981 for i=1,10 do
982 suboptiontable[i] = {text=i, value=i};
983 end
984 elseif (option == 5) then
985 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Group);
986 getglobal(button.."_Suboption2_Label"):SetText(DAB_TEXT.Bar);
987 for i=1,120 do
988 suboptiontable[i] = {text=i, value=i};
989 end
990 for i=1,10 do
991 suboption2table[i] = {text=i, value=i};
992 end
993 elseif (option == 6) then
994 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Bar);
995 getglobal(button.."_Suboption2_Label"):SetText(DAB_TEXT.Page);
996 for i=1,10 do
997 suboptiontable[i] = {text=i, value=i};
998 end
999 for i=1,DAB_Settings[DAB_INDEX].Bar[suboption].numBars do
1000 suboption2table[i] = {text=i, value=i};
1001 end
1002 elseif (option == 7 or option == 8) then
1003 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Bar);
1004 getglobal(button.."_Suboption2_Label"):SetText("");
1005 for i=1,10 do
1006 suboptiontable[i] = {text=i, value=i};
1007 end
1008 elseif (option == 9) then
1009 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Number);
1010 getglobal(button.."_Suboption2_Label"):SetText("");
1011 for i=1,120 do
1012 suboptiontable[i] = {text=i, value=i};
1013 end
1014 elseif (option == 12) then
1015 local _, _, bar, page = string.find(suboption, "(%d*)_(%d*)");
1016 bar = tonumber(bar);
1017 page = tonumber(page);
1018 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Bar);
1019 getglobal(button.."_Suboption2_Label"):SetText(DAB_TEXT.Button);
1020 local index = 0;
1021 for i=1,10 do
1022 for page=1, DAB_Settings[DAB_INDEX].Bar[i].numBars do
1023 index = index + 1;
1024 suboptiontable[index] = {text=DAB_TEXT.Bar.." "..i..", "..DAB_TEXT.Page.." "..page, value=i.."_"..page};
1025 end
1026 end
1027 for i=1,DAB_Settings[DAB_INDEX].Bar[bar].numButtons do
1028 local button = DAB_Settings[DAB_INDEX].Bar[bar].pages[page][i];
1029 suboption2table[i] = {text="["..i.."] "..DAB_Get_ActionName(button), value=i};
1030 end
1031 elseif (option == 13 or option == 14) then
1032 getglobal(button.."_Suboption_Label"):SetText(DAB_TEXT.Action);
1033 getglobal(button.."_Suboption2_Label"):SetText("");
1034 for i=1,120 do
1035 suboptiontable[i] = {text="["..i.."] "..DAB_Get_ActionName(i), value=i};
1036 end
1037 end
1038 DL_Init_MenuControl(getglobal(button.."_Suboption"), suboption);
1039 DL_Init_MenuControl(getglobal(button.."_Suboption2"), suboption2);
1040 local key1, key2 = DL_Get_KeybindingText("DAB_"..index, nil, 1);
1041 if (key1) then
1042 getglobal(button.."_Key1"):SetText(key1);
1043 else
1044 getglobal(button.."_Key1"):SetText("");
1045 end
1046 if (key2) then
1047 getglobal(button.."_Key2"):SetText(key2);
1048 else
1049 getglobal(button.."_Key2"):SetText("");
1050 end
1051 getglobal(button.."_Key1"):UnlockHighlight();
1052 getglobal(button.."_Key2"):UnlockHighlight();
1053 if (DAB_SELECTED_KEYBINDING.index == index) then
1054 if (DAB_SELECTED_KEYBINDING.keyID == 1) then
1055 getglobal(button.."_Key1"):LockHighlight();
1056 else
1057 getglobal(button.."_Key2"):LockHighlight();
1058 end
1059 end
1060 if (DAB_Settings[DAB_INDEX].Keybindings[index].down) then
1061 getglobal(button.."_Down"):SetChecked(1);
1062 else
1063 getglobal(button.."_Down"):SetChecked(0);
1064 end
1065 if (DAB_Settings[DAB_INDEX].Keybindings[index].up) then
1066 getglobal(button.."_Up"):SetChecked(1);
1067 else
1068 getglobal(button.."_Up"):SetChecked(0);
1069 end
1070 end
1071  
1072 FauxScrollFrame_Update(DAB_KeybindingOptions_KeybindingBrowser, numOptions, 10, 50);
1073 end
1074  
1075 function DAB_KeybindingButton_OnClick(button, key)
1076 local index = this:GetParent().index;
1077 if (DAB_SELECTED_KEYBINDING) then
1078 if ( button == "LeftButton" or button == "RightButton" ) then
1079 if (DAB_SELECTED_KEYBINDING.index == index) then
1080 DAB_SELECTED_KEYBINDING.index = nil;
1081 else
1082 DAB_SELECTED_KEYBINDING.index = index;
1083 DAB_SELECTED_KEYBINDING.button = this;
1084 DAB_SELECTED_KEYBINDING.keyID = key;
1085 end
1086 DAB_KeybindingBrowser_Update();
1087 return;
1088 end
1089 DAB_KeyBindingFrame_OnKeyDown(button);
1090 else
1091 if (DAB_SELECTED_KEYBINDING.button) then
1092 DAB_SELECTED_KEYBINDING.button:UnlockHighlight();
1093 end
1094 DAB_SELECTED_KEYBINDING.index = index;
1095 DAB_SELECTED_KEYBINDING.button = this;
1096 DAB_SELECTED_KEYBINDING.keyID = key;
1097 end
1098 end
1099  
1100 function DAB_KeyBindingFrame_OnKeyDown(button)
1101 if ( not IsMacClient() ) then
1102 if ( arg1 == "PRINTSCREEN" ) then
1103 Screenshot();
1104 return;
1105 end
1106 end
1107 if ( button == "LeftButton" ) then
1108 button = "BUTTON1";
1109 elseif ( button == "RightButton" ) then
1110 button = "BUTTON2";
1111 elseif ( button == "MiddleButton" ) then
1112 button = "BUTTON3";
1113 elseif ( button == "Button4" ) then
1114 button = "BUTTON4"
1115 elseif ( button == "Button5" ) then
1116 button = "BUTTON5"
1117 end
1118 if (DAB_SELECTED_KEYBINDING.index) then
1119 local keybinding = "DAB_"..DAB_SELECTED_KEYBINDING.index;
1120 local keyPressed;
1121 if ( button ) then
1122 if ( button == "BUTTON1" or button == "BUTTON2" ) then
1123 return;
1124 end
1125 keyPressed = button;
1126 else
1127 keyPressed = arg1;
1128 end
1129 if ( keyPressed == "UNKNOWN" ) then
1130 return;
1131 end
1132 if ( keyPressed == "SHIFT" or keyPressed == "CTRL" or keyPressed == "ALT") then
1133 return;
1134 end
1135 if ( IsShiftKeyDown() ) then
1136 keyPressed = "SHIFT-"..keyPressed;
1137 end
1138 if ( IsControlKeyDown() ) then
1139 keyPressed = "CTRL-"..keyPressed;
1140 end
1141 if ( IsAltKeyDown() ) then
1142 keyPressed = "ALT-"..keyPressed;
1143 end
1144 local key1, key2 = GetBindingKey(keybinding);
1145 if ( key1 ) then
1146 SetBinding(key1);
1147 end
1148 if ( key2 ) then
1149 SetBinding(key2);
1150 end
1151 if ( DAB_SELECTED_KEYBINDING.keyID == 1 ) then
1152 DAB_SetBinding(keyPressed, keybinding, key1);
1153 if ( key2 ) then
1154 SetBinding(key2, keybinding);
1155 end
1156 else
1157 if ( key1 ) then
1158 DAB_SetBinding(key1, keybinding);
1159 end
1160 DAB_SetBinding(keyPressed, keybinding, key2);
1161 end
1162 DAB_Save_Keybindings();
1163 DAB_Update_Keybindings();
1164 DAB_KeybindingBrowser_Update();
1165 DAB_SELECTED_KEYBINDING.index = nil;
1166 DAB_SELECTED_KEYBINDING.button:UnlockHighlight();
1167 end
1168 end
1169  
1170 function DAB_Load_PresetBackdrop()
1171 local bgtexture, bordertexture, tile, tileSize, edgeSize, left, right, top, bottom = DL_Get_Backdrop(this.value);
1172 if (DAB_BAR_OPTIONS == "DAB_BarOptions_LabelTab") then
1173 DAB_Update_Setting("Label", bgtexture, "Label", "texture", nil, 1);
1174 DAB_Update_Setting("Label", bordertexture, "Label", "btexture", nil, 1);
1175 DAB_Update_Setting("Label", tile, "Label", "tile", nil, 1);
1176 DAB_Update_Setting("Label", tileSize, "Label", "tileSize", nil, 1);
1177 DAB_Update_Setting("Label", edgeSize, "Label", "edgeSize", nil, 1);
1178 DAB_Update_Setting("Label", left, "Label", "left", nil, 1);
1179 DAB_Update_Setting("Label", right, "Label", "right", nil, 1);
1180 DAB_Update_Setting("Label", top, "Label", "top", nil, 1);
1181 DAB_Update_Setting("Label", bottom, "Label", "bottom");
1182 else
1183 DAB_Update_Setting("Backdrop", bgtexture, "Background", "texture", nil, 1);
1184 DAB_Update_Setting("Backdrop", bordertexture, "Background", "btexture", nil, 1);
1185 DAB_Update_Setting("Backdrop", tile, "Background", "tile", nil, 1);
1186 DAB_Update_Setting("Backdrop", tileSize, "Background", "tileSize", nil, 1);
1187 DAB_Update_Setting("Backdrop", edgeSize, "Background", "edgeSize", nil, 1);
1188 DAB_Update_Setting("Backdrop", left, "Background", "left", nil, 1);
1189 DAB_Update_Setting("Backdrop", right, "Background", "right", nil, 1);
1190 DAB_Update_Setting("Backdrop", top, "Background", "top", nil, 1);
1191 DAB_Update_Setting("Backdrop", bottom, "Background", "bottom");
1192 end
1193 if (DAB_OBJECT_TYPE == "Bar") then
1194 DAB_Init_BarOptions();
1195 else
1196 DAB_Init_OtherBarOptions();
1197 end
1198 DAB_Update_TextureList();
1199 end
1200  
1201 function DAB_MenuEditBox_OnEnterPressed()
1202 this:ClearFocus();
1203 DAB_Update_Setting(this:GetParent().settingType, this:GetText(), this:GetParent().index, this:GetParent().subindex);
1204 end
1205  
1206 function DAB_Nudge(button, dragframe)
1207 local dir = this:GetID();
1208 local amt = 1;
1209 if (button == "RightButton") then
1210 amt = 10;
1211 elseif (button == "MiddleButton") then
1212 amt = 3;
1213 end
1214 local x = DAB_Get_Setting("Anchor", "x");
1215 local y = DAB_Get_Setting("Anchor", "y");
1216 if (dir == 1) then
1217 getglobal(this.updateFrame):SetText(y + amt);
1218 DAB_Update_Setting("Location", y + amt, "Anchor", "y");
1219 elseif (dir == 2) then
1220 getglobal(this.updateFrame):SetText(y - amt);
1221 DAB_Update_Setting("Location", y - amt, "Anchor", "y");
1222 elseif (dir == 3) then
1223 getglobal(this.updateFrame):SetText(x - amt);
1224 DAB_Update_Setting("Location", x - amt, "Anchor", "x");
1225 elseif (dir == 4) then
1226 getglobal(this.updateFrame):SetText(x + amt);
1227 DAB_Update_Setting("Location", x + amt, "Anchor", "x");
1228 end
1229 end
1230  
1231 function DAB_Nudge_OnUpdate(elapsed, dragframe)
1232 if (not this.timer) then
1233 this.timer = 1 / 30;
1234 end
1235 if (this.movingframe) then
1236 this.timer = this.timer - elapsed;
1237 if (this.timer < 0) then
1238 this.timer = 1 / 30;
1239 DAB_Nudge("MiddleButton");
1240 end
1241 end
1242 end
1243  
1244 function DAB_NumButtons_OnMouseWheel()
1245 if (arg1 < 0) then
1246 DAB_Remove_ButtonOrPage(this:GetID());
1247 elseif (arg1 > 0) then
1248 DAB_Add_ButtonOrPage(this:GetID());
1249 end
1250 end
1251  
1252 function DAB_NumButtons_SetWarning(num)
1253 local warning = string.gsub(DAB_TEXT.Warning, "$n", num);
1254 DAB_NumButtons_Warning:SetText(warning);
1255 DAB_NumButtons_Warning:SetTextColor(1, 1, 0, 1);
1256 DAB_NumButtons.timer = 3;
1257 end
1258  
1259 function DAB_NumButtons_WarningTimeOut(elapsed)
1260 if (not this.timer) then return; end
1261 this.timer = this.timer - elapsed;
1262 if (this.timer < 0) then
1263 this.timer = nil;
1264 DAB_NumButtons_Warning:SetText("");
1265 elseif (this.timer < .5) then
1266 DAB_NumButtons_Warning:SetTextColor(1, 1, 0, this.timer * 2);
1267 end
1268 end
1269  
1270 function DAB_Options_OnShow()
1271 DAB_Update_FloaterList();
1272 DAB_Update_ObjectList();
1273 DAB_BarBrowser_Update();
1274 end
1275  
1276 function DAB_OtherBarOptions_OnMouseWheel(direction)
1277 if (direction > 0) then
1278 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX - 1;
1279 elseif (direction < 0) then
1280 DAB_OBJECT_INDEX = DAB_OBJECT_INDEX + 1;
1281 end
1282 if (DAB_OBJECT_INDEX > 16) then
1283 DAB_OBJECT_INDEX = 13;
1284 elseif (DAB_OBJECT_INDEX < 13) then
1285 DAB_OBJECT_INDEX = 16;
1286 end
1287 DAB_OBJECT_SUBINDEX = DAB_BAR_LIST[DAB_OBJECT_INDEX].value;
1288 DAB_Init_OtherBarOptions();
1289 DAB_BarBrowser_Update();
1290 end
1291  
1292 function DAB_Paste_ControlSettings()
1293 if (not DAB_CONTROL_BUFFER) then return; end
1294 if (DAB_BarOptions_ButtonControl:IsVisible()) then
1295 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
1296 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
1297 local bar = DAB_OBJECT_SUBINDEX;
1298 DL_Copy_Table(DAB_CONTROL_BUFFER, DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button]);
1299 elseif (DAB_OBJECT_TYPE == "Bar") then
1300 DL_Copy_Table(DAB_CONTROL_BUFFER, DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions);
1301 elseif (DAB_OBJECT_TYPE == "Floaters") then
1302 DL_Copy_Table(DAB_CONTROL_BUFFER, DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions);
1303 end
1304 DAB_ConditionMenu_Update();
1305 end
1306  
1307 function DAB_Paste_Settings()
1308 if (DAB_BUFFER_TYPE ~= DAB_OBJECT_TYPE) then return; end
1309 local initType;
1310 local oldSettings = {};
1311 if (DAB_OBJECT_TYPE == "Bar") then
1312 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX], oldSettings);
1313 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX] = {};
1314 DL_Copy_Table(DAB_BUFFER, DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX]);
1315 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].numBars = oldSettings.numBars;
1316 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].numButtons = oldSettings.numButtons;
1317 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].page = oldSettings.page;
1318 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].middleClick = oldSettings.middleClick;
1319 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].rightClick = oldSettings.rightClick;
1320 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].rows = oldSettings.rows;
1321 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Label.text = oldSettings.Label.text;
1322 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Anchor = {
1323 frame = oldSettings.Anchor.frame,
1324 to = oldSettings.Anchor.to,
1325 point = oldSettings.Anchor.point,
1326 x = oldSettings.Anchor.x,
1327 y = oldSettings.Anchor.y
1328 };
1329 DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Scripts = {};
1330 DL_Copy_Table(oldSettings.Scripts, DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Scripts);
1331 DAB_Init_BarOptions();
1332 DAB_Bar_Location(DAB_OBJECT_SUBINDEX);
1333 DAB_Bar_Initialize(DAB_OBJECT_SUBINDEX);
1334 DAB_Bar_Label(DAB_OBJECT_SUBINDEX);
1335 DAB_Bar_Backdrop(DAB_OBJECT_SUBINDEX);
1336 DAB_Bar_ButtonTextures(DAB_OBJECT_SUBINDEX);
1337 DAB_Bar_ButtonText(DAB_OBJECT_SUBINDEX);
1338 DAB_Bar_ButtonSize(DAB_OBJECT_SUBINDEX);
1339 DAB_Bar_ButtonAlpha(DAB_OBJECT_SUBINDEX);
1340 elseif (DAB_OBJECT_TYPE == "Floaters") then
1341 DL_Copy_Table(DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX], oldSettings);
1342 DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX] = {};
1343 DL_Copy_Table(DAB_BUFFER, DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX]);
1344 DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX].middleClick = oldSettings.middleClick;
1345 DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX].rightClick = oldSettings.rightClick;
1346 DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX].Anchor = {
1347 frame = oldSettings.Anchor.frame,
1348 to = oldSettings.Anchor.to,
1349 point = oldSettings.Anchor.point,
1350 x = oldSettings.Anchor.x,
1351 y = oldSettings.Anchor.y
1352 };
1353 DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX].Scripts = {};
1354 DL_Copy_Table(oldSettings.Scripts, DAB_Settings[DAB_INDEX].Floaters[DAB_OBJECT_SUBINDEX].Scripts);
1355 DAB_Floater_Initialize(DAB_OBJECT_SUBINDEX);
1356 DAB_Init_FloaterOptions();
1357 elseif (DAB_OBJECT_TYPE == "ControlBox") then
1358 DL_Copy_Table(DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX], oldSettings);
1359 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX] = {};
1360 DL_Copy_Table(DAB_BUFFER, DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX]);
1361 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].Anchor = {};
1362 DL_Copy_Table(oldSettings.Anchor, DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].Anchor);
1363 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].group = oldSettings.group;
1364 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].rcgroup = oldSettings.rcgroup;
1365 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].mcgroup = oldSettings.mcgroup;
1366 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].text = oldSettings.text;
1367 DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].Scripts = {};
1368 DL_Copy_Table(oldSettings.Scripts, DAB_Settings[DAB_INDEX].ControlBox[DAB_OBJECT_SUBINDEX].Scripts);
1369 DAB_ControlBox_Initialize(DAB_OBJECT_SUBINDEX);
1370 DAB_Init_ControlBoxOptions();
1371 elseif (DAB_OBJECT_TYPE == "OtherBar") then
1372 DL_Copy_Table(DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX], oldSettings);
1373 DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX] = {};
1374 DL_Copy_Table(DAB_BUFFER, DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX]);
1375 DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX].Anchor = {};
1376 DL_Copy_Table(oldSettings.Anchor, DAB_Settings[DAB_INDEX].OtherBar[DAB_OBJECT_SUBINDEX].Anchor);
1377 DAB_OtherBar_Initialize(DAB_OBJECT_SUBINDEX);
1378 DAB_Init_OtherBarOptions();
1379 end
1380 end
1381  
1382 function DAB_Remove_ButtonOrPage(id)
1383 if (not id) then
1384 id = this:GetParent():GetID();
1385 end
1386 if (id < 11) then
1387 if (DAB_Settings[DAB_INDEX].Bar[id].numButtons == 0) then return; end
1388 local button;
1389 for i=1, 120 do
1390 if (DAB_Settings[DAB_INDEX].Buttons[i].Bar == id) then
1391 button = i;
1392 end
1393 end
1394 DAB_Settings[DAB_INDEX].Buttons[button] = {Conditions={}, Scripts={}, action=button};
1395 getglobal("DAB_FloaterBox_"..button):ClearAllPoints();
1396 getglobal("DAB_FloaterBox_"..button):SetPoint("CENTER", UIParent, "CENTER", 0, 0);
1397 DAB_Settings[DAB_INDEX].FreeButtons[table.getn(DAB_Settings[DAB_INDEX].FreeButtons) + 1] = button;
1398 for page=1, DAB_Settings[DAB_INDEX].Bar[id].numBars do
1399 DAB_Settings[DAB_INDEX].Bar[id].pages[page][DAB_Settings[DAB_INDEX].Bar[id].numButtons] = nil;
1400 DAB_Settings[DAB_INDEX].Bar[id].pageconditions[page][DAB_Settings[DAB_INDEX].Bar[id].numButtons] = nil;
1401 end
1402 DAB_Settings[DAB_INDEX].Bar[id].numButtons = DAB_Settings[DAB_INDEX].Bar[id].numButtons - 1;
1403 else
1404 id = id - 10;
1405 if (DAB_Settings[DAB_INDEX].Bar[id].numBars == 1) then return; end
1406 local p = DAB_Settings[DAB_INDEX].Bar[id].numBars;
1407 DAB_Settings[DAB_INDEX].Bar[id].pages[p] = nil;
1408 DAB_Settings[DAB_INDEX].Bar[id].pageconditions[p] = nil;
1409 getglobal("DAB_ActionBar_"..id).pagemap[DAB_Settings[DAB_INDEX].Bar[id].numBars] = nil;
1410 DAB_Settings[DAB_INDEX].Bar[id].numBars = DAB_Settings[DAB_INDEX].Bar[id].numBars - 1;
1411 if (DAB_Settings[DAB_INDEX].Bar[id].page > DAB_Settings[DAB_INDEX].Bar[id].numBars) then
1412 DAB_Settings[DAB_INDEX].Bar[id].page = DAB_Settings[DAB_INDEX].Bar[id].numBars;
1413 end
1414 DAB_Bar_SetPage(id, 1, 1);
1415 end
1416 if (DAB_Settings[DAB_INDEX].Bar[id].rows > DAB_Settings[DAB_INDEX].Bar[id].numButtons) then
1417 DAB_Settings[DAB_INDEX].Bar[id].rows = DAB_Settings[DAB_INDEX].Bar[id].numButtons;
1418 if (DAB_Settings[DAB_INDEX].Bar[id].rows == 0) then
1419 DAB_Settings[DAB_INDEX].Bar[id].rows = 1;
1420 end
1421 end
1422 DAB_Init_ButtonLayout();
1423 DAB_Bar_Initialize(id);
1424 if (DAB_Settings[DAB_INDEX].AutoConfigureKB) then
1425 DAB_AutoConfigure_Keybindings();
1426 end
1427 DAB_Update_Keybindings();
1428 end
1429  
1430 function DAB_Remove_Floater(id)
1431 if (not id) then
1432 id = this.value;
1433 end
1434 DAB_Settings[DAB_INDEX].Floaters[id] = nil;
1435 DAB_Settings[DAB_INDEX].FreeButtons[table.getn(DAB_Settings[DAB_INDEX].FreeButtons) + 1] = id;
1436 DAB_Settings[DAB_INDEX].Buttons[id] = {Conditions={}, Scripts={}, action=id};
1437 getglobal("DAB_FloaterBox_"..id):ClearAllPoints();
1438 getglobal("DAB_FloaterBox_"..id):SetPoint("CENTER", UIParent, "CENTER", 0, 0);
1439 DAB_Init_ButtonLayout();
1440 DAB_Update_ObjectList();
1441 DAB_Update_FloaterList();
1442 DAB_Update_AnchorsList();
1443 DAB_BarBrowser_Update();
1444 if (DAB_Settings[DAB_INDEX].AutoConfigureKB) then
1445 DAB_AutoConfigure_Keybindings();
1446 end
1447 DAB_Update_Keybindings();
1448 end
1449  
1450 function DAB_Reset_Parameters(options, toggle)
1451 if (not toggle) then
1452 getglobal(options.."_ActionID"):Hide();
1453 getglobal(options.."_ActionID_Setting"):SetText("");
1454 getglobal(options.."_Bars"):Hide();
1455 getglobal(options.."_Bars_Setting"):SetText("");
1456 getglobal(options.."_IgnoreGlobal"):Hide();
1457 getglobal(options.."_IgnoreGlobal"):SetChecked(0);
1458 getglobal(options.."_Unit"):Hide();
1459 getglobal(options.."_Unit_Setting"):SetText("");
1460 getglobal(options.."_Unit2"):Hide();
1461 getglobal(options.."_Unit2_Setting"):SetText("");
1462 getglobal(options.."_Buff"):Hide();
1463 getglobal(options.."_Buff"):SetText("");
1464 getglobal(options.."_Comparison"):Hide();
1465 getglobal(options.."_Comparison_Setting"):SetText("");
1466 getglobal(options.."_Number"):Hide();
1467 getglobal(options.."_Number"):SetText("");
1468 getglobal(options.."_Text"):Hide();
1469 getglobal(options.."_Text"):SetText("");
1470 getglobal(options.."_Forms"):Hide();
1471 getglobal(options.."_Forms_Setting"):SetText("");
1472 getglobal(options.."_Targets"):Hide();
1473 getglobal(options.."_Targets_Setting"):SetText("");
1474 end
1475 if (DAB_OBJECT_TYPE == "Bar") then
1476 getglobal(options.."_Page"):Hide();
1477 getglobal(options.."_Page_Setting"):SetText("");
1478 if (getglobal(options.."_Page2")) then
1479 getglobal(options.."_Page2"):Hide();
1480 getglobal(options.."_Page2_Setting"):SetText("");
1481 end
1482 end
1483 getglobal(options.."_Alpha"):Hide();
1484 getglobal(options.."_Alpha_Display"):SetText("");
1485 getglobal(options.."_Color"):Hide();
1486 getglobal(options.."_Amount"):Hide();
1487 getglobal(options.."_Amount_Display"):SetText("");
1488 getglobal(options.."_ResponseNumber"):Hide();
1489 getglobal(options.."_ResponseNumber"):SetText("");
1490 getglobal(options.."_ResponseText"):Hide();
1491 getglobal(options.."_ResponseText"):SetText("");
1492 getglobal(options.."_ResponseUnit"):Hide();
1493 getglobal(options.."_ResponseUnit_Setting"):SetText("");
1494 if (getglobal(options.."_ResponseActionID")) then
1495 getglobal(options.."_ResponseActionID"):Hide();
1496 getglobal(options.."_ResponseActionID_Setting"):SetText("");
1497 end
1498 if (getglobal(options.."_ResponseX")) then
1499 getglobal(options.."_ResponseX"):Hide();
1500 getglobal(options.."_ResponseX"):SetText("");
1501 getglobal(options.."_ResponseY"):Hide();
1502 getglobal(options.."_ResponseY"):SetText("");
1503 end
1504 end
1505  
1506 function DAB_Scripts_Compile()
1507 DAB_Compile_Scripts(DAB_OBJECT_TYPE, DAB_OBJECT_SUBINDEX);
1508 end
1509  
1510 function DAB_Scripts_Update()
1511 if (DAB_CURRENT_SCRIPT) then
1512 DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX].Scripts[DAB_CURRENT_SCRIPT] = DAB_ScriptOptions_EditBox_Text:GetText();
1513 DAB_Update_ScriptsList();
1514 end
1515 end
1516  
1517 function DAB_ScrollMenu_OnClick()
1518 this:GetParent():Hide();
1519 local text = "";
1520 local list = getglobal(DAB_ScrollMenu.table);
1521 for _, value in list do
1522 if (value.value == this.value) then
1523 text = value.text;
1524 end
1525 end
1526 getglobal(DAB_ScrollMenu.controlbox):SetText(text);
1527 if (DAB_ScrollMenu.initFunc) then
1528 DAB_ScrollMenu.initFunc();
1529 else
1530 DAB_Update_Setting(DAB_ScrollMenu.settingType, this.value, DAB_ScrollMenu.index, DAB_ScrollMenu.subindex, DAB_ScrollMenu.subindex2);
1531 end
1532 end
1533  
1534 function DAB_ScrollMenu_Update()
1535 local list = getglobal(this:GetParent().table);
1536 if (not list) then return; end
1537 local numOptions = table.getn(list);
1538 local offset = FauxScrollFrame_GetOffset(DAB_ScrollMenu_ScrollFrame);
1539 if (not offset) then offset = 0; end
1540 local index, button;
1541  
1542 for i=1, 10 do
1543 button = getglobal("DAB_ScrollMenu_Button"..i);
1544 buttontext = getglobal("DAB_ScrollMenu_Button"..i.."Text");
1545 index = offset + i;
1546 if ( list[index] ) then
1547 buttontext:SetText(list[index].text);
1548 button:Show();
1549 button:SetChecked(0);
1550 button.value = list[index].value;
1551 button.desc = list[index].desc;
1552 else
1553 button:Hide();
1554 end
1555 end
1556  
1557 FauxScrollFrame_Update(DAB_ScrollMenu_ScrollFrame, numOptions, 10, 20 );
1558 end
1559  
1560 function DAB_Select_BarButton()
1561 DAB_SELECTED_BARBUTTON = this.index;
1562 DAB_BarButtonsMenu_Update();
1563 DAB_ConditionMenu_Update();
1564 end
1565  
1566 function DAB_Select_BarOptions(index)
1567 DAB_BarOptions_BarAppearance:Hide();
1568 DAB_BarOptions_ButtonAppearance:Hide();
1569 DAB_BarOptions_BarControl:Hide();
1570 DAB_BarOptions_Label:Hide();
1571 DAB_ScriptOptions:Hide();
1572 DAB_BarOptions_ButtonControl:Hide();
1573 if (index == 1) then
1574 DAB_BarOptions_BarAppearance:Show();
1575 elseif (index == 2) then
1576 DAB_BarOptions_BarControl:Show();
1577 DAB_ConditionMenu_Update();
1578 elseif (index == 3) then
1579 DAB_BarOptions_ButtonAppearance:Show();
1580 elseif (index == 4) then
1581 DAB_BarOptions_ButtonControl:Show();
1582 DAB_BarButtonsMenu_Update();
1583 DAB_ConditionMenu_Update();
1584 elseif (index == 5) then
1585 DAB_BarOptions_Label:Show();
1586 elseif (index == 6) then
1587 DAB_ScriptOptions:Show();
1588 DAB_Update_ScriptsList();
1589 end
1590 end
1591  
1592 function DAB_Select_ButtonLayoutOptions(index)
1593 DAB_NumButtons:Hide();
1594 DAB_SetActionIDs:Hide();
1595 if (index == 1) then
1596 DAB_NumButtons:Show();
1597 else
1598 DAB_SetActionIDs:Show();
1599 DAB_Update_ActionIDsList();
1600 end
1601 end
1602  
1603 function DAB_Select_CboxOptions(index)
1604 DAB_CBoxOptions_Config:Hide();
1605 DAB_CBoxOptions_Control:Hide();
1606 DAB_ScriptOptions:Hide();
1607 if (index == 1) then
1608 DAB_CBoxOptions_Config:Show();
1609 elseif (index == 2) then
1610 DAB_CBoxOptions_Control:Show();
1611 elseif (index == 3) then
1612 DAB_ScriptOptions:Show();
1613 DAB_Update_ScriptsList();
1614 end
1615 end
1616  
1617 function DAB_Select_Condition(condition, menucontrol)
1618 if (not condition) then
1619 DAB_CONDITION_EDITTING = nil;
1620 condition = this.value;
1621 DAB_CONDITION_BUFFER = { condition = condition };
1622 else
1623 DAB_CONDITION_EDITTING = condition;
1624 DAB_CONDITION_BUFFER = {};
1625 if (DAB_BarOptions_ButtonControl:IsVisible()) then
1626 local page = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].page;
1627 local button = DAB_BAR_BUTTONS[DAB_SELECTED_BARBUTTON].button;
1628 local bar = DAB_OBJECT_SUBINDEX;
1629 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button][condition], DAB_CONDITION_BUFFER);
1630 DL_Init_MenuControl(DAB_BarOptions_ButtonControl_Condition, DAB_CONDITION_BUFFER.condition);
1631 DAB_CONDITION_BUFFER.overrides = "";
1632 for i,o in DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button][condition].overrides do
1633 if (i == table.getn(DAB_Settings[DAB_INDEX].Bar[bar].pageconditions[page][button][condition].overrides)) then
1634 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o;
1635 else
1636 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o..", ";
1637 end
1638 DAB_BarOptions_ButtonControl_Overrides:SetText(DAB_CONDITION_BUFFER.overrides);
1639 end
1640 elseif (DAB_OBJECT_TYPE == "Bar") then
1641 DL_Copy_Table(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions[condition], DAB_CONDITION_BUFFER);
1642 DL_Init_MenuControl(DAB_BarOptions_BarControl_Condition, DAB_CONDITION_BUFFER.condition);
1643 DAB_CONDITION_BUFFER.overrides = "";
1644 for i,o in DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions[condition].overrides do
1645 if (i == table.getn(DAB_Settings[DAB_INDEX].Bar[DAB_OBJECT_SUBINDEX].Conditions[condition].overrides)) then
1646 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o;
1647 else
1648 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o..", ";
1649 end
1650 DAB_BarOptions_BarControl_Overrides:SetText(DAB_CONDITION_BUFFER.overrides);
1651 end
1652 elseif (DAB_OBJECT_TYPE == "Floaters") then
1653 DL_Copy_Table(DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions[condition], DAB_CONDITION_BUFFER);
1654 DL_Init_MenuControl(DAB_FloaterOptions_Control_Condition, DAB_CONDITION_BUFFER.condition);
1655 DAB_CONDITION_BUFFER.overrides = "";
1656 for i,o in DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions[condition].overrides do
1657 if (i == table.getn(DAB_Settings[DAB_INDEX].Buttons[DAB_OBJECT_SUBINDEX].Conditions[condition].overrides)) then
1658 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o;
1659 else
1660 DAB_CONDITION_BUFFER.overrides = DAB_CONDITION_BUFFER.overrides..o..", ";
1661 end
1662 DAB_FloaterOptions_Control_Overrides:SetText(DAB_CONDITION_BUFFER.overrides);
1663 end
1664 end
1665 condition = DAB_CONDITION_BUFFER.condition;
1666 end
1667 if (not menucontrol) then menucontrol = DAB_ScrollMenu.cboxbase; end
1668 local options = getglobal(menucontrol):GetParent():GetName();
1669 DAB_Reset_Parameters(options);
1670 local conditionsIndex;
1671 for index, value in DL_CONDITIONS_MENU do
1672 if (value.value == condition) then
1673 conditionsIndex = index;
1674 break;
1675 end
1676 end
1677 local params = DL_CONDITIONS_MENU[conditionsIndex].params;
1678 if (params == 1) then
1679 DAB_Show_Parameters({"_ActionID", "_IgnoreGlobal"}, {1, 2}, options);
1680 elseif (params == 2) then
1681 DAB_Show_Parameters({"_ActionID"}, {1}, options);
1682 elseif (params == 3) then
1683 if (not DAB_CONDITION_EDITTING) then
1684 DAB_CONDITION_BUFFER.unit = "player";
1685 end
1686 DAB_Show_Parameters({"_Unit", "_Buff"}, {1, 3}, options);
1687 elseif (params == 4) then
1688 DL_Set_Anchor("_ConditionMenu", 0, -50, nil, nil, nil, getglobal(options.."_Comparison"));
1689 DL_Set_Anchor("_ConditionMenu", 0, -75, nil, nil, nil, getglobal(options.."_Number"));
1690 DAB_Show_Parameters({"_Comparison", "_Number"}, {1, 3}, options);
1691 elseif (params == 5) then
1692 if (not DAB_CONDITION_EDITTING) then
1693 DAB_CONDITION_BUFFER.unit = "player";
1694 end
1695 DAB_Show_Parameters({"_Unit", "_Text"}, {1, 3}, options);
1696 elseif (params == 6) then
1697 DL_Set_Anchor("_ConditionMenu", 0, -100, nil, nil, nil, getglobal(options.."_Comparison"));
1698 DL_Set_Anchor("_Comparison", 5, 0, "LEFT", "RIGHT", nil, getglobal(options.."_Number"));
1699 if (not DAB_CONDITION_EDITTING) then
1700 DAB_CONDITION_BUFFER.unit = "player";
1701 end
1702 DAB_Show_Parameters({"_Unit", "_Text", "_Comparison", "_Number"}, {1, 3, 1, 3}, options);
1703 elseif (params == 7) then
1704 DL_Set_Anchor("_ConditionMenu", 0, -75, nil, nil, nil, getglobal(options.."_Comparison"));
1705 DL_Set_Anchor("_ConditionMenu", 0, -100, nil, nil, nil, getglobal(options.."_Number"));
1706 if (not DAB_CONDITION_EDITTING) then
1707 DAB_CONDITION_BUFFER.unit = "player";
1708 end
1709 DAB_Show_Parameters({"_Unit", "_Comparison", "_Number"}, {1, 1, 3}, options);
1710 elseif (params == 8) then
1711 DAB_Show_Parameters({"_Forms"}, {1}, options);
1712 elseif (params == 9) then
1713 DAB_Show_Parameters({"_Targets"}, {1}, options);
1714 elseif (params == 10) then
1715 DL_Set_Anchor("_ConditionMenu", 0, -50, nil, nil, nil, getglobal(options.."_Number"));
1716 DAB_Show_Parameters({"_Number"}, {3}, options);
1717 elseif (params == 11) then
1718 DL_Set_Anchor("_ConditionMenu", 0, -75, nil, nil, nil, getglobal(options.."_Comparison"));
1719 DL_Set_Anchor("_ConditionMenu", 0, -100, nil, nil, nil, getglobal(options.."_Number"));
1720 DAB_Show_Parameters({"_ActionID", "_Comparison", "_Number"}, {1, 1, 3}, options);
1721 elseif (params == 12) then
1722 DAB_Show_Parameters({"_Text"}, {3}, options);
1723 elseif (params == 13) then
1724 if (not DAB_CONDITION_EDITTING) then
1725 DAB_CONDITION_BUFFER.unit = "player";
1726 end
1727 DAB_Show_Parameters({"_Unit"}, {1}, options);
1728 elseif (params == 14) then
1729 if (not DAB_CONDITION_EDITTING) then
1730 DAB_CONDITION_BUFFER.unit = "player";
1731 DAB_CONDITION_BUFFER.unit2 = "player";
1732 end
1733 DAB_Show_Parameters({"_Unit", "_Unit2"}, {1, 1}, options);
1734 elseif (params == 200) then
1735 DL_Set_Anchor("_ConditionMenu", 0, -75, nil, nil, nil, getglobal(options.."_Comparison"));
1736 DL_Set_Anchor("_ConditionMenu", 0, -100, nil, nil, nil, getglobal(options.."_Number"));
1737 DAB_Show_Parameters({"_Bars", "_Comparison", "_Number"}, {1, 1, 3}, options);
1738 end
1739 end
1740  
1741 function DAB_Select_Event()
1742 DAB_MACRO_EVENT = this.value;
1743 local desc = "";
1744 for _,v in DAB_EVENTS do
1745 if (v.value == DAB_MACRO_EVENT) then
1746 desc = v.desc;
1747 break;
1748 end
1749 end
1750 DAB_OnEventMacros_Description:SetText(desc);
1751 if (DAB_Settings[DAB_INDEX].EventMacros[DAB_MACRO_EVENT]) then
1752 DAB_OnEventMacros_EditBox_Text:SetText(DAB_Settings[DAB_INDEX].EventMacros[DAB_MACRO_EVENT]);
1753 else
1754 DAB_OnEventMacros_EditBox_Text:SetText("");
1755 end
1756 end
1757  
1758 function DAB_Select_FloaterOptions(index)
1759 DAB_FloaterOptions_Config:Hide();
1760 DAB_FloaterOptions_AdvConfig:Hide();
1761 DAB_FloaterOptions_Control:Hide();
1762 DAB_ScriptOptions:Hide();
1763 if (index == 1) then
1764 DAB_FloaterOptions_Config:Show();
1765 elseif (index == 2) then
1766 DAB_FloaterOptions_AdvConfig:Show();
1767 elseif (index == 3) then
1768 DAB_FloaterOptions_Control:Show();
1769 elseif (index == 4) then
1770 DAB_ScriptOptions:Show();
1771 DAB_Update_ScriptsList();
1772 end
1773 end
1774  
1775 function DAB_Select_Response(response, menucontrol)
1776 if (not DAB_CONDITION_BUFFER) then return; end
1777 if (not menucontrol) then menucontrol = DAB_ScrollMenu.cboxbase; end
1778 local options = getglobal(menucontrol):GetParent():GetName();
1779 if (not response) then
1780 response = this.value;
1781 DAB_CONDITION_BUFFER.response = response;
1782 else
1783 response = DAB_CONDITION_BUFFER.response;
1784 DL_Init_MenuControl(getglobal(options.."_Response"), response);
1785 end
1786 DAB_Reset_Parameters(options, 1);
1787 if (response == 1) then
1788 DAB_Show_Parameters({"_Page"}, {1}, options);
1789 elseif (response == 4 or response == 5 or response == 7) then
1790 if (not DAB_CONDITION_EDITTING) then
1791 DAB_CONDITION_BUFFER.alpha = 1;
1792 DL_Init_Slider(getglobal(options.."_Alpha"), 1);
1793 end
1794 DAB_Show_Parameters({"_Alpha"}, {4}, options);
1795 elseif (response == 6 or response == 8 or response == 20 or response == 22) then
1796 if (response ~= 22 or (not DAB_BarOptions_BarControl:IsShown())) then
1797 DAB_CONDITION_BUFFER.color = {r=1, g=1, b=1};
1798 DL_Init_ColorPicker(getglobal(options.."_Color"), DAB_CONDITION_BUFFER.color);
1799 DAB_Show_Parameters({"_Color"}, {5}, options);
1800 end
1801 elseif (response == 10) then
1802 DAB_Show_Parameters({"_ResponseNumber"}, {3}, options);
1803 elseif (response == 19 or (response > 10 and response < 19)) then
1804 if (not DAB_CONDITION_EDITTING) then
1805 DAB_CONDITION_BUFFER.amount = 50;
1806 DL_Init_Slider(getglobal(options.."_Amount"), 50);
1807 end
1808 DAB_Show_Parameters({"_Amount"}, {4}, options);
1809 elseif (response == 100 or response == 101 or response == 108 or response == 109 or response == 114 or response == 115) then
1810 DAB_Show_Parameters({"_ResponseText"}, {3}, options);
1811 elseif (response == 23 or (response > 101 and response < 108)) then
1812 DAB_Show_Parameters({"_ResponseNumber"}, {3}, options);
1813 elseif (response == 29 or response == 111) then
1814 DAB_Show_Parameters({"_ResponseActionID"}, {1}, options);
1815 elseif (response == 32) then
1816 DAB_Show_Parameters({"_Page", "_Page2"}, {1, 1}, options);
1817 elseif (response == 33) then
1818 DAB_Show_Parameters({"_ResponseUnit"}, {1}, options);
1819 elseif (response == 35) then
1820 DAB_Show_Parameters({"_ResponseX", "_ResponseY"}, {3,3}, options);
1821 elseif (response == 110) then
1822 DAB_Show_Parameters({"_ResponseActionID", "_ResponseUnit"}, {1,1}, options);
1823 elseif (response == 113) then
1824 DAB_Show_Parameters({"_ResponseNumber", "_ResponseText"}, {3,3}, options);
1825 end
1826 end
1827  
1828 function DAB_Select_Script(value)
1829 if (not value) then
1830 value = this.value;
1831 end
1832 DAB_CURRENT_SCRIPT = value;
1833 local desc = "";
1834 for _,v in DAB_SCRIPTS do
1835 if (v.value == DAB_CURRENT_SCRIPT) then
1836 desc = v.desc;
1837 break;
1838 end
1839 end
1840 DAB_ScriptOptions_Description:SetText(desc);
1841 local text = DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX].Scripts[DAB_CURRENT_SCRIPT];
1842 if (text) then
1843 DAB_ScriptOptions_EditBox_Text:SetText(text);
1844 else
1845 DAB_ScriptOptions_EditBox_Text:SetText("");
1846 end
1847 end
1848  
1849 function DAB_Set_OptionsScale(override)
1850 if (override) then
1851 DAB_Settings[DAB_INDEX].optionsScale = override;
1852 else
1853 DAB_Settings[DAB_INDEX].optionsScale = this.value;
1854 end
1855 DAB_Options:SetScale(DAB_Settings[DAB_INDEX].optionsScale / 100);
1856 DAB_Options:ClearAllPoints();
1857 DAB_Options:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
1858 end
1859  
1860 function DAB_SetActionIDsMenu_Update()
1861 local numOptions = table.getn(DAB_ACTIONIDS_LIST);
1862 local offset = FauxScrollFrame_GetOffset(DAB_SetActionIDs_ScrollMenu);
1863 if (not offset) then offset = 0; end
1864 local index, button, buttontext, menucontrol;
1865  
1866 for i=1, 19 do
1867 button = getglobal("DAB_SetActionIDs_ScrollMenu_Button"..i);
1868 buttontext = getglobal("DAB_SetActionIDs_ScrollMenu_Button"..i.."_Text");
1869 menucontrol = getglobal("DAB_SetActionIDs_ScrollMenu_Button"..i.."_ActionMenu");
1870 index = offset + i;
1871 if ( DAB_ACTIONIDS_LIST[index] ) then
1872 button:Show();
1873 menucontrol.subindex = DAB_ACTIONIDS_LIST[index].bar;
1874 if (DAB_ACTIONIDS_LIST[index].bar == "F") then
1875 buttontext:SetText("Floater "..DAB_ACTIONIDS_LIST[index].button);
1876 menucontrol.subindex2 = DAB_ACTIONIDS_LIST[index].button;
1877 else
1878 buttontext:SetText("Bar "..DAB_ACTIONIDS_LIST[index].bar..", Page "..DAB_ACTIONIDS_LIST[index].page..", Button "..DAB_ACTIONIDS_LIST[index].button);
1879 menucontrol.subindex2 = index;
1880 end
1881 DL_Init_MenuControl(menucontrol, DAB_ACTIONIDS_LIST[index].action);
1882 else
1883 button:Hide();
1884 end
1885 end
1886  
1887 FauxScrollFrame_Update(DAB_SetActionIDs_ScrollMenu, numOptions, 19, 25 );
1888 DAB_SetActionIDs_ScrollMenu:Show();
1889 end
1890  
1891 function DAB_SetBinding(key, selectedBinding, oldKey)
1892 if ( SetBinding(key, selectedBinding) ) then
1893 return;
1894 else
1895 if ( oldKey ) then
1896 SetBinding(oldKey, selectedBinding);
1897 end
1898 DL_Error("Can't bind mousewheel to actions with up and down states");
1899 end
1900 end
1901  
1902 function DAB_Show_Parameters(parameters, types, base)
1903 for i, param in parameters do
1904 local frame = getglobal(base..param);
1905 frame:Show();
1906 if (DAB_CONDITION_EDITTING) then
1907 if (types[i] == 1) then
1908 DL_Init_MenuControl(frame, DAB_CONDITION_BUFFER[frame.subindex]);
1909 elseif (types[i] == 2) then
1910 DL_Init_CheckBox(frame, DAB_CONDITION_BUFFER[frame.subindex]);
1911 elseif (types[i] == 3) then
1912 DL_Init_EditBox(frame, DAB_CONDITION_BUFFER[frame.subindex]);
1913 elseif (types[i] == 4) then
1914 if (not DAB_CONDITION_BUFFER[frame.subindex]) then
1915 local min, max = frame:GetMinMaxValues();
1916 if (frame.scale) then
1917 max = max / frame.scale;
1918 end
1919 DAB_CONDITION_BUFFER[frame.subindex] = max;
1920 end
1921 DL_Init_Slider(frame, DAB_CONDITION_BUFFER[frame.subindex]);
1922 elseif (types[i] == 5) then
1923 if (not DAB_CONDITION_BUFFER[frame.subindex]) then
1924 DAB_CONDITION_BUFFER[frame.subindex] = {r=1, g=1, b=1};
1925 end
1926 DL_Init_ColorPicker(frame, DAB_CONDITION_BUFFER[frame.subindex]);
1927 end
1928 elseif (param == "_Unit" or param == "_Unit2") then
1929 DL_Init_MenuControl(frame, "player");
1930 end
1931 end
1932 end
1933  
1934 function DAB_Show_Window(index)
1935 DAB_HideAllOptions();
1936  
1937 DAB_OBJECT_INDEX = index;
1938 if (index < 12) then
1939 DAB_OBJECT_TYPE = "Bar";
1940 elseif (index > 12 and index < 17) then
1941 DAB_OBJECT_TYPE = "OtherBar";
1942 elseif (index < 28) then
1943 DAB_OBJECT_TYPE = "ControlBox";
1944 else
1945 DAB_OBJECT_TYPE = "Floaters";
1946 end
1947 DAB_OBJECT_SUBINDEX = DAB_BAR_LIST[index].value;
1948  
1949 if (DAB_OBJECT_TYPE == "Bar") then
1950 DAB_BarOptions:Show();
1951 DAB_Init_BarOptions();
1952 if (DAB_BAR_OPTIONS == "DAB_BarOptions_ScriptsTab") then
1953 DAB_ScriptOptions:Show();
1954 DAB_Update_ScriptsList();
1955 end
1956 elseif (DAB_OBJECT_TYPE == "Floaters") then
1957 DAB_FloaterOptions:Show();
1958 DAB_Init_FloaterOptions();
1959 if (DAB_FLOATER_OPTIONS == "DAB_FloaterOptions_ScriptsTab") then
1960 DAB_ScriptOptions:Show();
1961 DAB_Update_ScriptsList();
1962 end
1963 elseif (DAB_OBJECT_TYPE == "ControlBox") then
1964 DAB_CBoxOptions:Show();
1965 DAB_Init_ControlBoxOptions();
1966 if (DAB_CBOX_OPTIONS == "DAB_CBoxOptions_ScriptsTab") then
1967 DAB_ScriptOptions:Show();
1968 DAB_Update_ScriptsList();
1969 end
1970 elseif (DAB_OBJECT_TYPE == "OtherBar") then
1971 DAB_OtherBarOptions:Show();
1972 DAB_Init_OtherBarOptions();
1973 end
1974 end
1975  
1976 function DAB_Slider_Update()
1977 if (not DAB_INITIALIZED) then return; end
1978 if (not this.minmaxset) then return; end
1979 local setting = DAB_Get_Setting(this.index, this.subindex);
1980 if (this.scale) then
1981 setting = setting * this.scale;
1982 end
1983 if (setting == this:GetValue()) then return; end
1984 local min, max = this:GetMinMaxValues();
1985 if (setting < min or setting > max) then
1986 return;
1987 end
1988 local value = this:GetValue();
1989 getglobal(this:GetName().."_Display"):SetText(value);
1990 if (this.scale) then
1991 value = value / this.scale;
1992 end
1993 DAB_Update_Setting(this.settingType, value, this.index, this.subindex, this.subindex2);
1994 end
1995  
1996 function DAB_Slider_UpdateFromEditBox()
1997 local value = this:GetNumber();
1998 if (not value) then value = 0; end
1999 local min, max = this:GetParent():GetMinMaxValues();
2000 if (this:GetParent().minlocked and value < min) then value = min; end
2001 if (this:GetParent().maxlocked and value > max) then value = max; end
2002 this:SetText(value);
2003 if (value >= min and value <= max) then
2004 this:GetParent():SetValue(value);
2005 end
2006 this:ClearFocus();
2007 if (this:GetParent().scale) then
2008 value = value / this:GetParent().scale;
2009 end
2010 DAB_Update_Setting(this:GetParent().settingType, value, this:GetParent().index, this:GetParent().subindex);
2011 end
2012  
2013 function DAB_TextureEditBox_OnEnterPressed()
2014 DAB_MenuEditBox_OnEnterPressed();
2015 DAB_Update_TextureList();
2016 end
2017  
2018 function DAB_UnitEditBox_OnEnterPressed()
2019 DAB_MenuEditBox_OnEnterPressed();
2020 DAB_Update_UnitList();
2021 end
2022  
2023 function DAB_Update_ActionIDsList()
2024 DAB_ACTIONIDS_LIST = {};
2025 local index = 0;
2026 if (DAB_ACTIONIDS_FILTER1 ~= 2) then
2027 for bar = 1, DAB_NUM_BARS do
2028 if (DAB_ACTIONIDS_FILTER1 == 1 or bar == DAB_ACTIONIDS_FILTER1 - 2) then
2029 for page = 1, DAB_Settings[DAB_INDEX].Bar[bar].numBars do
2030 if (DAB_ACTIONIDS_FILTER2 == 1 or page == DAB_ACTIONIDS_FILTER2 - 1) then
2031 for button = 1, DAB_Settings[DAB_INDEX].Bar[bar].numButtons do
2032 index = index + 1;
2033 DAB_ACTIONIDS_LIST[index] = {bar = bar, page = page, button = button, action = DAB_Settings[DAB_INDEX].Bar[bar].pages[page][button]};
2034 end
2035 end
2036 end
2037 end
2038 end
2039 end
2040 if (DAB_ACTIONIDS_FILTER1 < 3) then
2041 for i=1,DAB_NUM_BUTTONS do
2042 if (DAB_Settings[DAB_INDEX].Floaters[i]) then
2043 index = index + 1;
2044 DAB_ACTIONIDS_LIST[index] = {bar = "F", button = i, action = DAB_Settings[DAB_INDEX].Buttons[i].action};
2045 end
2046 end
2047 end
2048 DAB_SetActionIDsMenu_Update();
2049 end
2050  
2051 function DAB_Update_ScriptsList()
2052 for index, val in DAB_SCRIPTS do
2053 if (DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX].Scripts[val.value] and DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX].Scripts[val.value] ~= "") then
2054 if (string.sub(DAB_SCRIPTS[index].text, -2) ~= " *") then
2055 DAB_SCRIPTS[index].text = DAB_SCRIPTS[index].text.." *";
2056 end
2057 elseif (string.sub(DAB_SCRIPTS[index].text, -2) == " *") then
2058 DAB_SCRIPTS[index].text = string.sub(DAB_SCRIPTS[index].text, 1, -2);
2059 end
2060 end
2061 end
2062  
2063 function DAB_Update_Setting(settingType, value, index, subindex, subindex2, override)
2064 if (subindex == "font") then
2065 if (not string.find(value, "\\")) then
2066 value = DAB_Settings[DAB_INDEX].defaultFont..value;
2067 end
2068 end
2069 if ((index and string.find(index, "texture")) or (subindex and string.find(subindex, "texture"))) then
2070 if (not string.find(value, "\\")) then
2071 value = DAB_Settings[DAB_INDEX].defaultTexture..value;
2072 end
2073 end
2074 if (index == "Misc") then
2075 if (subindex == "UpdateSpeed") then
2076 DAB_Settings[DAB_INDEX].UpdateSpeed = value;
2077 DAB_UPDATE_SPEED = 1 / DAB_Settings[DAB_INDEX].UpdateSpeed;
2078 else
2079 DAB_Settings[DAB_INDEX][subindex] = value;
2080 if (subindex2) then
2081 subindex2();
2082 end
2083 end
2084 return;
2085 elseif (index == "SETACTIONID") then
2086 if (subindex == "F") then
2087 DAB_Settings[DAB_INDEX].Buttons[subindex2].action = value;
2088 DAB_ActionButton_Update(subindex2);
2089 DAB_Update_FloaterList();
2090 DAB_Update_ObjectList();
2091 DAB_BarBrowser_Update();
2092 else
2093 DAB_Settings[DAB_INDEX].Bar[subindex].pages[DAB_ACTIONIDS_LIST[subindex2].page][DAB_ACTIONIDS_LIST[subindex2].button] = value;
2094 DAB_Bar_SetPage(subindex, DAB_ACTIONIDS_LIST[subindex2].page, 1);
2095 end
2096 DAB_Update_ActionIDsList();
2097 DAB_SetActionIDsMenu_Update();
2098 return;
2099 elseif (index == "CONDITION") then
2100 DAB_CONDITION_BUFFER[subindex] = value;
2101 elseif (index == "MainMenuBar") then
2102 DAB_Settings[DAB_INDEX].MainMenuBar[subindex] = value;
2103 DAB_Update_MainMenuBar();
2104 return;
2105 elseif (index == "KEYBINDING") then
2106 local kbindex;
2107 if (subindex2 == "CheckBox") then
2108 kbindex = this:GetParent().index;
2109 elseif (subindex2 == "DropMenu") then
2110 local cbox = string.gsub(DAB_DropMenu.controlbox, "_Setting", "");
2111 kbindex = getglobal(cbox):GetParent().index;
2112 else
2113 local cbox = string.gsub(DAB_ScrollMenu.controlbox, "_Setting", "");
2114 kbindex = getglobal(cbox):GetParent().index;
2115 end
2116 DAB_Settings[DAB_INDEX].Keybindings[kbindex][subindex] = value;
2117 if (subindex2 == "DropMenu") then
2118 if (value == 12) then
2119 DAB_Settings[DAB_INDEX].Keybindings[kbindex].suboption = "1_1";
2120 DAB_Settings[DAB_INDEX].Keybindings[kbindex].suboption2 = 1;
2121 else
2122 DAB_Settings[DAB_INDEX].Keybindings[kbindex].suboption = 1;
2123 DAB_Settings[DAB_INDEX].Keybindings[kbindex].suboption2 = 1;
2124 end
2125 end
2126 DAB_KeybindingBrowser_Update();
2127 DAB_Update_Keybindings();
2128 return;
2129 else
2130 if (subindex2) then
2131 DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index][subindex][subindex2] = value;
2132 elseif (subindex) then
2133 DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index][subindex] = value;
2134 else
2135 DAB_Settings[DAB_INDEX][DAB_OBJECT_TYPE][DAB_OBJECT_SUBINDEX][index] = value;
2136 end
2137 end
2138 if ((not override) and settingType ~= 0) then
2139 local func;
2140 if (DAB_OBJECT_TYPE == "Bar") then
2141 func = "DAB_Bar_";
2142 elseif (DAB_OBJECT_TYPE == "Floaters") then
2143 func = "DAB_Floater_";
2144 elseif (DAB_OBJECT_TYPE == "ControlBox") then
2145 func = "DAB_ControlBox_";
2146 settingType = nil;
2147 elseif (DAB_OBJECT_TYPE == "OtherBar") then
2148 func = "DAB_OtherBar_";
2149 settingType = nil;
2150 end
2151 if (not settingType) then
2152 settingType = "Initialize";
2153 end
2154 getglobal(func..settingType)(DAB_OBJECT_SUBINDEX);
2155 end
2156 if (index == "Label" and subindex == "text") then
2157 DAB_Update_ObjectList();
2158 DAB_BarBrowser_Update();
2159 end
2160 end