vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Title: LoadIT Menu
2 -- Author: Saur of Emerald Dream (EU)
3 -- Original author: Ru of Frostmane
4 --
5 -- This is a simple mod to provide a GUI for LoadIT
6 --
7 -- * Making a Custom GUI
8 -- *
9 -- * to make a custom GUI for LoadIT, set LoadITmenu to 1 in your mod. This will enable
10 -- * support for the external UI from within LoadIT and offer the '/mods menu' command.
11 -- * Name the Frame for the menu, LoadITmenuFrame, and define the following function in your GUI to
12 -- * receive status updates from LoadIT:
13 -- *
14 -- * function LoadIT_UpdateMenu(func, param)
15 -- *
16 -- * func = function being performed (see code in LoadIT)
17 -- * param = parameter for function (see code in LoadIT)
18 -- *
19 -- * Be sure to declare LoadIT as a dependency in your .toc, so you can overwrite the value of
20 -- * LoadITmenu, by forcing your mod to load after LoadIT
21 -- *
22 LoadITmenu = 1;
23  
24 local LO_RED = '|cffff0000';
25 local LO_GREEN = '|cff00ff00';
26 local LO_BLUE = '|cff0000ff';
27 local LO_MAGENTA = '|cffff00ff';
28 local LO_YELLOW = '|cffffff00';
29 local LO_CYAN = '|cff00ffff';
30 local LO_WHITE = '|cffffffff';
31 local LO_GREY = '|ccccccccc';
32 local LO_GREY_HI = '|ceeeeeeee';
33 local LO_BLUE_LOW = '|cff5e9ae4';
34 local LO_BEIGE = '|cffffffa0';
35  
36 LOADIT_TAB_1 = 'Live';
37 LOADIT_TAB_2 = 'Profile';
38 LOADIT_TAB_3 = 'Options';
39 LOADIT_TAB_4 = 'Edit';
40 LOADIT_TAB_5 = 'Help';
41  
42 LOADIT_NUM_TABS = 5;
43  
44 LOADIT_SCROLL_LINES = 17; -- number of lines to display in scrollbar
45 LOADIT_SCROLL_HEIGHT = 17; -- height of each scrollbar line
46  
47 local LoadITList = {};
48 local LoadITProfiles = {};
49 local LoadITEditList = {};
50 DDProfileList = {};
51  
52 LoadITglo = {};
53  
54 LOADITOPT_VERSION = LOADIT_VERSION .. ' by Saur (originally by Ru)';
55  
56 BINDING_NAME_LOADITMENU = "Toggle Menu";
57 BINDING_HEADER_LOADITMENU = "LoadIT Menu";
58  
59 LOADIT_SELECT_PROFILE = '(Select a profile to edit on the Profile tab)';
60 LOADIT_SELECTED_PROFILE = 'EDIT Profile: ';
61  
62 -- * LoadIT_UpdateMenu()
63 -- * This function is called by LoadIT to notify the GUI of any changes
64 --
65 function LoadIT_UpdateMenu(func, param, norefresh)
66 -- * other valid func values = loadprofile
67  
68 -- * if module states change
69 if ((func == "disable") or (func == "enable") or (func == "load") or (func == "defaults")) then
70 local count = GetNumAddOns();
71 LoadITList = {};
72 if (count) then
73 local i = 1;
74 while (i <= count) do
75 local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(i);
76 local loaded = IsAddOnLoaded(i);
77 local loadondemand = IsAddOnLoadOnDemand(i);
78  
79 if (not title) then title = name; end
80 if (not enabled) then enabled = 0; end
81 if (not loaded) then loaded = 0; end
82 if (not loadondemand) then loadondemand = 0; end
83  
84 table.insert(LoadITList, { name=name, title=title, enabled=enabled, loaded=loaded, LoD=loadondemand });
85 i = i + 1;
86 end
87 end
88 if (not norefresh) then
89 LoadITLive_UpdateButtonData();
90 FauxScrollFrame_Update(LoadITLiveScrollFrame,table.getn(LoadITList),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
91 end
92 end
93  
94 -- * if profile states change
95 if ((func == "saveprofile") or (func == "deleteprofile") or (func == "defaults")) then
96 local key,s;
97 local count = 0;
98 local tmplist;
99 LoadITProfiles = {};
100  
101 local sel = UIDropDownMenu_GetSelectedID(DDProfiles);
102 if ((sel > 1) and (sel <= table.getn(DDProfileList))) then
103 tmplist = LoadITcf.Classes[DDProfileList[sel]];
104 else
105 tmplist = LoadITcf.Sets;
106 end
107  
108 for key,_ in tmplist do
109 table.insert(LoadITProfiles, { name=key });
110 end
111 table.sort(LoadITProfiles, function (a1, a2) return (string.lower(a1.name) < string.lower(a2.name)); end);
112 LoadITLiveFrame.SelectedIndex = nil;
113 LoadITLiveFrame.SelectedName = nil;
114 LoadITProfileFrame.SelectedIndex = nil;
115 LoadITProfileFrame.SelectedName = nil;
116 if (not norefresh) then
117 LoadITProfile_UpdateButtonData();
118 FauxScrollFrame_Update(LoadITProfileScrollFrame,table.getn(LoadITProfiles),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
119 end
120 LoadITEdit_Reset();
121 LoadITEdit_OnUpdate();
122 end
123  
124 -- * if default settings were restored
125 if (func == "defaults") then
126 LoadIT_ResetMenu();
127 end
128 end
129  
130 function LoadITopt_OnLoad()
131 this:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 0.4);
132 this:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 0.8);
133  
134 tinsert(UISpecialFrames,"LoadITmenuFrame");
135  
136 PanelTemplates_SetNumTabs(LoadITmenuFrame, LOADIT_NUM_TABS);
137 PanelTemplates_SetTab(LoadITmenuFrame, 1);
138 PanelTemplates_DisableTab(LoadITmenuFrame, 5);
139 end
140  
141 function LoadITopt_OnShow()
142 LoadITLive_OnUpdate();
143 LoadITProfile_OnUpdate();
144 PlaySound("igCharacterInfoOpen");
145 end
146  
147 function LoadITopt_OnHide()
148 LoadITEdit_Reset();
149 LoadITEdit_OnUpdate();
150 LoadITProfile_UpdateButtonData();
151 PlaySound("igCharacterInfoClose");
152 end
153  
154 function LoadIToptTab_OnClick(id)
155 PanelTemplates_Tab_OnClick(LoadITmenuFrame);
156 PanelTemplates_SetTab(LoadITmenuFrame, id);
157 if (id == 1) then
158 LoadITLiveFrame:Show();
159 LoadITProfileFrame:Hide();
160 LoadITOptionsFrame:Hide();
161 LoadITEditFrame:Hide();
162 FauxScrollFrame_Update(LoadITLiveScrollFrame,table.getn(LoadITList),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
163 elseif (id == 2) then
164 LoadITLiveFrame:Hide();
165 LoadITProfileFrame:Show();
166 LoadITOptionsFrame:Hide();
167 LoadITEditFrame:Hide();
168 FauxScrollFrame_Update(LoadITProfileScrollFrame,table.getn(LoadITProfiles),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
169 elseif (id == 3) then
170 LoadITLiveFrame:Hide();
171 LoadITProfileFrame:Hide();
172 LoadITOptionsFrame:Show();
173 LoadITEditFrame:Hide();
174 elseif (id == 4) then
175 LoadITLiveFrame:Hide();
176 LoadITProfileFrame:Hide();
177 LoadITOptionsFrame:Hide();
178 LoadITEditFrame:Show();
179 FauxScrollFrame_Update(LoadITEditScrollFrame,table.getn(LoadITEditList),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
180 end
181  
182 -- for i = 1, LOADIT_NUM_TABS do
183 -- if (i == 1) then
184 -- getglobal(LOADIT_FRAMES[i]):Show();
185 -- else
186 -- getglobal(LOADIT_FRAMES[i]):Hide();
187 -- end
188 -- end
189  
190 PlaySound("igCharacterInfoTab");
191 end
192  
193 function LoadITopt_OnMouseDown(arg1)
194 if (LoadITcf.LockMenu) then return; end
195 if (arg1 == "LeftButton") then
196 LoadITmenuFrame:StartMoving();
197 end
198 end
199  
200 function LoadITopt_OnMouseUp(arg1)
201 if (LoadITcf.LockMenu) then return; end
202 if (arg1 == "LeftButton") then
203 LoadITmenuFrame:StopMovingOrSizing();
204 end
205 end
206  
207 function LoadITopt_ProfileLoad(id)
208 local tmp = nil;
209 local itemIndex = id + FauxScrollFrame_GetOffset(LoadITProfileScrollFrame);
210  
211 local sel = UIDropDownMenu_GetSelectedID(DDProfiles);
212 if ((sel > 1) and (sel <= table.getn(DDProfileList))) then
213 tmp = 'class';
214 end
215 LoadIT_LoadProfile(LoadITProfiles[itemIndex].name, tmp);
216 end
217  
218 function LoadITopt_ProfileRemove(id)
219 local tmp = nil;
220 local itemIndex = id + FauxScrollFrame_GetOffset(LoadITProfileScrollFrame);
221  
222 local sel = UIDropDownMenu_GetSelectedID(DDProfiles);
223 if ((sel > 1) and (sel <= table.getn(DDProfileList))) then
224 tmp = 'class';
225 end
226 LoadIT_DeleteProfile(LoadITProfiles[itemIndex].name, tmp);
227 end
228  
229 function LoadITEdit_Remove(id)
230 local index = id + FauxScrollFrame_GetOffset(LoadITEditScrollFrame);
231 table.remove(LoadITEditList, index);
232 LoadITEdit_UpdateButtonData();
233 end
234  
235 function LoadITLiveButton_OnClick()
236 local i = this:GetID();
237 local index = i + FauxScrollFrame_GetOffset(LoadITLiveScrollFrame);
238 LoadITLiveFrame.SelectedIndex = index;
239 LoadITLiveFrame.SelectedName = getglobal("LoadITLiveButton" .. i .."Name"):GetText();
240 LoadITLive_UpdateButtonData();
241 end
242  
243 function LoadITProfileButton_OnClick()
244 local i = this:GetID();
245 local index = i + FauxScrollFrame_GetOffset(LoadITProfileScrollFrame);
246  
247 -- * toggle highlighted selection since we clicked on it
248 if (LoadITProfileFrame.SelectedIndex and (LoadITProfileFrame.SelectedIndex == index)) then
249 LoadITEdit_Reset();
250 else
251 LoadITProfileFrame.SelectedIndex = index;
252 LoadITProfileFrame.SelectedName = getglobal("LoadITProfileButton" .. i .."Name"):GetText();
253 LoadITEdit_GetList();
254 end
255 LoadITProfile_UpdateButtonData();
256 LoadITEdit_OnUpdate();
257 end
258  
259 function LoadITEdit_Reset()
260 LoadITProfileFrame.SelectedIndex = nil;
261 LoadITProfileFrame.SelectedName = nil;
262 LoadITEditFrame.SelectedIndex = nil;
263 LoadITEditFrame.SelectedName = nil;
264 EditProfileName:SetText('');
265 EditProfileName:Hide();
266 LoadITEditList = {};
267 LoadITEditProfileNotSelectedText:SetText(LOADIT_SELECT_PROFILE);
268  
269 -- * hide buttons
270 LoadITEditSaveButton:Hide();
271 LoadITEditUndoButton:Hide();
272 LoadITEditCheckAllButton:Hide();
273 LoadITEditUnCheckAllButton:Hide();
274 LoadITEditInfoButton:Hide();
275 end
276  
277 function LoadITEditButton_OnClick()
278 local i = this:GetID();
279 local index = i + FauxScrollFrame_GetOffset(LoadITEditScrollFrame);
280  
281 -- * toggle highlighted selection since we clicked on it
282 if (LoadITEditFrame.SelectedIndex and (LoadITEditFrame.SelectedIndex == index)) then
283 LoadITEditFrame.SelectedIndex = nil;
284 LoadITEditFrame.SelectedName = nil;
285 else
286 LoadITEditFrame.SelectedIndex = index;
287 LoadITEditFrame.SelectedName = LoadITEditList[index].name;
288 end
289 LoadITEdit_UpdateButtonData();
290 end
291  
292 function LoadITLive_SetSelection(id, checked)
293 local index = id + FauxScrollFrame_GetOffset(LoadITLiveScrollFrame);
294 LoadITopt_SetCheck(id, checked);
295 if (id <= table.getn(LoadITList)) then
296 LoadITList[index].enabled = checked;
297 LoadITLiveFrame.SelectedIndex = index;
298 LoadITLiveFrame.SelectedName = getglobal("LoadITLiveButton" .. id .. "Name"):GetText();
299 LoadITProfile_UpdateButtonData();
300 end
301 end
302  
303 function LoadITEdit_SetCheck(id, checked)
304 local index = id + FauxScrollFrame_GetOffset(LoadITEditScrollFrame);
305 if (id <= table.getn(LoadITEditList)) then
306 LoadITEditList[index].enabled = checked;
307 end
308 LoadITEditFrame.SelectedIndex = index;
309 LoadITEditFrame.SelectedName = getglobal("LoadITEditButton" .. id .. "Name"):GetText();
310 LoadITEdit_UpdateButtonData();
311 end
312  
313 function LoadITLive_OnUpdate()
314 LoadIT_UpdateMenu("load", 0, 1);
315 LoadITLive_UpdateButtonData();
316 FauxScrollFrame_Update(LoadITLiveScrollFrame,table.getn(LoadITList),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
317 end
318  
319 function LoadITProfile_OnUpdate()
320 LoadIT_UpdateMenu("saveprofile", 0, 1);
321 LoadITProfile_UpdateButtonData();
322 FauxScrollFrame_Update(LoadITProfileScrollFrame,table.getn(LoadITProfiles),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
323 end
324  
325 function LoadITEdit_OnUpdate()
326 LoadITEdit_UpdateButtonData();
327 FauxScrollFrame_Update(LoadITEditScrollFrame,table.getn(LoadITEditList),LOADIT_SCROLL_LINES,LOADIT_SCROLL_HEIGHT);
328 end
329  
330 function LoadITEdit_Undo()
331 LoadITEdit_GetList();
332 LoadITEdit_OnUpdate();
333 end
334  
335 function LoadITEdit_Save()
336 local tmplist = {};
337 local p = LoadITProfileFrame.SelectedName;
338 local sel = UIDropDownMenu_GetSelectedID(DDProfiles);
339  
340 local i;
341 for i = 1, table.getn(LoadITEditList) do
342 local tmp = LoadITEditList[i].enabled;
343 if (tmp) then
344 tmplist[LoadITEditList[i].name] = 1;
345 else
346 tmplist[LoadITEditList[i].name] = 0;
347 end
348 end
349  
350 if ((sel > 1) and (sel <= table.getn(DDProfileList))) then
351 local class = DDProfileList[sel];
352 if (LoadITcf.Classes[class][p]) then
353 LoadITcf.Classes[class][p].Modules = tmplist;
354 LoadIT_Print(LO_YELLOW .. 'Changes saved to ' .. class .. ' Profile: ' .. LO_CYAN .. p);
355 end
356 else
357 if (LoadITcf.Sets[p]) then
358 LoadITcf.Sets[p].Modules = tmplist;
359 LoadIT_Print(LO_YELLOW .. 'Changes saved to Profile: ' .. LO_CYAN .. p);
360 end
361 end
362 end
363  
364 function LoadITEdit_GetList()
365 LoadITEditList = {};
366 local tmplist = {};
367 local p = LoadITProfileFrame.SelectedName;
368 local sel = UIDropDownMenu_GetSelectedID(DDProfiles);
369 local class = DDProfileList[sel];
370 if ((sel > 1) and (sel <= table.getn(DDProfileList))) then
371 if (LoadITcf.Classes[class][p]) then
372 tmplist = LoadITcf.Classes[class][p].Modules;
373 end
374 else
375 if (LoadITcf.Sets[p]) then
376 tmplist = LoadITcf.Sets[p].Modules;
377 end
378 end
379 local key, enabled;
380 for key,enabled in tmplist do
381 local name, title, notes, _, _, _, _ = GetAddOnInfo(key);
382 local error = 0;
383 if (not title) then
384 name = key;
385 error = 1;
386 end
387 if (not title) then title = name; end
388 if (not notes) then notes = ''; end
389 if (enabled == 0) then enabled = nil; end
390 table.insert(LoadITEditList, { name=key, enabled=enabled, title=title, notes=notes, error=error });
391 end
392 table.sort(LoadITEditList, function (a1, a2) return (string.lower(a1.title) < string.lower(a2.title)); end);
393 LoadITEditProfileNotSelectedText:SetText('');
394 EditProfileName:SetText(LOADIT_SELECTED_PROFILE .. LoadITProfileFrame.SelectedName);
395 EditProfileName:Show();
396  
397 -- * show buttons
398 LoadITEditSaveButton:Show();
399 LoadITEditUndoButton:Show();
400 LoadITEditCheckAllButton:Show();
401 LoadITEditUnCheckAllButton:Show();
402 LoadITEditInfoButton:Show();
403 end
404  
405 function LoadITLive_UpdateButtonData()
406 local i;
407 local index;
408  
409 for i = 1, LOADIT_SCROLL_LINES do
410 index = i + FauxScrollFrame_GetOffset(LoadITLiveScrollFrame);
411 if (index <= table.getn(LoadITList)) then
412 if (LoadITList[index].loaded == 1) then
413 getglobal("LoadITLiveButton" .. i .. "Name"):SetVertexColor(1.0, 0.82, 0.0);
414 else
415 getglobal("LoadITLiveButton" .. i .. "Name"):SetVertexColor(0.5, 0.5, 0.5);
416 end
417 getglobal("LoadITLiveButton" .. i .. "Name"):SetText(LoadITList[index].title);
418  
419 -- * load on demand
420 if (LoadITList[index].LoD == 1) then
421 getglobal("LoadITLiveButton" .. i .. "LoD"):SetText(LO_CYAN .. 'LD');
422 else
423 getglobal("LoadITLiveButton" .. i .. "LoD"):SetText('');
424 end
425  
426 getglobal("LoadITLiveButton".. i .."Enabled"):SetChecked(LoadITList[index].enabled);
427 getglobal("LoadITLiveButton" .. i):Show();
428 if ( LoadITLiveFrame.SelectedIndex == index ) then
429 getglobal("LoadITLiveButton" .. i):LockHighlight();
430 else
431 getglobal("LoadITLiveButton" .. i):UnlockHighlight();
432 end
433 else
434 getglobal("LoadITLiveButton" .. i .. "Name"):SetText('');
435 getglobal("LoadITLiveButton" .. i .. "LoD"):SetText('');
436 getglobal("LoadITLiveButton" .. i):Hide();
437 getglobal("LoadITLiveButton" .. i):UnlockHighlight();
438 end
439 end
440 end
441  
442 function LoadITEdit_UpdateButtonData()
443 local i;
444 local index;
445  
446 for i = 1, LOADIT_SCROLL_LINES do
447 index = i + FauxScrollFrame_GetOffset(LoadITEditScrollFrame);
448 if (index <= table.getn(LoadITEditList)) then
449 if (LoadITEditList[index].error == 0) then
450 getglobal("LoadITEditButton" .. i .. "Name"):SetVertexColor(1.0, 0.82, 0.0);
451 else
452 getglobal("LoadITEditButton" .. i .. "Name"):SetVertexColor(1.0, 0.0, 0.0);
453 end
454 getglobal("LoadITEditButton" .. i .. "Name"):SetText(LoadITEditList[index].title);
455  
456 getglobal("LoadITEditButton".. i .."Enabled"):SetChecked(LoadITEditList[index].enabled);
457 getglobal("LoadITEditButton" .. i):Show();
458 if ( LoadITEditFrame.SelectedIndex == index ) then
459 getglobal("LoadITEditButton" .. i):LockHighlight();
460 else
461 getglobal("LoadITEditButton" .. i):UnlockHighlight();
462 end
463 else
464 getglobal("LoadITEditButton" .. i .. "Name"):SetText('');
465 getglobal("LoadITEditButton" .. i):Hide();
466 getglobal("LoadITEditButton" .. i):UnlockHighlight();
467 end
468 end
469 end
470  
471 -- * LoadITLive_ToggleAll(arg )
472 -- * Toggles enabled/disabled state for all modules
473 --
474 -- * arg - value to set all states to
475 --
476 function LoadITLive_ToggleAll(arg)
477 local i;
478 for i = 1, table.getn(LoadITList) do
479 if (arg == 1) then
480 LoadITList[i].enabled = 1;
481 LoadIT_Enable(LoadITList[i].name, LoadITcf.Verbose, 1);
482 else
483 LoadITList[i].enabled = 0;
484 LoadIT_Disable(LoadITList[i].name, LoadITcf.Verbose, 1);
485 end
486 if (i <= LOADIT_SCROLL_LINES) then
487 getglobal("LoadITLiveButton" .. i .. "Enabled"):SetChecked(LoadITList[i].enabled);
488 end
489 end
490 end
491  
492 function LoadITEdit_ToggleAll(arg)
493 local i;
494 for i = 1, table.getn(LoadITEditList) do
495 if (arg == 1) then
496 LoadITEditList[i].enabled = 1;
497 else
498 LoadITEditList[i].enabled = nil;
499 end
500 if (i <= LOADIT_SCROLL_LINES) then
501 getglobal("LoadITEditButton" .. i .. "Enabled"):SetChecked(LoadITEditList[i].enabled);
502 end
503 end
504 end
505  
506 function LoadITProfile_UpdateButtonData()
507 local i;
508 local index;
509  
510 for i = 1, LOADIT_SCROLL_LINES do
511 index = i + FauxScrollFrame_GetOffset(LoadITProfileScrollFrame);
512 if (index <= table.getn(LoadITProfiles)) then
513 getglobal("LoadITProfileButton" .. i .. "Name"):SetText(LoadITProfiles[index].name);
514 getglobal("LoadITProfileButton" .. i .. "Name"):SetVertexColor(1.0, 0.82, 0.0);
515 getglobal("LoadITProfileButton" .. i):Show();
516 if ( LoadITProfileFrame.SelectedIndex == index ) then
517 getglobal("LoadITProfileButton" .. i):LockHighlight();
518 else
519 getglobal("LoadITProfileButton" .. i):UnlockHighlight();
520 end
521 else
522 getglobal("LoadITProfileButton" .. i .. "Name"):SetText('');
523 getglobal("LoadITProfileButton" .. i):Hide();
524 getglobal("LoadITProfileButton" .. i):UnlockHighlight();
525 end
526 end
527 end
528  
529 function LoadITopt_SetCheck(id, checked)
530 local index = id + FauxScrollFrame_GetOffset(LoadITLiveScrollFrame);
531 if (checked) then
532 LoadIT_Enable(LoadITList[index].name);
533 else
534 LoadIT_Disable(LoadITList[index].name);
535 end
536 end
537  
538 function LoadIT_FindAddonIndex(name)
539 local i;
540 for i = 1, table.getn(LoadITList) do
541 if (LoadITList[i].name == name) then
542 return i;
543 end
544 end
545 end
546  
547 function LoadIT_AddonTooltip(idx)
548 local s;
549 local txt = LO_YELLOW;
550 local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(LoadITList[idx].name);
551 local loaded = IsAddOnLoaded(LoadITList[idx].name);
552 if (title) then
553 txt = txt .. title .. "|r\n";
554 else
555 txt = txt .. name .. "|r\n";
556 end
557  
558 local tmp = "";
559 if (notes) then
560 for s in string.gfind(notes, "%a+") do
561 if (string.len(tmp) > 30) then
562 txt = txt .. s .. "\n";
563 tmp = '';
564 else
565 txt = txt .. s .. ' ';
566 tmp = tmp .. s .. ' ';
567 end
568 end
569 end
570 if (string.byte(txt, string.len(txt)) ~= string.byte("\n", 1)) then
571 txt = txt .. "\n";
572 end
573 GameTooltip:SetText(txt .. "\n", 0.5, 0.5, 0.5);
574  
575 if (enabled) then enabled = LO_GREEN .. "Yes"; else enabled = LO_RED .. "No"; end
576 if (loadable) then loadable = LO_GREEN .. "Yes"; else loadable = LO_RED .. "No"; end
577 if (loaded) then loaded = LO_GREEN .. "Yes"; else loaded = LO_RED .. "No"; end
578  
579 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. 'Security:', security);
580 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. 'Loadable:', loadable);
581 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. 'Loaded:', loaded);
582 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. 'Enabled:', enabled);
583  
584 local loadondemand = IsAddOnLoadOnDemand(LoadITList[idx].name);
585 if (loadondemand) then loadondemand = LO_GREEN .. "Yes"; else loadondemand = LO_RED .. "No"; end
586 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. 'Load On Demand:', loadondemand);
587  
588 local s = LoadIT_DependencyString(LoadITList[idx].name);
589 if (s ~= '') then
590 GameTooltip:AddDoubleLine(LO_BLUE_LOW .. "\nDependencies: ", "\n" .. s);
591 end
592  
593 end
594  
595 function DDProfiles_OnLoad()
596  
597 DDProfileList = {};
598 DDProfileList[1] = 'Global';
599  
600 -- * load this player's class
601 DDProfileList[2] = UnitClass("player");
602  
603 -- * load profiles for all player classes (disabled for now)
604 -- local i = 2;
605 -- for key,_ in LoadITcf.Classes do
606 -- DDProfileList[i] = key;
607 -- i = i + 1;
608 -- end;
609  
610 if (not LoadITglo.View) then
611 LoadITglo.View = 1;
612 end
613  
614 UIDropDownMenu_Initialize(DDProfiles, DDProfiles_Initialize);
615 UIDropDownMenu_SetSelectedID(DDProfiles, LoadITglo.View);
616 UIDropDownMenu_SetText('View: ' .. DDProfileList[LoadITglo.View] .. ' Profiles', DDProfiles);
617  
618 UIDropDownMenu_SetWidth(190, DDProfiles);
619 UIDropDownMenu_SetButtonWidth(190, DDProfiles);
620 end
621  
622 function DDProfiles_OnShow()
623 DDProfiles_OnLoad();
624 end
625  
626 function DDProfiles_Initialize()
627 local i;
628 for i = 1, getn(DDProfileList), 1 do
629 local info = { };
630 info.text = DDProfileList[i] .. ' Profiles';
631 info.value = DDProfileList[i];
632 info.func = DDProfiles_OnClick;
633 UIDropDownMenu_AddButton(info);
634 end
635 end
636  
637 function DDProfiles_OnClick()
638 local id = this:GetID();
639 UIDropDownMenu_SetSelectedID(DDProfiles, id);
640 UIDropDownMenu_SetText('View: ' .. DDProfileList[id] .. ' Profiles', DDProfiles);
641  
642 LoadITEdit_Reset();
643 LoadITProfile_OnUpdate();
644 LoadITEdit_OnUpdate();
645  
646 -- * remember character's view preference
647 LoadITglo.View = id;
648 end
649  
650 function LoadITmenu_ToggleMenu()
651 if (LoadITmenuFrame:IsVisible()) then
652 HideUIPanel(LoadITmenuFrame);
653 else
654 if (LoadIT_OffScreen()) then
655 LoadIT_ResetMenu();
656 end
657 ShowUIPanel(LoadITmenuFrame);
658 end
659 end