vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Title: LoadIT |
2 | -- Author: Saur of Emerald Dream (EU) |
||
3 | -- Original author: Ru of Frostmane |
||
4 | -- |
||
5 | -- This is a simple mod to load/unload and enable/disable mods in-game |
||
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 below) |
||
17 | -- * param = parameter for function (see code below) |
||
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 = nil; |
||
23 | |||
24 | local LO_VERSION = '11200.1'; |
||
25 | local LO_RELEASE_DATE = "August 24, 2006"; |
||
26 | |||
27 | LOADIT_VERSION = 'LoadIT ' .. LO_VERSION; |
||
28 | |||
29 | -- myAddons support |
||
30 | local LoadITDetails = |
||
31 | { |
||
32 | name = "LoadIT", |
||
33 | version = LO_VERSION, |
||
34 | releaseDate = LO_RELEASE_DATE, |
||
35 | author = "Saur (originally by Ru)", |
||
36 | email = "pkj@axis.com", |
||
37 | website = "http://www.curse-gaming.com/mod.php?addid=3512", |
||
38 | category = MYADDONS_CATEGORY_OTHERS |
||
39 | }; |
||
40 | |||
41 | local LO_RED = '|cffff0000'; |
||
42 | local LO_GREEN = '|cff00ff00'; |
||
43 | local LO_BLUE = '|cff0000ff'; |
||
44 | local LO_MAGENTA = '|cffff00ff'; |
||
45 | local LO_YELLOW = '|cffffff00'; |
||
46 | local LO_CYAN = '|cff00ffff'; |
||
47 | local LO_WHITE = '|cffffffff'; |
||
48 | local LO_GREY = '|ccccccccc'; |
||
49 | local LO_GREY_HI = '|ceeeeeeee'; |
||
50 | local LO_BLUE_LOW = '|cff5e9ae4'; |
||
51 | local LO_BEIGE = '|cffffffa0'; |
||
52 | |||
53 | local LO_PREFIX = LO_GREY_HI .. 'LoadIT ' .. LO_YELLOW .. ':: ' .. LO_GREY; |
||
54 | local LO_HELP = { |
||
55 | LOADIT_VERSION .. ', by Saur (originally by Ru) :: Help Menu', |
||
56 | 'list .......................... display list of addons', |
||
57 | 'load <name> ......... load addon', |
||
58 | 'disable <name/#> . disable an addon', |
||
59 | 'disable_all ............. disable all addons', |
||
60 | 'enable <name/#> .. enable & load an addon', |
||
61 | 'enable_all ............. enable all addons', |
||
62 | 'reset_all ................ reset all disabled addons', |
||
63 | 'info <name/#> ....... display details for module', |
||
64 | 'brief ....................... toggle verbose profile loading', |
||
65 | 'reload or rl ............. same as /console reloadui', |
||
66 | 'defaults [save]........ clear all settings [save profiles]', |
||
67 | '', |
||
68 | 'Add-on profiling Commands:', |
||
69 | 'profiles .................. list all profiles', |
||
70 | 'savep <profile> ..... save profile', |
||
71 | 'loadp <profile> ...... load profile', |
||
72 | 'showp <profile> .... show a profile', |
||
73 | 'delp <profile> ........ delete a profile', |
||
74 | 'rl <profile> ............ load profile and reload console', |
||
75 | 'class ...................... list all class profiles', |
||
76 | 'savec <profile> ..... save module states to class profile', |
||
77 | 'loadc <profile> ...... load a class profile', |
||
78 | 'showc <profile> .... show a class profile', |
||
79 | 'delc <profile> ........ delete a class profile', |
||
80 | 'rlc <profile> ........... load class profile and reload console', |
||
81 | }; |
||
82 | |||
83 | local LO_HELP2 = { |
||
84 | '', |
||
85 | 'menu ..................... configuration menu', |
||
86 | 'menu reset ............ reset menu position', |
||
87 | }; |
||
88 | |||
89 | local LO_TEXT_YELLOW = {r = 1.0, g = 1.0, b = 0.0}; |
||
90 | local LO_DEFAULT_POSITION = { x = 0, y = 0 }; |
||
91 | |||
92 | LoadITglo = {}; -- storage for session globals |
||
93 | |||
94 | function LoadIT_OnLoad() |
||
95 | |||
96 | -- RegisterForSave("LoadITcf"); |
||
97 | this:RegisterEvent("ADDON_LOADED"); |
||
98 | this:RegisterEvent("VARIABLES_LOADED"); |
||
99 | |||
100 | LoadIT_Defaults(); |
||
101 | |||
102 | SlashCmdList["LOADIT"] = LoadIT_command; |
||
103 | SLASH_LOADIT1 = '/mods'; |
||
104 | SLASH_LOADIT2 = '/loadit'; |
||
105 | |||
106 | LoadIT_Print(LOADIT_VERSION .. ', by Saur (originally by Ru) :: Type ' .. LO_CYAN .. '/mods' .. LO_GREY .. ' for Help'); |
||
107 | end |
||
108 | |||
109 | function LoadIT_OnEvent(event, arg1) |
||
110 | if (event == "ADDON_LOADED" and arg1 == "LoadIT") then |
||
111 | if (myAddOnsFrame_Register) then |
||
112 | myAddOnsFrame_Register(LoadITDetails); |
||
113 | end |
||
114 | end |
||
115 | |||
116 | -- * add player's class profiles if not found |
||
117 | if (event == "VARIABLES_LOADED") then |
||
118 | local class = UnitClass("player"); |
||
119 | local toon = LoadIT_Who(); |
||
120 | if (not LoadITcf.Classes) then LoadITcf.Classes = {}; end |
||
121 | if (not LoadITcf.Classes[class]) then LoadITcf.Classes[class] = {}; end |
||
122 | if (not LoadITcf.Characters) then LoadITcf.Characters = {}; end |
||
123 | if (not LoadITcf.Characters[toon]) then LoadITcf.Characters[toon] = {}; end |
||
124 | end |
||
125 | end |
||
126 | |||
127 | function LoadIT_Defaults(arg) |
||
128 | |||
129 | local classes, sets; |
||
130 | |||
131 | --* save profiles |
||
132 | if (arg == 'save') then |
||
133 | sets = LoadITcf.Sets; |
||
134 | classes = LoadITcf.Classes; |
||
135 | end |
||
136 | |||
137 | -- * set configuration defaults |
||
138 | LoadITcf = {}; |
||
139 | LoadITcf.Position = LO_DEFAULT_POSITION; |
||
140 | LoadITcf.BTReloadUI = 1; |
||
141 | LoadITcf.Verbose = 1; |
||
142 | LoadITcf.LockMenu = 1; |
||
143 | LoadITcf.Sets = {}; |
||
144 | LoadITcf.Classes = {}; -- default global sets |
||
145 | LoadITcf.Classes[UnitClass("player")] = {}; -- default set for char class |
||
146 | |||
147 | LoadITcf.TTdetails = 1; -- default display addon details tooltip |
||
148 | LoadITcf.TTbuttons = 1; -- default display button tooltips |
||
149 | |||
150 | --* save profiles |
||
151 | if (arg == 'save') then |
||
152 | LoadITcf.Sets = sets; |
||
153 | LoadITcf.Classes = classes; |
||
154 | end |
||
155 | |||
156 | --* character specific settings |
||
157 | LoadITcf.Characters = {}; |
||
158 | end |
||
159 | |||
160 | -- |
||
161 | -- LoadIT_Who() - returns character-specific identity |
||
162 | -- |
||
163 | function LoadIT_Who() |
||
164 | local toon = GetCVar("realmName") .. ':' .. UnitName("player"); |
||
165 | return toon; |
||
166 | end |
||
167 | |||
168 | -- |
||
169 | -- LoadIT_Print(msg, silent) - displays a message in chat window |
||
170 | -- |
||
171 | -- msg = message to display |
||
172 | -- silent = does not display message when true; used in profiles to silence output of other calls |
||
173 | -- |
||
174 | function LoadIT_Print(msg, silent) |
||
175 | if (silent) then return; end |
||
176 | DEFAULT_CHAT_FRAME:AddMessage(LO_PREFIX .. msg .. '|r'); |
||
177 | end |
||
178 | |||
179 | -- |
||
180 | -- LoadIT_Show_Addons() - displays list of all addons |
||
181 | -- |
||
182 | function LoadIT_Show_AddOns() |
||
183 | |||
184 | local count = GetNumAddOns(); |
||
185 | |||
186 | if (count) then |
||
187 | LoadIT_Print( 'List of AddOns: Enabled = Green, Disabled = Red' ); |
||
188 | |||
189 | local i = 1; |
||
190 | while (i <= count) do |
||
191 | local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(i); |
||
192 | local loaded = IsAddOnLoaded(i); |
||
193 | |||
194 | if (not title) then title = name; end |
||
195 | if (not reason) then reason = ''; end |
||
196 | if (not security) then security = ''; end |
||
197 | |||
198 | local s = string.format("%2d", i); |
||
199 | |||
200 | if (loaded) then |
||
201 | s = s .. LO_BLUE_LOW .. ' <L> ' .. LO_GREY; |
||
202 | else |
||
203 | s = s .. ' <-> '; |
||
204 | end |
||
205 | |||
206 | if (enabled) then s = s .. LO_GREEN; else s = s .. LO_RED; end |
||
207 | |||
208 | s = s .. ' ' .. title; |
||
209 | if (notes) then s = s .. LO_GREY .. ' - ' .. notes; end; |
||
210 | |||
211 | LoadIT_Print(s .. ' (' .. name .. ')'); |
||
212 | i = i + 1; |
||
213 | end |
||
214 | end |
||
215 | end |
||
216 | |||
217 | -- |
||
218 | -- LoadIT_ShowProfiles() - displays list of all profiles |
||
219 | -- |
||
220 | function LoadIT_ShowProfiles(type) |
||
221 | |||
222 | local key,s; |
||
223 | local count = 0; |
||
224 | local tmplist = {}; |
||
225 | local tmp = ''; |
||
226 | |||
227 | local class = UnitClass("player"); |
||
228 | if (type == 'class') then |
||
229 | tmplist = LoadITcf.Classes[class]; |
||
230 | tmp = class .. ' '; |
||
231 | else |
||
232 | tmplist = LoadITcf.Sets; |
||
233 | end |
||
234 | |||
235 | for key,_ in tmplist do count = count + 1; end; |
||
236 | |||
237 | if (count > 0) then |
||
238 | LoadIT_Print(LO_YELLOW .. 'You have ' .. count .. ' saved ' .. tmp .. 'profiles:'); |
||
239 | for key,_ in tmplist do |
||
240 | LoadIT_Print('Profile :: ' .. key); |
||
241 | end |
||
242 | else |
||
243 | LoadIT_Print(LO_RED .. 'No saved ' .. tmp .. 'profiles'); |
||
244 | end |
||
245 | |||
246 | end |
||
247 | |||
248 | -- |
||
249 | -- LoadIT_DeleteProfile() - removes the specified profile |
||
250 | -- |
||
251 | function LoadIT_DeleteProfile(p, type) |
||
252 | local tmp = ''; |
||
253 | if (type == 'class') then |
||
254 | local class = UnitClass("player"); |
||
255 | LoadITcf.Classes[class][p] = nil; |
||
256 | tmp = class .. ' '; |
||
257 | else |
||
258 | LoadITcf.Sets[p] = nil; |
||
259 | end |
||
260 | LoadIT_Print(LO_YELLOW .. 'Removed ' .. tmp .. 'profile: ' .. p); |
||
261 | |||
262 | -- ** LoadITmenu: update GUI |
||
263 | if (LoadITmenu) then LoadIT_UpdateMenu('deleteprofile', p); end |
||
264 | end |
||
265 | |||
266 | |||
267 | -- |
||
268 | -- LoadIT_LoadProfile() - loads the specified profile |
||
269 | -- |
||
270 | function LoadIT_LoadProfile(p, type) |
||
271 | |||
272 | local key, s; |
||
273 | local count = 0; |
||
274 | local tmp = ''; |
||
275 | |||
276 | local reload_dis = nil; |
||
277 | local reload_ena = nil; |
||
278 | |||
279 | local Verbose = nil; |
||
280 | if (not LoadITcf.Verbose) then Verbose = 1; end |
||
281 | |||
282 | local class = UnitClass("player"); |
||
283 | if (type == 'class') then |
||
284 | tmp = class .. ' '; |
||
285 | end |
||
286 | |||
287 | if ((not p) or (p == '')) then |
||
288 | LoadIT_Print(LO_RED .. 'No ' .. tmp .. 'profile name specified'); |
||
289 | return; |
||
290 | end |
||
291 | |||
292 | local modules = {}; |
||
293 | if (type == 'class') then |
||
294 | if (LoadITcf.Classes[class][p]) then |
||
295 | modules = LoadITcf.Classes[class][p].Modules; |
||
296 | else |
||
297 | LoadIT_Print(LO_RED .. 'No ' .. tmp .. 'profile ' .. p .. ' exists'); |
||
298 | return; |
||
299 | end |
||
300 | else |
||
301 | if (LoadITcf.Sets[p]) then |
||
302 | modules = LoadITcf.Sets[p].Modules; |
||
303 | else |
||
304 | LoadIT_Print(LO_RED .. 'No profile ' .. p .. ' exists'); |
||
305 | return; |
||
306 | end |
||
307 | end |
||
308 | |||
309 | LoadIT_Print(LO_YELLOW .. 'Loading ' .. tmp .. 'profile: ' .. p); |
||
310 | for key,s in modules do |
||
311 | |||
312 | local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(key); |
||
313 | |||
314 | if ((enabled) and (s == 0)) then |
||
315 | if (LoadIT_Disable(name, Verbose, 1)) then reload_dis = 1; end |
||
316 | count = count + 1; |
||
317 | elseif ((not enabled) and (s == 1)) then |
||
318 | if (not LoadIT_Enable(name, Verbose, 1)) then reload_ena = 1; end |
||
319 | count = count + 1; |
||
320 | end |
||
321 | end |
||
322 | LoadIT_Print('Loaded ' .. tmp .. 'profile: ' .. p); |
||
323 | LoadIT_Print('Total: ' .. count .. ' changes were made'); |
||
324 | if (reload_dis) then LoadIT_Reload(0); end |
||
325 | if (reload_ena) then LoadIT_Reload(1); end |
||
326 | |||
327 | -- ** LoadITmenu: update GUI |
||
328 | if (LoadITmenu) then LoadIT_UpdateMenu('loadprofile', p); end |
||
329 | return 1; |
||
330 | end |
||
331 | |||
332 | -- |
||
333 | -- LoadIT_ShowProfile(p, type) - displays the specified profile |
||
334 | -- |
||
335 | function LoadIT_ShowProfile(p, type) |
||
336 | |||
337 | local key, s; |
||
338 | local count = 0; |
||
339 | local errors = 0; |
||
340 | local tmp = ''; |
||
341 | |||
342 | local class = UnitClass("player"); |
||
343 | if (type == 'class') then |
||
344 | tmp = class .. ' '; |
||
345 | end |
||
346 | |||
347 | if ((not p) or (p == '')) then |
||
348 | LoadIT_Print(LO_RED .. 'No ' .. tmp .. 'profile name specified'); |
||
349 | return; |
||
350 | end |
||
351 | |||
352 | local modules = {}; |
||
353 | if (type == 'class') then |
||
354 | if (LoadITcf.Classes[class][p]) then |
||
355 | modules = LoadITcf.Classes[class][p].Modules; |
||
356 | else |
||
357 | LoadIT_Print(LO_RED .. 'No ' .. tmp .. 'profile ' .. p .. ' exists'); |
||
358 | return; |
||
359 | end |
||
360 | else |
||
361 | if (LoadITcf.Sets[p]) then |
||
362 | modules = LoadITcf.Sets[p].Modules; |
||
363 | else |
||
364 | LoadIT_Print(LO_RED .. 'No profile ' .. p .. ' exists'); |
||
365 | return; |
||
366 | end |
||
367 | end |
||
368 | |||
369 | LoadIT_Print(''); |
||
370 | LoadIT_Print(LO_YELLOW .. 'Begin Display Profile: ' .. LO_CYAN .. p); |
||
371 | |||
372 | for key,enabled in modules do |
||
373 | |||
374 | local name, title, notes, _, loadable, reason, security = GetAddOnInfo(key); |
||
375 | local s = ''; |
||
376 | |||
377 | if (not name) then -- module missing |
||
378 | name = '** (' .. key .. ') **'; |
||
379 | errors = errors + 1; |
||
380 | elseif (title) then |
||
381 | name = title; |
||
382 | end |
||
383 | |||
384 | if (enabled == 1) then |
||
385 | s = LO_GREEN .. ' ' .. name; |
||
386 | else |
||
387 | s = LO_RED .. ' ' .. name; |
||
388 | end |
||
389 | |||
390 | LoadIT_Print(s); |
||
391 | count = count + 1; |
||
392 | end |
||
393 | LoadIT_Print('Total: ' .. count .. ' addons in profile'); |
||
394 | if (errors > 0) then |
||
395 | LoadIT_Print(LO_RED .. 'Error: ' .. errors .. ' addons missing in profile'); |
||
396 | end |
||
397 | LoadIT_Print(LO_YELLOW .. 'End Display ' .. tmp .. 'Profile: ' .. LO_CYAN .. p); |
||
398 | end |
||
399 | |||
400 | -- |
||
401 | -- LoadIT_SaveProfile() - saves the specified profile |
||
402 | -- |
||
403 | function LoadIT_SaveProfile(p, type) |
||
404 | |||
405 | local modules = {}; |
||
406 | |||
407 | if ((not p) or (p == '')) then |
||
408 | LoadIT_Print(LO_RED .. 'No profile name specified'); |
||
409 | return; |
||
410 | end |
||
411 | |||
412 | local count = GetNumAddOns(); |
||
413 | |||
414 | if (count) then |
||
415 | |||
416 | local tmplist = {}; |
||
417 | |||
418 | local i = 1; |
||
419 | while (i <= count) do |
||
420 | local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(i); |
||
421 | if (not enabled) then enabled = 0; end |
||
422 | modules[name] = enabled; |
||
423 | i = i + 1; |
||
424 | end |
||
425 | |||
426 | local tmp = ''; |
||
427 | if (type == 'class') then |
||
428 | local class = UnitClass("player"); |
||
429 | LoadITcf.Classes[class][p] = {}; |
||
430 | LoadITcf.Classes[class][p].Modules = modules; |
||
431 | tmp = class .. ' '; |
||
432 | else |
||
433 | LoadITcf.Sets[p] = {}; |
||
434 | LoadITcf.Sets[p].Modules = modules; |
||
435 | end |
||
436 | LoadIT_Print(LO_YELLOW .. 'Saved current module state to ' .. tmp .. 'profile: ' .. p); |
||
437 | |||
438 | -- ** LoadITmenu: update GUI |
||
439 | if (LoadITmenu) then LoadIT_UpdateMenu('saveprofile', p); end |
||
440 | else |
||
441 | LoadIT_Print(LO_RED .. 'No modules to save.'); |
||
442 | end |
||
443 | end |
||
444 | |||
445 | function LoadIT_AddOnSeparator(arg, c) |
||
446 | if (arg) then |
||
447 | local s = LO_GREY; |
||
448 | if (not c) then |
||
449 | s = s .. ', '; |
||
450 | end |
||
451 | local loaded = IsAddOnLoaded(arg); |
||
452 | if (loaded) then |
||
453 | s = s .. arg; |
||
454 | else |
||
455 | s = s .. LO_RED .. arg .. "|r"; |
||
456 | end |
||
457 | return s; |
||
458 | else |
||
459 | return ''; |
||
460 | end |
||
461 | end |
||
462 | |||
463 | function LoadIT_DependencyString(name) |
||
464 | local s = ''; |
||
465 | local key, tmp; |
||
466 | local deps = { GetAddOnDependencies(name) }; |
||
467 | if (deps[1]) then |
||
468 | local first = 1; |
||
469 | for key, tmp in deps do |
||
470 | s = s .. LoadIT_AddOnSeparator(tmp, first); |
||
471 | if (first) then first = nil; end |
||
472 | end |
||
473 | end |
||
474 | return s; |
||
475 | end |
||
476 | |||
477 | -- |
||
478 | -- LoadIT_Details(addon) - displays details for specified addon |
||
479 | -- |
||
480 | function LoadIT_Details(addon) |
||
481 | |||
482 | local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(addon); |
||
483 | |||
484 | if (not title) then |
||
485 | LoadIT_Print(LO_RED .. 'Error detailing module ' .. addon .. '; Reason: ' .. reason); |
||
486 | return; |
||
487 | end |
||
488 | |||
489 | local loaded = IsAddOnLoaded(addon); |
||
490 | |||
491 | LoadIT_Print(LO_YELLOW .. 'Begin Module Details: ' .. LO_BLUE_LOW .. name); |
||
492 | |||
493 | if (enabled) then enabled = 'Yes'; else enabled = 'No'; end |
||
494 | if (loadable) then loadable = 'Yes'; else loadable = 'No'; end |
||
495 | if (loaded) then loaded = 'Yes'; else loaded = 'No'; end |
||
496 | |||
497 | if (title) then LoadIT_Print('Title ......... ' .. title); end |
||
498 | if (notes) then LoadIT_Print('Notes ....... ' .. notes); end |
||
499 | if (security) then LoadIT_Print('Security .... ' .. security); end |
||
500 | |||
501 | local loadondemand = IsAddOnLoadOnDemand(name); |
||
502 | |||
503 | LoadIT_Print('Loadable .. ' .. loadable); |
||
504 | if (reason) then LoadIT_Print('Reason ....... ' .. reason); end |
||
505 | LoadIT_Print('Loaded .... ' .. loaded); |
||
506 | LoadIT_Print('Enabled .... ' .. enabled) |
||
507 | if (loadondemand) then LoadIT_Print('(LoadOnDemand Supported)'); end |
||
508 | |||
509 | local s = LoadIT_DependencyString(name); |
||
510 | if (s ~= '') then |
||
511 | LoadIT_Print('Dependencies: ' .. s); |
||
512 | end |
||
513 | |||
514 | LoadIT_Print(LO_YELLOW .. 'End Module Details: ' .. LO_BLUE_LOW .. name); |
||
515 | |||
516 | end |
||
517 | |||
518 | -- |
||
519 | -- LoadIT_Disable(p, silent, bulk) - disables an addon |
||
520 | -- p = addon to disable |
||
521 | -- silent = disables output when true |
||
522 | -- bulk = disables reload messages during bulk operations |
||
523 | -- |
||
524 | -- return 1 = module was disabled |
||
525 | -- return nil = module not disabled |
||
526 | -- |
||
527 | function LoadIT_Disable(p, silent, bulk) |
||
528 | if (p) then |
||
529 | DisableAddOn(p); |
||
530 | |||
531 | -- ** LoadITmenu: update GUI |
||
532 | if ((LoadITmenu) and (not silent)) then LoadIT_UpdateMenu('disable', p); end |
||
533 | |||
534 | local name, _, _, enabled, _, _, _ = GetAddOnInfo(p); |
||
535 | if (not enabled) then |
||
536 | LoadIT_Print(LO_GREEN .. 'DISABLED module ' .. name, silent); |
||
537 | local loaded = IsAddOnLoaded(name); |
||
538 | if ((loaded) and (not silent) and (not bulk)) then |
||
539 | LoadIT_Reload(0); |
||
540 | end |
||
541 | return 1; |
||
542 | else |
||
543 | LoadIT_Print(LO_RED .. 'Failed to disable module ' .. name); |
||
544 | end |
||
545 | else |
||
546 | LoadIT_Print(LO_RED .. 'No addon name was specified'); |
||
547 | end |
||
548 | end |
||
549 | |||
550 | -- |
||
551 | -- LoadIT_Reload(s, silent) - displays message to user to reload ui |
||
552 | -- |
||
553 | -- s = 1 to notify ~enabled modules | 0 to notify ~disabled modules |
||
554 | -- silent = disables output when true |
||
555 | -- |
||
556 | function LoadIT_Reload(s, silent) |
||
557 | if (silent) then return; end |
||
558 | if (s == 0) then |
||
559 | LoadIT_Print(LO_YELLOW .. "You must type '/mods rl' to remove disabled modules from memory"); |
||
560 | else |
||
561 | LoadIT_Print(LO_YELLOW .. "You must type '/mods rl' to load enabled modules that are not dynamically loadable"); |
||
562 | end |
||
563 | end |
||
564 | |||
565 | -- |
||
566 | -- LoadIT_Enable(p, silent, bulk) - enables an addon |
||
567 | -- |
||
568 | -- p = addon to enable |
||
569 | -- silent = disables output when true |
||
570 | -- bulk = disables reload messages during bulk operations |
||
571 | -- |
||
572 | -- return 1 = module was enabled |
||
573 | -- return nil = module not enabled |
||
574 | -- |
||
575 | function LoadIT_Enable(p, silent, bulk) |
||
576 | if (p) then |
||
577 | EnableAddOn(p); |
||
578 | |||
579 | -- ** LoadITmenu: update GUI |
||
580 | if ((LoadITmenu) and (not silent)) then LoadIT_UpdateMenu('enable', p); end |
||
581 | |||
582 | local name, _, _, enabled, loadable, reason, _ = GetAddOnInfo(p); |
||
583 | if (enabled) then |
||
584 | LoadIT_Print(LO_GREEN .. 'ENABLED module ' .. name, silent); |
||
585 | -- |
||
586 | -- disabled auto-loading until a method is available to check if a module supports load-on-demand |
||
587 | -- |
||
588 | local loaded = IsAddOnLoaded(name); |
||
589 | -- if (not loaded) then |
||
590 | -- return LoadIT_Load(name, silent); |
||
591 | -- end |
||
592 | -- return 1; |
||
593 | if ((not loaded) and (not silent) and (not bulk)) then |
||
594 | LoadIT_Reload(1); |
||
595 | end |
||
596 | return 1; |
||
597 | else |
||
598 | LoadIT_Print(LO_RED .. 'Failed to enable ' .. p .. '; Reason: ' .. reason); |
||
599 | end |
||
600 | else |
||
601 | LoadIT_Print(LO_RED .. 'No addon name was specified'); |
||
602 | end |
||
603 | end |
||
604 | |||
605 | -- |
||
606 | -- LoadIT_Load(p, silent) - load an addon |
||
607 | -- |
||
608 | -- p = addon to load |
||
609 | -- silent = disables output when true |
||
610 | -- |
||
611 | -- return 1 = module was loaded |
||
612 | -- return nil = module not loaded |
||
613 | -- |
||
614 | function LoadIT_Load(p, silent) |
||
615 | if (p) then |
||
616 | local name, _, _, _, loadable, _, _ = GetAddOnInfo(p); |
||
617 | if (not loadable) then |
||
618 | LoadIT_Print(LO_RED .. 'Module is DISABLED or not dynamically loadable: ' .. name, silent); |
||
619 | return; |
||
620 | end |
||
621 | local loaded,reason = LoadAddOn(p); |
||
622 | |||
623 | -- ** LoadITmenu: update GUI |
||
624 | if ((LoadITmenu) and (not silent)) then LoadIT_UpdateMenu('load', p); end |
||
625 | |||
626 | if (loaded) then |
||
627 | LoadIT_Print(LO_GREEN .. 'Loaded ' .. name, silent); |
||
628 | return 1; |
||
629 | else |
||
630 | LoadIT_Print(LO_RED .. 'Failed to load ' .. name .. '; Reason: ' .. reason, silent); |
||
631 | end |
||
632 | else |
||
633 | LoadIT_Print(LO_RED .. 'No addon name was specified', silent); |
||
634 | end |
||
635 | end |
||
636 | |||
637 | function LoadIT_ResetMenu() |
||
638 | LoadITmenuFrame:ClearAllPoints(); |
||
639 | LoadITmenuFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
640 | end |
||
641 | |||
642 | function LoadIT_OffScreen() |
||
643 | local left = LoadITmenuFrame:GetLeft(); |
||
644 | local right = LoadITmenuFrame:GetRight(); |
||
645 | |||
646 | if (left and right) then |
||
647 | -- left, right = left - (right - left), right + (right - left); |
||
648 | else |
||
649 | return 1; -- off screen |
||
650 | end |
||
651 | |||
652 | if (left and left < UIParent:GetLeft()) then |
||
653 | return 1; -- off screen |
||
654 | end |
||
655 | if (right and right > UIParent:GetRight()) then |
||
656 | return 1; -- off screen |
||
657 | end |
||
658 | end |
||
659 | |||
660 | function LoadIT_command(msg) |
||
661 | |||
662 | local key,s, enabled, name, reason; |
||
663 | local _,_,c,p = string.find(msg,"([%w%p]+)%s*(.*)$"); |
||
664 | |||
665 | if (c == 'list') then |
||
666 | LoadIT_Show_AddOns(); |
||
667 | elseif (c == 'brief') then |
||
668 | if (LoadITcf.Verbose) then |
||
669 | LoadITcf.Verbose = nil; |
||
670 | LoadIT_Print(LO_YELLOW .. 'Verbose mode DISABLED'); |
||
671 | else |
||
672 | LoadITcf.Verbose = 1; |
||
673 | LoadIT_Print(LO_YELLOW .. 'Verbose mode ENABLED'); |
||
674 | end |
||
675 | elseif (c == 'info') then |
||
676 | LoadIT_Details(p); |
||
677 | elseif (c == 'defaults') then |
||
678 | LoadIT_Defaults(p); |
||
679 | if (p == 'save') then |
||
680 | LoadIT_Print(LO_RED .. 'RESET all settings and SAVE profiles'); |
||
681 | else |
||
682 | LoadIT_Print(LO_RED .. 'RESET all settings and profiles'); |
||
683 | end |
||
684 | if (LoadITmenu) then LoadIT_UpdateMenu('defaults'); end |
||
685 | elseif (c == 'load') then |
||
686 | LoadIT_Load(p); |
||
687 | elseif (c == 'disable') then |
||
688 | LoadIT_Disable(p); |
||
689 | elseif (c == 'enable') then |
||
690 | LoadIT_Enable(p); |
||
691 | elseif (c == 'disable_all') then |
||
692 | DisableAllAddOns(); |
||
693 | LoadIT_Print('All addons have been ' .. LO_RED .. 'DISABLED'); |
||
694 | elseif (c == 'enable_all') then |
||
695 | EnableAllAddOns(); |
||
696 | LoadIT_Print('All addons have been ' .. LO_GREEN .. 'ENABLED'); |
||
697 | elseif (c == 'reset_all') then |
||
698 | ResetDisabledAddOns(); |
||
699 | LoadIT_Print('All disabled addon states have been ' .. LO_RED .. 'RESET'); |
||
700 | elseif ((c == 'profile') or (c == 'profiles')) then |
||
701 | LoadIT_ShowProfiles(); |
||
702 | elseif ((c == 'class') or (c == 'cp')) then |
||
703 | LoadIT_ShowProfiles('class'); |
||
704 | elseif ((c == 'del') or (c == 'delp')) then |
||
705 | LoadIT_DeleteProfile(p); |
||
706 | elseif (c == 'delc') then |
||
707 | LoadIT_DeleteProfile(p, 'class'); |
||
708 | elseif ((c == 'savec') or (c == 'saveclass')) then |
||
709 | LoadIT_SaveProfile(p, 'class'); |
||
710 | elseif ((c == 'loadc') or (c == 'loadclass')) then |
||
711 | LoadIT_LoadProfile(p, 'class'); |
||
712 | elseif ((c == 'savep') or (c == 'saveprofile')) then |
||
713 | LoadIT_SaveProfile(p); |
||
714 | elseif ((c == 'loadp') or (c == 'loadprofile')) then |
||
715 | LoadIT_LoadProfile(p); |
||
716 | elseif ((c == 'showp') or (c == 'showprofile')) then |
||
717 | LoadIT_ShowProfile(p); |
||
718 | elseif (c == 'showc') then |
||
719 | LoadIT_ShowProfile(p, 'class'); |
||
720 | elseif ((c == 'rl') or (c == 'reload')) then |
||
721 | if ((p) and (p ~= '')) then |
||
722 | if (not LoadIT_LoadProfile(p)) then |
||
723 | return; |
||
724 | end |
||
725 | end |
||
726 | ReloadUI(); |
||
727 | elseif (c == 'rlc') then |
||
728 | if ((p) and (p ~= '')) then |
||
729 | if (not LoadIT_LoadProfile(p, 'class')) then |
||
730 | return; |
||
731 | end |
||
732 | end |
||
733 | ReloadUI(); |
||
734 | elseif ((c == 'menu') or (LoadITcf.ShortcutMenu and (not c)))then |
||
735 | if (LoadITmenu) then |
||
736 | if (((p) and (p == 'reset')) or LoadIT_OffScreen()) then |
||
737 | LoadIT_ResetMenu(); |
||
738 | end |
||
739 | ShowUIPanel(LoadITmenuFrame); |
||
740 | else |
||
741 | LoadIT_Print(LO_RED .. 'LoadITmenu is not loaded'); |
||
742 | end |
||
743 | else |
||
744 | for key,s in LO_HELP do |
||
745 | LoadIT_Print(s); |
||
746 | end |
||
747 | if (LoadITmenu) then |
||
748 | for key,s in LO_HELP2 do |
||
749 | LoadIT_Print(s); |
||
750 | end |
||
751 | end |
||
752 | LoadIT_Print(''); |
||
753 | if (LoadITcf.Verbose == 1) then |
||
754 | LoadIT_Print('Verbose profile loading is ' .. LO_GREEN .. 'ON'); |
||
755 | else |
||
756 | LoadIT_Print('Verbose profile loading is ' .. LO_RED .. 'OFF'); |
||
757 | end |
||
758 | end |
||
759 | end |