vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Name: AceAddon-2.0 |
||
3 | Revision: $Rev: 9774 $ |
||
4 | Author(s): ckknight (ckknight@gmail.com) |
||
5 | Inspired By: Ace 1.x by Turan (<email here>) |
||
6 | Website: http://www.wowace.com/ |
||
7 | Documentation: http://wiki.wowace.com/index.php/AceAddon-2.0 |
||
8 | SVN: http://svn.wowace.com/root/trunk/Ace2/AceAddon-2.0 |
||
9 | Description: Base for all Ace addons to inherit from. |
||
10 | Dependencies: AceLibrary, AceOO-2.0, AceEvent-2.0, (optional) AceConsole-2.0 |
||
11 | ]] |
||
12 | |||
13 | local MAJOR_VERSION = "AceAddon-2.0" |
||
14 | local MINOR_VERSION = "$Revision: 9774 $" |
||
15 | |||
16 | -- This ensures the code is only executed if the libary doesn't already exist, or is a newer version |
||
17 | if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end |
||
18 | if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end |
||
19 | |||
20 | if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end |
||
21 | |||
22 | -- Localization |
||
23 | local STANDBY, TITLE, NOTES, VERSION, AUTHOR, DATE, CATEGORY, EMAIL, WEBSITE, CATEGORIES, ABOUT, PRINT_ADDON_INFO |
||
24 | if false then -- GetLocale() == "deDE" |
||
25 | else -- enUS |
||
26 | STANDBY = "|cffff5050(standby)|r" |
||
27 | |||
28 | TITLE = "Title" |
||
29 | NOTES = "Notes" |
||
30 | VERSION = "Version" |
||
31 | AUTHOR = "Author" |
||
32 | DATE = "Date" |
||
33 | CATEGORY = "Category" |
||
34 | EMAIL = "E-mail" |
||
35 | WEBSITE = "Website" |
||
36 | |||
37 | ABOUT = "About" |
||
38 | PRINT_ADDON_INFO = "Print out addon info" |
||
39 | |||
40 | CATEGORIES = { |
||
41 | ["Action Bars"] = "Action Bars", |
||
42 | ["Auction"] = "Auction", |
||
43 | ["Audio"] = "Audio", |
||
44 | ["Battlegrounds/PvP"] = "Battlegrounds/PvP", |
||
45 | ["Buffs"] = "Buffs", |
||
46 | ["Chat/Communication"] = "Chat/Communication", |
||
47 | ["Druid"] = "Druid", |
||
48 | ["Hunter"] = "Hunter", |
||
49 | ["Mage"] = "Mage", |
||
50 | ["Paladin"] = "Paladin", |
||
51 | ["Priest"] = "Priest", |
||
52 | ["Rogue"] = "Rogue", |
||
53 | ["Shaman"] = "Shaman", |
||
54 | ["Warlock"] = "Warlock", |
||
55 | ["Warrior"] = "Warrior", |
||
56 | ["Healer"] = "Healer", |
||
57 | ["Tank"] = "Tank", |
||
58 | ["Caster"] = "Caster", |
||
59 | ["Combat"] = "Combat", |
||
60 | ["Compilations"] = "Compilations", |
||
61 | ["Data Export"] = "Data Export", |
||
62 | ["Development Tools "] = "Development Tools ", |
||
63 | ["Guild"] = "Guild", |
||
64 | ["Frame Modification"] = "Frame Modification", |
||
65 | ["Interface Enhancements"] = "Interface Enhancements", |
||
66 | ["Inventory"] = "Inventory", |
||
67 | ["Library"] = "Library", |
||
68 | ["Map"] = "Map", |
||
69 | ["Mail"] = "Mail", |
||
70 | ["Miscellaneous"] = "Miscellaneous", |
||
71 | ["Quest"] = "Quest", |
||
72 | ["Raid"] = "Raid", |
||
73 | ["Tradeskill"] = "Tradeskill", |
||
74 | ["UnitFrame"] = "UnitFrame", |
||
75 | } |
||
76 | end |
||
77 | |||
78 | setmetatable(CATEGORIES, { __index = function(self, key) -- case-insensitive |
||
79 | local lowerKey = string.lower(key) |
||
80 | for k,v in CATEGORIES do |
||
81 | if string.lower(k) == lowerKey then |
||
82 | return v |
||
83 | end |
||
84 | end |
||
85 | end }) |
||
86 | |||
87 | -- Create the library object |
||
88 | |||
89 | local AceOO = AceLibrary("AceOO-2.0") |
||
90 | local AceAddon = AceOO.Class() |
||
91 | local AceEvent |
||
92 | local AceConsole |
||
93 | local AceModuleCore |
||
94 | |||
95 | function AceAddon:ToString() |
||
96 | return "AceAddon" |
||
97 | end |
||
98 | |||
99 | local function print(text) |
||
100 | DEFAULT_CHAT_FRAME:AddMessage(text) |
||
101 | end |
||
102 | |||
103 | function AceAddon:ADDON_LOADED(name) |
||
104 | while table.getn(self.nextAddon) > 0 do |
||
105 | local addon = table.remove(self.nextAddon, 1) |
||
106 | table.insert(self.addons, addon) |
||
107 | if not self.addons[name] then |
||
108 | self.addons[name] = addon |
||
109 | end |
||
110 | self:InitializeAddon(addon, name) |
||
111 | end |
||
112 | end |
||
113 | |||
114 | local function RegisterOnEnable(self) |
||
115 | if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage then -- HACK |
||
116 | AceAddon.playerLoginFired = true |
||
117 | end |
||
118 | if AceAddon.playerLoginFired then |
||
119 | AceAddon.addonsStarted[self] = true |
||
120 | if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then |
||
121 | local current = self.class |
||
122 | while true do |
||
123 | if current == AceOO.Class then |
||
124 | break |
||
125 | end |
||
126 | if current.mixins then |
||
127 | for mixin in pairs(current.mixins) do |
||
128 | if type(mixin.OnEmbedEnable) == "function" then |
||
129 | mixin:OnEmbedEnable(self) |
||
130 | end |
||
131 | end |
||
132 | end |
||
133 | current = current.super |
||
134 | end |
||
135 | if type(self.OnEnable) == "function" then |
||
136 | self:OnEnable() |
||
137 | end |
||
138 | end |
||
139 | else |
||
140 | if not AceAddon.addonsToOnEnable then |
||
141 | AceAddon.addonsToOnEnable = {} |
||
142 | end |
||
143 | table.insert(AceAddon.addonsToOnEnable, self) |
||
144 | end |
||
145 | end |
||
146 | |||
147 | local function stripSpaces(text) |
||
148 | if type(text) == "string" then |
||
149 | return (string.gsub(string.gsub(text, "^%s*(.-)%s*$", "%1"), "%s%s+", " ")) |
||
150 | end |
||
151 | return text |
||
152 | end |
||
153 | |||
154 | function AceAddon:InitializeAddon(addon, name) |
||
155 | if addon.name == nil then |
||
156 | addon.name = name |
||
157 | end |
||
158 | if GetAddOnMetadata then |
||
159 | -- TOC checks |
||
160 | if addon.title == nil then |
||
161 | addon.title = GetAddOnMetadata(name, "Title") |
||
162 | if addon.title then |
||
163 | local num = string.find(addon.title, " |cff7fff7f %-Ace2%-|r$") |
||
164 | if num then |
||
165 | addon.title = string.sub(addon.title, 1, num - 1) |
||
166 | end |
||
167 | addon.title = stripSpaces(addon.title) |
||
168 | end |
||
169 | end |
||
170 | if addon.notes == nil then |
||
171 | addon.notes = GetAddOnMetadata(name, "Notes") |
||
172 | addon.notes = stripSpaces(addon.notes) |
||
173 | end |
||
174 | if addon.version == nil then |
||
175 | addon.version = GetAddOnMetadata(name, "Version") |
||
176 | if addon.version then |
||
177 | if string.find(addon.version, "%$Revision: (%d+) %$") then |
||
178 | addon.version = string.gsub(addon.version, "%$Revision: (%d+) %$", "%1") |
||
179 | elseif string.find(addon.version, "%$Rev: (%d+) %$") then |
||
180 | addon.version = string.gsub(addon.version, "%$Rev: (%d+) %$", "%1") |
||
181 | elseif string.find(addon.version, "%$LastChangedRevision: (%d+) %$") then |
||
182 | addon.version = string.gsub(addon.version, "%$LastChangedRevision: (%d+) %$", "%1") |
||
183 | end |
||
184 | end |
||
185 | addon.version = stripSpaces(addon.version) |
||
186 | end |
||
187 | if addon.author == nil then |
||
188 | addon.author = GetAddOnMetadata(name, "Author") |
||
189 | addon.author = stripSpaces(addon.author) |
||
190 | end |
||
191 | if addon.date == nil then |
||
192 | addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate") |
||
193 | if addon.date then |
||
194 | if string.find(addon.date, "%$Date: (.-) %$") then |
||
195 | addon.date = string.gsub(addon.date, "%$Date: (.-) %$", "%1") |
||
196 | elseif string.find(addon.date, "%$LastChangedDate: (.-) %$") then |
||
197 | addon.date = string.gsub(addon.date, "%$LastChangedDate: (.-) %$", "%1") |
||
198 | end |
||
199 | end |
||
200 | addon.date = stripSpaces(addon.date) |
||
201 | end |
||
202 | if addon.category == nil then |
||
203 | addon.category = GetAddOnMetadata(name, "X-Category") |
||
204 | addon.category = stripSpaces(addon.category) |
||
205 | end |
||
206 | if addon.email == nil then |
||
207 | addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email") |
||
208 | addon.email = stripSpaces(addon.email) |
||
209 | end |
||
210 | if addon.website == nil then |
||
211 | addon.website = GetAddOnMetadata(name, "X-Website") |
||
212 | addon.website = stripSpaces(addon.website) |
||
213 | end |
||
214 | end |
||
215 | local current = addon.class |
||
216 | while true do |
||
217 | if current == AceOO.Class then |
||
218 | break |
||
219 | end |
||
220 | if current.mixins then |
||
221 | for mixin in pairs(current.mixins) do |
||
222 | if type(mixin.OnEmbedInitialize) == "function" then |
||
223 | mixin:OnEmbedInitialize(addon, name) |
||
224 | end |
||
225 | end |
||
226 | end |
||
227 | current = current.super |
||
228 | end |
||
229 | if type(addon.OnInitialize) == "function" then |
||
230 | addon:OnInitialize(name) |
||
231 | end |
||
232 | RegisterOnEnable(addon) |
||
233 | end |
||
234 | |||
235 | function AceAddon.prototype:PrintAddonInfo() |
||
236 | local x |
||
237 | if self.title then |
||
238 | x = "|cffffff7f" .. tostring(self.title) .. "|r" |
||
239 | elseif self.name then |
||
240 | x = "|cffffff7f" .. tostring(self.name) .. "|r" |
||
241 | else |
||
242 | x = "|cffffff7f<" .. tostring(self.class) .. " instance>|r" |
||
243 | end |
||
244 | if type(self.IsActive) == "function" then |
||
245 | if not self:IsActive() then |
||
246 | x = x .. " " .. STANDBY |
||
247 | end |
||
248 | end |
||
249 | if self.version then |
||
250 | x = x .. " - |cffffff7f" .. tostring(self.version) .. "|r" |
||
251 | end |
||
252 | if self.notes then |
||
253 | x = x .. " - " .. tostring(self.notes) |
||
254 | end |
||
255 | print(x) |
||
256 | if self.author then |
||
257 | print(" - |cffffff7f" .. AUTHOR .. ":|r " .. tostring(self.author)) |
||
258 | end |
||
259 | if self.date then |
||
260 | print(" - |cffffff7f" .. DATE .. ":|r " .. tostring(self.date)) |
||
261 | end |
||
262 | if self.category then |
||
263 | local category = CATEGORIES[self.category] |
||
264 | if category then |
||
265 | print(" - |cffffff7f" .. CATEGORY .. ":|r " .. category) |
||
266 | end |
||
267 | end |
||
268 | if self.email then |
||
269 | print(" - |cffffff7f" .. EMAIL .. ":|r " .. tostring(self.email)) |
||
270 | end |
||
271 | if self.website then |
||
272 | print(" - |cffffff7f" .. WEBSITE .. ":|r " .. tostring(self.website)) |
||
273 | end |
||
274 | end |
||
275 | |||
276 | local options |
||
277 | function AceAddon:GetAceOptionsDataTable(target) |
||
278 | if not options then |
||
279 | options = { |
||
280 | about = { |
||
281 | name = ABOUT, |
||
282 | desc = PRINT_ADDON_INFO, |
||
283 | type = "execute", |
||
284 | func = "PrintAddonInfo", |
||
285 | order = -1, |
||
286 | } |
||
287 | } |
||
288 | end |
||
289 | return options |
||
290 | end |
||
291 | |||
292 | function AceAddon:PLAYER_LOGIN() |
||
293 | self.playerLoginFired = true |
||
294 | if self.addonsToOnEnable then |
||
295 | while table.getn(self.addonsToOnEnable) > 0 do |
||
296 | local addon = table.remove(self.addonsToOnEnable, 1) |
||
297 | self.addonsStarted[addon] = true |
||
298 | if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then |
||
299 | local current = addon.class |
||
300 | while true do |
||
301 | if current == AceOO.Class then |
||
302 | break |
||
303 | end |
||
304 | if current.mixins then |
||
305 | for mixin in pairs(current.mixins) do |
||
306 | if type(mixin.OnEmbedEnable) == "function" then |
||
307 | mixin:OnEmbedEnable(addon) |
||
308 | end |
||
309 | end |
||
310 | end |
||
311 | current = current.super |
||
312 | end |
||
313 | if type(addon.OnEnable) == "function" then |
||
314 | addon:OnEnable() |
||
315 | end |
||
316 | end |
||
317 | end |
||
318 | self.addonsToOnEnable = nil |
||
319 | end |
||
320 | end |
||
321 | |||
322 | function AceAddon.prototype:Inject(t) |
||
323 | AceAddon:argCheck(t, 2, "table") |
||
324 | for k,v in pairs(t) do |
||
325 | self[k] = v |
||
326 | end |
||
327 | end |
||
328 | |||
329 | function AceAddon.prototype:init() |
||
330 | if not AceEvent then |
||
331 | error(MAJOR_VERSION .. " requires AceEvent-2.0", 4) |
||
332 | end |
||
333 | AceAddon.super.prototype.init(self) |
||
334 | |||
335 | self.super = self.class.prototype |
||
336 | |||
337 | AceAddon:RegisterEvent("ADDON_LOADED", "ADDON_LOADED", true) |
||
338 | table.insert(AceAddon.nextAddon, self) |
||
339 | end |
||
340 | |||
341 | function AceAddon.prototype:ToString() |
||
342 | local x |
||
343 | if type(self.title) == "string" then |
||
344 | x = self.title |
||
345 | elseif type(self.name) == "string" then |
||
346 | x = self.name |
||
347 | else |
||
348 | x = "<" .. tostring(self.class) .. " instance>" |
||
349 | end |
||
350 | if (type(self.IsActive) == "function" and not self:IsActive()) or (AceModuleCore and AceModuleCore:IsModule(addon) and AceModuleCore:IsModuleActive(addon)) then |
||
351 | x = x .. " " .. STANDBY |
||
352 | end |
||
353 | return x |
||
354 | end |
||
355 | |||
356 | AceAddon.new = function(self, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20) |
||
357 | local class = AceAddon:pcall(AceOO.Classpool, self, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20) |
||
358 | return class:new() |
||
359 | end |
||
360 | |||
361 | local function external(self, major, instance) |
||
362 | if major == "AceEvent-2.0" then |
||
363 | AceEvent = instance |
||
364 | |||
365 | AceEvent:embed(self) |
||
366 | |||
367 | self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true) |
||
368 | elseif major == "AceConsole-2.0" then |
||
369 | AceConsole = instance |
||
370 | |||
371 | local slashCommands = { "/ace2" } |
||
372 | local _,_,_,enabled,loadable = GetAddOnInfo("Ace") |
||
373 | if not enabled or not loadable then |
||
374 | table.insert(slashCommands, "/ace") |
||
375 | end |
||
376 | local function listAddon(addon, depth) |
||
377 | if not depth then |
||
378 | depth = 0 |
||
379 | end |
||
380 | |||
381 | local s = string.rep(" ", depth) .. " - " .. tostring(addon) |
||
382 | if addon.version then |
||
383 | s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r" |
||
384 | end |
||
385 | if addon.slashCommand then |
||
386 | s = s .. " |cffffff7f(" .. tostring(addon.slashCommand) .. ")|r" |
||
387 | end |
||
388 | print(s) |
||
389 | if type(addon.modules) == "table" then |
||
390 | local i = 0 |
||
391 | for k,v in pairs(addon.modules) do |
||
392 | i = i + 1 |
||
393 | if i == 6 then |
||
394 | print(string.rep(" ", depth + 1) .. " - more...") |
||
395 | break |
||
396 | else |
||
397 | listAddon(v, depth + 1) |
||
398 | end |
||
399 | end |
||
400 | end |
||
401 | end |
||
402 | local function listNormalAddon(i) |
||
403 | local name,_,_,enabled,loadable = GetAddOnInfo(i) |
||
404 | if not loadable then |
||
405 | enabled = false |
||
406 | end |
||
407 | if self.addons[name] then |
||
408 | local addon = self.addons[name] |
||
409 | if not AceCoreAddon or not AceCoreAddon:IsModule(addon) then |
||
410 | listAddon(addon) |
||
411 | end |
||
412 | else |
||
413 | local s = " - " .. tostring(GetAddOnMetadata(i, "Title") or name) |
||
414 | local version = GetAddOnMetadata(i, "Version") |
||
415 | if version then |
||
416 | if string.find(version, "%$Revision: (%d+) %$") then |
||
417 | version = string.gsub(version, "%$Revision: (%d+) %$", "%1") |
||
418 | elseif string.find(version, "%$Rev: (%d+) %$") then |
||
419 | version = string.gsub(version, "%$Rev: (%d+) %$", "%1") |
||
420 | elseif string.find(version, "%$LastChangedRevision: (%d+) %$") then |
||
421 | version = string.gsub(version, "%$LastChangedRevision: (%d+) %$", "%1") |
||
422 | end |
||
423 | s = s .. " - |cffffff7f" .. version .. "|r" |
||
424 | end |
||
425 | if not enabled then |
||
426 | s = s .. " |cffff0000(disabled)|r" |
||
427 | end |
||
428 | if IsAddOnLoadOnDemand(i) then |
||
429 | s = s .. " |cff00ff00[LoD]|r" |
||
430 | end |
||
431 | print(s) |
||
432 | end |
||
433 | end |
||
434 | local function mySort(alpha, bravo) |
||
435 | return tostring(alpha) < tostring(bravo) |
||
436 | end |
||
437 | AceConsole.RegisterChatCommand(self, slashCommands, { |
||
438 | desc = "AddOn development framework", |
||
439 | name = "Ace2", |
||
440 | type = "group", |
||
441 | args = { |
||
442 | about = { |
||
443 | desc = "Get information about Ace2", |
||
444 | name = "About", |
||
445 | type = "execute", |
||
446 | func = function() |
||
447 | print("|cffffff7fAce2|r - |cffffff7f2.0." .. string.gsub(MINOR_VERSION, "%$Revision: (%d+) %$", "%1") .. "|r - AddOn development framework") |
||
448 | print(" - |cffffff7f" .. AUTHOR .. ":|r Ace Development Team") |
||
449 | print(" - |cffffff7f" .. WEBSITE .. ":|r http://www.wowace.com/") |
||
450 | end |
||
451 | }, |
||
452 | list = { |
||
453 | desc = "List addons", |
||
454 | name = "List", |
||
455 | type = "group", |
||
456 | args = { |
||
457 | ace2 = { |
||
458 | desc = "List addons using Ace2", |
||
459 | name = "Ace2", |
||
460 | type = "execute", |
||
461 | func = function() |
||
462 | print("|cffffff7fAddon list:|r") |
||
463 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
464 | table.sort(self.addons, mySort) |
||
465 | for _,v in ipairs(self.addons) do |
||
466 | if not AceCoreAddon or not AceCoreAddon:IsModule(v) then |
||
467 | listAddon(v) |
||
468 | end |
||
469 | end |
||
470 | end |
||
471 | }, |
||
472 | all = { |
||
473 | desc = "List all addons", |
||
474 | name = "All", |
||
475 | type = "execute", |
||
476 | func = function() |
||
477 | print("|cffffff7fAddon list:|r") |
||
478 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
479 | local count = GetNumAddOns() |
||
480 | for i = 1, count do |
||
481 | listNormalAddon(i) |
||
482 | end |
||
483 | end |
||
484 | }, |
||
485 | enabled = { |
||
486 | desc = "List all enabled addons", |
||
487 | name = "Enabled", |
||
488 | type = "execute", |
||
489 | func = function() |
||
490 | print("|cffffff7fAddon list:|r") |
||
491 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
492 | local count = GetNumAddOns() |
||
493 | for i = 1, count do |
||
494 | local _,_,_,enabled,loadable = GetAddOnInfo(i) |
||
495 | if enabled and loadable then |
||
496 | listNormalAddon(i) |
||
497 | end |
||
498 | end |
||
499 | end |
||
500 | }, |
||
501 | disabled = { |
||
502 | desc = "List all disabled addons", |
||
503 | name = "Disabled", |
||
504 | type = "execute", |
||
505 | func = function() |
||
506 | print("|cffffff7fAddon list:|r") |
||
507 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
508 | local count = GetNumAddOns() |
||
509 | for i = 1, count do |
||
510 | local _,_,_,enabled,loadable = GetAddOnInfo(i) |
||
511 | if not enabled or not loadable then |
||
512 | listNormalAddon(i) |
||
513 | end |
||
514 | end |
||
515 | end |
||
516 | }, |
||
517 | lod = { |
||
518 | desc = "List all LoadOnDemand addons", |
||
519 | name = "LoadOnDemand", |
||
520 | type = "execute", |
||
521 | func = function() |
||
522 | print("|cffffff7fAddon list:|r") |
||
523 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
524 | local count = GetNumAddOns() |
||
525 | for i = 1, count do |
||
526 | if IsAddOnLoadOnDemand(i) then |
||
527 | listNormalAddon(i) |
||
528 | end |
||
529 | end |
||
530 | end |
||
531 | }, |
||
532 | ace1 = { |
||
533 | desc = "List all addons using Ace1", |
||
534 | name = "Ace 1.x", |
||
535 | type = "execute", |
||
536 | func = function() |
||
537 | print("|cffffff7fAddon list:|r") |
||
538 | local count = GetNumAddOns() |
||
539 | for i = 1, count do |
||
540 | local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) |
||
541 | if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then |
||
542 | listNormalAddon(i) |
||
543 | end |
||
544 | end |
||
545 | end |
||
546 | }, |
||
547 | libs = { |
||
548 | desc = "List all libraries using AceLibrary", |
||
549 | name = "Libraries", |
||
550 | type = "execute", |
||
551 | func = function() |
||
552 | if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then |
||
553 | print("|cffffff7fLibrary list:|r") |
||
554 | for name, data in pairs(AceLibrary.libs) do |
||
555 | local s |
||
556 | if data.minor then |
||
557 | s = " - " .. tostring(name) .. "." .. tostring(data.minor) |
||
558 | else |
||
559 | s = " - " .. tostring(name) |
||
560 | end |
||
561 | if AceLibrary(name).slashCommand then |
||
562 | s = s .. " |cffffff7f(" .. tostring(AceLibrary(name).slashCommand) .. "|cffffff7f)" |
||
563 | end |
||
564 | print(s) |
||
565 | end |
||
566 | end |
||
567 | end |
||
568 | }, |
||
569 | search = { |
||
570 | desc = "Search by name", |
||
571 | name = "Search", |
||
572 | type = "text", |
||
573 | usage = "<keyword>", |
||
574 | input = true, |
||
575 | get = false, |
||
576 | set = function(...) |
||
577 | for i,v in ipairs(arg) do |
||
578 | arg[i] = string.lower(string.gsub(string.gsub(v, '%*', '.*'), '%%', '%%%%')) |
||
579 | end |
||
580 | local count = GetNumAddOns() |
||
581 | for i = 1, count do |
||
582 | local name = GetAddOnInfo(i) |
||
583 | local good = true |
||
584 | for _,v in ipairs(arg) do |
||
585 | if not string.find(string.lower(name), v) then |
||
586 | good = false |
||
587 | break |
||
588 | end |
||
589 | end |
||
590 | if good then |
||
591 | listNormalAddon(i) |
||
592 | end |
||
593 | end |
||
594 | end |
||
595 | } |
||
596 | }, |
||
597 | }, |
||
598 | enable = { |
||
599 | desc = "Enable addon", |
||
600 | name = "Enable", |
||
601 | type = "text", |
||
602 | usage = "<addon>", |
||
603 | get = false, |
||
604 | set = function(text) |
||
605 | local name,title,_,_,_,reason = GetAddOnInfo(text) |
||
606 | if reason == "MISSING" then |
||
607 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text)) |
||
608 | else |
||
609 | EnableAddOn(text) |
||
610 | print(string.format("|cffffff7fAce2:|r %s is now enabled", title or name)) |
||
611 | end |
||
612 | end, |
||
613 | }, |
||
614 | disable = { |
||
615 | desc = "Disable addon", |
||
616 | name = "Disable", |
||
617 | type = "text", |
||
618 | usage = "<addon>", |
||
619 | get = false, |
||
620 | set = function(text) |
||
621 | local name,title,_,_,_,reason = GetAddOnInfo(text) |
||
622 | if reason == "MISSING" then |
||
623 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text)) |
||
624 | else |
||
625 | DisableAddOn(text) |
||
626 | print(string.format("|cffffff7fAce2:|r %s is now disabled", title or name)) |
||
627 | end |
||
628 | end, |
||
629 | }, |
||
630 | load = { |
||
631 | desc = "Load addon", |
||
632 | name = "Load", |
||
633 | type = "text", |
||
634 | usage = "<addon>", |
||
635 | get = false, |
||
636 | set = function(text) |
||
637 | local name,title,_,_,loadable,reason = GetAddOnInfo(text) |
||
638 | if reason == "MISSING" then |
||
639 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist.", text)) |
||
640 | elseif not loadable then |
||
641 | print(string.format("|cffffff7fAce2:|r AddOn %q is not loadable. Reason: %s", text, reason)) |
||
642 | else |
||
643 | LoadAddOn(text) |
||
644 | print(string.format("|cffffff7fAce2:|r %s is now loaded", title or name)) |
||
645 | end |
||
646 | end |
||
647 | }, |
||
648 | info = { |
||
649 | desc = "Display information", |
||
650 | name = "Information", |
||
651 | type = "execute", |
||
652 | func = function() |
||
653 | local mem, threshold = gcinfo() |
||
654 | print(string.format(" - |cffffff7fMemory usage [|r%.3f MiB|cffffff7f]|r", mem / 1024)) |
||
655 | print(string.format(" - |cffffff7fThreshold [|r%.3f MiB|cffffff7f]|r", threshold / 1024)) |
||
656 | print(string.format(" - |cffffff7fFramerate [|r%.0f fps|cffffff7f]|r", GetFramerate())) |
||
657 | local bandwidthIn, bandwidthOut, latency = GetNetStats() |
||
658 | bandwidthIn, bandwidthOut = floor(bandwidthIn * 1024), floor(bandwidthOut * 1024) |
||
659 | print(string.format(" - |cffffff7fLatency [|r%.0f ms|cffffff7f]|r", latency)) |
||
660 | print(string.format(" - |cffffff7fBandwidth in [|r%.0f B/s|cffffff7f]|r", bandwidthIn)) |
||
661 | print(string.format(" - |cffffff7fBandwidth out [|r%.0f B/s|cffffff7f]|r", bandwidthOut)) |
||
662 | print(string.format(" - |cffffff7fTotal addons [|r%d|cffffff7f]|r", GetNumAddOns())) |
||
663 | print(string.format(" - |cffffff7fAce2 addons [|r%d|cffffff7f]|r", table.getn(self.addons))) |
||
664 | local ace = 0 |
||
665 | local enabled = 0 |
||
666 | local disabled = 0 |
||
667 | local lod = 0 |
||
668 | for i = 1, GetNumAddOns() do |
||
669 | local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) |
||
670 | if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then |
||
671 | ace = ace + 1 |
||
672 | end |
||
673 | if IsAddOnLoadOnDemand(i) then |
||
674 | lod = lod + 1 |
||
675 | end |
||
676 | local _,_,_,IsActive,loadable = GetAddOnInfo(i) |
||
677 | if not IsActive or not loadable then |
||
678 | disabled = disabled + 1 |
||
679 | else |
||
680 | enabled = enabled + 1 |
||
681 | end |
||
682 | end |
||
683 | print(string.format(" - |cffffff7fAce 1.x addons [|r%d|cffffff7f]|r", ace)) |
||
684 | print(string.format(" - |cffffff7fLoadOnDemand addons [|r%d|cffffff7f]|r", lod)) |
||
685 | print(string.format(" - |cffffff7fenabled addons [|r%d|cffffff7f]|r", enabled)) |
||
686 | print(string.format(" - |cffffff7fdisabled addons [|r%d|cffffff7f]|r", disabled)) |
||
687 | local libs = 0 |
||
688 | if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then |
||
689 | for _ in pairs(AceLibrary.libs) do |
||
690 | libs = libs + 1 |
||
691 | end |
||
692 | end |
||
693 | print(string.format(" - |cffffff7fAceLibrary instances [|r%d|cffffff7f]|r", libs)) |
||
694 | end |
||
695 | } |
||
696 | } |
||
697 | }) |
||
698 | elseif major == "AceModuleCore-2.0" then |
||
699 | AceModuleCore = instance |
||
700 | end |
||
701 | end |
||
702 | |||
703 | local function activate(self, oldLib, oldDeactivate) |
||
704 | AceAddon = self |
||
705 | |||
706 | if oldLib then |
||
707 | self.playerLoginFired = oldLib.playerLoginFired or DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage |
||
708 | self.addonsToOnEnable = oldLib.addonsToOnEnable |
||
709 | self.addons = oldLib.addons |
||
710 | self.nextAddon = oldLib.nextAddon |
||
711 | self.addonsStarted = oldLib.addonsStarted |
||
712 | end |
||
713 | if not self.addons then |
||
714 | self.addons = {} |
||
715 | end |
||
716 | if not self.nextAddon then |
||
717 | self.nextAddon = {} |
||
718 | end |
||
719 | if not self.addonsStarted then |
||
720 | self.addonsStarted = {} |
||
721 | end |
||
722 | if oldDeactivate then |
||
723 | oldDeactivate(oldLib) |
||
724 | end |
||
725 | end |
||
726 | |||
727 | AceLibrary:Register(AceAddon, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |
||
728 | AceAddon = AceLibrary(MAJOR_VERSION) |