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