vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Name: AceAddon-2.0 |
||
3 | Revision: $Rev: 14196 $ |
||
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: 14196 $" |
||
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"] = "Jไger", |
||
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 | else -- enUS |
||
178 | STANDBY = "|cffff5050(standby)|r" |
||
179 | |||
180 | TITLE = "Title" |
||
181 | NOTES = "Notes" |
||
182 | VERSION = "Version" |
||
183 | AUTHOR = "Author" |
||
184 | DATE = "Date" |
||
185 | CATEGORY = "Category" |
||
186 | EMAIL = "E-mail" |
||
187 | WEBSITE = "Website" |
||
188 | |||
189 | ABOUT = "About" |
||
190 | PRINT_ADDON_INFO = "Print out addon info" |
||
191 | |||
192 | CATEGORIES = { |
||
193 | ["Action Bars"] = "Action Bars", |
||
194 | ["Auction"] = "Auction", |
||
195 | ["Audio"] = "Audio", |
||
196 | ["Battlegrounds/PvP"] = "Battlegrounds/PvP", |
||
197 | ["Buffs"] = "Buffs", |
||
198 | ["Chat/Communication"] = "Chat/Communication", |
||
199 | ["Druid"] = "Druid", |
||
200 | ["Hunter"] = "Hunter", |
||
201 | ["Mage"] = "Mage", |
||
202 | ["Paladin"] = "Paladin", |
||
203 | ["Priest"] = "Priest", |
||
204 | ["Rogue"] = "Rogue", |
||
205 | ["Shaman"] = "Shaman", |
||
206 | ["Warlock"] = "Warlock", |
||
207 | ["Warrior"] = "Warrior", |
||
208 | ["Healer"] = "Healer", |
||
209 | ["Tank"] = "Tank", |
||
210 | ["Caster"] = "Caster", |
||
211 | ["Combat"] = "Combat", |
||
212 | ["Compilations"] = "Compilations", |
||
213 | ["Data Export"] = "Data Export", |
||
214 | ["Development Tools"] = "Development Tools", |
||
215 | ["Guild"] = "Guild", |
||
216 | ["Frame Modification"] = "Frame Modification", |
||
217 | ["Interface Enhancements"] = "Interface Enhancements", |
||
218 | ["Inventory"] = "Inventory", |
||
219 | ["Library"] = "Library", |
||
220 | ["Map"] = "Map", |
||
221 | ["Mail"] = "Mail", |
||
222 | ["Miscellaneous"] = "Miscellaneous", |
||
223 | ["Quest"] = "Quest", |
||
224 | ["Raid"] = "Raid", |
||
225 | ["Tradeskill"] = "Tradeskill", |
||
226 | ["UnitFrame"] = "UnitFrame", |
||
227 | } |
||
228 | end |
||
229 | |||
230 | setmetatable(CATEGORIES, { __index = function(self, key) -- case-insensitive |
||
231 | local lowerKey = string.lower(key) |
||
232 | for k,v in CATEGORIES do |
||
233 | if string.lower(k) == lowerKey then |
||
234 | return v |
||
235 | end |
||
236 | end |
||
237 | end }) |
||
238 | |||
239 | -- Create the library object |
||
240 | |||
241 | local AceOO = AceLibrary("AceOO-2.0") |
||
242 | local AceAddon = AceOO.Class() |
||
243 | local AceEvent |
||
244 | local AceConsole |
||
245 | local AceModuleCore |
||
246 | |||
247 | function AceAddon:ToString() |
||
248 | return "AceAddon" |
||
249 | end |
||
250 | |||
251 | local function print(text) |
||
252 | DEFAULT_CHAT_FRAME:AddMessage(text) |
||
253 | end |
||
254 | |||
255 | function AceAddon:ADDON_LOADED(name) |
||
256 | while table.getn(self.nextAddon) > 0 do |
||
257 | local addon = table.remove(self.nextAddon, 1) |
||
258 | table.insert(self.addons, addon) |
||
259 | if not self.addons[name] then |
||
260 | self.addons[name] = addon |
||
261 | end |
||
262 | self:InitializeAddon(addon, name) |
||
263 | end |
||
264 | end |
||
265 | |||
266 | local function RegisterOnEnable(self) |
||
267 | if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage then -- HACK |
||
268 | AceAddon.playerLoginFired = true |
||
269 | end |
||
270 | if AceAddon.playerLoginFired then |
||
271 | AceAddon.addonsStarted[self] = true |
||
272 | if (type(self.IsActive) ~= "function" or self:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(self) or AceModuleCore:IsModuleActive(self)) then |
||
273 | local current = self.class |
||
274 | while true do |
||
275 | if current == AceOO.Class then |
||
276 | break |
||
277 | end |
||
278 | if current.mixins then |
||
279 | for mixin in pairs(current.mixins) do |
||
280 | if type(mixin.OnEmbedEnable) == "function" then |
||
281 | mixin:OnEmbedEnable(self) |
||
282 | end |
||
283 | end |
||
284 | end |
||
285 | current = current.super |
||
286 | end |
||
287 | if type(self.OnEnable) == "function" then |
||
288 | self:OnEnable() |
||
289 | end |
||
290 | end |
||
291 | else |
||
292 | if not AceAddon.addonsToOnEnable then |
||
293 | AceAddon.addonsToOnEnable = {} |
||
294 | end |
||
295 | table.insert(AceAddon.addonsToOnEnable, self) |
||
296 | end |
||
297 | end |
||
298 | |||
299 | local function stripSpaces(text) |
||
300 | if type(text) == "string" then |
||
301 | return (string.gsub(string.gsub(text, "^%s*(.-)%s*$", "%1"), "%s%s+", " ")) |
||
302 | end |
||
303 | return text |
||
304 | end |
||
305 | |||
306 | function AceAddon:InitializeAddon(addon, name) |
||
307 | if addon.name == nil then |
||
308 | addon.name = name |
||
309 | end |
||
310 | if GetAddOnMetadata then |
||
311 | -- TOC checks |
||
312 | if addon.title == nil then |
||
313 | addon.title = GetAddOnMetadata(name, "Title") |
||
314 | if addon.title then |
||
315 | local num = string.find(addon.title, " |cff7fff7f %-Ace2%-|r$") |
||
316 | if num then |
||
317 | addon.title = string.sub(addon.title, 1, num - 1) |
||
318 | end |
||
319 | addon.title = stripSpaces(addon.title) |
||
320 | end |
||
321 | end |
||
322 | if addon.notes == nil then |
||
323 | addon.notes = GetAddOnMetadata(name, "Notes") |
||
324 | addon.notes = stripSpaces(addon.notes) |
||
325 | end |
||
326 | if addon.version == nil then |
||
327 | addon.version = GetAddOnMetadata(name, "Version") |
||
328 | if addon.version then |
||
329 | if string.find(addon.version, "%$Revision: (%d+) %$") then |
||
330 | addon.version = string.gsub(addon.version, "%$Revision: (%d+) %$", "%1") |
||
331 | elseif string.find(addon.version, "%$Rev: (%d+) %$") then |
||
332 | addon.version = string.gsub(addon.version, "%$Rev: (%d+) %$", "%1") |
||
333 | elseif string.find(addon.version, "%$LastChangedRevision: (%d+) %$") then |
||
334 | addon.version = string.gsub(addon.version, "%$LastChangedRevision: (%d+) %$", "%1") |
||
335 | end |
||
336 | end |
||
337 | addon.version = stripSpaces(addon.version) |
||
338 | end |
||
339 | if addon.author == nil then |
||
340 | addon.author = GetAddOnMetadata(name, "Author") |
||
341 | addon.author = stripSpaces(addon.author) |
||
342 | end |
||
343 | if addon.date == nil then |
||
344 | addon.date = GetAddOnMetadata(name, "X-Date") or GetAddOnMetadata(name, "X-ReleaseDate") |
||
345 | if addon.date then |
||
346 | if string.find(addon.date, "%$Date: (.-) %$") then |
||
347 | addon.date = string.gsub(addon.date, "%$Date: (.-) %$", "%1") |
||
348 | elseif string.find(addon.date, "%$LastChangedDate: (.-) %$") then |
||
349 | addon.date = string.gsub(addon.date, "%$LastChangedDate: (.-) %$", "%1") |
||
350 | end |
||
351 | end |
||
352 | addon.date = stripSpaces(addon.date) |
||
353 | end |
||
354 | if addon.category == nil then |
||
355 | addon.category = GetAddOnMetadata(name, "X-Category") |
||
356 | addon.category = stripSpaces(addon.category) |
||
357 | end |
||
358 | if addon.email == nil then |
||
359 | addon.email = GetAddOnMetadata(name, "X-eMail") or GetAddOnMetadata(name, "X-Email") |
||
360 | addon.email = stripSpaces(addon.email) |
||
361 | end |
||
362 | if addon.website == nil then |
||
363 | addon.website = GetAddOnMetadata(name, "X-Website") |
||
364 | addon.website = stripSpaces(addon.website) |
||
365 | end |
||
366 | end |
||
367 | local current = addon.class |
||
368 | while true do |
||
369 | if current == AceOO.Class then |
||
370 | break |
||
371 | end |
||
372 | if current.mixins then |
||
373 | for mixin in pairs(current.mixins) do |
||
374 | if type(mixin.OnEmbedInitialize) == "function" then |
||
375 | mixin:OnEmbedInitialize(addon, name) |
||
376 | end |
||
377 | end |
||
378 | end |
||
379 | current = current.super |
||
380 | end |
||
381 | if type(addon.OnInitialize) == "function" then |
||
382 | addon:OnInitialize(name) |
||
383 | end |
||
384 | RegisterOnEnable(addon) |
||
385 | end |
||
386 | |||
387 | function AceAddon.prototype:PrintAddonInfo() |
||
388 | local x |
||
389 | if self.title then |
||
390 | x = "|cffffff7f" .. tostring(self.title) .. "|r" |
||
391 | elseif self.name then |
||
392 | x = "|cffffff7f" .. tostring(self.name) .. "|r" |
||
393 | else |
||
394 | x = "|cffffff7f<" .. tostring(self.class) .. " instance>|r" |
||
395 | end |
||
396 | if type(self.IsActive) == "function" then |
||
397 | if not self:IsActive() then |
||
398 | x = x .. " " .. STANDBY |
||
399 | end |
||
400 | end |
||
401 | if self.version then |
||
402 | x = x .. " - |cffffff7f" .. tostring(self.version) .. "|r" |
||
403 | end |
||
404 | if self.notes then |
||
405 | x = x .. " - " .. tostring(self.notes) |
||
406 | end |
||
407 | print(x) |
||
408 | if self.author then |
||
409 | print(" - |cffffff7f" .. AUTHOR .. ":|r " .. tostring(self.author)) |
||
410 | end |
||
411 | if self.date then |
||
412 | print(" - |cffffff7f" .. DATE .. ":|r " .. tostring(self.date)) |
||
413 | end |
||
414 | if self.category then |
||
415 | local category = CATEGORIES[self.category] |
||
416 | if category then |
||
417 | print(" - |cffffff7f" .. CATEGORY .. ":|r " .. category) |
||
418 | end |
||
419 | end |
||
420 | if self.email then |
||
421 | print(" - |cffffff7f" .. EMAIL .. ":|r " .. tostring(self.email)) |
||
422 | end |
||
423 | if self.website then |
||
424 | print(" - |cffffff7f" .. WEBSITE .. ":|r " .. tostring(self.website)) |
||
425 | end |
||
426 | end |
||
427 | |||
428 | local options |
||
429 | function AceAddon:GetAceOptionsDataTable(target) |
||
430 | if not options then |
||
431 | options = { |
||
432 | about = { |
||
433 | name = ABOUT, |
||
434 | desc = PRINT_ADDON_INFO, |
||
435 | type = "execute", |
||
436 | func = "PrintAddonInfo", |
||
437 | order = -1, |
||
438 | } |
||
439 | } |
||
440 | end |
||
441 | return options |
||
442 | end |
||
443 | |||
444 | function AceAddon:PLAYER_LOGIN() |
||
445 | self.playerLoginFired = true |
||
446 | if self.addonsToOnEnable then |
||
447 | while table.getn(self.addonsToOnEnable) > 0 do |
||
448 | local addon = table.remove(self.addonsToOnEnable, 1) |
||
449 | self.addonsStarted[addon] = true |
||
450 | if (type(addon.IsActive) ~= "function" or addon:IsActive()) and (not AceModuleCore or not AceModuleCore:IsModule(addon) or AceModuleCore:IsModuleActive(addon)) then |
||
451 | local current = addon.class |
||
452 | while true do |
||
453 | if current == AceOO.Class then |
||
454 | break |
||
455 | end |
||
456 | if current.mixins then |
||
457 | for mixin in pairs(current.mixins) do |
||
458 | if type(mixin.OnEmbedEnable) == "function" then |
||
459 | mixin:OnEmbedEnable(addon) |
||
460 | end |
||
461 | end |
||
462 | end |
||
463 | current = current.super |
||
464 | end |
||
465 | if type(addon.OnEnable) == "function" then |
||
466 | addon:OnEnable() |
||
467 | end |
||
468 | end |
||
469 | end |
||
470 | self.addonsToOnEnable = nil |
||
471 | end |
||
472 | end |
||
473 | |||
474 | function AceAddon.prototype:Inject(t) |
||
475 | AceAddon:argCheck(t, 2, "table") |
||
476 | for k,v in pairs(t) do |
||
477 | self[k] = v |
||
478 | end |
||
479 | end |
||
480 | |||
481 | function AceAddon.prototype:init() |
||
482 | if not AceEvent then |
||
483 | error(MAJOR_VERSION .. " requires AceEvent-2.0", 4) |
||
484 | end |
||
485 | AceAddon.super.prototype.init(self) |
||
486 | |||
487 | self.super = self.class.prototype |
||
488 | |||
489 | AceAddon:RegisterEvent("ADDON_LOADED", "ADDON_LOADED", true) |
||
490 | table.insert(AceAddon.nextAddon, self) |
||
491 | end |
||
492 | |||
493 | function AceAddon.prototype:ToString() |
||
494 | local x |
||
495 | if type(self.title) == "string" then |
||
496 | x = self.title |
||
497 | elseif type(self.name) == "string" then |
||
498 | x = self.name |
||
499 | else |
||
500 | x = "<" .. tostring(self.class) .. " instance>" |
||
501 | end |
||
502 | if (type(self.IsActive) == "function" and not self:IsActive()) or (AceModuleCore and AceModuleCore:IsModule(addon) and AceModuleCore:IsModuleActive(addon)) then |
||
503 | x = x .. " " .. STANDBY |
||
504 | end |
||
505 | return x |
||
506 | end |
||
507 | |||
508 | AceAddon.new = function(self, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18, m19, m20) |
||
509 | 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) |
||
510 | return class:new() |
||
511 | end |
||
512 | |||
513 | local function external(self, major, instance) |
||
514 | if major == "AceEvent-2.0" then |
||
515 | AceEvent = instance |
||
516 | |||
517 | AceEvent:embed(self) |
||
518 | |||
519 | self:RegisterEvent("PLAYER_LOGIN", "PLAYER_LOGIN", true) |
||
520 | elseif major == "AceConsole-2.0" then |
||
521 | AceConsole = instance |
||
522 | |||
523 | local slashCommands = { "/ace2" } |
||
524 | local _,_,_,enabled,loadable = GetAddOnInfo("Ace") |
||
525 | if not enabled or not loadable then |
||
526 | table.insert(slashCommands, "/ace") |
||
527 | end |
||
528 | local function listAddon(addon, depth) |
||
529 | if not depth then |
||
530 | depth = 0 |
||
531 | end |
||
532 | |||
533 | local s = string.rep(" ", depth) .. " - " .. tostring(addon) |
||
534 | if rawget(addon, 'version') then |
||
535 | s = s .. " - |cffffff7f" .. tostring(addon.version) .. "|r" |
||
536 | end |
||
537 | if rawget(addon, 'slashCommand') then |
||
538 | s = s .. " |cffffff7f(" .. tostring(addon.slashCommand) .. ")|r" |
||
539 | end |
||
540 | print(s) |
||
541 | if type(rawget(addon, 'modules')) == "table" then |
||
542 | local i = 0 |
||
543 | for k,v in pairs(addon.modules) do |
||
544 | i = i + 1 |
||
545 | if i == 6 then |
||
546 | print(string.rep(" ", depth + 1) .. " - more...") |
||
547 | break |
||
548 | else |
||
549 | listAddon(v, depth + 1) |
||
550 | end |
||
551 | end |
||
552 | end |
||
553 | end |
||
554 | local function listNormalAddon(i) |
||
555 | local name,_,_,enabled,loadable = GetAddOnInfo(i) |
||
556 | if not loadable then |
||
557 | enabled = false |
||
558 | end |
||
559 | if self.addons[name] then |
||
560 | local addon = self.addons[name] |
||
561 | if not AceCoreAddon or not AceCoreAddon:IsModule(addon) then |
||
562 | listAddon(addon) |
||
563 | end |
||
564 | else |
||
565 | local s = " - " .. tostring(GetAddOnMetadata(i, "Title") or name) |
||
566 | local version = GetAddOnMetadata(i, "Version") |
||
567 | if version then |
||
568 | if string.find(version, "%$Revision: (%d+) %$") then |
||
569 | version = string.gsub(version, "%$Revision: (%d+) %$", "%1") |
||
570 | elseif string.find(version, "%$Rev: (%d+) %$") then |
||
571 | version = string.gsub(version, "%$Rev: (%d+) %$", "%1") |
||
572 | elseif string.find(version, "%$LastChangedRevision: (%d+) %$") then |
||
573 | version = string.gsub(version, "%$LastChangedRevision: (%d+) %$", "%1") |
||
574 | end |
||
575 | s = s .. " - |cffffff7f" .. version .. "|r" |
||
576 | end |
||
577 | if not enabled then |
||
578 | s = s .. " |cffff0000(disabled)|r" |
||
579 | end |
||
580 | if IsAddOnLoadOnDemand(i) then |
||
581 | s = s .. " |cff00ff00[LoD]|r" |
||
582 | end |
||
583 | print(s) |
||
584 | end |
||
585 | end |
||
586 | local function mySort(alpha, bravo) |
||
587 | return tostring(alpha) < tostring(bravo) |
||
588 | end |
||
589 | AceConsole.RegisterChatCommand(self, slashCommands, { |
||
590 | desc = "AddOn development framework", |
||
591 | name = "Ace2", |
||
592 | type = "group", |
||
593 | args = { |
||
594 | about = { |
||
595 | desc = "Get information about Ace2", |
||
596 | name = "About", |
||
597 | type = "execute", |
||
598 | func = function() |
||
599 | print("|cffffff7fAce2|r - |cffffff7f2.0." .. string.gsub(MINOR_VERSION, "%$Revision: (%d+) %$", "%1") .. "|r - AddOn development framework") |
||
600 | print(" - |cffffff7f" .. AUTHOR .. ":|r Ace Development Team") |
||
601 | print(" - |cffffff7f" .. WEBSITE .. ":|r http://www.wowace.com/") |
||
602 | end |
||
603 | }, |
||
604 | list = { |
||
605 | desc = "List addons", |
||
606 | name = "List", |
||
607 | type = "group", |
||
608 | args = { |
||
609 | ace2 = { |
||
610 | desc = "List addons using Ace2", |
||
611 | name = "Ace2", |
||
612 | type = "execute", |
||
613 | func = function() |
||
614 | print("|cffffff7fAddon list:|r") |
||
615 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
616 | table.sort(self.addons, mySort) |
||
617 | for _,v in ipairs(self.addons) do |
||
618 | if not AceCoreAddon or not AceCoreAddon:IsModule(v) then |
||
619 | listAddon(v) |
||
620 | end |
||
621 | end |
||
622 | end |
||
623 | }, |
||
624 | all = { |
||
625 | desc = "List all addons", |
||
626 | name = "All", |
||
627 | type = "execute", |
||
628 | func = function() |
||
629 | print("|cffffff7fAddon list:|r") |
||
630 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
631 | local count = GetNumAddOns() |
||
632 | for i = 1, count do |
||
633 | listNormalAddon(i) |
||
634 | end |
||
635 | end |
||
636 | }, |
||
637 | enabled = { |
||
638 | desc = "List all enabled addons", |
||
639 | name = "Enabled", |
||
640 | type = "execute", |
||
641 | func = function() |
||
642 | print("|cffffff7fAddon list:|r") |
||
643 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
644 | local count = GetNumAddOns() |
||
645 | for i = 1, count do |
||
646 | local _,_,_,enabled,loadable = GetAddOnInfo(i) |
||
647 | if enabled and loadable then |
||
648 | listNormalAddon(i) |
||
649 | end |
||
650 | end |
||
651 | end |
||
652 | }, |
||
653 | disabled = { |
||
654 | desc = "List all disabled addons", |
||
655 | name = "Disabled", |
||
656 | type = "execute", |
||
657 | func = function() |
||
658 | print("|cffffff7fAddon list:|r") |
||
659 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
660 | local count = GetNumAddOns() |
||
661 | for i = 1, count do |
||
662 | local _,_,_,enabled,loadable = GetAddOnInfo(i) |
||
663 | if not enabled or not loadable then |
||
664 | listNormalAddon(i) |
||
665 | end |
||
666 | end |
||
667 | end |
||
668 | }, |
||
669 | lod = { |
||
670 | desc = "List all LoadOnDemand addons", |
||
671 | name = "LoadOnDemand", |
||
672 | type = "execute", |
||
673 | func = function() |
||
674 | print("|cffffff7fAddon list:|r") |
||
675 | local AceCoreAddon = AceLibrary:HasInstance("AceCoreAddon-2.0") and AceLibrary("AceCoreAddon-2.0") |
||
676 | local count = GetNumAddOns() |
||
677 | for i = 1, count do |
||
678 | if IsAddOnLoadOnDemand(i) then |
||
679 | listNormalAddon(i) |
||
680 | end |
||
681 | end |
||
682 | end |
||
683 | }, |
||
684 | ace1 = { |
||
685 | desc = "List all addons using Ace1", |
||
686 | name = "Ace 1.x", |
||
687 | type = "execute", |
||
688 | func = function() |
||
689 | print("|cffffff7fAddon list:|r") |
||
690 | local count = GetNumAddOns() |
||
691 | for i = 1, count do |
||
692 | local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) |
||
693 | if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then |
||
694 | listNormalAddon(i) |
||
695 | end |
||
696 | end |
||
697 | end |
||
698 | }, |
||
699 | libs = { |
||
700 | desc = "List all libraries using AceLibrary", |
||
701 | name = "Libraries", |
||
702 | type = "execute", |
||
703 | func = function() |
||
704 | if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then |
||
705 | print("|cffffff7fLibrary list:|r") |
||
706 | for name, data in pairs(AceLibrary.libs) do |
||
707 | local s |
||
708 | if data.minor then |
||
709 | s = " - " .. tostring(name) .. "." .. tostring(data.minor) |
||
710 | else |
||
711 | s = " - " .. tostring(name) |
||
712 | end |
||
713 | if AceLibrary(name).slashCommand then |
||
714 | s = s .. " |cffffff7f(" .. tostring(AceLibrary(name).slashCommand) .. "|cffffff7f)" |
||
715 | end |
||
716 | print(s) |
||
717 | end |
||
718 | end |
||
719 | end |
||
720 | }, |
||
721 | search = { |
||
722 | desc = "Search by name", |
||
723 | name = "Search", |
||
724 | type = "text", |
||
725 | usage = "<keyword>", |
||
726 | input = true, |
||
727 | get = false, |
||
728 | set = function(...) |
||
729 | for i,v in ipairs(arg) do |
||
730 | arg[i] = string.lower(string.gsub(string.gsub(v, '%*', '.*'), '%%', '%%%%')) |
||
731 | end |
||
732 | local count = GetNumAddOns() |
||
733 | for i = 1, count do |
||
734 | local name = GetAddOnInfo(i) |
||
735 | local good = true |
||
736 | for _,v in ipairs(arg) do |
||
737 | if not string.find(string.lower(name), v) then |
||
738 | good = false |
||
739 | break |
||
740 | end |
||
741 | end |
||
742 | if good then |
||
743 | listNormalAddon(i) |
||
744 | end |
||
745 | end |
||
746 | end |
||
747 | } |
||
748 | }, |
||
749 | }, |
||
750 | enable = { |
||
751 | desc = "Enable addon", |
||
752 | name = "Enable", |
||
753 | type = "text", |
||
754 | usage = "<addon>", |
||
755 | get = false, |
||
756 | set = function(text) |
||
757 | local name,title,_,_,_,reason = GetAddOnInfo(text) |
||
758 | if reason == "MISSING" then |
||
759 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text)) |
||
760 | else |
||
761 | EnableAddOn(text) |
||
762 | print(string.format("|cffffff7fAce2:|r %s is now enabled", title or name)) |
||
763 | end |
||
764 | end, |
||
765 | }, |
||
766 | disable = { |
||
767 | desc = "Disable addon", |
||
768 | name = "Disable", |
||
769 | type = "text", |
||
770 | usage = "<addon>", |
||
771 | get = false, |
||
772 | set = function(text) |
||
773 | local name,title,_,_,_,reason = GetAddOnInfo(text) |
||
774 | if reason == "MISSING" then |
||
775 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist", text)) |
||
776 | else |
||
777 | DisableAddOn(text) |
||
778 | print(string.format("|cffffff7fAce2:|r %s is now disabled", title or name)) |
||
779 | end |
||
780 | end, |
||
781 | }, |
||
782 | load = { |
||
783 | desc = "Load addon", |
||
784 | name = "Load", |
||
785 | type = "text", |
||
786 | usage = "<addon>", |
||
787 | get = false, |
||
788 | set = function(text) |
||
789 | local name,title,_,_,loadable,reason = GetAddOnInfo(text) |
||
790 | if reason == "MISSING" then |
||
791 | print(string.format("|cffffff7fAce2:|r AddOn %q does not exist.", text)) |
||
792 | elseif not loadable then |
||
793 | print(string.format("|cffffff7fAce2:|r AddOn %q is not loadable. Reason: %s", text, reason)) |
||
794 | else |
||
795 | LoadAddOn(text) |
||
796 | print(string.format("|cffffff7fAce2:|r %s is now loaded", title or name)) |
||
797 | end |
||
798 | end |
||
799 | }, |
||
800 | info = { |
||
801 | desc = "Display information", |
||
802 | name = "Information", |
||
803 | type = "execute", |
||
804 | func = function() |
||
805 | local mem, threshold = gcinfo() |
||
806 | print(string.format(" - |cffffff7fMemory usage [|r%.3f MiB|cffffff7f]|r", mem / 1024)) |
||
807 | print(string.format(" - |cffffff7fThreshold [|r%.3f MiB|cffffff7f]|r", threshold / 1024)) |
||
808 | print(string.format(" - |cffffff7fFramerate [|r%.0f fps|cffffff7f]|r", GetFramerate())) |
||
809 | local bandwidthIn, bandwidthOut, latency = GetNetStats() |
||
810 | bandwidthIn, bandwidthOut = floor(bandwidthIn * 1024), floor(bandwidthOut * 1024) |
||
811 | print(string.format(" - |cffffff7fLatency [|r%.0f ms|cffffff7f]|r", latency)) |
||
812 | print(string.format(" - |cffffff7fBandwidth in [|r%.0f B/s|cffffff7f]|r", bandwidthIn)) |
||
813 | print(string.format(" - |cffffff7fBandwidth out [|r%.0f B/s|cffffff7f]|r", bandwidthOut)) |
||
814 | print(string.format(" - |cffffff7fTotal addons [|r%d|cffffff7f]|r", GetNumAddOns())) |
||
815 | print(string.format(" - |cffffff7fAce2 addons [|r%d|cffffff7f]|r", table.getn(self.addons))) |
||
816 | local ace = 0 |
||
817 | local enabled = 0 |
||
818 | local disabled = 0 |
||
819 | local lod = 0 |
||
820 | for i = 1, GetNumAddOns() do |
||
821 | local dep1, dep2, dep3, dep4 = GetAddOnDependencies(i) |
||
822 | if dep1 == "Ace" or dep2 == "Ace" or dep3 == "Ace" or dep4 == "Ace" then |
||
823 | ace = ace + 1 |
||
824 | end |
||
825 | if IsAddOnLoadOnDemand(i) then |
||
826 | lod = lod + 1 |
||
827 | end |
||
828 | local _,_,_,IsActive,loadable = GetAddOnInfo(i) |
||
829 | if not IsActive or not loadable then |
||
830 | disabled = disabled + 1 |
||
831 | else |
||
832 | enabled = enabled + 1 |
||
833 | end |
||
834 | end |
||
835 | print(string.format(" - |cffffff7fAce 1.x addons [|r%d|cffffff7f]|r", ace)) |
||
836 | print(string.format(" - |cffffff7fLoadOnDemand addons [|r%d|cffffff7f]|r", lod)) |
||
837 | print(string.format(" - |cffffff7fenabled addons [|r%d|cffffff7f]|r", enabled)) |
||
838 | print(string.format(" - |cffffff7fdisabled addons [|r%d|cffffff7f]|r", disabled)) |
||
839 | local libs = 0 |
||
840 | if type(AceLibrary) == "table" and type(AceLibrary.libs) == "table" then |
||
841 | for _ in pairs(AceLibrary.libs) do |
||
842 | libs = libs + 1 |
||
843 | end |
||
844 | end |
||
845 | print(string.format(" - |cffffff7fAceLibrary instances [|r%d|cffffff7f]|r", libs)) |
||
846 | end |
||
847 | } |
||
848 | } |
||
849 | }) |
||
850 | elseif major == "AceModuleCore-2.0" then |
||
851 | AceModuleCore = instance |
||
852 | end |
||
853 | end |
||
854 | |||
855 | local function activate(self, oldLib, oldDeactivate) |
||
856 | AceAddon = self |
||
857 | |||
858 | if oldLib then |
||
859 | self.playerLoginFired = oldLib.playerLoginFired or DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.defaultLanguage |
||
860 | self.addonsToOnEnable = oldLib.addonsToOnEnable |
||
861 | self.addons = oldLib.addons |
||
862 | self.nextAddon = oldLib.nextAddon |
||
863 | self.addonsStarted = oldLib.addonsStarted |
||
864 | end |
||
865 | if not self.addons then |
||
866 | self.addons = {} |
||
867 | end |
||
868 | if not self.nextAddon then |
||
869 | self.nextAddon = {} |
||
870 | end |
||
871 | if not self.addonsStarted then |
||
872 | self.addonsStarted = {} |
||
873 | end |
||
874 | if oldDeactivate then |
||
875 | oldDeactivate(oldLib) |
||
876 | end |
||
877 | end |
||
878 | |||
879 | AceLibrary:Register(AceAddon, MAJOR_VERSION, MINOR_VERSION, activate, nil, external) |
||
880 | AceAddon = AceLibrary(MAJOR_VERSION) |