vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | ------------------------------ |
||
3 | -- Are you local? -- |
||
4 | ------------------------------ |
||
5 | |||
6 | local BZ = AceLibrary("Babble-Zone-2.2") |
||
7 | local BB = AceLibrary("Babble-Boss-2.2") |
||
8 | local L = AceLibrary("AceLocale-2.2"):new("BigWigs") |
||
9 | |||
10 | |||
11 | ---------------------------- |
||
12 | -- Localization -- |
||
13 | ---------------------------- |
||
14 | |||
15 | L:RegisterTranslations("enUS", function() return { |
||
16 | ["%s mod enabled"] = true, |
||
17 | ["Target monitoring enabled"] = true, |
||
18 | ["Target monitoring disabled"] = true, |
||
19 | ["%s has been defeated"] = true, -- "<boss> has been defeated" |
||
20 | ["%s have been defeated"] = true, -- "<bosses> have been defeated" |
||
21 | |||
22 | -- AceConsole strings |
||
23 | ["boss"] = true, |
||
24 | ["Bosses"] = true, |
||
25 | ["Options for boss modules."] = true, |
||
26 | ["Options for bosses in %s."] = true, -- "Options for bosses in <zone>" |
||
27 | ["Options for %s (r%s)."] = true, -- "Options for <boss> (<revision>)" |
||
28 | ["plugin"] = true, |
||
29 | ["Plugins"] = true, |
||
30 | ["Options for plugins."] = true, |
||
31 | ["extra"] = true, |
||
32 | ["Extras"] = true, |
||
33 | ["Options for extras."] = true, |
||
34 | ["toggle"] = true, |
||
35 | ["Active"] = true, |
||
36 | ["Activate or deactivate this module."] = true, |
||
37 | ["reboot"] = true, |
||
38 | ["Reboot"] = true, |
||
39 | ["Reboot this module."] = true, |
||
40 | ["debug"] = true, |
||
41 | ["Debugging"] = true, |
||
42 | ["Show debug messages."] = true, |
||
43 | bosskill_cmd = "kill", |
||
44 | bosskill_name = "Boss death", |
||
45 | bosskill_desc = "Announce when boss is defeated", |
||
46 | |||
47 | ["Other"] = true, |
||
48 | ["Load"] = true, |
||
49 | ["Load All"] = true, |
||
50 | ["Load all %s modules."] = true, |
||
51 | |||
52 | -- AceConsole zone commands |
||
53 | ["Zul'Gurub"] = "ZG", |
||
54 | ["Molten Core"] = "MC", |
||
55 | ["Blackwing Lair"] = "BWL", |
||
56 | ["Ahn'Qiraj"] = "AQ40", |
||
57 | ["Ruins of Ahn'Qiraj"] = "AQ20", |
||
58 | ["Onyxia's Lair"] = "Onyxia", |
||
59 | ["Naxxramas"] = "Naxxramas", |
||
60 | ["Silithus"] = true, |
||
61 | ["Outdoor Raid Bosses"] = "Outdoor", |
||
62 | ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
63 | } end) |
||
64 | |||
65 | L:RegisterTranslations("frFR", function() return { |
||
66 | ["%s mod enabled"] = "Module %s activ\195\169", |
||
67 | ["Target monitoring enabled"] = "Suivi des cibles activ\195\169", |
||
68 | ["Target monitoring disabled"] = "Suivi des cibles d\195\169sactiv\195\169", |
||
69 | ["%s has been defeated"] = "%s a \195\169t\195\169 vaincu", -- "<boss> has been defeated" |
||
70 | ["%s have been defeated"] = "%s ont \195\169t\195\169 vaincu", -- "<bosses> have been defeated" |
||
71 | |||
72 | -- AceConsole strings |
||
73 | -- ["boss"] = true, |
||
74 | ["Bosses"] = "Boss", |
||
75 | ["Options for boss modules."] = "Options des modules des boss.", |
||
76 | ["Options for bosses in %s."] = "Options des boss dans %s.", -- "Options for bosses in <zone>" |
||
77 | ["Options for %s (r%s)."] = "Options pour %s (r%s).", -- "Options for <boss> (<revision>)" |
||
78 | -- ["plugin"] = true, |
||
79 | -- ["Plugins"] = true, |
||
80 | ["Options for plugins."] = "Options pour les plugins.", |
||
81 | -- ["extra"] = true, |
||
82 | -- ["Extras"] = true, |
||
83 | ["Options for extras."] ="Options pour les extras.", |
||
84 | -- ["toggle"] = true, |
||
85 | ["Active"] = "Actif", |
||
86 | ["Activate or deactivate this module."] = "Activer ou d\195\169sactiver ce module.", |
||
87 | -- ["reboot"] = true, |
||
88 | ["Reboot"] = "Red\195\169marrer", |
||
89 | ["Reboot this module."] = "Red\195\169marrer ce module.", |
||
90 | -- ["debug"] = true, |
||
91 | ["Debugging"] = "D\195\169boguage", |
||
92 | ["Show debug messages."] = "Afficher les messages de d\195\169boguage.", |
||
93 | bosskill_name = "Mort des Boss", |
||
94 | bosskill_desc = "Annoncer la mort des boss.", |
||
95 | |||
96 | -- AceConsole zone commands |
||
97 | ["Zul'Gurub"] = "ZG", |
||
98 | ["Molten Core"] = "MC", |
||
99 | ["Blackwing Lair"] = "BWL", |
||
100 | ["Ahn'Qiraj"] = "AQ40", |
||
101 | ["Ruins of Ahn'Qiraj"] = "AQ20", |
||
102 | ["Onyxia's Lair"] = "Onyxia", |
||
103 | ["Naxxramas"] = "Naxxramas", |
||
104 | -- ["Silithus"] = true, |
||
105 | ["Outdoor Raid Bosses"] = "Ext\195\169rieur", |
||
106 | ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
107 | } end) |
||
108 | |||
109 | L:RegisterTranslations("deDE", function() return { |
||
110 | ["%s mod enabled"] = "%s Modul aktiviert", |
||
111 | ["Target monitoring enabled"] = "Ziel\195\188berwachung aktiviert", |
||
112 | ["Target monitoring disabled"] = "Ziel\195\188berwachung deaktiviert", |
||
113 | ["%s has been defeated"] = "%s wurde besiegt", -- "<boss> has been defeated" |
||
114 | ["%s have been defeated"] = "%s wurden besiegt", -- "<bosses> have been defeated" |
||
115 | |||
116 | -- AceConsole strings |
||
117 | -- ["boss"] = true, |
||
118 | ["Bosses"] = "Bosse", |
||
119 | ["Options for boss modules."] = "Optionen f\195\188r Boss Module.", |
||
120 | ["Options for bosses in %s."] = "Optionen f\195\188r Bosse in %s.", -- "Options for bosses in <zone>" |
||
121 | ["Options for %s (r%s)."] = "Optionen f\195\188r %s (r%s).", -- "Options for <boss> (<revision>)" |
||
122 | -- ["plugin"] = true, |
||
123 | ["Plugins"] = "Plugins", |
||
124 | ["Options for plugins."] = "Optionen f\195\188r Plugins.", |
||
125 | -- ["extra"] = true, |
||
126 | ["Extras"] = "Extras", |
||
127 | ["Options for extras."] = "Optionen f\195\188r Extras.", |
||
128 | -- ["toggle"] = true, |
||
129 | ["Active"] = "Aktivieren", |
||
130 | ["Activate or deactivate this module."] = "Aktiviert oder deaktiviert dieses Modul.", |
||
131 | -- ["reboot"] = true, |
||
132 | ["Reboot"] = "Neustarten", |
||
133 | ["Reboot this module."] = "Startet dieses Modul neu.", |
||
134 | -- ["debug"] = true, |
||
135 | ["Debugging"] = "Debugging", |
||
136 | ["Show debug messages."] = "Zeige Debug Nachrichten.", |
||
137 | -- bosskill_cmd = "kill", |
||
138 | bosskill_name = "Boss besiegt", |
||
139 | bosskill_desc = "Melde, wenn ein Boss besiegt wurde.", |
||
140 | |||
141 | -- AceConsole zone commands |
||
142 | ["Zul'Gurub"] = "ZG", |
||
143 | ["Molten Core"] = "MC", |
||
144 | ["Blackwing Lair"] = "BWL", |
||
145 | ["Ahn'Qiraj"] = "AQ40", |
||
146 | ["Ruins of Ahn'Qiraj"] = "AQ20", |
||
147 | ["Onyxia's Lair"] = "Onyxia", |
||
148 | ["Naxxramas"] = "Naxxramas", |
||
149 | -- ["Silithus"] = true, |
||
150 | ["Outdoor Raid Bosses"] = "Outdoor", |
||
151 | -- ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
152 | } end) |
||
153 | |||
154 | L:RegisterTranslations("koKR", function() return { |
||
155 | ["%s mod enabled"] = "%s 모듈 시작", |
||
156 | ["Target monitoring enabled"] = "타겟 확인 시작", |
||
157 | ["Target monitoring disabled"] = "타겟 확인 꺼짐", |
||
158 | ["%s has been defeated"] = "<%s> 물리쳤습니다.", -- "<boss> has been defeated" |
||
159 | ["%s have been defeated"] = "<%s> 물리쳤습니다.", -- "<bosses> have been defeated" |
||
160 | |||
161 | -- AceConsole strings |
||
162 | ["Bosses"] = "보스들", |
||
163 | ["Options for boss modules."] = "보스 모듈 설정", |
||
164 | ["Options for bosses in %s."] = "%s 에 보스들을 위한 설정", -- "Options for bosses in <zone>" |
||
165 | ["Options for %s (r%s)."] = "%s에 대한 설정(r%s).", -- "Options for <boss> (<revision>)" |
||
166 | ["Plugins"] = "플러그인들", |
||
167 | ["Options for plugins."] = "플러그인 설정", |
||
168 | ["Extras"] = "기타", |
||
169 | ["Options for extras."] = "기타 설정.", |
||
170 | ["Active"] = "활성화", |
||
171 | ["Activate or deactivate this module."] = "활성화 혹은 모둘 발견", |
||
172 | ["Reboot"] = "재시작", |
||
173 | ["Reboot this module."] = "모듈 재시작", |
||
174 | ["Debugging"] = "디버깅", |
||
175 | ["Show debug messages."] = "디버그 메세지 표시", |
||
176 | bosskill_name = "보스 사망", |
||
177 | bosskill_desc = "보스를 물리쳤을 때 알림", |
||
178 | |||
179 | ["Other"] = "외부", |
||
180 | ["Load"] = "불러오기", |
||
181 | ["Load All"] = "모두 불러오기", |
||
182 | ["Load all %s modules."] = "모든 %s 모듈들을 불러옵니다.", |
||
183 | |||
184 | -- AceConsole zone commands |
||
185 | ["Zul'Gurub"] = "ZG", |
||
186 | ["Molten Core"] = "MC", |
||
187 | ["Blackwing Lair"] = "BWL", |
||
188 | ["Ahn'Qiraj"] = "AQ40", |
||
189 | ["Ruins of Ahn'Qiraj"] = "AQ20", |
||
190 | ["Onyxia's Lair"] = "오닉시아", |
||
191 | ["Naxxramas"] = "낙스라마스", |
||
192 | ["Silithus"] = "실리더스", |
||
193 | ["Outdoor Raid Bosses"] = "야외", |
||
194 | ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
195 | } end) |
||
196 | |||
197 | L:RegisterTranslations("zhCN", function() return { |
||
198 | ["%s mod enabled"] = "%s模块已开启", |
||
199 | ["Target monitoring enabled"] = "目标监视已开启", |
||
200 | ["Target monitoring disabled"] = "目标监视已关闭", |
||
201 | ["%s has been defeated"] = "%s被击败了!", -- "<boss> has been defeated" |
||
202 | ["%s have been defeated"] = "%s被击败了!", -- "<bosses> have been defeated" |
||
203 | |||
204 | -- AceConsole strings |
||
205 | ["Bosses"] = "首领", |
||
206 | ["boss"] = "首领", |
||
207 | ["Options for boss modules."] = "首领模块设置。", |
||
208 | ["Options for bosses in %s."] = "%s首领模块设置。", -- "Options for bosses in <zone>" |
||
209 | ["Options for %s (r%s)."] = "%s模块设置 版本(r%s).", -- "Options for <boss> (<revision>)" |
||
210 | ["plugin"] = "插件", |
||
211 | ["Plugins"] = "插件", |
||
212 | ["Options for plugins."] = "插件设置。", |
||
213 | ["extra"] = "额外", |
||
214 | ["Extras"] = "额外", |
||
215 | ["Options for extras."] = "额外的设置", |
||
216 | ["toggle"] = "切换", |
||
217 | ["Active"] = "激活", |
||
218 | ["Activate or deactivate this module."] = "激活或关闭此模块。", |
||
219 | ["reboot"] = "重启", |
||
220 | ["Reboot"] = "重启", |
||
221 | ["Reboot this module."] = "重启此模块", |
||
222 | ["debug"] = "除错", |
||
223 | ["Debugging"] = "除错", |
||
224 | ["Show debug messages."] = "显示除错信息。", |
||
225 | bosskill_name = "首领死亡", |
||
226 | bosskill_desc = "首领死亡时提示", |
||
227 | |||
228 | ["Other"] = "其他", |
||
229 | ["Load"] = "载入", |
||
230 | ["Load All"] = "载入所有", |
||
231 | ["Load all %s modules."] = "载入所有%s的模块", |
||
232 | |||
233 | bosskill_name = "首领死亡", |
||
234 | bosskill_desc = "首领被击败时发出提示", |
||
235 | |||
236 | -- AceConsole zone commands |
||
237 | ["Zul'Gurub"] = "祖尔格拉布", |
||
238 | ["Molten Core"] = "熔火之心", |
||
239 | ["Blackwing Lair"] = "黑翼之巢", |
||
240 | ["Ahn'Qiraj"] = "安其拉", |
||
241 | ["Ruins of Ahn'Qiraj"] = "安其拉废墟", |
||
242 | ["Onyxia's Lair"] = "奥妮克希亚的巢穴", |
||
243 | ["Naxxramas"] = "纳克萨玛斯", |
||
244 | ["Silithus"] = "希利苏斯", |
||
245 | ["Outdoor Raid Bosses"] = "野外首领", |
||
246 | ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
247 | } end) |
||
248 | |||
249 | L:RegisterTranslations("zhTW", function() return { |
||
250 | ["%s mod enabled"] = "%s模組已開啟", |
||
251 | ["Target monitoring enabled"] = "目標監視已開啟", |
||
252 | ["Target monitoring disabled"] = "目標監視已關閉", |
||
253 | ["%s has been defeated"] = "%s被擊敗了!", -- "<boss> has been defeated" |
||
254 | ["%s have been defeated"] = "%s被擊敗了!", -- "<bosses> have been defeated" |
||
255 | |||
256 | -- AceConsole strings |
||
257 | ["Bosses"] = "首領", |
||
258 | ["boss"] = "boss", |
||
259 | ["Options for boss modules."] = "首領模組選項。", |
||
260 | ["Options for bosses in %s."] = "%s首領模組選項。", -- "Options for bosses in <zone>" |
||
261 | ["Options for %s (r%s)."] = "%s模組選項 版本(r%s).", -- "Options for <boss> (<revision>)" |
||
262 | ["Extras"] = "其他", |
||
263 | ["Options for extras."] = "其他模組選項", |
||
264 | ["Plugins"] = "插件", |
||
265 | ["Options for plugins."] = "插件選項。", |
||
266 | ["toggle"] = "切換", |
||
267 | ["Active"] = "啟動", |
||
268 | ["Activate or deactivate this module."] = "開啟或關閉此模組。", |
||
269 | ["Reboot"] = "重啟", |
||
270 | ["Reboot this module."] = "重啟此模組", |
||
271 | ["Debugging"] = "除錯", |
||
272 | ["Show debug messages."] = "顯示除錯訊息。", |
||
273 | |||
274 | bosskill_name = "首領死亡", |
||
275 | bosskill_desc = "首領被擊敗時發出提示。", |
||
276 | |||
277 | -- AceConsole zone commands |
||
278 | ["Zul'Gurub"] = "ZG", |
||
279 | ["Molten Core"] = "MC", |
||
280 | ["Blackwing Lair"] = "BWL", |
||
281 | ["Ahn'Qiraj"] = "TAQ", |
||
282 | ["Ruins of Ahn'Qiraj"] = "RAQ", |
||
283 | ["Onyxia's Lair"] = "OL", |
||
284 | ["Naxxramas"] = "NAX", |
||
285 | ["Silithus"] = "silithus", |
||
286 | ["Outdoor Raid Bosses"] = "outdoor", |
||
287 | ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option |
||
288 | } end) |
||
289 | |||
290 | --------------------------------- |
||
291 | -- Addon Declaration -- |
||
292 | --------------------------------- |
||
293 | |||
294 | BigWigs = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceDebug-2.0", "AceModuleCore-2.0", "AceConsole-2.0", "AceDB-2.0", "AceHook-2.1") |
||
295 | BigWigs:SetModuleMixins("AceDebug-2.0", "AceEvent-2.0", "CandyBar-2.0") |
||
296 | BigWigs:RegisterDB("BigWigsDB", "BigWigsDBPerChar") |
||
297 | BigWigs.cmdtable = {type = "group", handler = BigWigs, args = { |
||
298 | [L["boss"]] = { |
||
299 | type = "group", |
||
300 | name = L["Bosses"], |
||
301 | desc = L["Options for boss modules."], |
||
302 | args = {}, |
||
303 | disabled = function() return not BigWigs:IsActive() end, |
||
304 | }, |
||
305 | [L["plugin"]] = { |
||
306 | type = "group", |
||
307 | name = L["Plugins"], |
||
308 | desc = L["Options for plugins."], |
||
309 | args = {}, |
||
310 | disabled = function() return not BigWigs:IsActive() end, |
||
311 | }, |
||
312 | [L["extra"]] = { |
||
313 | type = "group", |
||
314 | name = L["Extras"], |
||
315 | desc = L["Options for extras."], |
||
316 | args = {}, |
||
317 | disabled = function() return not BigWigs:IsActive() end, |
||
318 | }, |
||
319 | }} |
||
320 | BigWigs:RegisterChatCommand({"/bw", "/BigWigs"}, BigWigs.cmdtable) |
||
321 | BigWigs.debugFrame = ChatFrame5 |
||
322 | BigWigs.revision = tonumber(string.sub("$Revision: 17540 $", 12, -3)) |
||
323 | |||
324 | -------------------------------- |
||
325 | -- Module Prototype -- |
||
326 | -------------------------------- |
||
327 | |||
328 | BigWigs.modulePrototype.core = BigWigs |
||
329 | BigWigs.modulePrototype.debugFrame = ChatFrame5 |
||
330 | BigWigs.modulePrototype.revision = 1 -- To be overridden by the module! |
||
331 | |||
332 | |||
333 | function BigWigs.modulePrototype:OnInitialize() |
||
334 | -- Unconditionally register, this shouldn't happen from any other place |
||
335 | -- anyway. |
||
336 | self.core:RegisterModule(self.name, self) |
||
337 | end |
||
338 | |||
339 | |||
340 | function BigWigs.modulePrototype:IsBossModule() |
||
341 | return self.zonename and self.enabletrigger and true |
||
342 | end |
||
343 | |||
344 | |||
345 | function BigWigs.modulePrototype:GenericBossDeath(msg) |
||
346 | if msg == string.format(UNITDIESOTHER, self:ToString()) then |
||
347 | if self.db.profile.bosskill then self:TriggerEvent("BigWigs_Message", string.format(L["%s has been defeated"], self:ToString()), "Bosskill", nil, "Victory") end |
||
348 | self:TriggerEvent("BigWigs_RemoveRaidIcon") |
||
349 | if self.core:IsDebugging() then |
||
350 | self.core:LevelDebug(1, "Boss dead, disabling module ["..self:ToString().."].") |
||
351 | end |
||
352 | self.core:ToggleModuleActive(self, false) |
||
353 | end |
||
354 | end |
||
355 | |||
356 | |||
357 | function BigWigs.modulePrototype:Scan() |
||
358 | local t = self.enabletrigger |
||
359 | local a = self.wipemobs |
||
360 | if not t then return false end |
||
361 | if type(t) == "string" then t = {t} end |
||
362 | if a then |
||
363 | if type(a) == "string" then a = {a} end |
||
364 | for k,v in pairs(a) do table.insert(t, v) end |
||
365 | end |
||
366 | |||
367 | if UnitExists("target") and UnitAffectingCombat("target") then |
||
368 | local target = UnitName("target") |
||
369 | for _, mob in pairs(t) do |
||
370 | if target == mob then |
||
371 | return true |
||
372 | end |
||
373 | end |
||
374 | end |
||
375 | |||
376 | local num = GetNumRaidMembers() |
||
377 | for i = 1, num do |
||
378 | local raidUnit = string.format("raid%starget", i) |
||
379 | if UnitExists(raidUnit) and UnitAffectingCombat(raidUnit) then |
||
380 | local target = UnitName(raidUnit) |
||
381 | for _, mob in pairs(t) do |
||
382 | if target == mob then |
||
383 | return true |
||
384 | end |
||
385 | end |
||
386 | end |
||
387 | end |
||
388 | return false |
||
389 | end |
||
390 | |||
391 | |||
392 | function BigWigs.modulePrototype:GetEngageSync() |
||
393 | return "BossEngaged" |
||
394 | end |
||
395 | |||
396 | |||
397 | function BigWigs.modulePrototype:CheckForEngage() |
||
398 | local go = self:Scan() |
||
399 | local running = self:IsEventScheduled(self:ToString().."_CheckStart") |
||
400 | if go then |
||
401 | if self.core:IsDebugging() then |
||
402 | self.core:LevelDebug(1, "Scan returned true, engaging ["..self:ToString().."].") |
||
403 | end |
||
404 | self:CancelScheduledEvent(self:ToString().."_CheckStart") |
||
405 | if self:IsEventRegistered("PLAYER_REGEN_DISABLED") then |
||
406 | self:UnregisterEvent("PLAYER_REGEN_DISABLED") |
||
407 | end |
||
408 | self:TriggerEvent("BigWigs_SendSync", self:GetEngageSync().." "..self:ToString()) |
||
409 | elseif not running then |
||
410 | self:ScheduleRepeatingEvent(self:ToString().."_CheckStart", self.CheckForEngage, .5, self) |
||
411 | end |
||
412 | end |
||
413 | |||
414 | |||
415 | function BigWigs.modulePrototype:CheckForWipe() |
||
416 | local running = self:IsEventScheduled(self:ToString().."_CheckWipe") |
||
417 | -- If we are a hunter, we need to check for the FD buff. |
||
418 | local _, class = UnitClass("player") |
||
419 | if class == "HUNTER" then |
||
420 | for i = 1, 16 do |
||
421 | local buff = UnitBuff("player", i) |
||
422 | if buff and buff == "Interface\\Icons\\Ability_Rogue_FeignDeath" then |
||
423 | if not running then |
||
424 | self:ScheduleRepeatingEvent(self:ToString().."_CheckWipe", self.CheckForWipe, 2, self) |
||
425 | end |
||
426 | return |
||
427 | end |
||
428 | end |
||
429 | end |
||
430 | |||
431 | local go = self:Scan() |
||
432 | if not go then |
||
433 | if self.core:IsDebugging() then |
||
434 | self.core:LevelDebug(1, "Rebooting module ["..self:ToString().."].") |
||
435 | end |
||
436 | self:TriggerEvent("BigWigs_RebootModule", self) |
||
437 | elseif not running then |
||
438 | self:ScheduleRepeatingEvent(self:ToString().."_CheckWipe", self.CheckForWipe, 2, self) |
||
439 | end |
||
440 | end |
||
441 | |||
442 | function BigWigs.modulePrototype:IsRegistered() |
||
443 | return self.registered |
||
444 | end |
||
445 | |||
446 | ------------------------------ |
||
447 | -- Initialization -- |
||
448 | ------------------------------ |
||
449 | |||
450 | function BigWigs:OnInitialize() |
||
451 | if not self.version then self.version = GetAddOnMetadata("BigWigs", "Version") end |
||
452 | local rev = self.revision |
||
453 | for name, module in self:IterateModules() do |
||
454 | rev = math.max(rev, module.revision) |
||
455 | end |
||
456 | self.version = (self.version or "2.0").. " |cffff8888r"..rev.."|r" |
||
457 | self:Hook( self, "ToggleModuleActive", |
||
458 | function( self, module, state ) |
||
459 | self.hooks[self]["ToggleModuleActive"](self, module, state) |
||
460 | self:TriggerEvent( "BigWigs_ModuleToggle", module, state) |
||
461 | end ) |
||
462 | self.loading = true |
||
463 | -- Activate ourselves, or at least try to. If we were disabled during a reloadUI, OnEnable isn't called, |
||
464 | -- and self.loading will never be set to something else, resulting in a BigWigs that doesn't enable. |
||
465 | self:ToggleActive(true) |
||
466 | end |
||
467 | |||
468 | |||
469 | function BigWigs:OnEnable() |
||
470 | if AceLibrary("AceEvent-2.0"):IsFullyInitialized() then |
||
471 | self:AceEvent_FullyInitialized() |
||
472 | else |
||
473 | self:RegisterEvent("AceEvent_FullyInitialized") |
||
474 | end |
||
475 | end |
||
476 | |||
477 | function BigWigs:AceEvent_FullyInitialized() |
||
478 | if GetNumRaidMembers() > 0 or not self.loading then |
||
479 | -- Enable all disabled modules that are not boss modules. |
||
480 | for name, module in self:IterateModules() do |
||
481 | if type(module.IsBossModule) ~= "function" or not module:IsBossModule() then |
||
482 | self:ToggleModuleActive(module, true) |
||
483 | end |
||
484 | end |
||
485 | |||
486 | if BigWigsLoD then |
||
487 | self:CreateLoDMenu() |
||
488 | end |
||
489 | |||
490 | self:TriggerEvent("BigWigs_CoreEnabled") |
||
491 | |||
492 | self:RegisterEvent("BigWigs_TargetSeen") |
||
493 | self:RegisterEvent("BigWigs_RebootModule") |
||
494 | |||
495 | self:RegisterEvent("BigWigs_RecvSync") |
||
496 | self:TriggerEvent("BigWigs_ThrottleSync", "BossEngaged", 5 ) |
||
497 | else |
||
498 | self:ToggleActive(false) |
||
499 | end |
||
500 | self.loading = nil |
||
501 | end |
||
502 | |||
503 | |||
504 | function BigWigs:OnDisable() |
||
505 | -- Disable all modules |
||
506 | for name, module in self:IterateModules() do |
||
507 | self:ToggleModuleActive(module, false) |
||
508 | end |
||
509 | |||
510 | self:TriggerEvent("BigWigs_CoreDisabled") |
||
511 | end |
||
512 | |||
513 | |||
514 | ------------------------------- |
||
515 | -- Module Handling -- |
||
516 | ------------------------------- |
||
517 | |||
518 | function BigWigs:RegisterModule(name, module) |
||
519 | if module:IsRegistered() then |
||
520 | error(string.format("%q is already registered.", name)) |
||
521 | return |
||
522 | end |
||
523 | |||
524 | if module:IsBossModule() then self:ToggleModuleActive(module, false) end |
||
525 | |||
526 | -- Set up DB |
||
527 | local opts |
||
528 | if module:IsBossModule() and module.toggleoptions then |
||
529 | opts = {} |
||
530 | for _,v in pairs(module.toggleoptions) do if v ~= -1 then opts[v] = true end end |
||
531 | end |
||
532 | |||
533 | if module.db and module.RegisterDefaults and type(module.RegisterDefaults) == "function" then |
||
534 | module:RegisterDefaults("profile", opts or module.defaultDB or {}) |
||
535 | else |
||
536 | self:RegisterDefaults(name, "profile", opts or module.defaultDB or {}) |
||
537 | end |
||
538 | |||
539 | if not module.db then module.db = self:AcquireDBNamespace(name) end |
||
540 | |||
541 | -- Set up AceConsole |
||
542 | if module:IsBossModule() then |
||
543 | local cons |
||
544 | local revision = type(module.revision) == "number" and module.revision or -1 |
||
545 | local L2 = AceLibrary("AceLocale-2.2"):new("BigWigs"..name) |
||
546 | if module.toggleoptions then |
||
547 | local m = module |
||
548 | cons = { |
||
549 | type = "group", |
||
550 | name = name, |
||
551 | desc = string.format(L["Options for %s (r%s)."], name, revision), |
||
552 | args = { |
||
553 | [L["toggle"]] = { |
||
554 | type = "toggle", |
||
555 | name = L["Active"], |
||
556 | order = 1, |
||
557 | desc = L["Activate or deactivate this module."], |
||
558 | get = function() return m.core:IsModuleActive(m) end, |
||
559 | set = function() m.core:ToggleModuleActive(m) end, |
||
560 | }, |
||
561 | [L["reboot"]] = { |
||
562 | type = "execute", |
||
563 | name = L["Reboot"], |
||
564 | order = 2, |
||
565 | desc = L["Reboot this module."], |
||
566 | func = function() m.core:TriggerEvent("BigWigs_RebootModule", m) end, |
||
567 | hidden = function() return not m.core:IsModuleActive(m) end, |
||
568 | }, |
||
569 | [L["debug"]] = { |
||
570 | type = "toggle", |
||
571 | name = L["Debugging"], |
||
572 | desc = L["Show debug messages."], |
||
573 | order = 3, |
||
574 | get = function() return m:IsDebugging() end, |
||
575 | set = function(v) m:SetDebugging(v) end, |
||
576 | hidden = function() return not m:IsDebugging() and not BigWigs:IsDebugging() end, |
||
577 | }, |
||
578 | }, |
||
579 | } |
||
580 | local x = 10 |
||
581 | for _,v in pairs(module.toggleoptions) do |
||
582 | local val = v |
||
583 | x = x + 1 |
||
584 | if x == 11 and v ~= "bosskill" then |
||
585 | cons.args["headerblankspotthingy"] = { |
||
586 | type = "header", |
||
587 | order = 4, |
||
588 | } |
||
589 | end |
||
590 | if v == -1 then |
||
591 | cons.args["blankspacer"..x] = { |
||
592 | type = "header", |
||
593 | order = x, |
||
594 | } |
||
595 | else |
||
596 | local l = v == "bosskill" and L or L2 |
||
597 | if l:HasTranslation(v.."_validate") then |
||
598 | cons.args[l[v.."_cmd"]] = { |
||
599 | type = "text", |
||
600 | order = v == "bosskill" and -1 or x, |
||
601 | name = l[v.."_name"], |
||
602 | desc = l[v.."_desc"], |
||
603 | get = function() return m.db.profile[val] end, |
||
604 | set = function(v) m.db.profile[val] = v end, |
||
605 | validate = l[v.."_validate"], |
||
606 | } |
||
607 | else |
||
608 | cons.args[l[v.."_cmd"]] = { |
||
609 | type = "toggle", |
||
610 | order = v == "bosskill" and -1 or x, |
||
611 | name = l[v.."_name"], |
||
612 | desc = l[v.."_desc"], |
||
613 | get = function() return m.db.profile[val] end, |
||
614 | set = function(v) m.db.profile[val] = v end, |
||
615 | } |
||
616 | end |
||
617 | end |
||
618 | end |
||
619 | end |
||
620 | |||
621 | if cons or module.consoleOptions then |
||
622 | local zonename = type(module.zonename) == "table" and module.zonename[1] or module.zonename |
||
623 | local zone = zonename |
||
624 | if BZ:HasReverseTranslation(zonename) and L:HasTranslation(BZ:GetReverseTranslation(zonename)) then |
||
625 | zone = L[BZ:GetReverseTranslation(zonename)] |
||
626 | elseif L:HasTranslation(zonename) then |
||
627 | zone = L[zonename] |
||
628 | end |
||
629 | if not self.cmdtable.args[L["boss"]].args[zone] then |
||
630 | self.cmdtable.args[L["boss"]].args[zone] = { |
||
631 | type = "group", |
||
632 | name = zonename, |
||
633 | desc = string.format(L["Options for bosses in %s."], zonename), |
||
634 | args = {}, |
||
635 | } |
||
636 | end |
||
637 | if module.external then |
||
638 | self.cmdtable.args[L["extra"]].args[L2["cmd"]] = cons or module.consoleOptions |
||
639 | else |
||
640 | self.cmdtable.args[L["boss"]].args[zone].args[L2["cmd"]] = cons or module.consoleOptions |
||
641 | end |
||
642 | end |
||
643 | elseif module.consoleOptions then |
||
644 | if module.external then |
||
645 | self.cmdtable.args[L["extra"]].args[module.consoleCmd or name] = cons or module.consoleOptions |
||
646 | else |
||
647 | self.cmdtable.args[L["plugin"]].args[module.consoleCmd or name] = cons or module.consoleOptions |
||
648 | end |
||
649 | end |
||
650 | |||
651 | module.registered = true |
||
652 | if module.OnRegister and type(module.OnRegister) == "function" then |
||
653 | module:OnRegister() |
||
654 | end |
||
655 | |||
656 | -- Set up target monitoring, in case the monitor module has already initialized |
||
657 | self:TriggerEvent("BigWigs_RegisterForTargetting", module.zonename, module.enabletrigger) |
||
658 | end |
||
659 | |||
660 | |||
661 | function BigWigs:EnableModule(module, nosync) |
||
662 | local m = self:GetModule(module) |
||
663 | if m and m:IsBossModule() and not self:IsModuleActive(module) then |
||
664 | self:ToggleModuleActive(module, true) |
||
665 | self:TriggerEvent("BigWigs_Message", string.format(L["%s mod enabled"], m:ToString() or "??"), "Core", true) |
||
666 | if not nosync then self:TriggerEvent("BigWigs_SendSync", (m.external and "EnableExternal " or "EnableModule ") .. (m.synctoken or BB:GetReverseTranslation(module))) end |
||
667 | end |
||
668 | end |
||
669 | |||
670 | |||
671 | function BigWigs:BigWigs_RebootModule(module) |
||
672 | self:ToggleModuleActive(module, false) |
||
673 | self:ToggleModuleActive(module, true) |
||
674 | end |
||
675 | |||
676 | |||
677 | function BigWigs:BigWigs_RecvSync(sync, module) |
||
678 | if sync == "EnableModule" and module then |
||
679 | local name = BB:HasTranslation(module) and BB[module] or module |
||
680 | if self:HasModule(name) and self:GetModule(name).zonename == GetRealZoneText() then self:EnableModule(name, true) end |
||
681 | elseif sync == "EnableExternal" and module then |
||
682 | local name = BB:HasTranslation(module) and BB[module] or module |
||
683 | if self:HasModule(name) and self:GetModule(name).zonename == GetRealZoneText() then self:EnableModule(name, true) end |
||
684 | end |
||
685 | end |
||
686 | |||
687 | |||
688 | function BigWigs:BigWigs_TargetSeen(mobname, unit) |
||
689 | for name,module in self:IterateModules() do |
||
690 | if module:IsBossModule() and self:ZoneIsTrigger(module, GetRealZoneText()) and self:MobIsTrigger(module, mobname) |
||
691 | and (not module.VerifyEnable or module:VerifyEnable(unit)) then |
||
692 | self:EnableModule(name) |
||
693 | end |
||
694 | end |
||
695 | end |
||
696 | |||
697 | |||
698 | function BigWigs:ZoneIsTrigger(module, zone) |
||
699 | local t = module.zonename |
||
700 | if type(t) == "string" then return zone == t |
||
701 | elseif type(t) == "table" then |
||
702 | for _,mzone in pairs(t) do if mzone == zone then return true end end |
||
703 | end |
||
704 | end |
||
705 | |||
706 | |||
707 | function BigWigs:MobIsTrigger(module, name) |
||
708 | local t = module.enabletrigger |
||
709 | if type(t) == "string" then return name == t |
||
710 | elseif type(t) == "table" then |
||
711 | for _,mob in pairs(t) do if mob == name then return true end end |
||
712 | end |
||
713 | end |
||
714 | |||
715 | |||
716 | function BigWigs:CreateLoDMenu() |
||
717 | local zonelist = BigWigsLoD:GetZones() |
||
718 | for k,v in pairs( zonelist ) do |
||
719 | if type(v) ~= "table" then |
||
720 | self:AddLoDMenu( k ) |
||
721 | else |
||
722 | self:AddLoDMenu( L["Other"] ) |
||
723 | end |
||
724 | end |
||
725 | end |
||
726 | |||
727 | |||
728 | function BigWigs:AddLoDMenu( zonename ) |
||
729 | local zone = nil |
||
730 | if L:HasTranslation(zonename) then |
||
731 | zone = L[zonename] |
||
732 | else |
||
733 | zone = L["Other"] |
||
734 | end |
||
735 | if zone then |
||
736 | if not self.cmdtable.args[L["boss"]].args[zone] then |
||
737 | self.cmdtable.args[L["boss"]].args[zone] = { |
||
738 | type = "group", |
||
739 | name = zonename, |
||
740 | desc = string.format(L["Options for bosses in %s."], zonename), |
||
741 | args = {} |
||
742 | } |
||
743 | end |
||
744 | if zone == L["Other"] then |
||
745 | local zones = BigWigsLoD:GetZones() |
||
746 | zones = zones[L["Other"]] |
||
747 | self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = { |
||
748 | type = "execute", |
||
749 | name = L["Load All"], |
||
750 | desc = string.format( L["Load all %s modules."], zonename ), |
||
751 | order = 1, |
||
752 | func = function() |
||
753 | for z, v in pairs( zones ) do |
||
754 | BigWigsLoD:LoadZone( z ) |
||
755 | if self.cmdtable.args[L["boss"]].args[z] and self.cmdtable.args[L["boss"]].args[z].args[L["Load"]] then |
||
756 | self.cmdtable.args[L["boss"]].args[z].args[L["Load"]] = nil |
||
757 | end |
||
758 | end |
||
759 | self.cmdtable.args[L["boss"]].args[zone] = nil |
||
760 | end |
||
761 | } |
||
762 | else |
||
763 | self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = { |
||
764 | type = "execute", |
||
765 | name = L["Load All"], |
||
766 | desc = string.format( L["Load all %s modules."], zonename ), |
||
767 | order = 1, |
||
768 | func = function() |
||
769 | BigWigsLoD:LoadZone( zonename ) |
||
770 | self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = nil |
||
771 | end |
||
772 | } |
||
773 | end |
||
774 | end |
||
775 | end |
||
776 | |||
777 |