-
Notifications
You must be signed in to change notification settings - Fork 51
/
Core.lua
887 lines (772 loc) · 27.9 KB
/
Core.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
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
local revision = 20020
local forkName = "Classic-WoW" -- please change this name if you forked this addon. must not contain spaces
local isDeveloperVersion = false
------------------------------
-- Are you local? --
------------------------------
local BZ = AceLibrary("Babble-Zone-2.2")
local BB = AceLibrary("Babble-Boss-2.2")
local L = AceLibrary("AceLocale-2.2"):new("BigWigs")
local waterfall = AceLibrary("Waterfall-1.0")
local surface = AceLibrary("Surface-1.0")
surface:Register("Armory", "Interface\\AddOns\\BigWigs\\Textures\\Armory")
surface:Register("Otravi", "Interface\\AddOns\\BigWigs\\Textures\\otravi")
surface:Register("Smooth", "Interface\\AddOns\\BigWigs\\Textures\\smooth")
surface:Register("Glaze", "Interface\\AddOns\\BigWigs\\Textures\\glaze")
surface:Register("Charcoal", "Interface\\AddOns\\BigWigs\\Textures\\Charcoal")
surface:Register("BantoBar", "Interface\\AddOns\\BigWigs\\Textures\\default")
----------------------------
-- Localization --
----------------------------
L:RegisterTranslations("enUS", function() return {
["%s mod enabled"] = true,
["Target monitoring enabled"] = true,
["Target monitoring disabled"] = true,
["%s engaged!"] = true,
["%s has been defeated"] = true, -- "<boss> has been defeated"
["%s have been defeated"] = true, -- "<bosses> have been defeated"
-- AceConsole strings
["boss"] = true,
["Bosses"] = true,
["Options for boss modules."] = true,
["Options for bosses in %s."] = true, -- "Options for bosses in <zone>"
["Options for %s (r%s)."] = true, -- "Options for <boss> (<revision>)"
["plugin"] = true,
["Plugins"] = true,
["Options for plugins."] = true,
["extra"] = true,
["Extras"] = true,
["Options for extras."] = true,
["toggle"] = true,
["Active"] = true,
["Activate or deactivate this module."] = true,
["reboot"] = true,
["rebootall"] = true,
["Reboot"] = true,
["Reboot All"] = true,
["Reboot this module."] = true,
["debug"] = true,
["Debugging"] = true,
["Show debug messages."] = true,
["Forces the module to reset for everyone in the raid.\n\n(Requires assistant or higher)"] = true,
["%s has requested forced reboot for the %s module."] = true,
bosskill_cmd = "kill",
bosskill_name = "Boss death",
bosskill_desc = "Announce when boss is defeated",
["Other"] = true,
["Load"] = true,
["Load All"] = true,
["Load all %s modules."] = true,
-- AceConsole zone commands
["Zul'Gurub"] = "ZG",
["Molten Core"] = "MC",
["Blackwing Lair"] = "BWL",
["Ahn'Qiraj"] = "AQ40",
["Ruins of Ahn'Qiraj"] = "AQ20",
["Onyxia's Lair"] = "Onyxia",
["Naxxramas"] = "Naxxramas",
["Silithus"] = true,
["Outdoor Raid Bosses"] = "Outdoor",
["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option
--Name for exception bosses (neutrals that enable modules)
["Vaelastrasz the Corrupt"] = true,
["Lord Victor Nefarius"] = true,
["You have slain %s!"] = true,
["You are using a developer version of BigWigs.\nPlease download a proper release at https://github.com/xorann/BigWigs/releases"] = true,
["Close"] = true,
["Cancel"] = true,
} end)
L:RegisterTranslations("deDE", function() return {
["%s mod enabled"] = "%s Modul aktiviert",
["Target monitoring enabled"] = "Zielüberwachung aktiviert",
["Target monitoring disabled"] = "Zielüberwachung deaktiviert",
["%s engaged!"] = "%s angegriffen!",
["%s has been defeated"] = "%s wurde besiegt", -- "<boss> has been defeated"
["%s have been defeated"] = "%s wurden besiegt", -- "<bosses> have been defeated"
-- AceConsole strings
-- ["boss"] = true,
["Bosses"] = "Bosse",
["Options for boss modules."] = "Optionen für Boss Module.",
["Options for bosses in %s."] = "Optionen für Bosse in %s.", -- "Options for bosses in <zone>"
["Options for %s (r%s)."] = "Optionen für %s (r%s).", -- "Options for <boss> (<revision>)"
-- ["plugin"] = true,
["Plugins"] = "Plugins",
["Options for plugins."] = "Optionen für Plugins.",
-- ["extra"] = true,
["Extras"] = "Extras",
["Options for extras."] = "Optionen für Extras.",
-- ["toggle"] = true,
["Active"] = "Aktivieren",
["Activate or deactivate this module."] = "Aktiviert oder deaktiviert dieses Modul.",
-- ["reboot"] = true,
["Reboot"] = "Neustarten",
["Reboot All"] = "Alles Neustarten",
["Reboot this module."] = "Startet dieses Modul neu.",
-- ["debug"] = true,
["Debugging"] = "Debugging",
["Show debug messages."] = "Zeige Debug Nachrichten.",
["Forces the module to reset for everyone in the raid.\n\n(Requires assistant or higher)"] = "Erzwingt dass das Modul für jeden im Raid zurückgesetzt wird.\n\n(Benötigt Schlachtzugleiter oder Assistent)",
["%s has requested forced reboot for the %s module."] = "%s hat einen Zwangsneustart für das %s-Modul beantragt.",
-- bosskill_cmd = "kill",
bosskill_name = "Boss besiegt",
bosskill_desc = "Melde, wenn ein Boss besiegt wurde.",
-- AceConsole zone commands
["Zul'Gurub"] = "ZG",
["Molten Core"] = "MC",
["Blackwing Lair"] = "BWL",
["Ahn'Qiraj"] = "AQ40",
["Ruins of Ahn'Qiraj"] = "AQ20",
["Onyxia's Lair"] = "Onyxia",
["Naxxramas"] = "Naxxramas",
-- ["Silithus"] = true,
["Outdoor Raid Bosses"] = "Outdoor",
-- ["Outdoor Raid Bosses Zone"] = "Outdoor Raid Bosses", -- DO NOT EVER TRANSLATE untill I find a more elegant option
["You have slain %s!"] = "Ihr habt %s getötet!",
["You are using a developer version of BigWigs.\nPlease download a proper release at https://github.com/xorann/BigWigs/releases"] = "Du verwendest eine Entwicklerversion von BigWigs.\nBitte downloade einen ordentlichen Release von https://github.com/xorann/BigWigs/releases",
["Close"] = "Schliessen",
["Cancel"] = "Abbrechen",
} end)
---------------------------------
-- Addon Declaration --
---------------------------------
BigWigs = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceDebug-2.0", "AceModuleCore-2.0", "AceConsole-2.0", "AceDB-2.0", "AceHook-2.1")
BigWigs.BabbleZone = BZ
BigWigs.BabbleBoss = BB
BigWigs.i18n = {}
BigWigs.i18n["Core"] = L
BigWigs:SetModuleMixins("AceDebug-2.0", "AceEvent-2.0", "CandyBar-2.1")
BigWigs:RegisterDB("BigWigsDB", "BigWigsDBPerChar")
BigWigs.cmdtable = {type = "group", handler = BigWigs, args = {
[L["boss"]] = {
type = "group",
name = L["Bosses"],
desc = L["Options for boss modules."],
args = {},
disabled = function() return not BigWigs:IsActive() end,
},
[L["plugin"]] = {
type = "group",
name = L["Plugins"],
desc = L["Options for plugins."],
args = {},
disabled = function() return not BigWigs:IsActive() end,
},
[L["extra"]] = {
type = "group",
name = L["Extras"],
desc = L["Options for extras."],
args = {},
disabled = function() return not BigWigs:IsActive() end,
},
}}
BigWigs:RegisterChatCommand({"/bwcl", "/BigWigscl"}, BigWigs.cmdtable)
BigWigs:RegisterChatCommand({"/bw", "/BigWigs"}, function() waterfall:Open("BigWigs") end)
waterfall:Register('BigWigs', 'aceOptions',BigWigs.cmdtable, 'title','BigWigs', 'colorR', 0.2, 'colorG', 0.6, 'colorB', 0.2)
BigWigs.debugFrame = ChatFrame1
BigWigs.revision = revision
BigWigs.forkName = forkName
BigWigs.isDeveloperVersion = isDeveloperVersion
function BigWigs:DebugMessage(msg, module)
if not msg then msg = "" end
local prefix = "|cfB34DFFf[BigWigs Debug]|r - ";
local core = BigWigs
local debugFrame = DEFAULT_CHAT_FRAME
if module then
if module.core then
core = module.core
end
if module.debugFrame then
debugFrame = self.debugFrame
end
end
if core:IsDebugging() then
(debugFrame or DEFAULT_CHAT_FRAME):AddMessage(prefix .. msg)
end
end
------------------------------
-- Multi Server Support --
------------------------------
BigWigs.server = {}
--[[
BigWigs.server = {
["Classic-WoW"] = {
serverList = {
["Nefarian"] = true
},
supportedBosses = {
["The Twin Emperors"] = true, -- modulename
["C'Thun"] = true
}
}
}
]]
function BigWigs:RegisterServer(serverProjectName, serverName)
if serverProjectName and serverName then
-- check if server was already registered
for aServerProjectName, aServerProject in pairs(BigWigs.server) do
if aServerProject.serverList[serverName] then
local function warning()
BigWigs:Print("Server already registered by project " .. aServerProjectName)
end
BigWigs:ScheduleEvent("BigWigsRegisterServer"..serverProjectName, warning, 2)
return
end
end
-- server project already registered
if BigWigs.server[serverProjectName] then
-- server not registered
if not BigWigs.server[serverProjectName].serverList[serverName] then
BigWigs.server[serverProjectName].serverList[serverName] = true
end
-- server project not registered
else
BigWigs.server[serverProjectName] = {}
BigWigs.server[serverProjectName].serverList = {}
--table.insert(BigWigs.server[serverProjectName].serverList, serverName)
BigWigs.server[serverProjectName].serverList[serverName] = true
BigWigs.server[serverProjectName].supportedBosses = {}
end
end
end
function BigWigs:ServerProjectSupportsBoss(serverProjectName, bossName)
if serverProjectName and bossName and BigWigs.server[serverProjectName] then
BigWigs.server[serverProjectName].supportedBosses[bossName] = true
else
if not serverProjectName then
serverProjectName = "nil"
end
if not bossName then
bossName = "nil"
end
BigWigs:Print("(ServerProjectSupportsBoss) Unknown server. Could not add support for server " .. serverProjectName .. " and boss " .. bossName .. ". Please register server first using BigWigs:RegisterServer(serverProjectName, serverName)")
end
end
--[[
-- returns true if the current server is registered for the serverProject
]]
function BigWigs:IsServerRegisteredForServerProject(serverProjectName)
if serverProjectName then
-- project registered
if BigWigs.server[serverProjectName] then
-- server registered for project
if BigWigs.server[serverProjectName].serverList[GetRealmName()] then
return true
end
end
end
return false
end
--[[
-- returns true if the boss is supported by the server project
]]
function BigWigs:IsBossSupportedByServerProject(bossName, serverProjectName)
if bossName and serverProjectName then
-- project registered
if BigWigs.server[serverProjectName] then
-- boss registered for project
if BigWigs.server[serverProjectName].supportedBosses[bossName] then
return true
end
end
end
return false
end
--[[
returns nil if no server project registered the current server
returns the server project as string if exactly one server project registered the current server
returns a table of strings of all the server projects that registered the current server
]]
function BigWigs:IsServerRegisteredForAnyServerProject()
-- any server project registered
local project = nil
if BigWigs.server then
local currentServer = GetRealmName()
for aServerProjectName, aServerProject in pairs(BigWigs.server) do
if aServerProject.serverList[currentServer] then
if project == nil then
project = aServerProjectName
elseif type(project) == "table" then
table.insert(project, aServerProjectName)
else
local tmp = project
project = {}
table.insert(project, tmp)
table.insert(project, aServerProjectName)
end
end
end
end
return project
end
function BigWigs:IsBossSupportedByAnyServerProject(bossName)
if bossName then
if BigWigs.server then
local currentServer = GetRealmName()
for aServerProjectName, aServerProject in pairs(BigWigs.server) do
if aServerProject.serverList[currentServer] then
if aServerProject.supportedBosses[bossName] then
return true
end
end
end
end
end
return false
end
------------------------------
-- KLHThreatMeter --
------------------------------
local function IsKtmActive()
if IsAddOnLoaded("KLHThreatMeter") and klhtm and klhtm.net and klhtm.target then
return true
end
return false
end
function BigWigs:KTM_Reset()
if IsKtmActive() then
if IsRaidLeader() or IsRaidOfficer() then
klhtm.net.clearraidthreat()
end
end
end
BigWigs.masterTarget = nil;
BigWigs.forceReset = nil;
function BigWigs:KTM_ClearTarget(forceReset)
if IsKtmActive() and (IsRaidLeader() or IsRaidOfficer()) then
klhtm.net.clearmastertarget()
if forceReset then
self:KTM_Reset()
end
end
end
function BigWigs:PLAYER_TARGET_CHANGED()
if IsKtmActive() and BigWigs.masterTarget and (IsRaidLeader() or IsRaidOfficer()) then
if klhtm.target.targetismaster(BigWigs.masterTarget) then
-- the masterTarget was already setup correctly
BigWigs:UnregisterEvent("PLAYER_TARGET_CHANGED")
BigWigs.masterTarget = nil
BigWigs.forceReset = nil
return
end
if UnitName("target") == BigWigs.masterTarget then
-- our new target is the wanted target, setup masterTarget now
klhtm.net.sendmessage("target " .. BigWigs.masterTarget)
if BigWigs.forceReset then
BigWigs:KTM_Reset()
BigWigs.forceReset = nil
end
BigWigs.masterTarget = nil
BigWigs:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
else
BigWigs:UnregisterEvent("PLAYER_TARGET_CHANGED")
end
end
--------------------------------------
-- Generic Boss Module Functions --
--------------------------------------
--[[
BigWigs.bossmods = {
aq40 = {
twins = "The Twin Emperors",
cthun = "C'Thun"
}
}
BigWigs.bossmods.aq40.twins
]]
BigWigs.bossmods = {}
function BigWigs:CheckForEngage(module)
if module and module:IsBossModule() and not module.engaged then
local function IsBossInCombat()
local t = module.enabletrigger
local a = module.wipemobs
if not t then return false end
if type(t) == "string" then t = {t} end
if a then
if type(a) == "string" then a = {a} end
for k,v in pairs(a) do table.insert(t, v) end
end
if UnitExists("target") and UnitAffectingCombat("target") then
local target = UnitName("target")
for _, mob in pairs(t) do
if target == mob then
return true
end
end
end
local num = GetNumRaidMembers()
for i = 1, num do
local raidUnit = string.format("raid%starget", i)
if UnitExists(raidUnit) and UnitAffectingCombat(raidUnit) then
local target = UnitName(raidUnit)
for _, mob in pairs(t) do
if target == mob then
return true
end
end
end
end
return false
end
local inCombat = IsBossInCombat()
local running = module:IsEventScheduled(module:ToString().."_CheckStart")
if inCombat then
module:DebugMessage("Scan returned true, engaging ["..module:ToString().."].")
module:CancelScheduledEvent(module:ToString().."_CheckStart")
module:SendEngageSync()
elseif not running then
module:ScheduleRepeatingEvent(module:ToString().."_CheckStart", module.CheckForEngage, .5, module)
end
end
end
function BigWigs:CheckForWipe(module)
if module and module:IsBossModule() then
local isInZone = false
if type(module.zonename) == "string" and module.zonename == GetRealZoneText() then
isInZone = true
elseif type(module.zonename) == "table" then
for _, v in pairs(module.zonename) do
if v == GetRealZoneText() then
isInZone = true
break
end
end
end
if not isInZone then
BigWigs:DebugMessage("CheckForWipe: not in the zone: wipe ("..module:ToString()..")")
-- reset if you are not in the zone
module:Wipe()
return
end
--module:DebugMessage("BigWigs." .. module:ToString() .. ":CheckForWipe()")
-- start wipe check in regular intervals
local running = module:IsEventScheduled(module:ToString().."_CheckWipe")
if not running then
module:DebugMessage("CheckForWipe: not running, scheduling regular checks")
module:ScheduleRepeatingEvent(module:ToString().."_CheckWipe", module.CheckForWipe, 5, module)
return
end
local function RaidMemberInCombat()
if UnitAffectingCombat("player") then
module:DebugMessage("CheckForWipe: you are in combat")
return true
end
local num = GetNumRaidMembers()
for i = 1, num do
local raidUnit = string.format("raid%s", i)
if UnitExists(raidUnit) and UnitAffectingCombat(raidUnit) then
-- make sure player is in the correct zone
local _, _, _, _, _, _, zone = GetRaidRosterInfo(i)
if type(module.zonename) == "string" and module.zonename == zone then
module:DebugMessage("CheckForWipe: " .. raidUnit .. " in combat")
return true
elseif type(module.zonename) == "table" then
for _, v in pairs(module.zonename) do
if v == zone then
module:DebugMessage("CheckForWipe: " .. raidUnit .. " in combat")
return true
end
end
end
end
end
return false
end
local inCombat = RaidMemberInCombat()
if not inCombat then
module:DebugMessage("CheckForWipe: Wipe detected for module ["..module:ToString().."].")
module:CancelScheduledEvent(module:ToString().."_CheckWipe")
--self:TriggerEvent("BigWigs_RebootModule", module:ToString())
module:Wipe()
--module:SendWipeSync()
end
end
end
function BigWigs:CheckForBossDeath(msg, module)
if module and module:IsBossModule() then
if msg == string.format(UNITDIESOTHER, module:ToString()) or msg == string.format(L["You have slain %s!"], module.translatedName) then
module:SendBossDeathSync()
end
end
end
-- proximity
function BigWigs:Proximity(moduleName)
self:TriggerEvent("BigWigs_ShowProximity", moduleName)
end
function BigWigs:RemoveProximity()
self:TriggerEvent("BigWigs_HideProximity")
end
--------------------------------------
-- Do not use a developer version --
---------------------------------------
function BigWigs:CheckForDeveloperVersion()
if self.isDeveloperVersion then
BigWigs:Print(L["You are using a developer version of BigWigs.\nPlease download a proper release at https://github.com/xorann/BigWigs/releases"])
local dialog = nil
StaticPopupDialogs["BigWigsDeveloperVersionDialog"] = {
text = L["You are using a developer version of BigWigs.\nPlease download a proper release at https://github.com/xorann/BigWigs/releases"],
button1 = L["Close"],
button2 = L["Cancel"],
OnAccept = function()
StaticPopup_Hide ("BigWigsDeveloperVersionDialog")
end,
OnCancel = function()
StaticPopup_Hide ("BigWigsDeveloperVersionDialog")
end,
OnShow = function (self, data)
local editbox = getglobal(this:GetName().."WideEditBox")
editbox:SetText("https://github.com/xorann/BigWigs/releases")
editbox:SetWidth(250)
editbox:ClearFocus()
editbox:HighlightText()
--self.editBox:SetText("Some text goes here")
getglobal(this:GetName().."Button2"):Hide()
end,
hasEditBox = true,
hasWideEditBox = true,
maxLetters = 42,
--EditBox:setText("Text"),
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
local dialog = StaticPopup_Show ("BigWigsDeveloperVersionDialog")
end
end
------------------------------
-- Initialization --
------------------------------
function BigWigs:OnInitialize()
if not self.version then self.version = GetAddOnMetadata("BigWigs", "Version") end
local rev = self.revision
for name, module in self:IterateModules() do
--self:RegisterModule(name,module)
rev = math.max(rev, module.revision)
end
self.version = (self.version or "2.0").. " |cffff8888r"..rev.."|r"
--self:RegisterEvent("ADDON_LOADED")
self.loading = true
-- Activate ourselves, or at least try to. If we were disabled during a reloadUI, OnEnable isn't called,
-- and self.loading will never be set to something else, resulting in a BigWigs that doesn't enable.
self:ToggleActive(true)
-- show dialog if a developer version is being used
BigWigs:CheckForDeveloperVersion()
end
function BigWigs:OnEnable()
if AceLibrary("AceEvent-2.0"):IsFullyInitialized() then
self:AceEvent_FullyInitialized()
else
self:RegisterEvent("AceEvent_FullyInitialized")
end
end
function BigWigs:AceEvent_FullyInitialized()
if GetNumRaidMembers() > 0 or not self.loading then
-- Enable all disabled modules that are not boss modules.
for name, module in self:IterateModules() do
if type(module.IsBossModule) ~= "function" or not module:IsBossModule() then
self:ToggleModuleActive(module, true)
end
end
if BigWigsLoD then
self:CreateLoDMenu()
end
self:TriggerEvent("BigWigs_CoreEnabled")
self:RegisterEvent("BigWigs_TargetSeen")
self:RegisterEvent("BigWigs_RebootModule")
self:RegisterEvent("BigWigs_RecvSync")
--self:RegisterEvent("AceEvent_FullyInitialized", function() self:TriggerEvent("BigWigs_ThrottleSync", "BossEngaged", 5) end )
else
self:ToggleActive(false)
end
self.loading = nil
end
function BigWigs:OnDisable()
-- Disable all modules
for name, module in self:IterateModules() do
self:ToggleModuleActive(module, false)
end
self:TriggerEvent("BigWigs_CoreDisabled")
end
-------------------------------
-- External Modules --
-------------------------------
function BigWigs:ADDON_LOADED(addon)
local gname = GetAddOnMetadata(addon, "X-BigWigsModule")
if not gname then return end
local g = getglobal(gname)
if not g or not g.name then return end
g.external = true
self:RegisterModule(g.name, g)
end
-------------------------------
-- Event Handler --
-------------------------------
function BigWigs:BigWigs_RecvSync(sync, moduleName, nick)
local s, m, n, playername = "-", "-", "-", UnitName("player")
if sync then
if type(sync) == "string" then
s = sync
else
s = type(sync)
end
end
if moduleName then
if type(moduleName) == "string" then
m = moduleName
else
m = type(moduleName)
end
end
if nick then
if type(nick) == "string" then
if nick == playername then
n = "you"
else
n = nick
end
else
n = type(nick)
end
end
self:DebugMessage("sync: " .. s .. " rest: " .. m .. " nick: " .. n)
local moduleName = BB:HasTranslation(moduleName) and BB[moduleName] or moduleName
local module = nil
if self:HasModule(moduleName) then
module = self:GetModule(moduleName)
end
if module and sync == "EnableModule" then
moduleName = BB:HasTranslation(moduleName) and BB[moduleName] or moduleName
local isInZone = false
if type(module.zonename) == "string" and module.zonename == GetRealZoneText() then
isInZone = true
elseif type(module.zonename) == "table" then
for _, v in pairs(module.zonename) do
if v == GetRealZoneText() then
isInZone = true
break
end
end
end
if isInZone then self:EnableModule(moduleName, true) end
elseif module and sync == "EnableExternal" then
if module.zonename == GetRealZoneText() then
self:EnableModule(moduleName, true)
end
elseif sync == "RebootModule" and moduleName then
if nick ~= UnitName("player") then
self:Print(string.format(L["%s has requested forced reboot for the %s module."], nick, moduleName))
end
self:TriggerEvent("BigWigs_RebootModule", moduleName)
elseif module and sync == module:GetEngageSync() then
if module:IsBossModule() then
module:Engage()
end
--[[elseif module and sync == module:GetWipeSync() then
if module:IsBossModule() and BigWigs:IsModuleActive(module) then
self:TriggerEvent("BigWigs_RebootModule", moduleName)
end]]
elseif module and sync == module:GetBossDeathSync() then
if module:IsBossModule() and BigWigs:IsModuleActive(module) then
module:Victory()
end
end
end
function BigWigs:BigWigs_TargetSeen(mobname, unit)
for name,module in self:IterateModules() do
if module:IsBossModule() and self:ZoneIsTrigger(module, GetRealZoneText()) and self:MobIsTrigger(module, mobname)
and (not module.VerifyEnable or module:VerifyEnable(unit)) then
self:EnableModule(name)
--[[if UnitExists(unit.."target") then
-- if this is true the boss is apparantely already in combat!
-- this situation can happen on bosses which spawn the same time they enter combat (Arlokk/Mandokir) or when a player without BigWigs engages the boss
module:SendEngageSync()
end]]
end
end
end
-------------------------------
-- Utility --
-------------------------------
function BigWigs:ZoneIsTrigger(module, zone)
local t = module.zonename
if type(t) == "string" then return zone == t
elseif type(t) == "table" then
for _,mzone in pairs(t) do if mzone == zone then return true end end
end
end
function BigWigs:MobIsTrigger(module, name)
local t = module.enabletrigger
if type(t) == "string" then
return name == t
elseif type(t) == "table" then
for _,mob in pairs(t) do
if mob == name then
return true
end
end
end
end
function BigWigs:CreateLoDMenu()
local zonelist = BigWigsLoD:GetZones()
for k,v in pairs( zonelist ) do
if type(v) ~= "table" then
self:AddLoDMenu( k )
else
self:AddLoDMenu( L["Other"] )
end
end
end
function BigWigs:AddLoDMenu( zonename )
local zone = nil
if L:HasTranslation(zonename) then
zone = L[zonename]
else
zone = L["Other"]
end
if zone then
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 zone == L["Other"] then
-- local zones = BigWigsLoD:GetZones()
-- zones = zones[L["Other"]]
-- self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = {
-- type = "execute",
-- name = L["Load All"],
-- desc = string.format( L["Load all %s modules."], zonename ),
-- order = 1,
-- func = function()
-- for z, v in pairs( zones ) do
-- BigWigsLoD:LoadZone( z )
-- if self.cmdtable.args[L["boss"]].args[z] and self.cmdtable.args[L["boss"]].args[z].args[L["Load"]] then
-- self.cmdtable.args[L["boss"]].args[z].args[L["Load"]] = nil
-- end
-- end
-- self.cmdtable.args[L["boss"]].args[zone] = nil
-- end
-- }
-- else
-- self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = {
-- type = "execute",
-- name = L["Load All"],
-- desc = string.format( L["Load all %s modules."], zonename ),
-- order = 1,
-- func = function()
-- BigWigsLoD:LoadZone( zonename )
-- self.cmdtable.args[L["boss"]].args[zone].args[L["Load"]] = nil
-- end
-- }
-- end
end
end