Mercurial > wow > reaction
comparison modules/FuBar_ReActionFu/lib/AceAddon-2.0/AceAddon-2.0.lua @ 28:21bcaf8215ff
- converted to Ace3
- rearranged file layout
- configGUI menus not working right now
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Mon, 17 Mar 2008 18:24:53 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
27:f1e838841ce1 | 28:21bcaf8215ff |
---|---|
1 --[[ | |
2 Name: AceAddon-2.0 | |
3 Revision: $Rev: 46764 $ | |
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/wiki/AceAddon-2.0 | |
8 SVN: http://svn.wowace.com/wowace/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 License: LGPL v2.1 | |
12 ]] | |
13 | |
14 local MAJOR_VERSION = "AceAddon-2.0" | |
15 local MINOR_VERSION = "$Revision: 46764 $" | |
16 | |
17 -- This ensures the code is only executed if the libary doesn't already exist, or is a newer version | |
18 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end | |
19 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end | |
20 | |
21 if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0.") end | |
22 | |
23 local function safecall(func,...) | |
24 local success, err = pcall(func,...) | |
25 if not success then geterrorhandler()(err:find("%.lua:%d+:") and err or (debugstack():match("\n(.-: )in.-\n") or "") .. err) end | |
26 end | |
27 -- Localization | |
28 local STANDBY, TITLE, NOTES, VERSION, AUTHOR, DATE, CATEGORY, EMAIL, CREDITS, WEBSITE, CATEGORIES, ABOUT, LICENSE, PRINT_ADDON_INFO, DONATE, DONATE_DESC, HOWTO_DONATE_WINDOWS, HOWTO_DONATE_MAC | |
29 if GetLocale() == "deDE" then | |
30 STANDBY = "|cffff5050(Standby)|r" -- capitalized | |
31 | |
32 TITLE = "Titel" | |
33 NOTES = "Anmerkung" | |
34 VERSION = "Version" | |
35 AUTHOR = "Autor" | |
36 DATE = "Datum" | |
37 CATEGORY = "Kategorie" | |
38 EMAIL = "E-Mail" | |
39 WEBSITE = "Webseite" | |
40 CREDITS = "Credits" -- fix | |
41 LICENSE = "License" -- fix | |
42 | |
43 ABOUT = "Über" | |
44 PRINT_ADDON_INFO = "Gibt Addondaten aus" | |
45 DONATE = "Donate" -- fix | |
46 DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix | |
47 HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
48 HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
49 | |
50 CATEGORIES = { | |
51 ["Action Bars"] = "Aktionsleisten", | |
52 ["Auction"] = "Auktion", | |
53 ["Audio"] = "Audio", | |
54 ["Battlegrounds/PvP"] = "Schlachtfeld/PvP", | |
55 ["Buffs"] = "Stärkungszauber", | |
56 ["Chat/Communication"] = "Chat/Kommunikation", | |
57 ["Druid"] = "Druide", | |
58 ["Hunter"] = "Jäger", | |
59 ["Mage"] = "Magier", | |
60 ["Paladin"] = "Paladin", | |
61 ["Priest"] = "Priester", | |
62 ["Rogue"] = "Schurke", | |
63 ["Shaman"] = "Schamane", | |
64 ["Warlock"] = "Hexenmeister", | |
65 ["Warrior"] = "Krieger", | |
66 ["Healer"] = "Heiler", | |
67 ["Tank"] = "Tank", | |
68 ["Caster"] = "Zauberer", | |
69 ["Combat"] = "Kampf", | |
70 ["Compilations"] = "Zusammenstellungen", | |
71 ["Data Export"] = "Datenexport", | |
72 ["Development Tools"] = "Entwicklungs Tools", | |
73 ["Guild"] = "Gilde", | |
74 ["Frame Modification"] = "Frame Veränderungen", | |
75 ["Interface Enhancements"] = "Interface Verbesserungen", | |
76 ["Inventory"] = "Inventar", | |
77 ["Library"] = "Bibliotheken", | |
78 ["Map"] = "Karte", | |
79 ["Mail"] = "Post", | |
80 ["Miscellaneous"] = "Diverses", | |
81 ["Quest"] = "Quest", | |
82 ["Raid"] = "Schlachtzug", | |
83 ["Tradeskill"] = "Beruf", | |
84 ["UnitFrame"] = "Einheiten-Fenster", | |
85 } | |
86 elseif GetLocale() == "frFR" then | |
87 STANDBY = "|cffff5050(attente)|r" | |
88 | |
89 TITLE = "Titre" | |
90 NOTES = "Notes" | |
91 VERSION = "Version" | |
92 AUTHOR = "Auteur" | |
93 DATE = "Date" | |
94 CATEGORY = "Catégorie" | |
95 EMAIL = "E-mail" | |
96 WEBSITE = "Site web" | |
97 CREDITS = "Credits" -- fix | |
98 LICENSE = "License" -- fix | |
99 | |
100 ABOUT = "A propos" | |
101 PRINT_ADDON_INFO = "Afficher les informations sur l'addon" | |
102 DONATE = "Donate" -- fix | |
103 DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix | |
104 HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
105 HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
106 | |
107 CATEGORIES = { | |
108 ["Action Bars"] = "Barres d'action", | |
109 ["Auction"] = "Hôtel des ventes", | |
110 ["Audio"] = "Audio", | |
111 ["Battlegrounds/PvP"] = "Champs de bataille/JcJ", | |
112 ["Buffs"] = "Buffs", | |
113 ["Chat/Communication"] = "Chat/Communication", | |
114 ["Druid"] = "Druide", | |
115 ["Hunter"] = "Chasseur", | |
116 ["Mage"] = "Mage", | |
117 ["Paladin"] = "Paladin", | |
118 ["Priest"] = "Prêtre", | |
119 ["Rogue"] = "Voleur", | |
120 ["Shaman"] = "Chaman", | |
121 ["Warlock"] = "Démoniste", | |
122 ["Warrior"] = "Guerrier", | |
123 ["Healer"] = "Soigneur", | |
124 ["Tank"] = "Tank", | |
125 ["Caster"] = "Casteur", | |
126 ["Combat"] = "Combat", | |
127 ["Compilations"] = "Compilations", | |
128 ["Data Export"] = "Exportation de données", | |
129 ["Development Tools"] = "Outils de développement", | |
130 ["Guild"] = "Guilde", | |
131 ["Frame Modification"] = "Modification des fenêtres", | |
132 ["Interface Enhancements"] = "Améliorations de l'interface", | |
133 ["Inventory"] = "Inventaire", | |
134 ["Library"] = "Bibliothèques", | |
135 ["Map"] = "Carte", | |
136 ["Mail"] = "Courrier", | |
137 ["Miscellaneous"] = "Divers", | |
138 ["Quest"] = "Quêtes", | |
139 ["Raid"] = "Raid", | |
140 ["Tradeskill"] = "Métiers", | |
141 ["UnitFrame"] = "Fenêtres d'unité", | |
142 } | |
143 elseif GetLocale() == "koKR" then | |
144 STANDBY = "|cffff5050(사용가능)|r" | |
145 | |
146 TITLE = "제목" | |
147 NOTES = "노트" | |
148 VERSION = "버전" | |
149 AUTHOR = "저작자" | |
150 DATE = "날짜" | |
151 CATEGORY = "분류" | |
152 EMAIL = "전자 우편" | |
153 WEBSITE = "웹 사이트" | |
154 CREDITS = "공로자" | |
155 LICENSE = "라이센스" | |
156 | |
157 ABOUT = "정보" | |
158 PRINT_ADDON_INFO = "애드온에 대한 정보를 출력합니다." | |
159 DONATE = "기부" | |
160 DONATE_DESC = "이 애드온의 저작자에게 기부를 합니다." | |
161 HOWTO_DONATE_WINDOWS = "Ctrl-A를 눌려 링크를 선택후, Ctrl-C로 복사합니다. Alt-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다." | |
162 HOWTO_DONATE_MAC = "Cmd-A를 눌려 링크를 선택후, Cmd-C로 복사합니다. Cmd-Tab 눌려 게임으로 부터 나간후 웹 브라우저를 엽니다. 복사된 링크를 주소 창에 붙여넣기 합니다." | |
163 | |
164 CATEGORIES = { | |
165 ["Action Bars"] = "액션바", | |
166 ["Auction"] = "경매", | |
167 ["Audio"] = "음향", | |
168 ["Battlegrounds/PvP"] = "전장/PvP", | |
169 ["Buffs"] = "버프", | |
170 ["Chat/Communication"] = "대화/의사소통", | |
171 ["Druid"] = "드루이드", | |
172 ["Hunter"] = "사냥꾼", | |
173 ["Mage"] = "마법사", | |
174 ["Paladin"] = "성기사", | |
175 ["Priest"] = "사제", | |
176 ["Rogue"] = "도적", | |
177 ["Shaman"] = "주술사", | |
178 ["Warlock"] = "흑마법사", | |
179 ["Warrior"] = "전사", | |
180 ["Healer"] = "힐러", | |
181 ["Tank"] = "탱커", | |
182 ["Caster"] = "캐스터", | |
183 ["Combat"] = "전투", | |
184 ["Compilations"] = "복합", | |
185 ["Data Export"] = "자료 출력", | |
186 ["Development Tools"] = "개발 도구", | |
187 ["Guild"] = "길드", | |
188 ["Frame Modification"] = "구조 변경", | |
189 ["Interface Enhancements"] = "인터페이스 강화", | |
190 ["Inventory"] = "인벤토리", | |
191 ["Library"] = "라이브러리", | |
192 ["Map"] = "지도", | |
193 ["Mail"] = "우편", | |
194 ["Miscellaneous"] = "기타", | |
195 ["Quest"] = "퀘스트", | |
196 ["Raid"] = "공격대", | |
197 ["Tradeskill"] = "전문기술", | |
198 ["UnitFrame"] = "유닛 프레임", | |
199 } | |
200 elseif GetLocale() == "zhTW" then | |
201 STANDBY = "|cffff5050(待命)|r" | |
202 | |
203 TITLE = "標題" | |
204 NOTES = "註記" | |
205 VERSION = "版本" | |
206 AUTHOR = "作者" | |
207 DATE = "日期" | |
208 CATEGORY = "類別" | |
209 EMAIL = "電子郵件" | |
210 WEBSITE = "網站" | |
211 CREDITS = "特別感謝" | |
212 LICENSE = "版權" | |
213 | |
214 ABOUT = "關於" | |
215 PRINT_ADDON_INFO = "顯示插件資訊。" | |
216 DONATE = "捐贈" | |
217 DONATE_DESC = "捐贈金錢給插件作者。" | |
218 HOWTO_DONATE_WINDOWS = "請按Ctrl-A選擇網站連結,Ctrl-C複製網址,Alt-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。" | |
219 HOWTO_DONATE_MAC = "請按Cmd-A選擇網站連結,Cmd-C複製網址,Cmd-Tab切換到電腦桌面,打開瀏覽器,在網址列貼上網址。" | |
220 | |
221 CATEGORIES = { | |
222 ["Action Bars"] = "動作條", | |
223 ["Auction"] = "拍賣", | |
224 ["Audio"] = "音效", | |
225 ["Battlegrounds/PvP"] = "戰場/PvP", | |
226 ["Buffs"] = "增益", | |
227 ["Chat/Communication"] = "聊天/通訊", | |
228 ["Druid"] = "德魯伊", | |
229 ["Hunter"] = "獵人", | |
230 ["Mage"] = "法師", | |
231 ["Paladin"] = "聖騎士", | |
232 ["Priest"] = "牧師", | |
233 ["Rogue"] = "盜賊", | |
234 ["Shaman"] = "薩滿", | |
235 ["Warlock"] = "術士", | |
236 ["Warrior"] = "戰士", | |
237 ["Healer"] = "治療者", | |
238 ["Tank"] = "坦克", | |
239 ["Caster"] = "施法者", | |
240 ["Combat"] = "戰鬥", | |
241 ["Compilations"] = "整合", | |
242 ["Data Export"] = "資料匯出", | |
243 ["Development Tools"] = "開發工具", | |
244 ["Guild"] = "公會", | |
245 ["Frame Modification"] = "框架修改", | |
246 ["Interface Enhancements"] = "介面增強", | |
247 ["Inventory"] = "庫存", | |
248 ["Library"] = "程式庫", | |
249 ["Map"] = "地圖", | |
250 ["Mail"] = "郵件", | |
251 ["Miscellaneous"] = "雜項", | |
252 ["Quest"] = "任務", | |
253 ["Raid"] = "團隊", | |
254 ["Tradeskill"] = "交易技能", | |
255 ["UnitFrame"] = "單位框架", | |
256 } | |
257 elseif GetLocale() == "zhCN" then | |
258 STANDBY = "|cffff5050(暂挂)|r" | |
259 | |
260 TITLE = "标题" | |
261 NOTES = "附注" | |
262 VERSION = "版本" | |
263 AUTHOR = "作者" | |
264 DATE = "日期" | |
265 CATEGORY = "分类" | |
266 EMAIL = "电子邮件" | |
267 WEBSITE = "网站" | |
268 CREDITS = "Credits" -- fix | |
269 LICENSE = "License" -- fix | |
270 | |
271 ABOUT = "关于" | |
272 PRINT_ADDON_INFO = "印列出插件信息" | |
273 DONATE = "Donate" -- fix | |
274 DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix | |
275 HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
276 HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
277 | |
278 CATEGORIES = { | |
279 ["Action Bars"] = "动作条", | |
280 ["Auction"] = "拍卖", | |
281 ["Audio"] = "音频", | |
282 ["Battlegrounds/PvP"] = "战场/PvP", | |
283 ["Buffs"] = "增益魔法", | |
284 ["Chat/Communication"] = "聊天/交流", | |
285 ["Druid"] = "德鲁伊", | |
286 ["Hunter"] = "猎人", | |
287 ["Mage"] = "法师", | |
288 ["Paladin"] = "圣骑士", | |
289 ["Priest"] = "牧师", | |
290 ["Rogue"] = "盗贼", | |
291 ["Shaman"] = "萨满祭司", | |
292 ["Warlock"] = "术士", | |
293 ["Warrior"] = "战士", | |
294 -- ["Healer"] = "治疗保障", | |
295 -- ["Tank"] = "近战控制", | |
296 -- ["Caster"] = "远程输出", | |
297 ["Combat"] = "战斗", | |
298 ["Compilations"] = "编译", | |
299 ["Data Export"] = "数据导出", | |
300 ["Development Tools"] = "开发工具", | |
301 ["Guild"] = "公会", | |
302 ["Frame Modification"] = "框架修改", | |
303 ["Interface Enhancements"] = "界面增强", | |
304 ["Inventory"] = "背包", | |
305 ["Library"] = "库", | |
306 ["Map"] = "地图", | |
307 ["Mail"] = "邮件", | |
308 ["Miscellaneous"] = "杂项", | |
309 ["Quest"] = "任务", | |
310 ["Raid"] = "团队", | |
311 ["Tradeskill"] = "商业技能", | |
312 ["UnitFrame"] = "头像框架", | |
313 } | |
314 elseif GetLocale() == "esES" then | |
315 STANDBY = "|cffff5050(espera)|r" | |
316 | |
317 TITLE = "Título" | |
318 NOTES = "Notas" | |
319 VERSION = "Versión" | |
320 AUTHOR = "Autor" | |
321 DATE = "Fecha" | |
322 CATEGORY = "Categoría" | |
323 EMAIL = "E-mail" | |
324 WEBSITE = "Web" | |
325 CREDITS = "Créditos" | |
326 LICENSE = "License" -- fix | |
327 | |
328 ABOUT = "Acerca de" | |
329 PRINT_ADDON_INFO = "Muestra información acerca del accesorio." | |
330 DONATE = "Donate" -- fix | |
331 DONATE_DESC = "Give a much-needed donation to the author of this addon." -- fix | |
332 HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
333 HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." -- fix | |
334 | |
335 CATEGORIES = { | |
336 ["Action Bars"] = "Barras de Acción", | |
337 ["Auction"] = "Subasta", | |
338 ["Audio"] = "Audio", | |
339 ["Battlegrounds/PvP"] = "Campos de Batalla/JcJ", | |
340 ["Buffs"] = "Buffs", | |
341 ["Chat/Communication"] = "Chat/Comunicación", | |
342 ["Druid"] = "Druida", | |
343 ["Hunter"] = "Cazador", | |
344 ["Mage"] = "Mago", | |
345 ["Paladin"] = "Paladín", | |
346 ["Priest"] = "Sacerdote", | |
347 ["Rogue"] = "Pícaro", | |
348 ["Shaman"] = "Chamán", | |
349 ["Warlock"] = "Brujo", | |
350 ["Warrior"] = "Guerrero", | |
351 ["Healer"] = "Sanador", | |
352 ["Tank"] = "Tanque", | |
353 ["Caster"] = "Conjurador", | |
354 ["Combat"] = "Combate", | |
355 ["Compilations"] = "Compilaciones", | |
356 ["Data Export"] = "Exportar Datos", | |
357 ["Development Tools"] = "Herramientas de Desarrollo", | |
358 ["Guild"] = "Hermandad", | |
359 ["Frame Modification"] = "Modificación de Marcos", | |
360 ["Interface Enhancements"] = "Mejoras de la Interfaz", | |
361 ["Inventory"] = "Inventario", | |
362 ["Library"] = "Biblioteca", | |
363 ["Map"] = "Mapa", | |
364 ["Mail"] = "Correo", | |
365 ["Miscellaneous"] = "Misceláneo", | |
366 ["Quest"] = "Misión", | |
367 ["Raid"] = "Banda", | |
368 ["Tradeskill"] = "Habilidad de Comercio", | |
369 ["UnitFrame"] = "Marco de Unidades", | |
370 } | |
371 else -- enUS | |
372 STANDBY = "|cffff5050(standby)|r" | |
373 | |
374 TITLE = "Title" | |
375 NOTES = "Notes" | |
376 VERSION = "Version" | |
377 AUTHOR = "Author" | |
378 DATE = "Date" | |
379 CATEGORY = "Category" | |
380 EMAIL = "E-mail" | |
381 WEBSITE = "Website" | |
382 CREDITS = "Credits" | |
383 LICENSE = "License" | |
384 | |
385 ABOUT = "About" | |
386 PRINT_ADDON_INFO = "Show information about the addon." | |
387 DONATE = "Donate" | |
388 DONATE_DESC = "Give a much-needed donation to the author of this addon." | |
389 HOWTO_DONATE_WINDOWS = "Press Ctrl-A to select the link, then Ctrl-C to copy, then Alt-Tab out of the game, open your favorite web browser, and paste the link into the address bar." | |
390 HOWTO_DONATE_MAC = "Press Cmd-A to select the link, then Cmd-C to copy, then Cmd-Tab out of the game, open your favorite web browser, and paste the link into the address bar." | |
391 | |
392 CATEGORIES = { | |
393 ["Action Bars"] = "Action Bars", | |
394 ["Auction"] = "Auction", | |
395 ["Audio"] = "Audio", | |
396 ["Battlegrounds/PvP"] = "Battlegrounds/PvP", | |
397 ["Buffs"] = "Buffs", | |
398 ["Chat/Communication"] = "Chat/Communication", | |
399 ["Druid"] = "Druid", | |
400 ["Hunter"] = "Hunter", | |
401 ["Mage"] = "Mage", | |
402 ["Paladin"] = "Paladin", | |
403 ["Priest"] = "Priest", | |
404 ["Rogue"] = "Rogue", | |
405 ["Shaman"] = "Shaman", | |
406 ["Warlock"] = "Warlock", | |
407 ["Warrior"] = "Warrior", | |
408 ["Healer"] = "Healer", | |
409 ["Tank"] = "Tank", | |
410 ["Caster"] = "Caster", | |
411 ["Combat"] = "Combat", | |
412 ["Compilations"] = "Compilations", | |
413 ["Data Export"] = "Data Export", | |
414 ["Development Tools"] = "Development Tools", | |
415 ["Guild"] = "Guild", | |
416 ["Frame Modification"] = "Frame Modification", | |
417 ["Interface Enhancements"] = "Interface Enhancements", | |
418 ["Inventory"] = "Inventory", | |
419 ["Library"] = "Library", | |
420 ["Map"] = "Map", | |
421 ["Mail"] = "Mail", | |
422 ["Miscellaneous"] = "Miscellaneous", | |
423 ["Quest"] = "Quest", | |
424 ["Raid"] = "Raid", | |
425 ["Tradeskill"] = "Tradeskill", | |
426 ["UnitFrame"] = "UnitFrame", | |
427 } | |
428 end | |
429 | |
430 setmetatable(CATEGORIES, { __index = function(self, key) -- case-insensitive | |
431 local lowerKey = key:lower() | |
432 for k,v in pairs(CATEGORIES) do | |
433 if k:lower() == lowerKey then | |
434 return v | |
435 end | |
436 end | |
437 end }) | |
438 | |
439 -- Create the library object | |
440 | |
441 local AceOO = AceLibrary("AceOO-2.0") | |
442 local AceAddon = AceOO.Class() | |
443 local AceEvent | |
444 local AceConsole | |
445 local AceModuleCore | |
446 | |
447 function AceAddon:GetLocalizedCategory(name) | |
448 self:argCheck(name, 2, "string") | |
449 return CATEGORIES[name] or UNKNOWN | |
450 end | |
451 | |
452 function AceAddon:ToString() | |
453 return "AceAddon" | |
454 end | |
455 | |
456 local function print(text) | |
457 DEFAULT_CHAT_FRAME:AddMessage(text) | |
458 end | |
459 | |
460 function AceAddon:ADDON_LOADED(name) | |
461 local unregister = true | |
462 local initAddon = {} | |
463 while #self.nextAddon > 0 do | |
464 local addon = table.remove(self.nextAddon, 1) | |
465 if addon.possibleNames[name] then | |
466 table.insert(initAddon, addon) | |
467 else | |
468 unregister = nil | |
469 table.insert(self.skipAddon, addon) | |
470 end | |
471 end | |
472 self.nextAddon, self.skipAddon = self.skipAddon, self.nextAddon | |
473 if unregister then | |
474 AceAddon:UnregisterEvent("ADDON_LOADED") | |
475 end | |
476 while #initAddon > 0 do | |
477 local addon = table.remove(initAddon, 1) | |
478 table.insert(self.addons, addon) | |
479 if not self.addons[name] then | |
480 self.addons[name] = addon | |
481 end | |
482 addon.possibleNames = nil | |
483 self:InitializeAddon(addon, name) | |
484 end | |
485 end | |
486 | |
487 local function RegisterOnEnable(self) | |
488 if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage then -- HACK | |
489 AceAddon.playerLoginFired = true | |
490 end | |
491 if AceAddon.playerLoginFired then | |
492 AceAddon.addonsStarted[self] = true | |
493 if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then | |
494 AceAddon:ManualEnable(self) | |
495 end | |
496 else | |
497 if not AceAddon.addonsToOnEnable then | |
498 AceAddon.addonsToOnEnable = {} | |
499 end | |
500 table.insert(AceAddon.addonsToOnEnable, self) | |
501 end | |
502 end | |
503 | |
504 function AceAddon:InitializeAddon(addon, name) | |
505 if addon.name == nil then | |
506 addon.name = name | |
507 end | |
508 if GetAddOnMetadata then | |
509 -- TOC checks | |
510 if addon.title == nil then | |
511 addon.title = GetAddOnMetadata(name, "Title") | |
512 end | |
513 if type(addon.title) == "string" then | |
514 local num = addon.title:find(" |cff7fff7f %-Ace2%-|r$") | |
515 if num then | |
516 addon.title = addon.title:sub(1, num - 1) | |
517 end | |
518 addon.title = addon.title:trim() | |
519 end | |
520 if addon.notes == nil then | |
521 addon.notes = GetAddOnMetadata(name, "Notes") | |
522 end | |
523 if type(addon.notes) == "string" then | |
524 addon.notes = addon.notes:trim() | |
525 end | |
526 if addon.version == nil then | |
527 addon.version = GetAddOnMetadata(name, "Version") | |
528 end | |
529 if type(addon.version) == "string" then | |
530 if addon.version:find("%$Revision: (%d+) %$") then | |
531 addon.version = addon.version:gsub("%$Revision: (%d+) %$", "%1") | |
532 elseif addon.version:find("%$Rev: (%d+) %$") then | |
533 addon.version = addon.version:gsub("%$Rev: (%d+) %$", "%1") | |
534 elseif addon.version:find("%$LastChangedRevision: (%d+) %$") then | |
535 addon.version = addon.version:gsub("%$LastChangedRevision: (%d+) %$", "%1") | |
536 end | |
537 addon.version = addon.version:trim() | |
538 end | |
539 if addon.author == nil then | |
540 addon.author = GetAddOnMetadata(name, "Author") | |
541 end | |
542 if type(addon.author) == "string" then | |
543 addon.author = addon.author:trim() | |
544 end | |
545 if addon.credits == nil then | |
546 addon.credits = GetAddOnMetadata(name, "X-Credits") | |
547 end | |
548 if type(addon.credits) == "string" then | |
549 addon.credits = addon.credits:trim() | |
550 end | |
551 if addon.donate == nil then | |
552 addon.donate = GetAddOnMetadata(name, "X-Donate") | |
553 end | |
554 if type(addon.donate) == "string" then | |
555 addon.donate = addon.donate:trim() | |
556 end | |
557 if addon.date == nil then | |
558 addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate") | |
559 end | |
560 if type(addon.date) == "string" then | |
561 if addon.date:find("%$Date: (.-) %$") then | |
562 addon.date = addon.date:gsub("%$Date: (.-) %$", "%1") | |
563 elseif addon.date:find("%$LastChangedDate: (.-) %$") then | |
564 addon.date = addon.date:gsub("%$LastChangedDate: (.-) %$", "%1") | |
565 end | |
566 addon.date = addon.date:trim() | |
567 end | |
568 | |
569 if addon.category == nil then | |
570 addon.category = GetAddOnMetadata(name, "X-Category") | |
571 end | |
572 if type(addon.category) == "string" then | |
573 addon.category = addon.category:trim() | |
574 end | |
575 if addon.email == nil then | |
576 addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email") | |
577 end | |
578 if type(addon.email) == "string" then | |
579 addon.email = addon.email:trim() | |
580 end | |
581 if addon.license == nil then | |
582 addon.license = GetAddOnMetadata(name, "X-License") | |
583 end | |
584 if type(addon.license) == "string" then | |
585 addon.license = addon.license:trim() | |
586 end | |
587 if addon.website == nil then | |
588 addon.website = GetAddOnMetadata(name, "X-Website") | |
589 end | |
590 if type(addon.website) == "string" then | |
591 addon.website = addon.website:trim() | |
592 end | |
593 end | |
594 local current = addon.class | |
595 while true do | |
596 if current == AceOO.Class or not current then | |
597 break | |
598 end | |
599 if current.mixins then | |
600 for mixin in pairs(current.mixins) do | |
601 if type(mixin.OnEmbedInitialize) == "function" then | |
602 mixin:OnEmbedInitialize(addon, name) | |
603 end | |
604 end | |
605 end | |
606 current = current.super | |
607 end | |
608 local n = AceAddon.addonsToOnEnable and #AceAddon.addonsToOnEnable or 0 | |
609 | |
610 if type(addon.OnInitialize) == "function" then | |
611 safecall(addon.OnInitialize, addon, name) | |
612 end | |
613 if AceEvent then | |
614 AceEvent:TriggerEvent("Ace2_AddonInitialized", addon) | |
615 end | |
616 RegisterOnEnable(addon) | |
617 local n2 = AceAddon.addonsToOnEnable and #AceAddon.addonsToOnEnable or 0 | |
618 if n2 - n > 1 then | |
619 local mine = table.remove(AceAddon.addonsToOnEnable) | |
620 table.insert(AceAddon.addonsToOnEnable, n+1, mine) | |
621 end | |
622 end | |
623 | |
624 local aboutFrame | |
625 local function createAboutFrame() | |
626 aboutFrame = CreateFrame("Frame", "AceAddon20AboutFrame", UIParent, "DialogBoxFrame") | |
627 aboutFrame:SetWidth(500) | |
628 aboutFrame:SetHeight(400) | |
629 aboutFrame:SetPoint("CENTER") | |
630 aboutFrame:SetBackdrop({ | |
631 bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], | |
632 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | |
633 tile = true, tileSize = 16, edgeSize = 16, | |
634 insets = { left = 5, right = 5, top = 5, bottom = 5 } | |
635 }) | |
636 aboutFrame:SetBackdropColor(0,0,0,1) | |
637 | |
638 local donateButton = CreateFrame("Button", "AceAddon20AboutFrameDonateButton", aboutFrame, "UIPanelButtonTemplate2") | |
639 aboutFrame.donateButton = donateButton | |
640 donateButton:SetPoint("BOTTOMRIGHT", -20, 20) | |
641 _G.AceAddon20AboutFrameDonateButtonText:SetText(DONATE) | |
642 donateButton:SetWidth(_G.AceAddon20AboutFrameDonateButtonText:GetWidth()+20) | |
643 donateButton:SetScript("OnClick", function() | |
644 aboutFrame.currentAddon:OpenDonationFrame() | |
645 end) | |
646 | |
647 local text = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") | |
648 aboutFrame.title = text | |
649 text:SetPoint("TOP", 0, -5) | |
650 | |
651 aboutFrame:Hide() | |
652 | |
653 aboutFrame.lefts = {} | |
654 aboutFrame.rights = {} | |
655 aboutFrame.textLefts = {} | |
656 aboutFrame.textRights = {} | |
657 function aboutFrame:Clear() | |
658 self.title:SetText("") | |
659 for i = 1, #self.lefts do | |
660 self.lefts[i] = nil | |
661 self.rights[i] = nil | |
662 end | |
663 end | |
664 | |
665 function aboutFrame:AddLine(left, right) | |
666 aboutFrame.lefts[#aboutFrame.lefts+1] = left | |
667 aboutFrame.rights[#aboutFrame.rights+1] = right | |
668 end | |
669 | |
670 local aboutFrame_Show = aboutFrame.Show | |
671 function aboutFrame:Show(...) | |
672 local maxLeftWidth = 0 | |
673 local maxRightWidth = 0 | |
674 local textHeight = 0 | |
675 for i = 1, #self.lefts do | |
676 if not self.textLefts[i] then | |
677 local left = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal") | |
678 self.textLefts[i] = left | |
679 local right = aboutFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") | |
680 self.textRights[i] = right | |
681 if i == 1 then | |
682 left:SetPoint("TOPRIGHT", aboutFrame, "TOPLEFT", 75, -35) | |
683 else | |
684 left:SetPoint("TOPRIGHT", self.textLefts[i-1], "BOTTOMRIGHT", 0, -5) | |
685 end | |
686 right:SetPoint("LEFT", left, "RIGHT", 5, 0) | |
687 end | |
688 self.textLefts[i]:SetText(self.lefts[i] .. ":") | |
689 self.textRights[i]:SetText(self.rights[i]) | |
690 local leftWidth = self.textLefts[i]:GetWidth() | |
691 local rightWidth = self.textRights[i]:GetWidth() | |
692 textHeight = self.textLefts[i]:GetHeight() | |
693 if maxLeftWidth < leftWidth then | |
694 maxLeftWidth = leftWidth | |
695 end | |
696 if maxRightWidth < rightWidth then | |
697 maxRightWidth = rightWidth | |
698 end | |
699 end | |
700 for i = #self.lefts+1, #self.textLefts do | |
701 self.textLefts[i]:SetText('') | |
702 self.textRights[i]:SetText('') | |
703 end | |
704 aboutFrame:SetWidth(75 + maxRightWidth + 20) | |
705 aboutFrame:SetHeight(#self.lefts * (textHeight + 5) + 100) | |
706 | |
707 aboutFrame_Show(self, ...) | |
708 end | |
709 aboutFrame:Hide() | |
710 | |
711 createAboutFrame = nil | |
712 end | |
713 local donateFrame | |
714 | |
715 local function unobfuscateEmail(email) | |
716 return email:gsub(" AT ", "@"):gsub(" DOT ", ".") | |
717 end | |
718 | |
719 local function isGoodVariable(var) | |
720 return type(var) == "string" or type(var) == "number" | |
721 end | |
722 function AceAddon.prototype:PrintAddonInfo() | |
723 if createAboutFrame then | |
724 createAboutFrame() | |
725 end | |
726 aboutFrame:Clear() | |
727 local x | |
728 if isGoodVariable(self.title) then | |
729 x = tostring(self.title) | |
730 elseif isGoodVariable(self.name) then | |
731 x = tostring(self.name) | |
732 else | |
733 x = "<" .. tostring(self.class) .. " instance>" | |
734 end | |
735 if type(self.IsActive) == "function" then | |
736 if not self:IsActive() then | |
737 x = x .. " " .. STANDBY | |
738 end | |
739 end | |
740 aboutFrame.title:SetText(x) | |
741 | |
742 if isGoodVariable(self.version) then | |
743 aboutFrame:AddLine(VERSION, tostring(self.version)) | |
744 end | |
745 if isGoodVariable(self.notes) then | |
746 aboutFrame:AddLine(NOTES, tostring(self.notes)) | |
747 end | |
748 if isGoodVariable(self.author) then | |
749 aboutFrame:AddLine(AUTHOR, tostring(self.author)) | |
750 end | |
751 if isGoodVariable(self.credits) then | |
752 aboutFrame:AddLine(CREDITS, tostring(self.credits)) | |
753 end | |
754 if isGoodVariable(self.date) then | |
755 aboutFrame:AddLine(DATE, tostring(self.date)) | |
756 end | |
757 if self.category then | |
758 local category = CATEGORIES[self.category] | |
759 if category then | |
760 aboutFrame:AddLine(CATEGORY, tostring(self.category)) | |
761 end | |
762 end | |
763 if isGoodVariable(self.email) then | |
764 aboutFrame:AddLine(EMAIL, unobfuscateEmail(tostring(self.email))) | |
765 end | |
766 if isGoodVariable(self.website) then | |
767 aboutFrame:AddLine(WEBSITE, tostring(self.website)) | |
768 end | |
769 if isGoodVariable(self.license) then | |
770 aboutFrame:AddLine(LICENSE, tostring(self.license)) | |
771 end | |
772 | |
773 if donateFrame and donateFrame:IsShown() then | |
774 donateFrame:Hide() | |
775 end | |
776 | |
777 aboutFrame.currentAddon = self | |
778 | |
779 aboutFrame:Show() | |
780 | |
781 if self.donate then | |
782 aboutFrame.donateButton:Show() | |
783 else | |
784 aboutFrame.donateButton:Hide() | |
785 end | |
786 end | |
787 | |
788 local function createDonateFrame() | |
789 donateFrame = CreateFrame("Frame", "AceAddon20Frame", UIParent, "DialogBoxFrame") | |
790 | |
791 donateFrame:SetWidth(500) | |
792 donateFrame:SetHeight(200) | |
793 donateFrame:SetPoint("CENTER") | |
794 donateFrame:SetBackdrop({ | |
795 bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], | |
796 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | |
797 tile = true, tileSize = 16, edgeSize = 16, | |
798 insets = { left = 5, right = 5, top = 5, bottom = 5 } | |
799 }) | |
800 donateFrame:SetBackdropColor(0,0,0,1) | |
801 | |
802 local text = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") | |
803 text:SetPoint("TOP", 0, -5) | |
804 text:SetText(DONATE) | |
805 | |
806 local howto = donateFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") | |
807 howto:SetPoint("TOP", text, "BOTTOM", 0, -5) | |
808 howto:SetPoint("LEFT", 16, 0) | |
809 howto:SetPoint("RIGHT", -16, 0) | |
810 if not IsMacClient() then | |
811 -- Windows or Linux | |
812 howto:SetText(HOWTO_DONATE_WINDOWS) | |
813 else | |
814 howto:SetText(HOWTO_DONATE_MAC) | |
815 end | |
816 | |
817 local scrollFrame = CreateFrame("ScrollFrame", "AceAddon20FrameScrollFrame", donateFrame, "UIPanelScrollFrameTemplate") | |
818 scrollFrame:SetToplevel(true) | |
819 scrollFrame:SetPoint("TOP", -10, -76) | |
820 scrollFrame:SetWidth(455) | |
821 scrollFrame:SetHeight(70) | |
822 howto:SetPoint("BOTTOM", scrollFrame, "TOP") | |
823 | |
824 local editBox = CreateFrame("EditBox", nil, scrollFrame) | |
825 donateFrame.editBox = editBox | |
826 scrollFrame:SetScrollChild(editBox) | |
827 editBox:SetFontObject(ChatFontNormal) | |
828 editBox:SetMultiLine(true) | |
829 editBox:SetMaxLetters(99999) | |
830 editBox:SetWidth(450) | |
831 editBox:SetHeight(54) | |
832 editBox:SetPoint("BOTTOM", 5, 0) | |
833 editBox:SetJustifyH("LEFT") | |
834 editBox:SetJustifyV("TOP") | |
835 editBox:SetAutoFocus(false) | |
836 editBox:SetScript("OnTextChanged", function(this) | |
837 if this:GetText() ~= this.text then | |
838 this:SetText(this.text) | |
839 end | |
840 end) | |
841 editBox:SetScript("OnEscapePressed", function(this) | |
842 this:ClearFocus() | |
843 end) | |
844 createDonateFrame = nil | |
845 end | |
846 | |
847 local function fix(char) | |
848 return ("%%%02x"):format(char:byte()) | |
849 end | |
850 | |
851 local function urlencode(text) | |
852 return text:gsub("[^0-9A-Za-z]", fix) | |
853 end | |
854 | |
855 function AceAddon.prototype:OpenDonationFrame() | |
856 if createDonateFrame then | |
857 createDonateFrame() | |
858 end | |
859 local donate = self.donate | |
860 if type(donate) ~= "string" then | |
861 donate = "Wowace" | |
862 end | |
863 local style, data = (":"):split(donate, 2) | |
864 style = style:lower() | |
865 if style ~= "website" and style ~= "paypal" then | |
866 style = "wowace" | |
867 end | |
868 if style == "wowace" then | |
869 donateFrame.editBox.text = "http://www.wowace.com/wiki/Donations" | |
870 elseif style == "website" then | |
871 donateFrame.editBox.text = data | |
872 else -- PayPal | |
873 local text = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" .. urlencode(unobfuscateEmail(data)) | |
874 local name | |
875 if type(self.title) == "string" then | |
876 name = self.title | |
877 elseif type(self.name) == "string" then | |
878 name = self.name | |
879 end | |
880 if name then | |
881 name = name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") | |
882 text = text .. "&item_name=" .. urlencode(name) | |
883 end | |
884 donateFrame.editBox.text = text | |
885 end | |
886 donateFrame.editBox:SetText(donateFrame.editBox.text) | |
887 | |
888 if aboutFrame and aboutFrame:IsShown() then | |
889 aboutFrame:Hide() | |
890 end | |
891 | |
892 donateFrame:Show() | |
893 | |
894 donateFrame.editBox:SetFocus() | |
895 end | |
896 | |
897 local options | |
898 function AceAddon:GetAceOptionsDataTable(target) | |
899 return { | |
900 about = { | |
901 name = ABOUT, | |
902 desc = PRINT_ADDON_INFO, | |
903 type = "execute", | |
904 func = "PrintAddonInfo", | |
905 order = -1, | |
906 }, | |
907 donate = { | |
908 name = DONATE, | |
909 desc = DONATE_DESC, | |
910 type = "execute", | |
911 func = "OpenDonationFrame", | |
912 order = -1, | |
913 hidden = function() | |
914 return not target.donate | |
915 end | |
916 } | |
917 } | |
918 end | |
919 | |
920 function AceAddon:PLAYER_LOGIN() | |
921 self.playerLoginFired = true | |
922 if self.addonsToOnEnable then | |
923 while #self.addonsToOnEnable > 0 do | |
924 local addon = table.remove(self.addonsToOnEnable, 1) | |
925 self.addonsStarted[addon] = true | |
926 if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then | |
927 AceAddon:ManualEnable(addon) | |
928 end | |
929 end | |
930 self.addonsToOnEnable = nil | |
931 end | |
932 end | |
933 | |
934 function AceAddon.prototype:Inject(t) | |
935 AceAddon:argCheck(t, 2, "table") | |
936 for k,v in pairs(t) do | |
937 self[k] = v | |
938 end | |
939 end | |
940 | |
941 function AceAddon.prototype:init() | |
942 if not AceEvent then | |
943 error(MAJOR_VERSION .. " requires AceEvent-2.0", 4) | |
944 end | |
945 AceAddon.super.prototype.init(self) | |
946 | |
947 self.super = self.class.prototype | |
948 | |
949 AceAddon:RegisterEvent("ADDON_LOADED", "ADDON_LOADED") | |
950 local names = {} | |
951 for i = 1, GetNumAddOns() do | |
952 if IsAddOnLoaded(i) then names[GetAddOnInfo(i)] = true end | |
953 end | |
954 self.possibleNames = names | |
955 table.insert(AceAddon.nextAddon, self) | |
956 end | |
957 | |
958 function AceAddon.prototype:ToString() | |
959 local x | |
960 if type(self.title) == "string" then | |
961 x = self.title | |
962 elseif type(self.name) == "string" then | |
963 x = self.name | |
964 else | |
965 x = "<" .. tostring(self.class) .. " instance>" | |
966 end | |
967 if (type(self.IsActive) == "function" and not self:IsActive()) or (AceModuleCore and AceModuleCore:IsModule(addon) and AceModuleCore:IsModuleActive(addon)) then | |
968 x = x .. " " .. STANDBY | |
969 end | |
970 return x | |
971 end | |
972 | |
973 AceAddon.new = function(self, ...) | |
974 local class = AceAddon:pcall(AceOO.Classpool, self, ...) | |
975 return class:new() | |
976 end | |
977 | |
978 function AceAddon:ManualEnable(addon) | |
979 AceAddon:argCheck(addon, 2, "table") | |
980 local first = nil | |
981 if AceOO.inherits(addon, "AceAddon-2.0") then | |
982 if AceAddon.addonsEnabled and not AceAddon.addonsEnabled[addon] then | |
983 first = true | |
984 AceAddon.addonsEnabled[addon] = true | |
985 end | |
986 end | |
987 local current = addon.class | |
988 while current and current ~= AceOO.Class do | |
989 if current.mixins then | |
990 for mixin in pairs(current.mixins) do | |
991 if type(mixin.OnEmbedEnable) == "function" then | |
992 safecall(mixin.OnEmbedEnable, mixin, addon, first) | |
993 end | |
994 end | |
995 end | |
996 current = current.super | |
997 end | |
998 if type(addon.OnEnable) == "function" then | |
999 safecall(addon.OnEnable, addon, first) | |
1000 end | |
1001 if AceEvent then | |
1002 AceEvent:TriggerEvent("Ace2_AddonEnabled", addon, first) | |
1003 end | |
1004 end | |
1005 | |
1006 function AceAddon:ManualDisable(addon) | |
1007 AceAddon:argCheck(addon, 2, "table") | |
1008 local current = addon.class | |
1009 while current and current ~= AceOO.Class do | |
1010 if current.mixins then | |
1011 for mixin in pairs(current.mixins) do | |
1012 if type(mixin.OnEmbedDisable) == "function" then | |
1013 safecall(mixin.OnEmbedDisable, mixin, addon) | |
1014 end | |
1015 end | |
1016 end | |
1017 current = current.super | |
1018 end | |
1019 if type(module.OnDisable) == "function" then | |
1020 safecall(module.OnDisable, addon) | |
1021 end | |
1022 if AceEvent then | |
1023 AceEvent:TriggerEvent("Ace2_AddonDisabled", addon) | |
1024 end | |
1025 end | |
1026 | |
1027 local function external(self, major, instance) | |
1028 if major == "AceEvent-2.0" then | |
1029 AceEvent = instance | |
1030 | |
1031 AceEvent:embed(self) | |
1032 | |
1033 self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true) | |
1034 elseif major == "AceConsole-2.0" then | |
1035 AceConsole = instance | |
1036 | |
1037 local slashCommands = { "/ace2" } | |
1038 local _,_,_,enabled,loadable = GetAddOnInfo("Ace") | |
1039 if not enabled or not loadable then | |
1040 table.insert(slashCommands, "/ace") | |
1041 end | |
1042 local function listAddon(addon, depth) | |
1043 if not depth then | |
1044 depth = 0 | |
1045 end | |
1046 | |
1047 local s = (" "):rep(depth) .. " - " .. tostring(addon) | |
1048 if rawget(addon, 'version') then | |
1049 s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r" | |
1050 end | |
1051 if rawget(addon, 'slashCommand') then | |
1052 s = s .. " |cffffff7f(" .. tostring(addon.slashCommand) .. ")|r" | |
1053 end | |
1054 print(s) | |
1055 if type(rawget(addon, 'modules')) == "table" then | |
1056 local i = 0 | |
1057 for k,v in pairs(addon.modules) do | |
1058 i = i + 1 | |
1059 if i == 6 then | |
1060 print((" "):rep(depth + 1) .. " - more...") | |
1061 break | |
1062 else | |
1063 listAddon(v, depth + 1) | |
1064 end | |
1065 end | |
1066 end | |
1067 end | |
1068 local function listNormalAddon(i) | |
1069 local name,_,_,enabled,loadable = GetAddOnInfo(i) | |
1070 if not loadable then | |
1071 enabled = false | |
1072 end | |
1073 if self.addons[name] then | |
1074 listAddon(self.addons[name]) | |
1075 else | |
1076 local s = " - " .. tostring(GetAddOnMetadata(i, "Title") or name) | |
1077 local version = GetAddOnMetadata(i, "Version") | |
1078 if version then | |
1079 if version:find("%$Revision: (%d+) %$") then | |
1080 version = version:gsub("%$Revision: (%d+) %$", "%1") | |
1081 elseif version:find("%$Rev: (%d+) %$") then | |
1082 version = version:gsub("%$Rev: (%d+) %$", "%1") | |
1083 elseif version:find("%$LastChangedRevision: (%d+) %$") then | |
1084 version = version:gsub("%$LastChangedRevision: (%d+) %$", "%1") | |
1085 end | |
1086 s = s .. " - |cffffff7f" .. version .. "|r" | |
1087 end | |
1088 if not enabled then | |
1089 s = s .. " |cffff0000(disabled)|r" | |
1090 end | |
1091 if IsAddOnLoadOnDemand(i) then | |
1092 s = s .. " |cff00ff00[LoD]|r" | |
1093 end | |
1094 print(s) | |
1095 end | |
1096 end | |
1097 local function mySort(alpha, bravo) | |
1098 return tostring(alpha) < tostring(bravo) | |
1099 end | |
1100 AceConsole.RegisterChatCommand(self, slashCommands, { | |
1101 desc = "AddOn development framework", | |
1102 name = "Ace2", | |
1103 type = "group", | |
1104 args = { | |
1105 about = { | |
1106 desc = "Get information about Ace2", | |
1107 name = "About", | |
1108 type = "execute", | |
1109 func = function() | |
1110 print("|cffffff7fAce2|r - |cffffff7f2.0." .. MINOR_VERSION:gsub("%$Revision: (%d+) %$", "%1") .. "|r - AddOn development framework") | |
1111 print(" - |cffffff7f" .. AUTHOR .. ":|r Ace Development Team") | |
1112 print(" - |cffffff7f" .. WEBSITE .. ":|r http://www.wowace.com/") | |
1113 end | |
1114 }, | |
1115 list = { | |
1116 desc = "List addons", | |
1117 name = "List", | |
1118 type = "group", | |
1119 args = { | |
1120 ace2 = { | |
1121 desc = "List addons using Ace2", | |
1122 name = "Ace2", | |
1123 type = "execute", | |
1124 func = function() | |
1125 print("|cffffff7fAddon list:|r") | |
1126 table.sort(self.addons, mySort) | |
1127 for _,v in ipairs(self.addons) do | |
1128 listAddon(v) | |
1129 end | |
1130 end | |
1131 }, | |
1132 all = { | |
1133 desc = "List all addons", | |
1134 name = "All", | |
1135 type = "execute", | |
1136 func = function() | |
1137 print("|cffffff7fAddon list:|r") | |
1138 local count = GetNumAddOns() | |
1139 for i = 1, count do | |
1140 listNormalAddon(i) | |
1141 end | |
1142 end | |
1143 }, | |
1144 enabled = { | |
1145 desc = "List all enabled addons", | |
1146 name = "Enabled", | |
1147 type = "execute", | |
1148 func = function() | |
1149 print("|cffffff7fAddon list:|r") | |
1150 local count = GetNumAddOns() | |
1151 for i = 1, count do | |
1152 local _,_,_,enabled,loadable = GetAddOnInfo(i) | |
1153 if enabled and loadable then | |
1154 listNormalAddon(i) | |
1155 end | |
1156 end | |
1157 end | |
1158 }, | |
1159 disabled = { | |
1160 desc = "List all disabled addons", | |
1161 name = "Disabled", | |
1162 type = "execute", | |
1163 func = function() | |
1164 print("|cffffff7fAddon list:|r") | |
1165 local count = GetNumAddOns() | |
1166 for i = 1, count do | |
1167 local _,_,_,enabled,loadable = GetAddOnInfo(i) | |
1168 if not enabled or not loadable then | |
1169 listNormalAddon(i) | |
1170 end | |
1171 end | |
1172 end | |
1173 }, | |
1174 lod = { | |
1175 desc = "List all LoadOnDemand addons", | |
1176 name = "LoadOnDemand", | |
1177 type = "execute", | |
1178 func = function() | |
1179 print("|cffffff7fAddon list:|r") | |
1180 local count = GetNumAddOns() | |
1181 for i = 1, count do | |
1182 if IsAddOnLoadOnDemand(i) then | |
1183 listNormalAddon(i) | |
1184 end | |
1185 end | |
1186 end | |
1187 }, | |
1188 ace1 = { | |
1189 desc = "List all addons using Ace1", | |
1190 name = "Ace 1.x", | |
1191 type = "execute", | |
1192 func = function() | |
1193 print("|cffffff7fAddon list:|r") | |
1194 local count = GetNumAddOns() | |
1195 for i = 1, count do | |
1196 local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) | |
1197 if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then | |
1198 listNormalAddon(i) | |
1199 end | |
1200 end | |
1201 end | |
1202 }, | |
1203 libs = { | |
1204 desc = "List all libraries using AceLibrary", | |
1205 name = "Libraries", | |
1206 type = "execute", | |
1207 func = function() | |
1208 if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then | |
1209 print("|cffffff7fLibrary list:|r") | |
1210 for name, data in pairs(AceLibrary.libs) do | |
1211 local s | |
1212 if data.minor then | |
1213 s = " - " .. tostring(name) .. "." .. tostring(data.minor) | |
1214 else | |
1215 s = " - " .. tostring(name) | |
1216 end | |
1217 if rawget(AceLibrary(name), 'slashCommand') then | |
1218 s = s .. " |cffffff7f(" .. tostring(AceLibrary(name).slashCommand) .. "|cffffff7f)" | |
1219 end | |
1220 print(s) | |
1221 end | |
1222 end | |
1223 end | |
1224 }, | |
1225 search = { | |
1226 desc = "Search by name", | |
1227 name = "Search", | |
1228 type = "text", | |
1229 usage = "<keyword>", | |
1230 input = true, | |
1231 get = false, | |
1232 set = function(...) | |
1233 local arg = { ... } | |
1234 for i,v in ipairs(arg) do | |
1235 arg[i] = v:gsub('%*', '.*'):gsub('%%', '%%%%'):lower() | |
1236 end | |
1237 local count = GetNumAddOns() | |
1238 for i = 1, count do | |
1239 local name = GetAddOnInfo(i) | |
1240 local good = true | |
1241 for _,v in ipairs(arg) do | |
1242 if not name:lower():find(v) then | |
1243 good = false | |
1244 break | |
1245 end | |
1246 end | |
1247 if good then | |
1248 listNormalAddon(i) | |
1249 end | |
1250 end | |
1251 end | |
1252 } | |
1253 }, | |
1254 }, | |
1255 enable = { | |
1256 desc = "Enable addon(s).", | |
1257 name = "Enable", | |
1258 type = "text", | |
1259 usage = "<addon 1> <addon 2> ...", | |
1260 get = false, | |
1261 input = true, | |
1262 set = function(...) | |
1263 for i = 1, select("#", ...) do | |
1264 local addon = select(i, ...) | |
1265 local name, title, _, enabled, _, reason = GetAddOnInfo(addon) | |
1266 if reason == "MISSING" then | |
1267 print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon)) | |
1268 elseif not enabled then | |
1269 EnableAddOn(addon) | |
1270 print(("|cffffff7fAce2:|r %s is now enabled."):format(addon or name)) | |
1271 else | |
1272 print(("|cffffff7fAce2:|r %s is already enabled."):format(addon or name)) | |
1273 end | |
1274 end | |
1275 end, | |
1276 }, | |
1277 disable = { | |
1278 desc = "Disable addon(s).", | |
1279 name = "Disable", | |
1280 type = "text", | |
1281 usage = "<addon 1> <addon 2> ...", | |
1282 get = false, | |
1283 input = true, | |
1284 set = function(...) | |
1285 for i = 1, select("#", ...) do | |
1286 local addon = select(i, ...) | |
1287 local name, title, _, enabled, _, reason = GetAddOnInfo(addon) | |
1288 if reason == "MISSING" then | |
1289 print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon)) | |
1290 elseif enabled then | |
1291 DisableAddOn(addon) | |
1292 print(("|cffffff7fAce2:|r %s is now disabled."):format(addon or name)) | |
1293 else | |
1294 print(("|cffffff7fAce2:|r %s is already disabled."):format(addon or name)) | |
1295 end | |
1296 end | |
1297 end, | |
1298 }, | |
1299 load = { | |
1300 desc = "Load addon(s).", | |
1301 name = "Load", | |
1302 type = "text", | |
1303 usage = "<addon 1> <addon 2> ...", | |
1304 get = false, | |
1305 input = true, | |
1306 set = function(...) | |
1307 for i = 1, select("#", ...) do | |
1308 local addon = select(i, ...) | |
1309 local name, title, _, _, loadable, reason = GetAddOnInfo(addon) | |
1310 if reason == "MISSING" then | |
1311 print(("|cffffff7fAce2:|r AddOn %q does not exist."):format(addon)) | |
1312 elseif not loadable then | |
1313 print(("|cffffff7fAce2:|r AddOn %q is not loadable. Reason: %s."):format(addon, reason)) | |
1314 else | |
1315 LoadAddOn(addon) | |
1316 print(("|cffffff7fAce2:|r %s is now loaded."):format(addon or name)) | |
1317 end | |
1318 end | |
1319 end | |
1320 }, | |
1321 info = { | |
1322 desc = "Display information", | |
1323 name = "Information", | |
1324 type = "execute", | |
1325 func = function() | |
1326 local mem, threshold = gcinfo() | |
1327 print((" - |cffffff7fMemory usage [|r%.3f MiB|cffffff7f]|r"):format(mem / 1024)) | |
1328 if threshold then | |
1329 print((" - |cffffff7fThreshold [|r%.3f MiB|cffffff7f]|r"):format(threshold / 1024)) | |
1330 end | |
1331 print((" - |cffffff7fFramerate [|r%.0f fps|cffffff7f]|r"):format(GetFramerate())) | |
1332 local bandwidthIn, bandwidthOut, latency = GetNetStats() | |
1333 bandwidthIn, bandwidthOut = floor(bandwidthIn * 1024), floor(bandwidthOut * 1024) | |
1334 print((" - |cffffff7fLatency [|r%.0f ms|cffffff7f]|r"):format(latency)) | |
1335 print((" - |cffffff7fBandwidth in [|r%.0f B/s|cffffff7f]|r"):format(bandwidthIn)) | |
1336 print((" - |cffffff7fBandwidth out [|r%.0f B/s|cffffff7f]|r"):format(bandwidthOut)) | |
1337 print((" - |cffffff7fTotal addons [|r%d|cffffff7f]|r"):format(GetNumAddOns())) | |
1338 print((" - |cffffff7fAce2 addons [|r%d|cffffff7f]|r"):format(#self.addons)) | |
1339 local ace = 0 | |
1340 local enabled = 0 | |
1341 local disabled = 0 | |
1342 local lod = 0 | |
1343 for i = 1, GetNumAddOns() do | |
1344 local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) | |
1345 if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then | |
1346 ace = ace + 1 | |
1347 end | |
1348 if IsAddOnLoadOnDemand(i) then | |
1349 lod = lod + 1 | |
1350 end | |
1351 local isActive, loadable = select(4, GetAddOnInfo(i)) | |
1352 if not isActive or not loadable then | |
1353 disabled = disabled + 1 | |
1354 else | |
1355 enabled = enabled + 1 | |
1356 end | |
1357 end | |
1358 print((" - |cffffff7fAce 1.x addons [|r%d|cffffff7f]|r"):format(ace)) | |
1359 print((" - |cffffff7fLoadOnDemand addons [|r%d|cffffff7f]|r"):format(lod)) | |
1360 print((" - |cffffff7fenabled addons [|r%d|cffffff7f]|r"):format(enabled)) | |
1361 print((" - |cffffff7fdisabled addons [|r%d|cffffff7f]|r"):format(disabled)) | |
1362 local libs = 0 | |
1363 if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then | |
1364 for _ in pairs(AceLibrary.libs) do | |
1365 libs = libs + 1 | |
1366 end | |
1367 end | |
1368 print((" - |cffffff7fAceLibrary instances [|r%d|cffffff7f]|r"):format(libs)) | |
1369 end | |
1370 } | |
1371 } | |
1372 }) | |
1373 elseif major == "AceModuleCore-2.0" then | |
1374 AceModuleCore = instance | |
1375 end | |
1376 end | |
1377 | |
1378 local function activate(self, oldLib, oldDeactivate) | |
1379 AceAddon = self | |
1380 | |
1381 self.playerLoginFired = oldLib and oldLib.playerLoginFired or DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage | |
1382 self.addonsToOnEnable = oldLib and oldLib.addonsToOnEnable | |
1383 self.addons = oldLib and oldLib.addons or {} | |
1384 self.nextAddon = oldLib and oldLib.nextAddon or {} | |
1385 self.skipAddon = oldLib and oldLib.skipAddon or {} | |
1386 self.addonsStarted = oldLib and oldLib.addonsStarted or {} | |
1387 self.addonsEnabled = oldLib and oldLib.addonsEnabled or {} | |
1388 | |
1389 if oldDeactivate then | |
1390 oldDeactivate(oldLib) | |
1391 end | |
1392 end | |
1393 | |
1394 AceLibrary:Register(AceAddon, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |