|
tercio@0
|
1
|
|
tercio@0
|
2 PVPScan = LibStub ("AceAddon-3.0"):NewAddon ("PVPScan", "AceConsole-3.0", "AceEvent-3.0")
|
|
tercio@0
|
3
|
|
tercio@0
|
4 local LDB = LibStub ("LibDataBroker-1.1", true)
|
|
tercio@0
|
5 local LDBIcon = LDB and LibStub ("LibDBIcon-1.0", true)
|
|
tercio@0
|
6 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
|
tercio@0
|
7
|
|
tercio@0
|
8 local _bit_band = bit.band
|
|
tercio@0
|
9
|
|
tercio@0
|
10 local REACTION_HOSTILE = 0x00000040
|
|
tercio@1
|
11 local REACTION_NEUTRAL = 0x00000020
|
|
tercio@1
|
12
|
|
tercio@0
|
13 local OBJECT_TYPE_PLAYER = 0x00000400
|
|
tercio@0
|
14
|
|
tercio@1
|
15 PVPScan.IsInBattleground = false
|
|
tercio@1
|
16 PVPScan.IsInCity = false
|
|
tercio@1
|
17 PVPScan.IsInArena = false
|
|
tercio@1
|
18 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
19 PVPScan.ScanEnabled = true
|
|
tercio@0
|
20
|
|
tercio@0
|
21 local default_db = {
|
|
tercio@0
|
22 profile = {
|
|
tercio@0
|
23 SpotBarHeight = 20,
|
|
tercio@0
|
24 SpotBarAmount = 5,
|
|
tercio@0
|
25 SpotBarWidth = 150,
|
|
tercio@0
|
26 Locked = false,
|
|
tercio@0
|
27 SoundPlay = false,
|
|
tercio@0
|
28 SoundFile = "",
|
|
tercio@0
|
29 Minimap = {hide = false, radius = 160, minimapPos = 220},
|
|
tercio@0
|
30 },
|
|
tercio@0
|
31 }
|
|
tercio@0
|
32
|
|
tercio@0
|
33 function PVPScan:OnEnable()
|
|
tercio@0
|
34 end
|
|
tercio@0
|
35
|
|
tercio@0
|
36 function PVPScan:OnDisable()
|
|
tercio@0
|
37 end
|
|
tercio@0
|
38
|
|
tercio@0
|
39 local OptionsTable = {
|
|
tercio@0
|
40 name = "PVPScan",
|
|
tercio@0
|
41 type = "group",
|
|
tercio@0
|
42 args = {
|
|
tercio@0
|
43 SpotBarHeight = {
|
|
tercio@0
|
44 type = "range",
|
|
tercio@0
|
45 name = "Bar Height",
|
|
tercio@0
|
46 desc = "Change the height of spot bars.",
|
|
tercio@0
|
47 min = 10,
|
|
tercio@0
|
48 max = 40,
|
|
tercio@0
|
49 step = 1,
|
|
tercio@0
|
50 get = function() return PVPScan.db.profile.SpotBarHeight end,
|
|
tercio@0
|
51 set = function (self, val) PVPScan.db.profile.SpotBarHeight = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
52 order = 1,
|
|
tercio@0
|
53 },
|
|
tercio@0
|
54 SpotBarWidth = {
|
|
tercio@0
|
55 type = "range",
|
|
tercio@0
|
56 name = "Bar Width",
|
|
tercio@0
|
57 desc = "Change the width of spot bars.",
|
|
tercio@0
|
58 min = 50,
|
|
tercio@0
|
59 max = 250,
|
|
tercio@0
|
60 step = 1,
|
|
tercio@0
|
61 get = function() return PVPScan.db.profile.SpotBarWidth end,
|
|
tercio@0
|
62 set = function (self, val) PVPScan.db.profile.SpotBarWidth = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
63 order = 2,
|
|
tercio@0
|
64 },
|
|
tercio@0
|
65 SpotBarAmount = {
|
|
tercio@0
|
66 type = "range",
|
|
tercio@0
|
67 name = "Bar Amount",
|
|
tercio@0
|
68 desc = "Change the amount of spot bars.",
|
|
tercio@0
|
69 min = 1,
|
|
tercio@0
|
70 max = 40,
|
|
tercio@0
|
71 step = 1,
|
|
tercio@0
|
72 get = function() return PVPScan.db.profile.SpotBarAmount end,
|
|
tercio@0
|
73 set = function (self, val) PVPScan.db.profile.SpotBarAmount = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
74 order = 3,
|
|
tercio@0
|
75 },
|
|
tercio@0
|
76 Locked = {
|
|
tercio@0
|
77 type = "toggle",
|
|
tercio@1
|
78 name = "Lock Scan Frame",
|
|
tercio@0
|
79 desc = "Lock or unlock the SpotBars Frame.",
|
|
tercio@0
|
80 order = 4,
|
|
tercio@0
|
81 get = function() return PVPScan.db.profile.Locked end,
|
|
tercio@1
|
82 set = function (self, val) PVPScan.db.profile.Locked = not PVPScan.db.profile.Locked; PVPScan:LockScanFrame (PVPScan.db.profile.Locked) end,
|
|
tercio@0
|
83 },
|
|
tercio@0
|
84 SoundPlay = {
|
|
tercio@0
|
85 type = "toggle",
|
|
tercio@0
|
86 name = "Play Sound",
|
|
tercio@0
|
87 desc = "Play a sound when a enemy is found.",
|
|
tercio@0
|
88 order = 5,
|
|
tercio@0
|
89 get = function() return PVPScan.db.profile.SoundPlay end,
|
|
tercio@0
|
90 set = function (self, val) PVPScan.db.profile.SoundPlay = not PVPScan.db.profile.SoundPlay end,
|
|
tercio@0
|
91 },
|
|
tercio@0
|
92 SoundFile = {
|
|
tercio@0
|
93 type = "select",
|
|
tercio@0
|
94 name = "Sound File",
|
|
tercio@0
|
95 desc = "Choose the sound to play when a enemy is found.",
|
|
tercio@0
|
96 values = function()
|
|
tercio@0
|
97 local SoundTable = {}
|
|
tercio@0
|
98 for name, _ in pairs (SharedMedia:HashTable ("sound")) do
|
|
tercio@0
|
99 SoundTable [name] = name
|
|
tercio@0
|
100 end
|
|
tercio@0
|
101 return SoundTable
|
|
tercio@0
|
102 end,
|
|
tercio@0
|
103 get = function() return PVPScan.db.profile.SoundFile end,
|
|
tercio@0
|
104 set = function (self, file) PVPScan.db.profile.SoundFile = file end,
|
|
tercio@0
|
105 order = 6,
|
|
tercio@0
|
106 },
|
|
tercio@0
|
107 Minimap = {
|
|
tercio@0
|
108 type = "toggle",
|
|
tercio@0
|
109 name = "Hide Minimap Icon",
|
|
tercio@0
|
110 desc = "Show or hide the minimap icon.",
|
|
tercio@0
|
111 order = 7,
|
|
tercio@0
|
112 get = function() return PVPScan.db.profile.Minimap.hide end,
|
|
tercio@0
|
113 set = function (self, val)
|
|
tercio@0
|
114 PVPScan.db.profile.Minimap.hide = not PVPScan.db.profile.Minimap.hide
|
|
tercio@0
|
115 LDBIcon:Refresh ("PVPScan", PVPScan.db.profile.Minimap)
|
|
tercio@0
|
116 if (PVPScan.db.profile.Minimap.hide) then
|
|
tercio@0
|
117 LDBIcon:Hide ("PVPScan")
|
|
tercio@0
|
118 else
|
|
tercio@0
|
119 LDBIcon:Show ("PVPScan")
|
|
tercio@0
|
120 end
|
|
tercio@0
|
121 end,
|
|
tercio@0
|
122 },
|
|
tercio@0
|
123 },
|
|
tercio@0
|
124 }
|
|
tercio@0
|
125
|
|
tercio@0
|
126 function PVPScan:OnInitialize()
|
|
tercio@0
|
127
|
|
tercio@0
|
128 --declarar primeiro o db usando a global que é declarada no toc.
|
|
tercio@0
|
129 self.db = LibStub ("AceDB-3.0"):New ("PVPScanDB", default_db, true)
|
|
tercio@0
|
130
|
|
tercio@0
|
131 --declara agora as opções da tab raiz
|
|
tercio@0
|
132 LibStub("AceConfig-3.0"):RegisterOptionsTable ("PVPScan", OptionsTable)
|
|
tercio@0
|
133 PVPScan.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("PVPScan", "PVPScan")
|
|
tercio@0
|
134 --sub tab
|
|
tercio@0
|
135 LibStub ("AceConfig-3.0"):RegisterOptionsTable ("PVPScan-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
|
|
tercio@0
|
136 PVPScan.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("PVPScan-Profiles", "Profiles", "PVPScan")
|
|
tercio@0
|
137
|
|
tercio@0
|
138 if LDB then
|
|
tercio@0
|
139 local databroker = LDB:NewDataObject ("PVPScan", {
|
|
tercio@0
|
140 type = "launcher",
|
|
tercio@0
|
141 icon = [[Interface\PvPRankBadges\PvPRank15]],
|
|
tercio@0
|
142 --HotCornerIgnore = true,
|
|
tercio@0
|
143 OnClick = function (self, button)
|
|
tercio@0
|
144 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
145 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
146 end
|
|
tercio@0
|
147 })
|
|
tercio@0
|
148
|
|
tercio@0
|
149 if (databroker and not LDBIcon:IsRegistered ("PVPScan")) then
|
|
tercio@0
|
150 LDBIcon:Register ("PVPScan", databroker, PVPScan.db.profile.Minimap)
|
|
tercio@0
|
151 end
|
|
tercio@0
|
152 end
|
|
tercio@0
|
153
|
|
tercio@0
|
154 PVPScan:RefreshSpotBars()
|
|
tercio@1
|
155 PVPScan:LockScanFrame (PVPScan.db.profile.Locked)
|
|
tercio@0
|
156 end
|
|
tercio@0
|
157
|
|
tercio@0
|
158 PVPScan:RegisterChatCommand ("pvpscan", function()
|
|
tercio@0
|
159 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
160 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
161 end)
|
|
tercio@0
|
162
|
|
tercio@1
|
163
|
|
tercio@0
|
164 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
165 --> general
|
|
tercio@0
|
166
|
|
tercio@1
|
167 function PVPScan:ChangeZones()
|
|
tercio@1
|
168
|
|
tercio@1
|
169 local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()
|
|
tercio@1
|
170 local pvpType, isFFA, faction = GetZonePVPInfo()
|
|
tercio@1
|
171
|
|
tercio@1
|
172 PVPScan.IsInBattleground = false
|
|
tercio@1
|
173 PVPScan.IsInCity = false
|
|
tercio@1
|
174 PVPScan.IsInArena = false
|
|
tercio@1
|
175 PVPScan.IsInOutDoors = false
|
|
tercio@1
|
176 PVPScan.ScanEnabled = false
|
|
tercio@1
|
177
|
|
tercio@1
|
178 if (pvpType == "contested" and (not type or type == "none")) then
|
|
tercio@1
|
179 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
180 PVPScan.ScanEnabled = true
|
|
tercio@1
|
181
|
|
tercio@1
|
182 elseif (type == "pvp") then
|
|
tercio@1
|
183 PVPScan.IsInBattleground = true
|
|
tercio@1
|
184
|
|
tercio@1
|
185 elseif (type == "arena") then
|
|
tercio@1
|
186 PVPScan.IsInArena = true
|
|
tercio@1
|
187
|
|
tercio@1
|
188 elseif (type and (type == "scenario" or type == "party" or type == "raid" or pvpType == "friendly" or pvpType == "sanctuary")) then
|
|
tercio@1
|
189 PVPScan.ScanEnabled = false
|
|
tercio@1
|
190
|
|
tercio@1
|
191 else
|
|
tercio@1
|
192 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
193 PVPScan.ScanEnabled = true
|
|
tercio@1
|
194 end
|
|
tercio@1
|
195
|
|
tercio@1
|
196 if (PVPScan.ScanEnabled) then
|
|
tercio@1
|
197 PVPScan:EnableScan()
|
|
tercio@1
|
198 else
|
|
tercio@1
|
199 PVPScan:DisableScan()
|
|
tercio@1
|
200 end
|
|
tercio@1
|
201
|
|
tercio@1
|
202 end
|
|
tercio@1
|
203
|
|
tercio@1
|
204 PVPScan:RegisterEvent ("ZONE_CHANGED_NEW_AREA", "ChangeZones")
|
|
tercio@1
|
205 PVPScan:RegisterEvent ("PLAYER_ENTERING_WORLD", "ChangeZones")
|
|
tercio@1
|
206
|
|
tercio@1
|
207 function PVPScan:EnableScan()
|
|
tercio@1
|
208 PVPScan.EventFrame:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@1
|
209 PVPScan:RefreshSpotBars()
|
|
tercio@1
|
210 end
|
|
tercio@1
|
211
|
|
tercio@1
|
212 function PVPScan:DisableScan()
|
|
tercio@1
|
213 PVPScan.EventFrame:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@1
|
214 PVPScan:RefreshSpotBars()
|
|
tercio@1
|
215 end
|
|
tercio@1
|
216
|
|
tercio@1
|
217 function PVPScan:LockScanFrame (IsLocked)
|
|
tercio@1
|
218 if (IsLocked) then
|
|
tercio@1
|
219 PVPScanFrame.text:SetText ("")
|
|
tercio@1
|
220 PVPScanFrame:SetBackdrop (nil)
|
|
tercio@1
|
221 PVPScanFrame:EnableMouse (false)
|
|
tercio@1
|
222 else
|
|
tercio@1
|
223 PVPScanFrame.text:SetText ("PVPScan Anchor")
|
|
tercio@1
|
224 PVPScanFrame:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, TileSize = 64})
|
|
tercio@1
|
225 PVPScanFrame:SetBackdropColor (0, 0, 0, 1)
|
|
tercio@1
|
226 PVPScanFrame:EnableMouse (true)
|
|
tercio@1
|
227 end
|
|
tercio@1
|
228 end
|
|
tercio@1
|
229 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
230 --> outside world scan
|
|
tercio@1
|
231
|
|
tercio@1
|
232 --> parser
|
|
tercio@1
|
233
|
|
tercio@1
|
234 PVPScan.SpotBars = {}
|
|
tercio@1
|
235 PVPScan.NeedClass = {}
|
|
tercio@1
|
236 PVPScan.NextSpotBar = 1
|
|
tercio@1
|
237
|
|
tercio@1
|
238 local CurrentShownIndex = {}
|
|
tercio@1
|
239 local CurrentShownHash = {}
|
|
tercio@1
|
240 local CurrentShownTime = {}
|
|
tercio@1
|
241 local NeutralCandidate = {}
|
|
tercio@1
|
242
|
|
tercio@1
|
243 local find_neutral_players = false
|
|
tercio@1
|
244
|
|
tercio@1
|
245 PVPScan.EventFrame = CreateFrame ("frame", "PVPScanCombatLobReader", UIParent)
|
|
tercio@1
|
246 PVPScan.EventFrame:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@0
|
247
|
|
tercio@0
|
248 function PVPScan:OnParserEvent (event, time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, ...)
|
|
tercio@0
|
249
|
|
tercio@0
|
250 if (PVPScan.NeedClass [who_name]) then
|
|
tercio@0
|
251 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
252 if (class) then
|
|
tercio@0
|
253 PVPScan:UpdateBar (PVPScan.NeedClass [who_name], class, who_name)
|
|
tercio@0
|
254 PVPScan.NeedClass [who_name] = nil
|
|
tercio@0
|
255 end
|
|
tercio@0
|
256 return
|
|
tercio@0
|
257 end
|
|
tercio@0
|
258
|
|
tercio@0
|
259 if (PVPScan.NeedClass [target_name]) then
|
|
tercio@0
|
260 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
261 if (class) then
|
|
tercio@0
|
262 PVPScan:UpdateBar (PVPScan.NeedClass [target_name], class, target_name)
|
|
tercio@0
|
263 PVPScan.NeedClass [target_name] = nil
|
|
tercio@0
|
264 end
|
|
tercio@0
|
265 return
|
|
tercio@0
|
266 end
|
|
tercio@1
|
267
|
|
tercio@1
|
268 if (not CurrentShownHash [target_name] and _bit_band (target_flags, OBJECT_TYPE_PLAYER) ~= 0) then --> is player
|
|
tercio@1
|
269 if (_bit_band (target_flags, REACTION_HOSTILE) ~= 0) then --> is hostile
|
|
tercio@0
|
270 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
271 PVPScan:EnemySpoted (target_name, target_serial, target_flags, class)
|
|
tercio@1
|
272
|
|
tercio@1
|
273 elseif (find_neutral_players and _bit_band (target_flags, REACTION_NEUTRAL) ~= 0) then
|
|
tercio@1
|
274 if (NeutralCandidate [target_name]) then
|
|
tercio@1
|
275 NeutralCandidate [target_name] = NeutralCandidate [target_name] + 1
|
|
tercio@1
|
276 if (NeutralCandidate [target_name] == 5) then
|
|
tercio@1
|
277 --print ("neutral", target_name)
|
|
tercio@1
|
278 local class = PVPScan:GuessClass (...)
|
|
tercio@1
|
279 PVPScan:EnemySpoted (target_name, target_serial, target_flags, class)
|
|
tercio@1
|
280 end
|
|
tercio@1
|
281 else
|
|
tercio@1
|
282 NeutralCandidate [target_name] = 1
|
|
tercio@1
|
283 end
|
|
tercio@1
|
284
|
|
tercio@1
|
285 elseif (NeutralCandidate [target_name]) then
|
|
tercio@1
|
286 NeutralCandidate [target_name] = nil
|
|
tercio@0
|
287 end
|
|
tercio@0
|
288 end
|
|
tercio@0
|
289
|
|
tercio@1
|
290 if (not CurrentShownHash [who_name] and _bit_band (who_flags, OBJECT_TYPE_PLAYER) ~= 0) then --> is player
|
|
tercio@1
|
291 if (_bit_band (who_flags, REACTION_HOSTILE) ~= 0) then --> is hostile
|
|
tercio@0
|
292 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
293 PVPScan:EnemySpoted (who_name, who_serial, who_flags, class)
|
|
tercio@1
|
294
|
|
tercio@1
|
295 elseif (find_neutral_players and _bit_band (who_flags, REACTION_NEUTRAL) ~= 0) then
|
|
tercio@1
|
296 if (NeutralCandidate [who_name]) then
|
|
tercio@1
|
297 NeutralCandidate [who_name] = NeutralCandidate [who_name] + 1
|
|
tercio@1
|
298 if (NeutralCandidate [who_name] == 5) then
|
|
tercio@1
|
299 --print ("neutral", who_name)
|
|
tercio@1
|
300 local class = PVPScan:GuessClass (...)
|
|
tercio@1
|
301 PVPScan:EnemySpoted (who_name, who_serial, who_flags, class)
|
|
tercio@1
|
302 end
|
|
tercio@1
|
303 else
|
|
tercio@1
|
304 NeutralCandidate [who_name] = 1
|
|
tercio@1
|
305 end
|
|
tercio@1
|
306
|
|
tercio@1
|
307 elseif (NeutralCandidate [who_name]) then
|
|
tercio@1
|
308 NeutralCandidate [who_name] = nil
|
|
tercio@0
|
309 end
|
|
tercio@0
|
310 end
|
|
tercio@0
|
311 end
|
|
tercio@0
|
312
|
|
tercio@1
|
313 PVPScan.EventFrame:SetScript ("OnEvent", PVPScan.OnParserEvent)
|
|
tercio@0
|
314
|
|
tercio@0
|
315 function PVPScan:LeftCombatLockdown()
|
|
tercio@0
|
316 if (PVPScan.schedule_frame_update) then
|
|
tercio@0
|
317 PVPScan.schedule_frame_update = false
|
|
tercio@0
|
318 PVPScan:RefreshSpotBars()
|
|
tercio@0
|
319 end
|
|
tercio@0
|
320 end
|
|
tercio@0
|
321 function PVPScan:GotCombatLockdown()
|
|
tercio@0
|
322 end
|
|
tercio@0
|
323
|
|
tercio@0
|
324 PVPScan:RegisterEvent ("PLAYER_REGEN_DISABLED", "GotCombatLockdown")
|
|
tercio@0
|
325 PVPScan:RegisterEvent ("PLAYER_REGEN_ENABLED", "LeftCombatLockdown")
|
|
tercio@0
|
326
|
|
tercio@1
|
327 -- found a enemy on the scan
|
|
tercio@1
|
328
|
|
tercio@0
|
329 function PVPScan:EnemySpoted (name, serial, flags, class)
|
|
tercio@0
|
330
|
|
tercio@1
|
331 if (not name) then
|
|
tercio@1
|
332 return
|
|
tercio@1
|
333 end
|
|
tercio@1
|
334
|
|
tercio@0
|
335 --> check for overwrite
|
|
tercio@1
|
336 local current_player_shown = CurrentShownIndex [PVPScan.NextSpotBar]
|
|
tercio@0
|
337 if (current_player_shown) then
|
|
tercio@0
|
338 PVPScan.NeedClass [current_player_shown] = nil
|
|
tercio@0
|
339 end
|
|
tercio@0
|
340
|
|
tercio@0
|
341 local SpotBar = PVPScan.SpotBars [PVPScan.NextSpotBar]
|
|
tercio@0
|
342
|
|
tercio@0
|
343 if (class) then
|
|
tercio@0
|
344 PVPScan:UpdateBar (PVPScan.NextSpotBar, class, name)
|
|
tercio@0
|
345 else
|
|
tercio@0
|
346 PVPScan:UpdateBar (PVPScan.NextSpotBar, nil, name)
|
|
tercio@0
|
347 PVPScan.NeedClass [name] = PVPScan.NextSpotBar
|
|
tercio@0
|
348 end
|
|
tercio@0
|
349
|
|
tercio@1
|
350 CurrentShownIndex [PVPScan.NextSpotBar] = name
|
|
tercio@1
|
351 CurrentShownHash [name] = PVPScan.NextSpotBar
|
|
tercio@1
|
352 CurrentShownTime [name] = GetTime()
|
|
tercio@0
|
353
|
|
tercio@0
|
354 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
|
|
tercio@1
|
355 SpotBar:SetAttribute ("macrotext", "/cleartarget\n/targetexact " .. name)
|
|
tercio@0
|
356 end
|
|
tercio@0
|
357
|
|
tercio@0
|
358 SpotBar:Show()
|
|
tercio@0
|
359
|
|
tercio@0
|
360 PVPScan.NextSpotBar = PVPScan.NextSpotBar + 1
|
|
tercio@0
|
361 if (PVPScan.NextSpotBar > PVPScan.db.profile.SpotBarAmount) then
|
|
tercio@0
|
362 PVPScan.NextSpotBar = 1
|
|
tercio@0
|
363 end
|
|
tercio@0
|
364
|
|
tercio@0
|
365 end
|
|
tercio@0
|
366
|
|
tercio@1
|
367 -- frames
|
|
tercio@0
|
368
|
|
tercio@1
|
369 function PVPScanOnFrameMouseDown (self, button)
|
|
tercio@1
|
370 if (button == "LeftButton") then
|
|
tercio@1
|
371 if (not self.IsMoving) then
|
|
tercio@1
|
372 self:StartMoving()
|
|
tercio@1
|
373 self.IsMoving = true
|
|
tercio@1
|
374 end
|
|
tercio@0
|
375 end
|
|
tercio@0
|
376 end
|
|
tercio@0
|
377
|
|
tercio@1
|
378 function PVPScanOnFrameMouseUp (self, button)
|
|
tercio@1
|
379 if (button == "LeftButton") then
|
|
tercio@1
|
380 if (self.IsMoving) then
|
|
tercio@1
|
381 self:StopMovingOrSizing()
|
|
tercio@1
|
382 self.IsMoving = false
|
|
tercio@1
|
383 end
|
|
tercio@1
|
384
|
|
tercio@1
|
385 elseif (button == "RightButton") then
|
|
tercio@1
|
386 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@1
|
387 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
388 end
|
|
tercio@0
|
389 end
|
|
tercio@0
|
390
|
|
tercio@0
|
391 function PVPScan:UpdateBar (index, class, name)
|
|
tercio@0
|
392
|
|
tercio@1
|
393 if (UnitAffectingCombat ("player") or InCombatLockdown()) then
|
|
tercio@1
|
394 --return
|
|
tercio@1
|
395 end
|
|
tercio@1
|
396
|
|
tercio@0
|
397 local SpotBar = PVPScan.SpotBars [index]
|
|
tercio@0
|
398
|
|
tercio@0
|
399 if (class) then
|
|
tercio@0
|
400 local color = RAID_CLASS_COLORS [class]
|
|
tercio@0
|
401 SpotBar.classtexture:SetVertexColor (color.r, color.g, color.b)
|
|
tercio@0
|
402
|
|
tercio@0
|
403 local texcoord = CLASS_ICON_TCOORDS [class]
|
|
tercio@0
|
404 SpotBar.classicon:SetTexture ([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
|
|
tercio@0
|
405 SpotBar.classicon:SetTexCoord (unpack (texcoord))
|
|
tercio@0
|
406 else
|
|
tercio@0
|
407 SpotBar.classtexture:SetVertexColor (.7, .7, .7)
|
|
tercio@0
|
408 SpotBar.classicon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]])
|
|
tercio@0
|
409 SpotBar.classicon:SetTexCoord (0, 1, 0, 1)
|
|
tercio@0
|
410 end
|
|
tercio@0
|
411
|
|
tercio@0
|
412 SpotBar.name:SetText (name)
|
|
tercio@0
|
413
|
|
tercio@0
|
414 end
|
|
tercio@0
|
415
|
|
tercio@0
|
416 function PVPScan:RefreshSpotBars()
|
|
tercio@0
|
417
|
|
tercio@0
|
418 if (UnitAffectingCombat ("player") or InCombatLockdown()) then
|
|
tercio@0
|
419 PVPScan.schedule_frame_update = true
|
|
tercio@0
|
420 PVPScan:Print ("When the combat finishes, the frame will be updated.")
|
|
tercio@0
|
421 return
|
|
tercio@0
|
422 end
|
|
tercio@0
|
423
|
|
tercio@1
|
424 if (not PVPScan.ScanEnabled) then
|
|
tercio@1
|
425 PVPScanFrame:Hide()
|
|
tercio@1
|
426 else
|
|
tercio@1
|
427 PVPScanFrame:Show()
|
|
tercio@1
|
428 end
|
|
tercio@1
|
429
|
|
tercio@0
|
430 local amount_bars = PVPScan.db.profile.SpotBarAmount
|
|
tercio@1
|
431 PVPScanFrame:SetSize (PVPScan.db.profile.SpotBarWidth, 20)
|
|
tercio@0
|
432
|
|
tercio@0
|
433 --> we need extra bars?
|
|
tercio@0
|
434 if (amount_bars > #PVPScan.SpotBars) then
|
|
tercio@0
|
435 for i = #PVPScan.SpotBars+1, amount_bars do
|
|
tercio@0
|
436
|
|
tercio@0
|
437 local new_bar = CreateFrame ("Button", "PVPScanSpotBar" .. i, PVPScanFrame, "PVPScanSpotBarTemplate")
|
|
tercio@0
|
438
|
|
tercio@0
|
439 local y = (i-1) * PVPScan.db.profile.SpotBarHeight * -1
|
|
tercio@0
|
440
|
|
tercio@0
|
441 new_bar:SetPoint ("topleft", PVPScanFrame, "topleft", 0, y)
|
|
tercio@0
|
442 new_bar:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@0
|
443
|
|
tercio@0
|
444 tinsert (PVPScan.SpotBars, new_bar)
|
|
tercio@0
|
445 end
|
|
tercio@0
|
446 end
|
|
tercio@0
|
447
|
|
tercio@0
|
448 if (#PVPScan.SpotBars > amount_bars) then
|
|
tercio@0
|
449 for i = #PVPScan.SpotBars, amount_bars+1, -1 do
|
|
tercio@0
|
450 PVPScan.SpotBars [i]:Hide()
|
|
tercio@1
|
451 local name = CurrentShownIndex [i]
|
|
tercio@0
|
452 if (name) then
|
|
tercio@1
|
453 tremove (CurrentShownIndex, i)
|
|
tercio@1
|
454 CurrentShownHash [name] = nil
|
|
tercio@1
|
455 CurrentShownTime [name] = nil
|
|
tercio@0
|
456 PVPScan.NeedClass [name] = nil
|
|
tercio@0
|
457 end
|
|
tercio@0
|
458 end
|
|
tercio@0
|
459 end
|
|
tercio@0
|
460
|
|
tercio@0
|
461 --> refresh existing
|
|
tercio@0
|
462 for index, bar in ipairs (PVPScan.SpotBars) do
|
|
tercio@0
|
463 local y = (index-1) * PVPScan.db.profile.SpotBarHeight * -1
|
|
tercio@1
|
464 bar:SetPoint ("topleft", PVPScanFrame, "bottomleft", 0, y)
|
|
tercio@0
|
465 bar:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@1
|
466 bar.classtexture:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@1
|
467 bar.classicon:SetSize (PVPScan.db.profile.SpotBarHeight, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@0
|
468 end
|
|
tercio@0
|
469
|
|
tercio@0
|
470 end
|
|
tercio@0
|
471
|
|
tercio@1
|
472 --> misc
|
|
tercio@0
|
473
|
|
tercio@0
|
474 function PVPScan:GuessClass (...)
|
|
tercio@0
|
475 local arg1, arg2, arg3, arg4 = select (1, ...)
|
|
tercio@0
|
476
|
|
tercio@0
|
477 if (type (arg1) == "number") then
|
|
tercio@0
|
478 if (PVPScan.ClassSpellList [arg1]) then
|
|
tercio@0
|
479 return PVPScan.ClassSpellList [arg1]
|
|
tercio@0
|
480 end
|
|
tercio@0
|
481 end
|
|
tercio@0
|
482
|
|
tercio@0
|
483 if (type (arg3) == "number") then
|
|
tercio@0
|
484 if (PVPScan.ClassSpellList [arg3]) then
|
|
tercio@0
|
485 return PVPScan.ClassSpellList [arg3]
|
|
tercio@0
|
486 end
|
|
tercio@0
|
487 end
|
|
tercio@0
|
488
|
|
tercio@0
|
489 if (type (arg2) == "number") then
|
|
tercio@0
|
490 if (PVPScan.ClassSpellList [arg3]) then
|
|
tercio@0
|
491 return PVPScan.ClassSpellList [arg3]
|
|
tercio@0
|
492 end
|
|
tercio@0
|
493 end
|
|
tercio@0
|
494
|
|
tercio@0
|
495 if (type (arg4) == "number") then
|
|
tercio@0
|
496 if (PVPScan.ClassSpellList [arg4]) then
|
|
tercio@0
|
497 return PVPScan.ClassSpellList [arg4]
|
|
tercio@0
|
498 end
|
|
tercio@0
|
499 end
|
|
tercio@0
|
500
|
|
tercio@0
|
501 return nil
|
|
tercio@0
|
502 end
|
|
tercio@0
|
503
|
|
tercio@1
|
504
|
|
tercio@1
|
505 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
506 --> battlegrounds
|
|
tercio@1
|
507
|