-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathModulePrototype.lua
780 lines (650 loc) · 23.2 KB
/
ModulePrototype.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
assert(BigWigs, "BigWigs not found!")
local BB = BigWigs.BabbleBoss
local BZ = BigWigs.BabbleZone
local L = BigWigs.i18n["Core"]
--------------------------------
-- Module Prototype --
--------------------------------
-- do not override
BigWigs.modulePrototype.core = BigWigs
BigWigs.modulePrototype.debugFrame = ChatFrame1
BigWigs.modulePrototype.engaged = false
BigWigs.modulePrototype.bossSync = nil -- "Ouro"
-- override
BigWigs.modulePrototype.revision = 1 -- To be overridden by the module!
BigWigs.modulePrototype.started = false
BigWigs.modulePrototype.zonename = nil -- AceLibrary("Babble-Zone-2.2")["Ahn'Qiraj"]
BigWigs.modulePrototype.enabletrigger = nil -- boss
BigWigs.modulePrototype.wipemobs = nil -- adds that will be considered in CheckForEngage
BigWigs.modulePrototype.toggleoptions = nil -- {"sweep", "sandblast", "scarab", -1, "emerge", "submerge", -1, "berserk", "bosskill"}
BigWigs.modulePrototype.proximityCheck = nil -- function(unit) return CheckInteractDistance(unit, 2) end
BigWigs.modulePrototype.proximitySilent = nil -- false
BigWigs.modulePrototype.trashMod = nil -- change to true for trash/special boss mods
-- do not override
function BigWigs.modulePrototype:IsBossModule()
return self.zonename and self.enabletrigger and true
end
-- do not override
function BigWigs.modulePrototype:DebugMessage(msg)
self.core:DebugMessage(msg, self)
end
-- do not override
function BigWigs.modulePrototype:OnInitialize()
-- Unconditionally register, this shouldn't happen from any other place
-- anyway.
self.core:RegisterModule(self.name, self)
-- Notify observers that we have loaded.
self:TriggerEvent("BigWigs_ModuleLoaded", self.name, self)
-- workaround to trigger OnSetup if enabled manually
self:RegisterEvent("Ace2_AddonEnabled")
end
function BigWigs.modulePrototype:Ace2_AddonEnabled(module)
if module and type(module) == "table" and module:ToString() == self:ToString() and self:IsBossModule() then
BigWigs:SetupModule(module:ToString())
end
end
-- override
function BigWigs.modulePrototype:OnSetup()
end
function BigWigs.modulePrototype:OnEngage()
end
function BigWigs.modulePrototype:OnDisengage()
end
-- do not override
function BigWigs.modulePrototype:Engage()
self:DebugMessage("Engage() " .. self:ToString())
if not BigWigs:IsModuleActive(self) then
BigWigs:EnableModule(self:ToString())
end
if self.bossSync and not self.engaged then
self.engaged = true
if not self.trashMod then
self:Message(string.format(L["%s engaged!"], self.translatedName), "Positive")
BigWigsAutoReply:StartBossfight(self)
BigWigsBossRecords:StartBossfight(self)
self:KTM_SetTarget(self:ToString())
end
BigWigs:GetModule("CombatlogFilter"):OnEngage(self:ToString())
self:OnEngage()
if Stopwatch_Command then
Stopwatch_Command("reset")
Stopwatch_Command("play")
end
end
end
function BigWigs.modulePrototype:Disengage()
-- you already released but someone else was still sending syncs
self:CancelAllScheduledEvents()
if BigWigs:IsModuleActive(self) then
self.engaged = false
self.started = false
self:KTM_ClearTarget()
self:RemoveIcon()
self:RemoveWarningSign("", true)
BigWigsBars:Disable(self)
BigWigsBars:BigWigs_HideCounterBars()
self:RemoveProximity()
BigWigsEnrage:Stop()
self:OnDisengage()
if Stopwatch_Command then
Stopwatch_Command("pause")
end
end
end
function BigWigs.modulePrototype:IsEngaged()
if self.engaged then
return true
end
return false
end
function BigWigs.modulePrototype:GetBossPercentage()
local percentage = nil
local unitId = nil
if self:IsEngaged() then
unitId = "playertarget"
if UnitName(unitId) == self:ToString() then
percentage = UnitHealth(unitId) / UnitHealthMax(unitId) * 100
else
for i = 1, GetNumRaidMembers(), 1 do
unitId = "Raid" .. i .. "target"
if UnitName(unitId) == self:ToString() then
percentage = UnitHealth(unitId) / UnitHealthMax(unitId) * 100
break
end
end
end
end
-- round
--percentage = percentage + 0.5 - (percentage + 0.5) % 1
percentage = floor(percentage + 0.5)
return percentage
end
function BigWigs.modulePrototype:GetStatus()
local percentage = self:GetBossPercentage()
local alive = 0
local members = GetNumRaidMembers()
for i = 1, members, 1 do
if not UnitIsDead("Raid" .. i) then
alive = alive + 1
end
end
return percentage, alive, members
end
function BigWigs.modulePrototype:Victory()
if self:IsEngaged() then
if self.db.profile.bosskill then
self:Message(string.format(L["%s has been defeated"], self.translatedName), "Bosskill", nil, "Victory")
end
if not self.trashMod then
BigWigsAutoReply:Victory(self)
BigWigsBossRecords:EndBossfight(self)
end
self:DebugMessage("Boss dead, disabling module [" .. self:ToString() .. "].")
self.core:DisableModule(self:ToString())
end
end
function BigWigs.modulePrototype:Wipe()
if self:IsEngaged() then
if not self.trashMod then
BigWigsAutoReply:Wipe(self)
end
BigWigs:BigWigs_RebootModule(self:ToString())
end
end
function BigWigs.modulePrototype:Disable()
self:Disengage()
self.core:ToggleModuleActive(self, false)
end
-- synchronize functions
function BigWigs.modulePrototype:GetEngageSync()
return "BossEngaged"
end
function BigWigs.modulePrototype:SendEngageSync()
if self.bossSync then
--self:TriggerEvent("BigWigs_SendSync", "BossEngaged "..self:ToString())
self:Sync(self:GetEngageSync() .. " " .. self.bossSync)
end
end
function BigWigs.modulePrototype:GetWipeSync()
return "BossWipe"
end
--[[function BigWigs.modulePrototype:SendWipeSync()
if self.bossSync then
--self:TriggerEvent("BigWigs_SendSync", "BossEngaged "..self:ToString())
self:Sync(self:GetWipeSync() .. " " .. self.bossSync)
end
end]]
function BigWigs.modulePrototype:GetBossDeathSync()
return "BossDeath"
end
function BigWigs.modulePrototype:SendBossDeathSync()
if self.bossSync then
self:Sync(self:GetBossDeathSync() .. " " .. self.bossSync)
end
end
-- event handler
local yellTriggers = {} -- [i] = {yell, bossmod}
function BigWigs.modulePrototype:RegisterYellEngage(yell)
-- Bosses with Yells as Engagetrigger should go through even when the bossmod isn't active yet.
tinsert(yellTriggers, { yell, self })
end
function BigWigs:CHAT_MSG_MONSTER_YELL(msg)
for i = 1, table.getn(yellTriggers) do
local yell = yellTriggers[i][1]
local mod = yellTriggers[i][2]
if string.find(msg, yell) then
-- enable and engage
self:EnableModule(mod:ToString())
--self:TriggerEvent("BigWigs_SendSync", "BossEngaged "..self:ToString())
mod:SendEngageSync()
end
end
end
BigWigs:RegisterEvent("CHAT_MSG_MONSTER_YELL")
function BigWigs.modulePrototype:CheckForEngage()
BigWigs:CheckForEngage(self)
end
function BigWigs.modulePrototype:CheckForWipe()
BigWigs:CheckForWipe(self)
end
function BigWigs.modulePrototype:CheckForBossDeath(msg)
BigWigs:CheckForBossDeath(msg, self)
end
-- override
function BigWigs.modulePrototype:BigWigs_RecvSync(sync, rest, nick)
end
-- test functions
function BigWigs.modulePrototype:TestDisable()
self:CancelAllScheduledEvents()
self:RemoveIcon()
self:RemoveWarningSign("", true)
BigWigsBars:Disable(self)
BigWigsBars:BigWigs_HideCounterBars()
self:RemoveProximity()
BigWigsEnrage:Stop()
BigWigs:TriggerEvent("BigWigs_RebootModule", self:ToString())
BigWigs:DisableModule(self:ToString())
end
function BigWigs.modulePrototype:TestModule()
end
function BigWigs.modulePrototype:TestModuleCore()
end
function BigWigs.modulePrototype:TestVisual()
end
------------------------------
-- Provided API --
------------------------------
local delayPrefix = "ScheduledEventPrefix"
function BigWigs.modulePrototype:Sync(sync)
self:TriggerEvent("BigWigs_SendSync", sync)
end
function BigWigs.modulePrototype:DelayedSync(delay, sync)
self:ScheduleEvent(delayPrefix .. "Sync" .. self:ToString() .. sync, "BigWigs_SendSync", delay, sync)
end
function BigWigs.modulePrototype:CancelDelayedSync(sync)
self:CancelScheduledEvent(delayPrefix .. "Sync" .. self:ToString() .. sync)
end
function BigWigs.modulePrototype:ThrottleSync(throttle, sync)
self:TriggerEvent("BigWigs_ThrottleSync", sync, throttle)
end
function BigWigs.modulePrototype:Message(text, priority, noRaidSay, sound, broadcastOnly)
self:TriggerEvent("BigWigs_Message", text, priority, noRaidSay, sound, broadcastOnly)
end
function BigWigs.modulePrototype:DelayedMessage(delay, text, priority, noRaidSay, sound, broadcastOnly)
return self:ScheduleEvent(delayPrefix .. "Message" .. self:ToString() .. text, "BigWigs_Message", delay, text, priority, noRaidSay, sound, broadcastOnly)
end
function BigWigs.modulePrototype:CancelDelayedMessage(text)
self:CancelScheduledEvent(delayPrefix .. "Message" .. self:ToString() .. text)
end
function BigWigs.modulePrototype:Whisper(text, name)
self:TriggerEvent("BigWigs_SendTell", name, text)
end
--[[
starts a regular bar if time is a number
starts a irregular bar if time is a table with the keys min and max
]]
function BigWigs.modulePrototype:Bar(text, time, icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
BigWigsBars:StartBar(self, text, time, "Interface\\Icons\\" .. icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
end
function BigWigs.modulePrototype:RemoveBar(text)
self:TriggerEvent("BigWigs_StopBar", self, text)
end
function BigWigs.modulePrototype:IrregularBar(text, minTime, maxTime, icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
BigWigsBars:StartIrregularBar(self, text, minTime, maxTime, "Interface\\Icons\\" .. icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
end
function BigWigs.modulePrototype:DelayedBar(delay, text, time, icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
return self:ScheduleEvent(delayPrefix .. "Bar" .. self:ToString() .. text, "BigWigs_StartBar", delay, self, text, time, "Interface\\Icons\\" .. icon, otherColor, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
end
function BigWigs.modulePrototype:CancelDelayedBar(text)
self:CancelScheduledEvent(delayPrefix .. "Bar" .. self:ToString() .. text)
end
function BigWigs.modulePrototype:BarStatus(text)
local registered, time, elapsed, running = BigWigsBars:GetBarStatus(self, text)
return registered, time, elapsed, running
end
function BigWigs.modulePrototype:BarId(text)
return BigWigsBars:GetBarId(self, text)
end
function BigWigs.modulePrototype:Sound(sound)
self:TriggerEvent("BigWigs_Sound", sound)
end
function BigWigs.modulePrototype:DelayedSound(delay, sound, id)
if not id then id = "_" end
return self:ScheduleEvent(delayPrefix .. "Sound" .. self:ToString() .. sound .. id, "BigWigs_Sound", delay, sound)
end
function BigWigs.modulePrototype:CancelDelayedSound(sound, id)
if not id then id = "_" end
self:CancelScheduledEvent(delayPrefix .. "Sound" .. self:ToString() .. sound .. id)
end
function BigWigs.modulePrototype:Icon(name, iconnumber, restoreTime)
self:TriggerEvent("BigWigs_SetRaidIcon", name, iconnumber, restoreTime)
end
function BigWigs.modulePrototype:RemoveIcon()
self:TriggerEvent("BigWigs_RemoveRaidIcon")
end
function BigWigs.modulePrototype:DelayedRemoveIcon(delay)
self:ScheduleEvent(delayPrefix .. "Icon" .. self:ToString(), "BigWigs_RemoveRaidIcon", delay)
end
function BigWigs.modulePrototype:WarningSign(icon, duration, force)
self:TriggerEvent("BigWigs_ShowWarningSign", "Interface\\Icons\\" .. icon, duration, force)
end
function BigWigs.modulePrototype:RemoveWarningSign(icon, forceHide)
self:TriggerEvent("BigWigs_HideWarningSign", "Interface\\Icons\\" .. icon, forceHide)
end
function BigWigs.modulePrototype:DelayedWarningSign(delay, icon, duration, id)
if not id then id = "_" end
self:ScheduleEvent(delayPrefix .. "WarningSign" .. self:ToString() .. icon .. id, "BigWigs_ShowWarningSign", delay, "Interface\\Icons\\" .. icon, duration)
end
function BigWigs.modulePrototype:CancelDelayedWarningSign(icon, id)
if not id then id = "_" end
self:CancelScheduledEvent(delayPrefix .. "WarningSign" .. self:ToString() .. icon .. id)
end
function BigWigs.modulePrototype:WarningSignOnClick(func)
BigWigsWarningSign:OnClick(func)
end
function BigWigs.modulePrototype:Say(msg)
SendChatMessage(msg, "SAY")
end
function BigWigs.modulePrototype:CombatlogFilter(filter, callback, addStopwatch)
local CombatlogFilter = BigWigs:GetModule("CombatlogFilter")
CombatlogFilter:AddFilter(self:ToString(), filter, callback, addStopwatch)
end
-- CombatlogFilter
function BigWigs.modulePrototype:CombatlogFilter(filter, callback, addStopwatch)
local CombatlogFilter = BigWigs:GetModule("CombatlogFilter")
CombatlogFilter:AddFilter(self:ToString(), filter, callback, addStopwatch)
end
function BigWigs.modulePrototype:RemoveCombatlogFilter(filter)
local CombatlogFilter = BigWigs:GetModule("CombatlogFilter")
CombatlogFilter:AddFilter(self:ToString(), filter)
end
function BigWigs.modulePrototype:RemoveAllCombatlogFilters()
local CombatlogFilter = BigWigs:GetModule("CombatlogFilter")
CombatlogFilter:AddFilter(self:ToString())
end
-- proximity
function BigWigs.modulePrototype:Proximity()
BigWigs:Proximity(self:ToString())
end
function BigWigs.modulePrototype:RemoveProximity()
BigWigs:RemoveProximity()
end
-- KLHThreatMeter
function BigWigs.modulePrototype:KTM_Reset()
BigWigs:KTM_Reset()
end
function BigWigs.modulePrototype:KTM_ClearTarget(forceReset)
BigWigs:KTM_ClearTarget(forceReset)
end
function BigWigs.modulePrototype:KTM_SetTarget(targetName, forceReset)
if IsAddOnLoaded("KLHThreatMeter") and klhtm and klhtm.net and klhtm.target then
if targetName and type(targetName) == "string" and (IsRaidLeader() or IsRaidOfficer()) then
if UnitName("target") == targetName then
klhtm.net.sendmessage("target " .. targetName)
if forceReset then
self:KTM_Reset()
end
else
-- we need to delay the setting mastertarget, as KTM only allows it to work if the person
-- calling the mastertarget sync has the unit as target
BigWigs:RegisterEvent("PLAYER_TARGET_CHANGED")
BigWigs.masterTarget = targetName
BigWigs.forceReset = forceReset
end
end
end
end
-------------------------------
-- Module Handling --
-------------------------------
BigWigs.i18n = {}
function BigWigs:ModuleDeclaration(bossName, zoneName)
translatedName = AceLibrary("Babble-Boss-2.2")[bossName]
local module = BigWigs:NewModule(translatedName)
--local L = AceLibrary("AceLocale-2.2"):new("BigWigs" .. translatedName)
BigWigs.i18n[bossName] = AceLibrary("AceLocale-2.2"):new("BigWigs" .. module.name)
module.translatedName = translatedName
--local name = string.gsub(bossName, "%s", "") -- untranslated, unique string
module.bossSync = bossName
-- zone
local raidZones = { "Blackwing Lair", "Ruins of Ahn'Qiraj", "Ahn'Qiraj", "Molten Core", "Naxxramas", "Zul'Gurub" }
local isOutdoorraid = true
for i, value in ipairs(raidZones) do
if value == zoneName then
module.zonename = AceLibrary("Babble-Zone-2.2")[zoneName]
isOutdoorraid = false
break
end
end
if isOutdoorraid then
module.zonename = {
AceLibrary("AceLocale-2.2"):new("BigWigs")["Outdoor Raid Bosses Zone"],
AceLibrary("Babble-Zone-2.2")[zoneName]
}
end
--return module, L
return module, BigWigs.i18n[bossName]
end
function BigWigs:RegisterModule(name, module)
--[[if module:IsRegistered() then
error(string.format("%q is already registered.", name))
return
end]]
if module:IsBossModule() then
self:ToggleModuleActive(module, false)
end
-- Set up DB
local opts
if module:IsBossModule() and module.toggleoptions then
opts = {}
for _, v in pairs(module.toggleoptions) do
if v ~= -1 then
opts[v] = true
end
end
end
if module.db and module.RegisterDefaults and type(module.RegisterDefaults) == "function" then
module:RegisterDefaults("profile", opts or module.defaultDB or {})
else
self:RegisterDefaults(name, "profile", opts or module.defaultDB or {})
end
if not module.db then
module.db = self:AcquireDBNamespace(name)
end
-- Set up AceConsole
if module:IsBossModule() then
local cons
local revision = type(module.revision) == "number" and module.revision or -1
local L2 = AceLibrary("AceLocale-2.2"):new("BigWigs" .. name)
if module.toggleoptions then
local m = module
cons = {
type = "group",
name = name,
desc = string.format(L["Options for %s (r%s)."], name, revision),
args = {
[L["toggle"]] = {
type = "toggle",
name = L["Active"],
order = 1,
desc = L["Activate or deactivate this module."],
get = function() return m.core:IsModuleActive(m) end,
set = function() m.core:ToggleModuleActive(m) end,
},
[L["reboot"]] = {
type = "execute",
name = L["Reboot"],
order = 2,
desc = L["Reboot this module."],
func = function() m.core:TriggerEvent("BigWigs_RebootModule", m:ToString()) end,
hidden = function() return not m.core:IsModuleActive(m) end,
},
[L["rebootall"]] = {
type = "execute",
name = L["Reboot All"],
desc = L["Forces the module to reset for everyone in the raid.\n\n(Requires assistant or higher)"],
order = 3,
func = function()
if (IsRaidLeader() or IsRaidOfficer()) then
local name = tostring(module)
if BigWigs.BabbleBoss:HasReverseTranslation(name) then
name = BigWigs.BabbleBoss:GetReverseTranslation(name)
end
BigWigs:DebugMessage("module sync ".. name)
m.core:TriggerEvent("BigWigs_SendSync", "RebootModule " .. name)
end
end,
hidden = function() return not m.core:IsModuleActive(m) end,
},
[L["debug"]] = {
type = "toggle",
name = L["Debugging"],
desc = L["Show debug messages."],
order = 4,
get = function() return m:IsDebugging() end,
set = function(v) m:SetDebugging(v) end,
hidden = function() return not m:IsDebugging() and not BigWigs:IsDebugging() end,
},
},
}
local x = 10
for _, v in pairs(module.toggleoptions) do
local val = v
x = x + 1
if x == 11 and v ~= "bosskill" then
cons.args["headerblankspotthingy"] = {
type = "header",
order = 4,
}
end
if v == -1 then
cons.args["blankspacer" .. x] = {
type = "header",
order = x,
}
else
local l = v == "bosskill" and L or L2
if l:HasTranslation(v .. "_validate") then
cons.args[l[v .. "_cmd"]] = {
type = "text",
order = v == "bosskill" and -1 or x,
name = l[v .. "_name"],
desc = l[v .. "_desc"],
get = function() return m.db.profile[val] end,
set = function(v) m.db.profile[val] = v end,
validate = l[v .. "_validate"],
}
else
cons.args[l[v .. "_cmd"]] = {
type = "toggle",
order = v == "bosskill" and -1 or x,
name = l[v .. "_name"],
desc = l[v .. "_desc"],
get = function() return m.db.profile[val] end,
set = function(v) m.db.profile[val] = v end,
}
end
end
end
end
if cons or module.consoleOptions then
local zonename = type(module.zonename) == "table" and module.zonename[1] or module.zonename
local zone = zonename
if BZ:HasReverseTranslation(zonename) and L:HasTranslation(BZ:GetReverseTranslation(zonename)) then
zone = L[BZ:GetReverseTranslation(zonename)]
elseif L:HasTranslation(zonename) then
zone = L[zonename]
end
if not self.cmdtable.args[L["boss"]].args[zone] then
self.cmdtable.args[L["boss"]].args[zone] = {
type = "group",
name = zonename,
desc = string.format(L["Options for bosses in %s."], zonename),
args = {},
}
end
if module.external then
self.cmdtable.args[L["extra"]].args[L2["cmd"]] = cons or module.consoleOptions
else
self.cmdtable.args[L["boss"]].args[zone].args[L2["cmd"]] = cons or module.consoleOptions
end
end
elseif module.consoleOptions then
if module.external then
self.cmdtable.args[L["extra"]].args[module.consoleCmd or name] = cons or module.consoleOptions
else
self.cmdtable.args[L["plugin"]].args[module.consoleCmd or name] = cons or module.consoleOptions
end
end
module.registered = true
if module.OnRegister and type(module.OnRegister) == "function" then
module:OnRegister()
end
-- Set up target monitoring, in case the monitor module has already initialized
if module.zonename and module.enabletrigger then
self:TriggerEvent("BigWigs_RegisterForTargetting", module.zonename, module.enabletrigger)
end
end
function BigWigs:EnableModule(moduleName, nosync)
--local name = BB:HasTranslation(moduleName) and BB[moduleName] or moduleName
local m = self:GetModule(moduleName)
if m and not self:IsModuleActive(moduleName) then
self:ToggleModuleActive(moduleName, true)
if m:IsBossModule() then
--m.bossSync = m:ToString()
if not m.translatedName then
m.translatedName = m:ToString()
self:DebugMessage("translatedName for module " .. m:ToString() .. " missing")
end
if not m.trashMod then
self:TriggerEvent("BigWigs_Message", string.format(L["%s mod enabled"], m.translatedName or "??"), "Core", true)
end
end
--if not nosync then self:TriggerEvent("BigWigs_SendSync", (m.external and "EnableExternal " or "EnableModule ") .. m.bossSync or (BB:GetReverseTranslation(moduleName))) end
if not nosync then self:TriggerEvent("BigWigs_SendSync", (m.external and "EnableExternal " or "EnableModule ") .. (m.synctoken or BB:GetReverseTranslation(moduleName))) end
self:SetupModule(moduleName)
end
end
-- registers generic events
function BigWigs:SetupModule(moduleName)
--local name = BB:HasTranslation(moduleName) and BB[moduleName] or moduleName
local m = self:GetModule(moduleName)
if m and m:IsBossModule() then
--m.bossSync = m:ToString()
--m.bossSync = BB:GetReverseTranslation(moduleName) -- untranslated string
--self:Print("bossSync: " .. string.gsub(BB:GetReverseTranslation(moduleName), "%s", ""))
--m.bossSync = string.gsub(BB:GetReverseTranslation(moduleName), "%s", "") -- untranslated, unique string without spaces
m:RegisterEvent("PLAYER_REGEN_DISABLED", "CheckForEngage") -- addition
m:RegisterEvent("PLAYER_REGEN_ENABLED", "CheckForWipe")
m:RegisterEvent("CHAT_MSG_COMBAT_FRIENDLY_DEATH", "CheckForWipe")
m:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH", "CheckForBossDeath") -- addition
m:RegisterEvent("BigWigs_RecvSync")
m.engaged = false
m:OnSetup()
end
end
function BigWigs:DisableModule(moduleName)
--local name = BB:HasTranslation(moduleName) and BB[moduleName] or moduleName
local m = self:GetModule(moduleName)
if m then
if m:IsBossModule() then
m:Disengage()
end
self:ToggleModuleActive(m, false)
end
end
-- event handler
function BigWigs:BigWigs_RebootModule(moduleName)
if not BigWigs:HasModule(moduleName) then
-- requester has en client
if BB:HasTranslation(moduleName) then
moduleName = BB[moduleName]
-- requester has not en client
elseif BB:HasReverseTranslation(moduleName) then
moduleName = BB:GetReverseTranslation(moduleName)
end
end
local m = self:GetModule(moduleName)
if m and m:IsBossModule() then
self:DebugMessage("BigWigs:BigWigs_RebootModule(): " .. m:ToString())
m:Disengage()
self:SetupModule(moduleName)
end
end
function BigWigs:Test()
local count = 0
for name, module in self:IterateModules() do
local status, retval = pcall(module.TestModule)
if not status then
count = count + 1
BigWigs:Print("|cffff0000" .. name .. "|r TestModule |cffff0000failed:|r " .. retval)
end
end
local msg = ""
if count == 0 then
msg = "No errors found."
else
msg = tostring(count) .. " error(s) found"
end
BigWigs:Print(msg)
end