vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Name: AceAddon-2.0
3 Revision: $Rev: 16523 $
4 Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team)
5 Inspired By: Ace 1.x by Turan (turan@gryphon.com)
6 Website: http://www.wowace.com/
7 Documentation: http://www.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: 16523 $"
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, CREDITS, WEBSITE, CATEGORIES, ABOUT, PRINT_ADDON_INFO
24 if GetLocale() == "deDE" then
25 STANDBY = "|cffff5050(Standby)|r" -- capitalized
26  
27 TITLE = "Titel"
28 NOTES = "Anmerkung"
29 VERSION = "Version"
30 AUTHOR = "Autor"
31 DATE = "Datum"
32 CATEGORY = "Kategorie"
33 EMAIL = "E-mail"
34 WEBSITE = "Webseite"
35 CREDITS = "Credits" -- fix
36  
37 ABOUT = "\195\188ber"
38 PRINT_ADDON_INFO = "Gibt Addondaten aus"
39  
40 CATEGORIES = {
41 ["Action Bars"] = "Aktionsleisten",
42 ["Auction"] = "Auktion",
43 ["Audio"] = "Audio",
44 ["Battlegrounds/PvP"] = "Schlachtfeld/PvP",
45 ["Buffs"] = "Buffs",
46 ["Chat/Communication"] = "Chat/Kommunikation",
47 ["Druid"] = "Druide",
48 ["Hunter"] = "Jger",
49 ["Mage"] = "Magier",
50 ["Paladin"] = "Paladin",
51 ["Priest"] = "Priester",
52 ["Rogue"] = "Schurke",
53 ["Shaman"] = "Schamane",
54 ["Warlock"] = "Hexenmeister",
55 ["Warrior"] = "Krieger",
56 ["Healer"] = "Heiler",
57 ["Tank"] = "Tank", -- noone use "Brecher"...
58 ["Caster"] = "Caster",
59 ["Combat"] = "Kampf",
60 ["Compilations"] = "Compilations", -- whats that o_O
61 ["Data Export"] = "Datenexport",
62 ["Development Tools"] = "Entwicklungs Tools",
63 ["Guild"] = "Gilde",
64 ["Frame Modification"] = "Frame Modifikation",
65 ["Interface Enhancements"] = "Interface Verbesserungen",
66 ["Inventory"] = "Inventar",
67 ["Library"] = "Library",
68 ["Map"] = "Map",
69 ["Mail"] = "Mail",
70 ["Miscellaneous"] = "Diverses",
71 ["Quest"] = "Quest",
72 ["Raid"] = "Schlachtzug",
73 ["Tradeskill"] = "Handelsf\195\164higkeit",
74 ["UnitFrame"] = "UnitFrame",
75 }
76 elseif GetLocale() == "frFR" then
77 STANDBY = "|cffff5050(attente)|r"
78  
79 TITLE = "Titre"
80 NOTES = "Notes"
81 VERSION = "Version"
82 AUTHOR = "Auteur"
83 DATE = "Date"
84 CATEGORY = "Cat\195\169gorie"
85 EMAIL = "E-mail"
86 WEBSITE = "Site web"
87 CREDITS = "Credits" -- fix
88  
89 ABOUT = "A propos"
90 PRINT_ADDON_INFO = "Afficher les informations sur l'addon"
91  
92 CATEGORIES = {
93 ["Action Bars"] = "Barres d'action",
94 ["Auction"] = "H\195\180tel des ventes",
95 ["Audio"] = "Audio",
96 ["Battlegrounds/PvP"] = "Champs de bataille/JcJ",
97 ["Buffs"] = "Buffs",
98 ["Chat/Communication"] = "Chat/Communication",
99 ["Druid"] = "Druide",
100 ["Hunter"] = "Chasseur",
101 ["Mage"] = "Mage",
102 ["Paladin"] = "Paladin",
103 ["Priest"] = "Pr\195\170tre",
104 ["Rogue"] = "Voleur",
105 ["Shaman"] = "Chaman",
106 ["Warlock"] = "D\195\169moniste",
107 ["Warrior"] = "Guerrier",
108 ["Healer"] = "Soigneur",
109 ["Tank"] = "Tank",
110 ["Caster"] = "Casteur",
111 ["Combat"] = "Combat",
112 ["Compilations"] = "Compilations",
113 ["Data Export"] = "Exportation de donn\195\169es",
114 ["Development Tools"] = "Outils de d\195\169veloppement",
115 ["Guild"] = "Guilde",
116 ["Frame Modification"] = "Modification des fen\195\170tres",
117 ["Interface Enhancements"] = "Am\195\169liorations de l'interface",
118 ["Inventory"] = "Inventaire",
119 ["Library"] = "Biblioth\195\168ques",
120 ["Map"] = "Carte",
121 ["Mail"] = "Courrier",
122 ["Miscellaneous"] = "Divers",
123 ["Quest"] = "Qu\195\170tes",
124 ["Raid"] = "Raid",
125 ["Tradeskill"] = "M\195\169tiers",
126 ["UnitFrame"] = "Fen\195\170tres d'unit\195\169",
127 }
128 elseif GetLocale() == "koKR" then
129 STANDBY = "|cffff5050(사용가능)|r"
130  
131 TITLE = "제목"
132 NOTES = "노트"
133 VERSION = "버전"
134 AUTHOR = "저작자"
135 DATE = "날짜"
136 CATEGORY = "분류"
137 EMAIL = "E-mail"
138 WEBSITE = "웹사이트"
139 CREDITS = "Credits" -- fix
140  
141 ABOUT = "정보"
142 PRINT_ADDON_INFO = "애드온 정보 출력"
143  
144 CATEGORIES = {
145 ["Action Bars"] = "액션바",
146 ["Auction"] = "경매",
147 ["Audio"] = "음향",
148 ["Battlegrounds/PvP"] = "전장/PvP",
149 ["Buffs"] = "버프",
150 ["Chat/Communication"] = "대화/의사소통",
151 ["Druid"] = "드루이드",
152 ["Hunter"] = "사냥꾼",
153 ["Mage"] = "마법사",
154 ["Paladin"] = "성기사",
155 ["Priest"] = "사제",
156 ["Rogue"] = "도적",
157 ["Shaman"] = "주술사",
158 ["Warlock"] = "흑마법사",
159 ["Warrior"] = "전사",
160 ["Healer"] = "힐러",
161 ["Tank"] = "탱커",
162 ["Caster"] = "캐스터",
163 ["Combat"] = "전투",
164 ["Compilations"] = "복합",
165 ["Data Export"] = "자료 출력",
166 ["Development Tools"] = "개발 도구",
167 ["Guild"] = "길드",
168 ["Frame Modification"] = "구조 변경",
169 ["Interface Enhancements"] = "인터페이스 강화",
170 ["Inventory"] = "인벤토리",
171 ["Library"] = "라이브러리",
172 ["Map"] = "지도",
173 ["Mail"] = "우편",
174 ["Miscellaneous"] = "기타",
175 ["Quest"] = "퀘스트",
176 ["Raid"] = "공격대",
177 ["Tradeskill"] = "전문기술",
178 ["UnitFrame"] = "유닛 프레임",
179 }
180 elseif GetLocale() == "zhTW" then
181 STANDBY = "|cffff5050(待命)|r"
182  
183 TITLE = "標題"
184 NOTES = "註記"
185 VERSION = "版本"
186 AUTHOR = "作者"
187 DATE = "日期"
188 CATEGORY = "類別"
189 EMAIL = "E-mail"
190 WEBSITE = "網站"
191 CREDITS = "Credits" -- fix
192  
193 ABOUT = "關於"
194 PRINT_ADDON_INFO = "顯示插件資訊"
195  
196 CATEGORIES = {
197 ["Action Bars"] = "動作列",
198 ["Auction"] = "拍賣",
199 ["Audio"] = "音樂",
200 ["Battlegrounds/PvP"] = "戰場/PvP",
201 ["Buffs"] = "增益",
202 ["Chat/Communication"] = "聊天/通訊",
203 ["Druid"] = "德魯伊",
204 ["Hunter"] = "獵人",
205 ["Mage"] = "法師",
206 ["Paladin"] = "聖騎士",
207 ["Priest"] = "牧師",
208 ["Rogue"] = "盜賊",
209 ["Shaman"] = "薩滿",
210 ["Warlock"] = "術士",
211 ["Warrior"] = "戰士",
212 ["Healer"] = "治療者",
213 ["Tank"] = "坦克",
214 ["Caster"] = "施法者",
215 ["Combat"] = "戰鬥",
216 ["Compilations"] = "編輯",
217 ["Data Export"] = "資料匯出",
218 ["Development Tools"] = "開發工具",
219 ["Guild"] = "公會",
220 ["Frame Modification"] = "框架修改",
221 ["Interface Enhancements"] = "介面增強",
222 ["Inventory"] = "背包",
223 ["Library"] = "資料庫",
224 ["Map"] = "地圖",
225 ["Mail"] = "郵件",
226 ["Miscellaneous"] = "綜合",
227 ["Quest"] = "任務",
228 ["Raid"] = "團隊",
229 ["Tradeskill"] = "商業技能",
230 ["UnitFrame"] = "單位框架",
231 }
232 elseif GetLocale() == "zhCN" then
233 STANDBY = "|cffff5050(\230\154\130\230\140\130)|r"
234  
235 TITLE = "\230\160\135\233\162\152"
236 NOTES = "\233\153\132\230\179\168"
237 VERSION = "\231\137\136\230\156\172"
238 AUTHOR = "\228\189\156\232\128\133"
239 DATE = "\230\151\165\230\156\159"
240 CATEGORY = "\229\136\134\231\177\187"
241 EMAIL = "\231\148\181\229\173\144\233\130\174\228\187\182"
242 WEBSITE = "\231\189\145\231\171\153"
243 CREDITS = "Credits" -- fix
244  
245 ABOUT = "\229\133\179\228\186\142"
246 PRINT_ADDON_INFO = "\229\141\176\229\136\151\229\135\186\230\143\146\228\187\182\228\191\161\230\129\175"
247  
248 CATEGORIES = {
249 ["Action Bars"] = "\229\138\168\228\189\156\230\157\161",
250 ["Auction"] = "\230\139\141\229\141\150",
251 ["Audio"] = "\233\159\179\233\162\145",
252 ["Battlegrounds/PvP"] = "\230\136\152\229\156\186/PvP",
253 ["Buffs"] = "\229\162\158\231\155\138\233\173\148\230\179\149",
254 ["Chat/Communication"] = "\232\129\138\229\164\169/\228\186\164\230\181\129",
255 ["Druid"] = "\229\190\183\233\178\129\228\188\138",
256 ["Hunter"] = "\231\140\142\228\186\186",
257 ["Mage"] = "\230\179\149\229\184\136",
258 ["Paladin"] = "\229\156\163\233\170\145\229\163\171",
259 ["Priest"] = "\231\137\167\229\184\136",
260 ["Rogue"] = "\231\155\151\232\180\188",
261 ["Shaman"] = "\232\144\168\230\187\161\231\165\173\229\143\184",
262 ["Warlock"] = "\230\156\175\229\163\171",
263 ["Warrior"] = "\230\136\152\229\163\171",
264 -- ["Healer"] = "\230\178\187\231\150\151\228\191\157\233\154\156",
265 -- ["Tank"] = "\232\191\145\230\136\152\230\142\167\229\136\182",
266 -- ["Caster"] = "\232\191\156\231\168\139\232\190\147\229\135\186",
267 ["Combat"] = "\230\136\152\230\150\151",
268 ["Compilations"] = "\231\188\150\232\175\145",
269 ["Data Export"] = "\230\149\176\230\141\174\229\175\188\229\135\186",
270 ["Development Tools"] = "\229\188\128\229\143\145\229\183\165\229\133\183",
271 ["Guild"] = "\229\133\172\228\188\154",
272 ["Frame Modification"] = "\230\161\134\230\158\182\228\191\174\230\148\185",
273 ["Interface Enhancements"] = "\231\149\140\233\157\162\229\162\158\229\188\186",
274 ["Inventory"] = "\232\131\140\229\140\133",
275 ["Library"] = "\229\186\147",
276 ["Map"] = "\229\156\176\229\155\190",
277 ["Mail"] = "\233\130\174\228\187\182",
278 ["Miscellaneous"] = "\230\157\130\233\161\185",
279 ["Quest"] = "\228\187\187\229\138\161",
280 ["Raid"] = "\229\155\162\233\152\159",
281 ["Tradeskill"] = "\229\149\134\228\184\154\230\138\128\232\131\189",
282 ["UnitFrame"] = "\229\164\180\229\131\143\230\161\134\230\158\182",
283 }
284 else -- enUS
285 STANDBY = "|cffff5050(standby)|r"
286  
287 TITLE = "Title"
288 NOTES = "Notes"
289 VERSION = "Version"
290 AUTHOR = "Author"
291 DATE = "Date"
292 CATEGORY = "Category"
293 EMAIL = "E-mail"
294 WEBSITE = "Website"
295 CREDITS = "Credits"
296  
297 ABOUT = "About"
298 PRINT_ADDON_INFO = "Print out addon info"
299  
300 CATEGORIES = {
301 ["Action Bars"] = "Action Bars",
302 ["Auction"] = "Auction",
303 ["Audio"] = "Audio",
304 ["Battlegrounds/PvP"] = "Battlegrounds/PvP",
305 ["Buffs"] = "Buffs",
306 ["Chat/Communication"] = "Chat/Communication",
307 ["Druid"] = "Druid",
308 ["Hunter"] = "Hunter",
309 ["Mage"] = "Mage",
310 ["Paladin"] = "Paladin",
311 ["Priest"] = "Priest",
312 ["Rogue"] = "Rogue",
313 ["Shaman"] = "Shaman",
314 ["Warlock"] = "Warlock",
315 ["Warrior"] = "Warrior",
316 ["Healer"] = "Healer",
317 ["Tank"] = "Tank",
318 ["Caster"] = "Caster",
319 ["Combat"] = "Combat",
320 ["Compilations"] = "Compilations",
321 ["Data Export"] = "Data Export",
322 ["Development Tools"] = "Development Tools",
323 ["Guild"] = "Guild",
324 ["Frame Modification"] = "Frame Modification",
325 ["Interface Enhancements"] = "Interface Enhancements",
326 ["Inventory"] = "Inventory",
327 ["Library"] = "Library",
328 ["Map"] = "Map",
329 ["Mail"] = "Mail",
330 ["Miscellaneous"] = "Miscellaneous",
331 ["Quest"] = "Quest",
332 ["Raid"] = "Raid",
333 ["Tradeskill"] = "Tradeskill",
334 ["UnitFrame"] = "UnitFrame",
335 }
336 end
337  
338 setmetatable(CATEGORIES, { __index = function(self, key) -- case-insensitive
339 local lowerKey = string.lower(key)
340 for k,v in pairs(CATEGORIES) do
341 if string.lower(k) == lowerKey then
342 return v
343 end
344 end
345 end })
346  
347 -- Create the library object
348  
349 local AceOO = AceLibrary("AceOO-2.0")
350 local AceAddon = AceOO.Class()
351 local AceEvent
352 local AceConsole
353 local AceModuleCore
354  
355 function AceAddon:ToString()
356 return "AceAddon"
357 end
358  
359 local function print(text)
360 DEFAULT_CHAT_FRAME:AddMessage(text)
361 end
362  
363 function AceAddon:ADDON_LOADED(name)
364 while table.getn(self.nextAddon) > 0 do
365 local addon = table.remove(self.nextAddon, 1)
366 table.insert(self.addons, addon)
367 if not self.addons[name] then
368 self.addons[name] = addon
369 end
370 self:InitializeAddon(addon, name)
371 end
372 end
373  
374 local function RegisterOnEnable(self)
375 if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage then -- HACK
376 AceAddon.playerLoginFired = true
377 end
378 if AceAddon.playerLoginFired then
379 AceAddon.addonsStarted[self] = true
380 if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then
381 local current = self.class
382 while true do
383 if current == AceOO.Class then
384 break
385 end
386 if current.mixins then
387 for mixin in pairs(current.mixins) do
388 if type(mixin.OnEmbedEnable) == "function" then
389 mixin:OnEmbedEnable(self)
390 end
391 end
392 end
393 current = current.super
394 end
395 if type(self.OnEnable) == "function" then
396 self:OnEnable()
397 end
398 end
399 else
400 if not AceAddon.addonsToOnEnable then
401 AceAddon.addonsToOnEnable = {}
402 end
403 table.insert(AceAddon.addonsToOnEnable, self)
404 end
405 end
406  
407 local function stripSpaces(text)
408 if type(text) == "string" then
409 return (string.gsub(string.gsub(text, "^%s*(.-)%s*$", "%1"), "%s%s+", " "))
410 end
411 return text
412 end
413  
414 function AceAddon:InitializeAddon(addon, name)
415 if addon.name == nil then
416 addon.name = name
417 end
418 if GetAddOnMetadata then
419 -- TOC checks
420 if addon.title == nil then
421 addon.title = GetAddOnMetadata(name, "Title")
422 if addon.title then
423 local num = string.find(addon.title, " |cff7fff7f %-Ace2%-|r$")
424 if num then
425 addon.title = string.sub(addon.title, 1, num - 1)
426 end
427 addon.title = stripSpaces(addon.title)
428 end
429 end
430 if addon.notes == nil then
431 addon.notes = GetAddOnMetadata(name, "Notes")
432 addon.notes = stripSpaces(addon.notes)
433 end
434 if addon.version == nil then
435 addon.version = GetAddOnMetadata(name, "Version")
436 if addon.version then
437 if string.find(addon.version, "%$Revision: (%d+) %$") then
438 addon.version = string.gsub(addon.version, "%$Revision: (%d+) %$", "%1")
439 elseif string.find(addon.version, "%$Rev: (%d+) %$") then
440 addon.version = string.gsub(addon.version, "%$Rev: (%d+) %$", "%1")
441 elseif string.find(addon.version, "%$LastChangedRevision: (%d+) %$") then
442 addon.version = string.gsub(addon.version, "%$LastChangedRevision: (%d+) %$", "%1")
443 end
444 end
445 addon.version = stripSpaces(addon.version)
446 end
447 if addon.author == nil then
448 addon.author = GetAddOnMetadata(name, "Author")
449 addon.author = stripSpaces(addon.author)
450 end
451 if addon.credits == nil then
452 addon.credits = GetAddOnMetadata(name, "X-Credits")
453 addon.credits = stripSpaces(addon.credits)
454 end
455 if addon.date == nil then
456 addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate")
457 if addon.date then
458 if string.find(addon.date, "%$Date: (.-) %$") then
459 addon.date = string.gsub(addon.date, "%$Date: (.-) %$", "%1")
460 elseif string.find(addon.date, "%$LastChangedDate: (.-) %$") then
461 addon.date = string.gsub(addon.date, "%$LastChangedDate: (.-) %$", "%1")
462 end
463 end
464 addon.date = stripSpaces(addon.date)
465 end
466 if addon.category == nil then
467 addon.category = GetAddOnMetadata(name, "X-Category")
468 addon.category = stripSpaces(addon.category)
469 end
470 if addon.email == nil then
471 addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email")
472 addon.email = stripSpaces(addon.email)
473 end
474 if addon.website == nil then
475 addon.website = GetAddOnMetadata(name, "X-Website")
476 addon.website = stripSpaces(addon.website)
477 end
478 end
479 local current = addon.class
480 while true do
481 if current == AceOO.Class then
482 break
483 end
484 if current.mixins then
485 for mixin in pairs(current.mixins) do
486 if type(mixin.OnEmbedInitialize) == "function" then
487 mixin:OnEmbedInitialize(addon, name)
488 end
489 end
490 end
491 current = current.super
492 end
493 if type(addon.OnInitialize) == "function" then
494 addon:OnInitialize(name)
495 end
496 RegisterOnEnable(addon)
497 end
498  
499 function AceAddon.prototype:PrintAddonInfo()
500 local x
501 if self.title then
502 x = "|cffffff7f" .. tostring(self.title) .. "|r"
503 elseif self.name then
504 x = "|cffffff7f" .. tostring(self.name) .. "|r"
505 else
506 x = "|cffffff7f<" .. tostring(self.class) .. " instance>|r"
507 end
508 if type(self.IsActive) == "function" then
509 if not self:IsActive() then
510 x = x .. " " .. STANDBY
511 end
512 end
513 if self.version then
514 x = x .. " - |cffffff7f" .. tostring(self.version) .. "|r"
515 end
516 if self.notes then
517 x = x .. " - " .. tostring(self.notes)
518 end
519 print(x)
520 if self.author then
521 print(" - |cffffff7f" .. AUTHOR .. ":|r " .. tostring(self.author))
522 end
523 if self.credits then
524 print(" - |cffffff7f" .. CREDITS .. ":|r " .. tostring(self.credits))
525 end
526 if self.date then
527 print(" - |cffffff7f" .. DATE .. ":|r " .. tostring(self.date))
528 end
529 if self.category then
530 local category = CATEGORIES[self.category]
531 if category then
532 print(" - |cffffff7f" .. CATEGORY .. ":|r " .. category)
533 end
534 end
535 if self.email then
536 print(" - |cffffff7f" .. EMAIL .. ":|r " .. tostring(self.email))
537 end
538 if self.website then
539 print(" - |cffffff7f" .. WEBSITE .. ":|r " .. tostring(self.website))
540 end
541 end
542  
543 local options
544 function AceAddon:GetAceOptionsDataTable(target)
545 if not options then
546 options = {
547 about = {
548 name = ABOUT,
549 desc = PRINT_ADDON_INFO,
550 type = "execute",
551 func = "PrintAddonInfo",
552 order = -1,
553 }
554 }
555 end
556 return options
557 end
558  
559 function AceAddon:PLAYER_LOGIN()
560 self.playerLoginFired = true
561 if self.addonsToOnEnable then
562 while table.getn(self.addonsToOnEnable) > 0 do
563 local addon = table.remove(self.addonsToOnEnable, 1)
564 self.addonsStarted[addon] = true
565 if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then
566 local current = addon.class
567 while true do
568 if current == AceOO.Class then
569 break
570 end
571 if current.mixins then
572 for mixin in pairs(current.mixins) do
573 if type(mixin.OnEmbedEnable) == "function" then
574 mixin:OnEmbedEnable(addon)
575 end
576 end
577 end
578 current = current.super
579 end
580 if type(addon.OnEnable) == "function" then
581 addon:OnEnable()
582 end
583 end
584 end
585 self.addonsToOnEnable = nil
586 end
587 end
588  
589 function AceAddon.prototype:Inject(t)
590 AceAddon:argCheck(t, 2, "table")
591 for k,v in pairs(t) do
592 self[k] = v
593 end
594 end
595  
596 function AceAddon.prototype:init()
597 if not AceEvent then
598 error(MAJOR_VERSION .. " requires AceEvent-2.0", 4)
599 end
600 AceAddon.super.prototype.init(self)
601  
602 self.super = self.class.prototype
603  
604 AceAddon:RegisterEvent("ADDON_LOADED", "ADDON_LOADED", true)
605 table.insert(AceAddon.nextAddon, self)
606 end
607  
608 function AceAddon.prototype:ToString()
609 local x
610 if type(self.title) == "string" then
611 x = self.title
612 elseif type(self.name) == "string" then
613 x = self.name
614 else
615 x = "<" .. tostring(self.class) .. " instance>"
616 end
617 if (type(self.IsActive) == "function" and not self:IsActive()) or (AceModuleCore and AceModuleCore:IsModule(addon) and AceModuleCore:IsModuleActive(addon)) then
618 x = x .. " " .. STANDBY
619 end
620 return x
621 end
622  
623 AceAddon.new = function(self, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20)
624 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)
625 return class:new()
626 end
627  
628 local function external(self, major, instance)
629 if major == "AceEvent-2.0" then
630 AceEvent = instance
631  
632 AceEvent:embed(self)
633  
634 self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true)
635 elseif major == "AceConsole-2.0" then
636 AceConsole = instance
637  
638 local slashCommands = { "/ace2" }
639 local _,_,_,enabled,loadable = GetAddOnInfo("Ace")
640 if not enabled or not loadable then
641 table.insert(slashCommands, "/ace")
642 end
643 local function listAddon(addon, depth)
644 if not depth then
645 depth = 0
646 end
647  
648 local s = string.rep(" ", depth) .. " - " .. tostring(addon)
649 if rawget(addon, 'version') then
650 s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r"
651 end
652 if rawget(addon, 'slashCommand') then
653 s = s .. " |cffffff7f(" .. tostring(addon.slashCommand) .. ")|r"
654 end
655 print(s)
656 if type(rawget(addon, 'modules')) == "table" then
657 local i = 0
658 for k,v in pairs(addon.modules) do
659 i = i + 1
660 if i == 6 then
661 print(string.rep(" ", depth + 1) .. " - more...")
662 break
663 else
664 listAddon(v, depth + 1)
665 end
666 end
667 end
668 end
669 local function listNormalAddon(i)
670 local name,_,_,enabled,loadable = GetAddOnInfo(i)
671 if not loadable then
672 enabled = false
673 end
674 if self.addons[name] then
675 local addon = self.addons[name]
676 if not AceCoreAddon or not AceCoreAddon:IsModule(addon) then
677 listAddon(addon)
678 end
679 else
680 local s = " - " .. tostring(GetAddOnMetadata(i, "Title") or name)
681 local version = GetAddOnMetadata(i, "Version")
682 if version then
683 if string.find(version, "%$Revision: (%d+) %$") then
684 version = string.gsub(version, "%$Revision: (%d+) %$", "%1")
685 elseif string.find(version, "%$Rev: (%d+) %$") then
686 version = string.gsub(version, "%$Rev: (%d+) %$", "%1")
687 elseif string.find(version, "%$LastChangedRevision: (%d+) %$") then
688 version = string.gsub(version, "%$LastChangedRevision: (%d+) %$", "%1")
689 end
690 s = s .. " - |cffffff7f" .. version .. "|r"
691 end
692 if not enabled then
693 s = s .. " |cffff0000(disabled)|r"
694 end
695 if IsAddOnLoadOnDemand(i) then
696 s = s .. " |cff00ff00[LoD]|r"
697 end
698 print(s)
699 end
700 end
701 local function mySort(alpha, bravo)
702 return tostring(alpha) < tostring(bravo)
703 end
704 AceConsole.RegisterChatCommand(self, slashCommands, {
705 desc = "AddOn development framework",
706 name = "Ace2",
707 type = "group",
708 args = {
709 about = {
710 desc = "Get information about Ace2",
711 name = "About",
712 type = "execute",
713 func = function()
714 print("|cffffff7fAce2|r - |cffffff7f2.0." .. string.gsub(MINOR_VERSION, "%$Revision: (%d+) %$", "%1") .. "|r - AddOn development framework")
715 print(" - |cffffff7f" .. AUTHOR .. ":|r Ace Development Team")
716 print(" - |cffffff7f" .. WEBSITE .. ":|r http://www.wowace.com/")
717 end
718 },
719 list = {
720 desc = "List addons",
721 name = "List",
722 type = "group",
723 args = {
724 ace2 = {
725 desc = "List addons using Ace2",
726 name = "Ace2",
727 type = "execute",
728 func = function()
729 print("|cffffff7fAddon list:|r")
730 local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0")
731 table.sort(self.addons, mySort)
732 for _,v in ipairs(self.addons) do
733 if not AceCoreAddon or not AceCoreAddon:IsModule(v) then
734 listAddon(v)
735 end
736 end
737 end
738 },
739 all = {
740 desc = "List all addons",
741 name = "All",
742 type = "execute",
743 func = function()
744 print("|cffffff7fAddon list:|r")
745 local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0")
746 local count = GetNumAddOns()
747 for i = 1, count do
748 listNormalAddon(i)
749 end
750 end
751 },
752 enabled = {
753 desc = "List all enabled addons",
754 name = "Enabled",
755 type = "execute",
756 func = function()
757 print("|cffffff7fAddon list:|r")
758 local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0")
759 local count = GetNumAddOns()
760 for i = 1, count do
761 local _,_,_,enabled,loadable = GetAddOnInfo(i)
762 if enabled and loadable then
763 listNormalAddon(i)
764 end
765 end
766 end
767 },
768 disabled = {
769 desc = "List all disabled addons",
770 name = "Disabled",
771 type = "execute",
772 func = function()
773 print("|cffffff7fAddon list:|r")
774 local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0")
775 local count = GetNumAddOns()
776 for i = 1, count do
777 local _,_,_,enabled,loadable = GetAddOnInfo(i)
778 if not enabled or not loadable then
779 listNormalAddon(i)
780 end
781 end
782 end
783 },
784 lod = {
785 desc = "List all LoadOnDemand addons",
786 name = "LoadOnDemand",
787 type = "execute",
788 func = function()
789 print("|cffffff7fAddon list:|r")
790 local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0")
791 local count = GetNumAddOns()
792 for i = 1, count do
793 if IsAddOnLoadOnDemand(i) then
794 listNormalAddon(i)
795 end
796 end
797 end
798 },
799 ace1 = {
800 desc = "List all addons using Ace1",
801 name = "Ace 1.x",
802 type = "execute",
803 func = function()
804 print("|cffffff7fAddon list:|r")
805 local count = GetNumAddOns()
806 for i = 1, count do
807 local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i)
808 if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then
809 listNormalAddon(i)
810 end
811 end
812 end
813 },
814 libs = {
815 desc = "List all libraries using AceLibrary",
816 name = "Libraries",
817 type = "execute",
818 func = function()
819 if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then
820 print("|cffffff7fLibrary list:|r")
821 for name, data in pairs(AceLibrary.libs) do
822 local s
823 if data.minor then
824 s = " - " .. tostring(name) .. "." .. tostring(data.minor)
825 else
826 s = " - " .. tostring(name)
827 end
828 if AceLibrary(name).slashCommand then
829 s = s .. " |cffffff7f(" .. tostring(AceLibrary(name).slashCommand) .. "|cffffff7f)"
830 end
831 print(s)
832 end
833 end
834 end
835 },
836 search = {
837 desc = "Search by name",
838 name = "Search",
839 type = "text",
840 usage = "<keyword>",
841 input = true,
842 get = false,
843 set = function(...)
844 for i,v in ipairs(arg) do
845 arg[i] = string.lower(string.gsub(string.gsub(v, '%*', '.*'), '%%', '%%%%'))
846 end
847 local count = GetNumAddOns()
848 for i = 1, count do
849 local name = GetAddOnInfo(i)
850 local good = true
851 for _,v in ipairs(arg) do
852 if not string.find(string.lower(name), v) then
853 good = false
854 break
855 end
856 end
857 if good then
858 listNormalAddon(i)
859 end
860 end
861 end
862 }
863 },
864 },
865 enable = {
866 desc = "Enable addon",
867 name = "Enable",
868 type = "text",
869 usage = "<addon>",
870 get = false,
871 set = function(text)
872 local name,title,_,_,_,reason = GetAddOnInfo(text)
873 if reason == "MISSING" then
874 print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text))
875 else
876 EnableAddOn(text)
877 print(string.format("|cffffff7fAce2:|r %s is now enabled", title or name))
878 end
879 end,
880 },
881 disable = {
882 desc = "Disable addon",
883 name = "Disable",
884 type = "text",
885 usage = "<addon>",
886 get = false,
887 set = function(text)
888 local name,title,_,_,_,reason = GetAddOnInfo(text)
889 if reason == "MISSING" then
890 print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text))
891 else
892 DisableAddOn(text)
893 print(string.format("|cffffff7fAce2:|r %s is now disabled", title or name))
894 end
895 end,
896 },
897 load = {
898 desc = "Load addon",
899 name = "Load",
900 type = "text",
901 usage = "<addon>",
902 get = false,
903 set = function(text)
904 local name,title,_,_,loadable,reason = GetAddOnInfo(text)
905 if reason == "MISSING" then
906 print(string.format("|cffffff7fAce2:|r AddOn %q does not exist.", text))
907 elseif not loadable then
908 print(string.format("|cffffff7fAce2:|r AddOn %q is not loadable. Reason: %s", text, reason))
909 else
910 LoadAddOn(text)
911 print(string.format("|cffffff7fAce2:|r %s is now loaded", title or name))
912 end
913 end
914 },
915 info = {
916 desc = "Display information",
917 name = "Information",
918 type = "execute",
919 func = function()
920 local mem, threshold = gcinfo()
921 print(string.format(" - |cffffff7fMemory usage [|r%.3f MiB|cffffff7f]|r", mem / 1024))
922 print(string.format(" - |cffffff7fThreshold [|r%.3f MiB|cffffff7f]|r", threshold / 1024))
923 print(string.format(" - |cffffff7fFramerate [|r%.0f fps|cffffff7f]|r", GetFramerate()))
924 local bandwidthIn, bandwidthOut, latency = GetNetStats()
925 bandwidthIn, bandwidthOut = floor(bandwidthIn * 1024), floor(bandwidthOut * 1024)
926 print(string.format(" - |cffffff7fLatency [|r%.0f ms|cffffff7f]|r", latency))
927 print(string.format(" - |cffffff7fBandwidth in [|r%.0f B/s|cffffff7f]|r", bandwidthIn))
928 print(string.format(" - |cffffff7fBandwidth out [|r%.0f B/s|cffffff7f]|r", bandwidthOut))
929 print(string.format(" - |cffffff7fTotal addons [|r%d|cffffff7f]|r", GetNumAddOns()))
930 print(string.format(" - |cffffff7fAce2 addons [|r%d|cffffff7f]|r", table.getn(self.addons)))
931 local ace = 0
932 local enabled = 0
933 local disabled = 0
934 local lod = 0
935 for i = 1, GetNumAddOns() do
936 local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i)
937 if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then
938 ace = ace + 1
939 end
940 if IsAddOnLoadOnDemand(i) then
941 lod = lod + 1
942 end
943 local _,_,_,IsActive,loadable = GetAddOnInfo(i)
944 if not IsActive or not loadable then
945 disabled = disabled + 1
946 else
947 enabled = enabled + 1
948 end
949 end
950 print(string.format(" - |cffffff7fAce 1.x addons [|r%d|cffffff7f]|r", ace))
951 print(string.format(" - |cffffff7fLoadOnDemand addons [|r%d|cffffff7f]|r", lod))
952 print(string.format(" - |cffffff7fenabled addons [|r%d|cffffff7f]|r", enabled))
953 print(string.format(" - |cffffff7fdisabled addons [|r%d|cffffff7f]|r", disabled))
954 local libs = 0
955 if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then
956 for _ in pairs(AceLibrary.libs) do
957 libs = libs + 1
958 end
959 end
960 print(string.format(" - |cffffff7fAceLibrary instances [|r%d|cffffff7f]|r", libs))
961 end
962 }
963 }
964 })
965 elseif major == "AceModuleCore-2.0" then
966 AceModuleCore = instance
967 end
968 end
969  
970 local function activate(self, oldLib, oldDeactivate)
971 AceAddon = self
972  
973 if oldLib then
974 self.playerLoginFired = oldLib.playerLoginFired or DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage
975 self.addonsToOnEnable = oldLib.addonsToOnEnable
976 self.addons = oldLib.addons
977 self.nextAddon = oldLib.nextAddon
978 self.addonsStarted = oldLib.addonsStarted
979 end
980 if not self.addons then
981 self.addons = {}
982 end
983 if not self.nextAddon then
984 self.nextAddon = {}
985 end
986 if not self.addonsStarted then
987 self.addonsStarted = {}
988 end
989 if oldDeactivate then
990 oldDeactivate(oldLib)
991 end
992 end
993  
994 AceLibrary:Register(AceAddon, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)
995 AceAddon = AceLibrary(MAJOR_VERSION)