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 enablezones, enablemobs = {}, {} |
||
7 | |||
8 | |||
9 | --------------------------------- |
||
10 | -- Addon Declaration -- |
||
11 | --------------------------------- |
||
12 | |||
13 | BigWigsTargetMonitor = BigWigs:NewModule("Target Monitor") |
||
14 | |||
15 | |||
16 | ------------------------------ |
||
17 | -- Initialization -- |
||
18 | ------------------------------ |
||
19 | |||
20 | function BigWigsTargetMonitor:OnInitialize() |
||
21 | for name,module in self.core:IterateModules() do |
||
22 | self:BigWigs_RegisterForTargetting(module.zonename, module.enabletrigger) |
||
23 | end |
||
24 | self:RegisterEvent("BigWigs_RegisterForTargetting") |
||
25 | end |
||
26 | |||
27 | |||
28 | function BigWigsTargetMonitor:OnEnable() |
||
29 | self:RegisterEvent("BigWigs_RegisterForTargetting") |
||
30 | self:RegisterEvent("ZONE_CHANGED_NEW_AREA") |
||
31 | self:ZONE_CHANGED_NEW_AREA() |
||
32 | end |
||
33 | |||
34 | |||
35 | ------------------------------ |
||
36 | -- Event Handlers -- |
||
37 | ------------------------------ |
||
38 | |||
39 | function BigWigsTargetMonitor:BigWigs_RegisterForTargetting(zone, mob) |
||
40 | if type(zone) == "string" then enablezones[zone] = true |
||
41 | elseif type(zone) == "table" then |
||
42 | for _,z in pairs(zone) do enablezones[z] = true end |
||
43 | end |
||
44 | |||
45 | if type(mob) == "string" then enablemobs[mob] = true |
||
46 | elseif type(mob) == "table" then |
||
47 | for _,m in pairs(mob) do enablemobs[m] = true end |
||
48 | end |
||
49 | end |
||
50 | |||
51 | |||
52 | function BigWigsTargetMonitor:ZONE_CHANGED_NEW_AREA() |
||
53 | if enablezones[GetRealZoneText()] then |
||
54 | self.monitoring = true |
||
55 | --~~ self:TriggerEvent("BigWigs_Message", L"Target monitoring enabled", "LtBlue", true, false) |
||
56 | self:RegisterEvent("PLAYER_TARGET_CHANGED") |
||
57 | self:RegisterEvent("UPDATE_MOUSEOVER_UNIT") |
||
58 | elseif self.monitoring then |
||
59 | self.monitoring = nil |
||
60 | --~~ self:TriggerEvent("BigWigs_Message", L"Target monitoring disabled", "LtBlue", true, false) |
||
61 | self:UnregisterEvent("PLAYER_TARGET_CHANGED") |
||
62 | self:UnregisterEvent("UPDATE_MOUSEOVER_UNIT") |
||
63 | end |
||
64 | end |
||
65 | |||
66 | |||
67 | function BigWigsTargetMonitor:UPDATE_MOUSEOVER_UNIT() |
||
68 | self:TargetCheck("mouseover") |
||
69 | end |
||
70 | |||
71 | |||
72 | function BigWigsTargetMonitor:PLAYER_TARGET_CHANGED() |
||
73 | self:TargetCheck("target") |
||
74 | end |
||
75 | |||
76 | |||
77 | function BigWigsTargetMonitor:TargetCheck(unit) |
||
78 | local n = UnitName(unit) |
||
79 | if not n or UnitIsCorpse(unit) or UnitIsDead(unit) or UnitPlayerControlled(unit) then return end |
||
80 | if enablemobs[n] then self:TriggerEvent("BigWigs_TargetSeen", n, unit) end |
||
81 | end |
||
82 |