|
tercio@0
|
1
|
|
tercio@2
|
2 PVPScan = LibStub ("AceAddon-3.0"):NewAddon ("PVPScan", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
|
tercio@4
|
3
|
|
tercio@3
|
4 local PVPScan = PVPScan
|
|
tercio@0
|
5 local LDB = LibStub ("LibDataBroker-1.1", true)
|
|
tercio@0
|
6 local LDBIcon = LDB and LibStub ("LibDBIcon-1.0", true)
|
|
tercio@0
|
7 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
|
tercio@0
|
8
|
|
tercio@0
|
9 local _bit_band = bit.band
|
|
tercio@2
|
10 local GetTime = GetTime
|
|
tercio@0
|
11
|
|
tercio@0
|
12 local REACTION_HOSTILE = 0x00000040
|
|
tercio@1
|
13 local REACTION_NEUTRAL = 0x00000020
|
|
tercio@1
|
14
|
|
tercio@0
|
15 local OBJECT_TYPE_PLAYER = 0x00000400
|
|
tercio@0
|
16
|
|
tercio@1
|
17 PVPScan.IsInBattleground = false
|
|
tercio@1
|
18 PVPScan.IsInCity = false
|
|
tercio@1
|
19 PVPScan.IsInArena = false
|
|
tercio@1
|
20 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
21 PVPScan.ScanEnabled = true
|
|
tercio@0
|
22
|
|
tercio@0
|
23 local default_db = {
|
|
tercio@0
|
24 profile = {
|
|
tercio@0
|
25 SpotBarHeight = 20,
|
|
tercio@0
|
26 SpotBarAmount = 5,
|
|
tercio@0
|
27 SpotBarWidth = 150,
|
|
tercio@2
|
28 SpotBarTexture = "Blizzard Character Skills Bar",
|
|
tercio@2
|
29 SpotBarTimeOut = 10,
|
|
tercio@2
|
30 SpotBarCooldown = 5,
|
|
tercio@2
|
31 SpotBarPlayerCooldown = 10,
|
|
tercio@0
|
32 Locked = false,
|
|
tercio@0
|
33 SoundPlay = false,
|
|
tercio@0
|
34 SoundFile = "",
|
|
tercio@0
|
35 Minimap = {hide = false, radius = 160, minimapPos = 220},
|
|
tercio@0
|
36 },
|
|
tercio@0
|
37 }
|
|
tercio@0
|
38
|
|
tercio@0
|
39 function PVPScan:OnEnable()
|
|
tercio@0
|
40 end
|
|
tercio@0
|
41
|
|
tercio@0
|
42 function PVPScan:OnDisable()
|
|
tercio@0
|
43 end
|
|
tercio@0
|
44
|
|
tercio@0
|
45 local OptionsTable = {
|
|
tercio@0
|
46 name = "PVPScan",
|
|
tercio@0
|
47 type = "group",
|
|
tercio@0
|
48 args = {
|
|
tercio@0
|
49 SpotBarHeight = {
|
|
tercio@0
|
50 type = "range",
|
|
tercio@0
|
51 name = "Bar Height",
|
|
tercio@0
|
52 desc = "Change the height of spot bars.",
|
|
tercio@0
|
53 min = 10,
|
|
tercio@0
|
54 max = 40,
|
|
tercio@0
|
55 step = 1,
|
|
tercio@0
|
56 get = function() return PVPScan.db.profile.SpotBarHeight end,
|
|
tercio@0
|
57 set = function (self, val) PVPScan.db.profile.SpotBarHeight = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
58 order = 1,
|
|
tercio@0
|
59 },
|
|
tercio@0
|
60 SpotBarWidth = {
|
|
tercio@0
|
61 type = "range",
|
|
tercio@0
|
62 name = "Bar Width",
|
|
tercio@0
|
63 desc = "Change the width of spot bars.",
|
|
tercio@0
|
64 min = 50,
|
|
tercio@0
|
65 max = 250,
|
|
tercio@0
|
66 step = 1,
|
|
tercio@0
|
67 get = function() return PVPScan.db.profile.SpotBarWidth end,
|
|
tercio@0
|
68 set = function (self, val) PVPScan.db.profile.SpotBarWidth = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
69 order = 2,
|
|
tercio@0
|
70 },
|
|
tercio@0
|
71 SpotBarAmount = {
|
|
tercio@0
|
72 type = "range",
|
|
tercio@0
|
73 name = "Bar Amount",
|
|
tercio@0
|
74 desc = "Change the amount of spot bars.",
|
|
tercio@0
|
75 min = 1,
|
|
tercio@0
|
76 max = 40,
|
|
tercio@0
|
77 step = 1,
|
|
tercio@0
|
78 get = function() return PVPScan.db.profile.SpotBarAmount end,
|
|
tercio@0
|
79 set = function (self, val) PVPScan.db.profile.SpotBarAmount = val; PVPScan:RefreshSpotBars() end,
|
|
tercio@0
|
80 order = 3,
|
|
tercio@0
|
81 },
|
|
tercio@2
|
82 SpotBarTexture = {
|
|
tercio@2
|
83 type = "select",
|
|
tercio@2
|
84 name = "Bar Texture",
|
|
tercio@2
|
85 desc = "Choose the texture used on target bars.",
|
|
tercio@2
|
86 values = function()
|
|
tercio@2
|
87 local TextureTable = {}
|
|
tercio@2
|
88 for name, _ in pairs (SharedMedia:HashTable ("statusbar")) do
|
|
tercio@2
|
89 TextureTable [name] = name
|
|
tercio@2
|
90 end
|
|
tercio@2
|
91 return TextureTable
|
|
tercio@2
|
92 end,
|
|
tercio@2
|
93 get = function() return PVPScan.db.profile.SpotBarTexture end,
|
|
tercio@2
|
94 set = function (self, file) PVPScan.db.profile.SpotBarTexture = file; PVPScan:RefreshSpotBars() end,
|
|
tercio@2
|
95 order = 4,
|
|
tercio@2
|
96 },
|
|
tercio@2
|
97 SpotBarTimeOut = {
|
|
tercio@2
|
98 type = "range",
|
|
tercio@2
|
99 name = "Time Out",
|
|
tercio@2
|
100 desc = "How many time wait until the bar auto hide.",
|
|
tercio@2
|
101 min = 5,
|
|
tercio@2
|
102 max = 120,
|
|
tercio@2
|
103 step = 5,
|
|
tercio@2
|
104 get = function() return PVPScan.db.profile.SpotBarTimeOut end,
|
|
tercio@2
|
105 set = function (self, val) PVPScan.db.profile.SpotBarTimeOut = val; end,
|
|
tercio@2
|
106 order = 9,
|
|
tercio@2
|
107 },
|
|
tercio@0
|
108 Locked = {
|
|
tercio@0
|
109 type = "toggle",
|
|
tercio@1
|
110 name = "Lock Scan Frame",
|
|
tercio@0
|
111 desc = "Lock or unlock the SpotBars Frame.",
|
|
tercio@2
|
112 order = 5,
|
|
tercio@0
|
113 get = function() return PVPScan.db.profile.Locked end,
|
|
tercio@1
|
114 set = function (self, val) PVPScan.db.profile.Locked = not PVPScan.db.profile.Locked; PVPScan:LockScanFrame (PVPScan.db.profile.Locked) end,
|
|
tercio@0
|
115 },
|
|
tercio@0
|
116 SoundPlay = {
|
|
tercio@0
|
117 type = "toggle",
|
|
tercio@0
|
118 name = "Play Sound",
|
|
tercio@0
|
119 desc = "Play a sound when a enemy is found.",
|
|
tercio@2
|
120 order = 7,
|
|
tercio@0
|
121 get = function() return PVPScan.db.profile.SoundPlay end,
|
|
tercio@0
|
122 set = function (self, val) PVPScan.db.profile.SoundPlay = not PVPScan.db.profile.SoundPlay end,
|
|
tercio@0
|
123 },
|
|
tercio@0
|
124 SoundFile = {
|
|
tercio@0
|
125 type = "select",
|
|
tercio@0
|
126 name = "Sound File",
|
|
tercio@0
|
127 desc = "Choose the sound to play when a enemy is found.",
|
|
tercio@0
|
128 values = function()
|
|
tercio@0
|
129 local SoundTable = {}
|
|
tercio@0
|
130 for name, _ in pairs (SharedMedia:HashTable ("sound")) do
|
|
tercio@0
|
131 SoundTable [name] = name
|
|
tercio@0
|
132 end
|
|
tercio@0
|
133 return SoundTable
|
|
tercio@0
|
134 end,
|
|
tercio@0
|
135 get = function() return PVPScan.db.profile.SoundFile end,
|
|
tercio@0
|
136 set = function (self, file) PVPScan.db.profile.SoundFile = file end,
|
|
tercio@2
|
137 order = 8,
|
|
tercio@0
|
138 },
|
|
tercio@0
|
139 Minimap = {
|
|
tercio@0
|
140 type = "toggle",
|
|
tercio@0
|
141 name = "Hide Minimap Icon",
|
|
tercio@0
|
142 desc = "Show or hide the minimap icon.",
|
|
tercio@2
|
143 order = 6,
|
|
tercio@0
|
144 get = function() return PVPScan.db.profile.Minimap.hide end,
|
|
tercio@0
|
145 set = function (self, val)
|
|
tercio@0
|
146 PVPScan.db.profile.Minimap.hide = not PVPScan.db.profile.Minimap.hide
|
|
tercio@0
|
147 LDBIcon:Refresh ("PVPScan", PVPScan.db.profile.Minimap)
|
|
tercio@0
|
148 if (PVPScan.db.profile.Minimap.hide) then
|
|
tercio@0
|
149 LDBIcon:Hide ("PVPScan")
|
|
tercio@0
|
150 else
|
|
tercio@0
|
151 LDBIcon:Show ("PVPScan")
|
|
tercio@0
|
152 end
|
|
tercio@0
|
153 end,
|
|
tercio@0
|
154 },
|
|
tercio@0
|
155 },
|
|
tercio@0
|
156 }
|
|
tercio@0
|
157
|
|
tercio@0
|
158 function PVPScan:OnInitialize()
|
|
tercio@0
|
159
|
|
tercio@0
|
160 --declarar primeiro o db usando a global que é declarada no toc.
|
|
tercio@0
|
161 self.db = LibStub ("AceDB-3.0"):New ("PVPScanDB", default_db, true)
|
|
tercio@0
|
162
|
|
tercio@0
|
163 --declara agora as opções da tab raiz
|
|
tercio@0
|
164 LibStub("AceConfig-3.0"):RegisterOptionsTable ("PVPScan", OptionsTable)
|
|
tercio@0
|
165 PVPScan.OptionsFrame1 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("PVPScan", "PVPScan")
|
|
tercio@0
|
166 --sub tab
|
|
tercio@0
|
167 LibStub ("AceConfig-3.0"):RegisterOptionsTable ("PVPScan-Profiles", LibStub ("AceDBOptions-3.0"):GetOptionsTable (self.db))
|
|
tercio@0
|
168 PVPScan.OptionsFrame2 = LibStub ("AceConfigDialog-3.0"):AddToBlizOptions ("PVPScan-Profiles", "Profiles", "PVPScan")
|
|
tercio@0
|
169
|
|
tercio@0
|
170 if LDB then
|
|
tercio@0
|
171 local databroker = LDB:NewDataObject ("PVPScan", {
|
|
tercio@0
|
172 type = "launcher",
|
|
tercio@0
|
173 icon = [[Interface\PvPRankBadges\PvPRank15]],
|
|
tercio@0
|
174 --HotCornerIgnore = true,
|
|
tercio@0
|
175 OnClick = function (self, button)
|
|
tercio@0
|
176 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
177 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
178 end
|
|
tercio@0
|
179 })
|
|
tercio@0
|
180
|
|
tercio@0
|
181 if (databroker and not LDBIcon:IsRegistered ("PVPScan")) then
|
|
tercio@0
|
182 LDBIcon:Register ("PVPScan", databroker, PVPScan.db.profile.Minimap)
|
|
tercio@0
|
183 end
|
|
tercio@0
|
184 end
|
|
tercio@0
|
185
|
|
tercio@0
|
186 PVPScan:RefreshSpotBars()
|
|
tercio@1
|
187 PVPScan:LockScanFrame (PVPScan.db.profile.Locked)
|
|
tercio@2
|
188
|
|
tercio@2
|
189 PVPScan.EventFrame:SetScript ("OnEvent", PVPScan.OnParserEvent)
|
|
tercio@0
|
190 end
|
|
tercio@0
|
191
|
|
tercio@0
|
192 PVPScan:RegisterChatCommand ("pvpscan", function()
|
|
tercio@0
|
193 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
194 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
195 end)
|
|
tercio@0
|
196
|
|
tercio@1
|
197
|
|
tercio@0
|
198 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
199 --> general
|
|
tercio@0
|
200
|
|
tercio@1
|
201 function PVPScan:ChangeZones()
|
|
tercio@1
|
202
|
|
tercio@1
|
203 local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()
|
|
tercio@1
|
204 local pvpType, isFFA, faction = GetZonePVPInfo()
|
|
tercio@1
|
205
|
|
tercio@1
|
206 PVPScan.IsInBattleground = false
|
|
tercio@1
|
207 PVPScan.IsInCity = false
|
|
tercio@1
|
208 PVPScan.IsInArena = false
|
|
tercio@1
|
209 PVPScan.IsInOutDoors = false
|
|
tercio@1
|
210 PVPScan.ScanEnabled = false
|
|
tercio@1
|
211
|
|
tercio@1
|
212 if (pvpType == "contested" and (not type or type == "none")) then
|
|
tercio@1
|
213 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
214 PVPScan.ScanEnabled = true
|
|
tercio@1
|
215
|
|
tercio@1
|
216 elseif (type == "pvp") then
|
|
tercio@1
|
217 PVPScan.IsInBattleground = true
|
|
tercio@1
|
218
|
|
tercio@1
|
219 elseif (type == "arena") then
|
|
tercio@1
|
220 PVPScan.IsInArena = true
|
|
tercio@1
|
221
|
|
tercio@1
|
222 elseif (type and (type == "scenario" or type == "party" or type == "raid" or pvpType == "friendly" or pvpType == "sanctuary")) then
|
|
tercio@1
|
223 PVPScan.ScanEnabled = false
|
|
tercio@1
|
224
|
|
tercio@1
|
225 else
|
|
tercio@1
|
226 PVPScan.IsInOutDoors = true
|
|
tercio@1
|
227 PVPScan.ScanEnabled = true
|
|
tercio@1
|
228 end
|
|
tercio@1
|
229
|
|
tercio@1
|
230 if (PVPScan.ScanEnabled) then
|
|
tercio@1
|
231 PVPScan:EnableScan()
|
|
tercio@1
|
232 else
|
|
tercio@1
|
233 PVPScan:DisableScan()
|
|
tercio@1
|
234 end
|
|
tercio@1
|
235
|
|
tercio@1
|
236 end
|
|
tercio@1
|
237
|
|
tercio@1
|
238 PVPScan:RegisterEvent ("ZONE_CHANGED_NEW_AREA", "ChangeZones")
|
|
tercio@1
|
239 PVPScan:RegisterEvent ("PLAYER_ENTERING_WORLD", "ChangeZones")
|
|
tercio@1
|
240
|
|
tercio@1
|
241 function PVPScan:EnableScan()
|
|
tercio@1
|
242 PVPScan.EventFrame:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@1
|
243 PVPScan:RefreshSpotBars()
|
|
tercio@2
|
244 PVPScan.NextBarCheckForHide = GetTime() + PVPScan.db.profile.SpotBarTimeOut
|
|
tercio@2
|
245 PVPScan.BarChecker = PVPScan:ScheduleRepeatingTimer ("CheckBarTimeOut", 5)
|
|
tercio@1
|
246 end
|
|
tercio@1
|
247
|
|
tercio@1
|
248 function PVPScan:DisableScan()
|
|
tercio@1
|
249 PVPScan.EventFrame:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@1
|
250 PVPScan:RefreshSpotBars()
|
|
tercio@2
|
251 if (PVPScan.BarChecker) then
|
|
tercio@2
|
252 PVPScan:CancelTimer (PVPScan.BarChecker, true)
|
|
tercio@2
|
253 PVPScan.BarChecker = nil
|
|
tercio@2
|
254 end
|
|
tercio@1
|
255 end
|
|
tercio@1
|
256
|
|
tercio@1
|
257 function PVPScan:LockScanFrame (IsLocked)
|
|
tercio@1
|
258 if (IsLocked) then
|
|
tercio@1
|
259 PVPScanFrame.text:SetText ("")
|
|
tercio@1
|
260 PVPScanFrame:SetBackdrop (nil)
|
|
tercio@1
|
261 PVPScanFrame:EnableMouse (false)
|
|
tercio@1
|
262 else
|
|
tercio@1
|
263 PVPScanFrame.text:SetText ("PVPScan Anchor")
|
|
tercio@1
|
264 PVPScanFrame:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, TileSize = 64})
|
|
tercio@1
|
265 PVPScanFrame:SetBackdropColor (0, 0, 0, 1)
|
|
tercio@1
|
266 PVPScanFrame:EnableMouse (true)
|
|
tercio@1
|
267 end
|
|
tercio@1
|
268 end
|
|
tercio@1
|
269 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
270 --> outside world scan
|
|
tercio@1
|
271
|
|
tercio@1
|
272 --> parser
|
|
tercio@1
|
273
|
|
tercio@2
|
274 PVPScan.SpotBars = {} -- container para os objetos das barras
|
|
tercio@2
|
275
|
|
tercio@2
|
276 PVPScan.NeedClass = {} -- container para os jogadores que precisam saber a classe
|
|
tercio@2
|
277 PVPScan.CurrentShownPlayers = {} -- nomes dos jogadores que estão sendo mostrados com o index da barra no valos
|
|
tercio@2
|
278 PVPScan.CooldownShownPlayers = {} -- nomes dos jogadores com o tempo de quando eles podem ser mostrados novamente nas barras
|
|
tercio@1
|
279
|
|
tercio@1
|
280 PVPScan.EventFrame = CreateFrame ("frame", "PVPScanCombatLobReader", UIParent)
|
|
tercio@1
|
281 PVPScan.EventFrame:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
|
|
tercio@0
|
282
|
|
tercio@0
|
283 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
|
284
|
|
tercio@0
|
285 if (PVPScan.NeedClass [who_name]) then
|
|
tercio@0
|
286 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
287 if (class) then
|
|
tercio@2
|
288 PVPScan:UpdateBar (PVPScan.SpotBars [PVPScan.CurrentShownPlayers [who_name]], who_name, class, true)
|
|
tercio@0
|
289 PVPScan.NeedClass [who_name] = nil
|
|
tercio@0
|
290 end
|
|
tercio@0
|
291 return
|
|
tercio@0
|
292 end
|
|
tercio@0
|
293
|
|
tercio@2
|
294 if (not PVPScan.CurrentShownPlayers [target_name] and _bit_band (target_flags, OBJECT_TYPE_PLAYER) ~= 0) then --> is player
|
|
tercio@1
|
295 if (_bit_band (target_flags, REACTION_HOSTILE) ~= 0) then --> is hostile
|
|
tercio@0
|
296 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
297 PVPScan:EnemySpoted (target_name, target_serial, target_flags, class)
|
|
tercio@0
|
298 end
|
|
tercio@0
|
299 end
|
|
tercio@0
|
300
|
|
tercio@2
|
301 if (not PVPScan.CurrentShownPlayers [who_name] and _bit_band (who_flags, OBJECT_TYPE_PLAYER) ~= 0) then --> is player
|
|
tercio@1
|
302 if (_bit_band (who_flags, REACTION_HOSTILE) ~= 0) then --> is hostile
|
|
tercio@0
|
303 local class = PVPScan:GuessClass (...)
|
|
tercio@0
|
304 PVPScan:EnemySpoted (who_name, who_serial, who_flags, class)
|
|
tercio@0
|
305 end
|
|
tercio@0
|
306 end
|
|
tercio@0
|
307 end
|
|
tercio@0
|
308
|
|
tercio@0
|
309 function PVPScan:LeftCombatLockdown()
|
|
tercio@0
|
310 if (PVPScan.schedule_frame_update) then
|
|
tercio@0
|
311 PVPScan.schedule_frame_update = false
|
|
tercio@0
|
312 PVPScan:RefreshSpotBars()
|
|
tercio@0
|
313 end
|
|
tercio@2
|
314 PVPScan:CheckNonCombatSpotBars()
|
|
tercio@0
|
315 end
|
|
tercio@0
|
316 function PVPScan:GotCombatLockdown()
|
|
tercio@0
|
317 end
|
|
tercio@0
|
318
|
|
tercio@2
|
319 function PVPScan:GetNextSpotBar()
|
|
tercio@2
|
320 for i = 1, PVPScan.db.profile.SpotBarAmount do
|
|
tercio@2
|
321 local bar = PVPScan.SpotBars [i]
|
|
tercio@2
|
322 if (not bar) then
|
|
tercio@2
|
323 print (i, #PVPScan.SpotBars)
|
|
tercio@2
|
324 end
|
|
tercio@2
|
325 if (not bar.InUse and bar.Cooldown < GetTime()) then
|
|
tercio@2
|
326 return bar
|
|
tercio@2
|
327 end
|
|
tercio@2
|
328 end
|
|
tercio@2
|
329 return nil
|
|
tercio@2
|
330 end
|
|
tercio@2
|
331
|
|
tercio@0
|
332 PVPScan:RegisterEvent ("PLAYER_REGEN_DISABLED", "GotCombatLockdown")
|
|
tercio@0
|
333 PVPScan:RegisterEvent ("PLAYER_REGEN_ENABLED", "LeftCombatLockdown")
|
|
tercio@0
|
334
|
|
tercio@1
|
335 -- found a enemy on the scan
|
|
tercio@2
|
336 function PVPScan:EnemySpoted (name, serial, flags, class)
|
|
tercio@1
|
337
|
|
tercio@2
|
338 --se nao tiver nome, nao interessa
|
|
tercio@1
|
339 if (not name) then
|
|
tercio@1
|
340 return
|
|
tercio@1
|
341 end
|
|
tercio@2
|
342
|
|
tercio@2
|
343 --se o player tiver no cooldown para mostrar, ignora-lo
|
|
tercio@2
|
344 if (PVPScan.CooldownShownPlayers [name] and PVPScan.CooldownShownPlayers [name] > GetTime()) then
|
|
tercio@2
|
345 return
|
|
tercio@2
|
346 end
|
|
tercio@1
|
347
|
|
tercio@2
|
348 local SpotBar = PVPScan:GetNextSpotBar()
|
|
tercio@2
|
349
|
|
tercio@2
|
350 if (not SpotBar) then
|
|
tercio@2
|
351 return
|
|
tercio@0
|
352 end
|
|
tercio@0
|
353
|
|
tercio@2
|
354 --seta o cooldown deste jogador
|
|
tercio@2
|
355 PVPScan.CooldownShownPlayers [name] = GetTime() + PVPScan.db.profile.SpotBarPlayerCooldown
|
|
tercio@2
|
356 --seta em qual barra o jogador esta sendo mostrado
|
|
tercio@2
|
357 PVPScan.CurrentShownPlayers [name] = SpotBar.Index
|
|
tercio@2
|
358
|
|
tercio@2
|
359 --se nao tiver uma classe, agendar uma pesquisa
|
|
tercio@2
|
360 if (not class) then
|
|
tercio@2
|
361 PVPScan.NeedClass [name] = true
|
|
tercio@0
|
362 end
|
|
tercio@0
|
363
|
|
tercio@2
|
364 --atualiza a barra
|
|
tercio@2
|
365 PVPScan:UpdateBar (SpotBar, name, class)
|
|
tercio@0
|
366
|
|
tercio@2
|
367 --toca o som se a configuracao permitir
|
|
tercio@2
|
368 if (PVPScan.db.profile.SoundPlay) then
|
|
tercio@2
|
369 local sound = PVPScan.db.profile.SoundFile
|
|
tercio@2
|
370 sound = SharedMedia:Fetch ("sound", sound)
|
|
tercio@2
|
371 if (sound) then
|
|
tercio@2
|
372 PlaySoundFile (sound, "Master")
|
|
tercio@2
|
373 end
|
|
tercio@0
|
374 end
|
|
tercio@0
|
375 end
|
|
tercio@0
|
376
|
|
tercio@1
|
377 -- frames
|
|
tercio@2
|
378
|
|
tercio@2
|
379 function PVPScanOnFrameEnter (self)
|
|
tercio@2
|
380 GameTooltip:SetOwner (self, "ANCHOR_TOPLEFT")
|
|
tercio@2
|
381 GameTooltip:ClearLines()
|
|
tercio@2
|
382 GameTooltip:AddLine ("Right Click To Open Options Panel")
|
|
tercio@2
|
383 GameTooltip:Show()
|
|
tercio@2
|
384 end
|
|
tercio@2
|
385
|
|
tercio@2
|
386 function PVPScanOnFrameLeave (self)
|
|
tercio@2
|
387 GameTooltip:Hide()
|
|
tercio@2
|
388 end
|
|
tercio@0
|
389
|
|
tercio@1
|
390 function PVPScanOnFrameMouseDown (self, button)
|
|
tercio@1
|
391 if (button == "LeftButton") then
|
|
tercio@1
|
392 if (not self.IsMoving) then
|
|
tercio@1
|
393 self:StartMoving()
|
|
tercio@1
|
394 self.IsMoving = true
|
|
tercio@1
|
395 end
|
|
tercio@0
|
396 end
|
|
tercio@0
|
397 end
|
|
tercio@0
|
398
|
|
tercio@1
|
399 function PVPScanOnFrameMouseUp (self, button)
|
|
tercio@1
|
400 if (button == "LeftButton") then
|
|
tercio@1
|
401 if (self.IsMoving) then
|
|
tercio@1
|
402 self:StopMovingOrSizing()
|
|
tercio@1
|
403 self.IsMoving = false
|
|
tercio@1
|
404 end
|
|
tercio@1
|
405
|
|
tercio@1
|
406 elseif (button == "RightButton") then
|
|
tercio@1
|
407 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@1
|
408 InterfaceOptionsFrame_OpenToCategory ("PVPScan")
|
|
tercio@0
|
409 end
|
|
tercio@0
|
410 end
|
|
tercio@0
|
411
|
|
tercio@2
|
412 function PVPScan:CheckNonCombatSpotBars()
|
|
tercio@2
|
413 for i = 1, PVPScan.db.profile.SpotBarAmount do
|
|
tercio@2
|
414 local SpotObject = PVPScan.SpotBars [i]
|
|
tercio@2
|
415 if (SpotObject.InUse and (SpotObject.NonTargetFrame:IsShown() or SpotObject.NeedUpdate)) then
|
|
tercio@2
|
416 PVPScan:UpdateBar (SpotObject, SpotObject.PlayerName, SpotObject.PlayerClass)
|
|
tercio@2
|
417 end
|
|
tercio@2
|
418 end
|
|
tercio@2
|
419 end
|
|
tercio@0
|
420
|
|
tercio@2
|
421 function PVPScan:UpdateBar (SpotObject, Name, Class, ClassUpdate)
|
|
tercio@2
|
422
|
|
tercio@2
|
423 SpotObject.IsShown = true
|
|
tercio@2
|
424 SpotObject.InUse = true
|
|
tercio@2
|
425 SpotObject.PlayerName = Name
|
|
tercio@2
|
426 SpotObject.PlayerClass = Class
|
|
tercio@2
|
427 SpotObject.Cooldown = GetTime() + PVPScan.db.profile.SpotBarCooldown
|
|
tercio@2
|
428 SpotObject.ExpireAt = GetTime() + PVPScan.db.profile.SpotBarTimeOut
|
|
tercio@2
|
429 SpotObject.NeedUpdate = false
|
|
tercio@2
|
430
|
|
tercio@2
|
431 if (ClassUpdate) then
|
|
tercio@2
|
432 if (SpotObject.TargetFrame:IsShown()) then
|
|
tercio@2
|
433 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
|
|
tercio@2
|
434 local color = RAID_CLASS_COLORS [Class]
|
|
tercio@2
|
435 local texcoord = CLASS_ICON_TCOORDS [Class]
|
|
tercio@2
|
436 SpotObject.TargetFrame.classtexture:SetVertexColor (color.r, color.g, color.b)
|
|
tercio@2
|
437 SpotObject.TargetFrame.classicon:SetTexture ([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
|
|
tercio@2
|
438 SpotObject.TargetFrame.classicon:SetTexCoord (unpack (texcoord))
|
|
tercio@2
|
439 else
|
|
tercio@2
|
440 SpotObject.NeedUpdate = true
|
|
tercio@2
|
441 end
|
|
tercio@2
|
442 else
|
|
tercio@2
|
443 local color = RAID_CLASS_COLORS [Class]
|
|
tercio@2
|
444 local texcoord = CLASS_ICON_TCOORDS [Class]
|
|
tercio@2
|
445 SpotObject.NonTargetFrame.classtexture:SetVertexColor (color.r, color.g, color.b)
|
|
tercio@2
|
446 SpotObject.NonTargetFrame.classicon:SetTexture ([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
|
|
tercio@2
|
447 SpotObject.NonTargetFrame.classicon:SetTexCoord (unpack (texcoord))
|
|
tercio@2
|
448 end
|
|
tercio@2
|
449 end
|
|
tercio@2
|
450
|
|
tercio@1
|
451 if (UnitAffectingCombat ("player") or InCombatLockdown()) then
|
|
tercio@2
|
452 --> enable in combat bat
|
|
tercio@2
|
453 if (Class) then
|
|
tercio@2
|
454 local color = RAID_CLASS_COLORS [Class]
|
|
tercio@2
|
455 local texcoord = CLASS_ICON_TCOORDS [Class]
|
|
tercio@2
|
456 SpotObject.NonTargetFrame.classtexture:SetVertexColor (color.r, color.g, color.b)
|
|
tercio@2
|
457 SpotObject.NonTargetFrame.classicon:SetTexture ([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
|
|
tercio@2
|
458 SpotObject.NonTargetFrame.classicon:SetTexCoord (unpack (texcoord))
|
|
tercio@2
|
459 else
|
|
tercio@2
|
460 SpotObject.NonTargetFrame.classtexture:SetVertexColor (.7, .7, .7)
|
|
tercio@2
|
461 SpotObject.NonTargetFrame.classicon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]])
|
|
tercio@2
|
462 SpotObject.NonTargetFrame.classicon:SetTexCoord (0, 1, 0, 1)
|
|
tercio@2
|
463 end
|
|
tercio@2
|
464 SpotObject.NonTargetFrame.name:SetText (Name)
|
|
tercio@2
|
465 SpotObject.NonTargetFrame:Show()
|
|
tercio@2
|
466 SpotObject.NeedUpdate = true
|
|
tercio@2
|
467 else
|
|
tercio@2
|
468 --> enable spot bar
|
|
tercio@2
|
469 if (Class) then
|
|
tercio@2
|
470 local color = RAID_CLASS_COLORS [Class]
|
|
tercio@2
|
471 local texcoord = CLASS_ICON_TCOORDS [Class]
|
|
tercio@2
|
472 SpotObject.TargetFrame.classtexture:SetVertexColor (color.r, color.g, color.b)
|
|
tercio@2
|
473 SpotObject.TargetFrame.classicon:SetTexture ([[Interface\Glues\CHARACTERCREATE\UI-CHARACTERCREATE-CLASSES]])
|
|
tercio@2
|
474 SpotObject.TargetFrame.classicon:SetTexCoord (unpack (texcoord))
|
|
tercio@2
|
475 else
|
|
tercio@2
|
476 SpotObject.TargetFrame.classtexture:SetVertexColor (.7, .7, .7)
|
|
tercio@2
|
477 SpotObject.TargetFrame.classicon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]])
|
|
tercio@2
|
478 SpotObject.TargetFrame.classicon:SetTexCoord (0, 1, 0, 1)
|
|
tercio@2
|
479 end
|
|
tercio@2
|
480 SpotObject.TargetFrame:SetAttribute ("macrotext", "/cleartarget\n/targetexact " .. Name)
|
|
tercio@2
|
481 SpotObject.TargetFrame.name:SetText (Name)
|
|
tercio@2
|
482 SpotObject.TargetFrame.SpotObject = SpotObject
|
|
tercio@2
|
483 SpotObject.NonTargetFrame:Hide()
|
|
tercio@2
|
484 SpotObject.TargetFrame:Show()
|
|
tercio@1
|
485 end
|
|
tercio@2
|
486 end
|
|
tercio@1
|
487
|
|
tercio@2
|
488 function PVPScan:CheckBarTimeOut()
|
|
tercio@2
|
489 if (not UnitAffectingCombat ("player") and not InCombatLockdown()) then
|
|
tercio@0
|
490
|
|
tercio@2
|
491 local time = GetTime()
|
|
tercio@2
|
492
|
|
tercio@2
|
493 for repeat_twice = 1, 2 do
|
|
tercio@2
|
494 for i = 1, PVPScan.db.profile.SpotBarAmount do
|
|
tercio@2
|
495
|
|
tercio@2
|
496 local SpotObject = PVPScan.SpotBars [i]
|
|
tercio@2
|
497
|
|
tercio@2
|
498 if (SpotObject.InUse) then
|
|
tercio@2
|
499 --verifica se expirou
|
|
tercio@2
|
500 if (SpotObject.ExpireAt < time) then
|
|
tercio@2
|
501 PVPScan:DisableSpotBar (SpotObject)
|
|
tercio@2
|
502 end
|
|
tercio@2
|
503 else
|
|
tercio@2
|
504 for o = i+1, PVPScan.db.profile.SpotBarAmount do
|
|
tercio@2
|
505 local NextSpotObject = PVPScan.SpotBars [o]
|
|
tercio@2
|
506 if (NextSpotObject.InUse) then --> transferir pra cá
|
|
tercio@2
|
507 --seta a nova barra
|
|
tercio@2
|
508 local PlayerName = NextSpotObject.PlayerName
|
|
tercio@2
|
509 PVPScan:UpdateBar (SpotObject, PlayerName, NextSpotObject.PlayerClass)
|
|
tercio@2
|
510 --desliga a barra antiga
|
|
tercio@2
|
511 PVPScan:DisableSpotBar (NextSpotObject)
|
|
tercio@2
|
512 --seta em qual barra o jogador esta sendo mostrado
|
|
tercio@2
|
513 PVPScan.CurrentShownPlayers [PlayerName] = i
|
|
tercio@2
|
514 break
|
|
tercio@2
|
515 end
|
|
tercio@2
|
516 end
|
|
tercio@2
|
517 end
|
|
tercio@2
|
518 end
|
|
tercio@2
|
519 end
|
|
tercio@0
|
520 end
|
|
tercio@0
|
521
|
|
tercio@2
|
522 end
|
|
tercio@2
|
523
|
|
tercio@2
|
524 function PVPScanSpotBarClick (self)
|
|
tercio@2
|
525 if (self.SpotObject) then
|
|
tercio@2
|
526 self.SpotObject.Cooldown = GetTime() + PVPScan.db.profile.SpotBarCooldown
|
|
tercio@2
|
527 self.SpotObject.ExpireAt = GetTime() + PVPScan.db.profile.SpotBarTimeOut
|
|
tercio@2
|
528 end
|
|
tercio@2
|
529 end
|
|
tercio@2
|
530
|
|
tercio@2
|
531 function PVPScan:DisableSpotBar (SpotObject)
|
|
tercio@2
|
532 SpotObject.TargetFrame:Hide()
|
|
tercio@2
|
533 SpotObject.TargetFrame.SpotObject = nil
|
|
tercio@2
|
534 SpotObject.NonTargetFrame:Hide()
|
|
tercio@0
|
535
|
|
tercio@2
|
536 SpotObject.IsShown = false
|
|
tercio@2
|
537 SpotObject.NeedUpdate = false
|
|
tercio@2
|
538 SpotObject.InUse = false
|
|
tercio@2
|
539 SpotObject.Cooldown = 0
|
|
tercio@2
|
540 SpotObject.ExpireAt = 0
|
|
tercio@2
|
541
|
|
tercio@2
|
542 local name = SpotObject.PlayerName
|
|
tercio@2
|
543
|
|
tercio@2
|
544 if (name) then
|
|
tercio@2
|
545 PVPScan.NeedClass [name] = nil
|
|
tercio@2
|
546 PVPScan.CurrentShownPlayers [name] = nil
|
|
tercio@2
|
547 PVPScan.CooldownShownPlayers [name] = nil
|
|
tercio@2
|
548 end
|
|
tercio@2
|
549
|
|
tercio@2
|
550 SpotObject.PlayerName = nil
|
|
tercio@2
|
551 SpotObject.PlayerClass = nil
|
|
tercio@0
|
552 end
|
|
tercio@0
|
553
|
|
tercio@0
|
554 function PVPScan:RefreshSpotBars()
|
|
tercio@0
|
555
|
|
tercio@0
|
556 if (UnitAffectingCombat ("player") or InCombatLockdown()) then
|
|
tercio@0
|
557 PVPScan.schedule_frame_update = true
|
|
tercio@0
|
558 PVPScan:Print ("When the combat finishes, the frame will be updated.")
|
|
tercio@0
|
559 return
|
|
tercio@0
|
560 end
|
|
tercio@0
|
561
|
|
tercio@1
|
562 if (not PVPScan.ScanEnabled) then
|
|
tercio@1
|
563 PVPScanFrame:Hide()
|
|
tercio@1
|
564 else
|
|
tercio@1
|
565 PVPScanFrame:Show()
|
|
tercio@1
|
566 end
|
|
tercio@1
|
567
|
|
tercio@0
|
568 local amount_bars = PVPScan.db.profile.SpotBarAmount
|
|
tercio@1
|
569 PVPScanFrame:SetSize (PVPScan.db.profile.SpotBarWidth, 20)
|
|
tercio@0
|
570
|
|
tercio@0
|
571 --> we need extra bars?
|
|
tercio@0
|
572 if (amount_bars > #PVPScan.SpotBars) then
|
|
tercio@0
|
573 for i = #PVPScan.SpotBars+1, amount_bars do
|
|
tercio@0
|
574
|
|
tercio@2
|
575 local NewBarObject = {
|
|
tercio@2
|
576 Index = i,
|
|
tercio@2
|
577 TargetFrame = CreateFrame ("Button", "PVPScanSpotBar" .. i, PVPScanFrame, "PVPScanSpotBarTemplate"),
|
|
tercio@2
|
578 NonTargetFrame = CreateFrame ("Button", "PVPScanSpotBarInCombat" .. i, PVPScanFrame, "PVPScanSpotBarInCombatTemplate"),
|
|
tercio@2
|
579 IsShown = false, -- se a barra esta sendo mostrada
|
|
tercio@2
|
580 PlayerName = nil, -- nome do jogador que esta sendo mostrado
|
|
tercio@2
|
581 PlayerClass = nil,
|
|
tercio@2
|
582 NeedUpdate = false, -- se a barra precisa de um update após o termino do combate
|
|
tercio@2
|
583 InUse = false, -- se a barra esta em uso
|
|
tercio@2
|
584 ExpireAt = 0, -- quando a barra ira sumir automaticamente
|
|
tercio@2
|
585 Cooldown = 0, -- tempo para poder por outro jogador nesta barra
|
|
tercio@2
|
586 }
|
|
tercio@2
|
587
|
|
tercio@2
|
588 NewBarObject.NonTargetFrame:SetFrameLevel (NewBarObject.TargetFrame:GetFrameLevel()+1)
|
|
tercio@0
|
589
|
|
tercio@0
|
590 local y = (i-1) * PVPScan.db.profile.SpotBarHeight * -1
|
|
tercio@0
|
591
|
|
tercio@2
|
592 NewBarObject.TargetFrame:SetPoint ("topleft", PVPScanFrame, "topleft", 0, y)
|
|
tercio@2
|
593 NewBarObject.NonTargetFrame:SetPoint ("topleft", PVPScanFrame, "topleft", 0, y)
|
|
tercio@0
|
594
|
|
tercio@2
|
595 NewBarObject.TargetFrame:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
596 NewBarObject.NonTargetFrame:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
597
|
|
tercio@2
|
598 tinsert (PVPScan.SpotBars, NewBarObject)
|
|
tercio@0
|
599 end
|
|
tercio@0
|
600 end
|
|
tercio@0
|
601
|
|
tercio@0
|
602 if (#PVPScan.SpotBars > amount_bars) then
|
|
tercio@0
|
603 for i = #PVPScan.SpotBars, amount_bars+1, -1 do
|
|
tercio@2
|
604 PVPScan:DisableSpotBar (PVPScan.SpotBars [i])
|
|
tercio@0
|
605 end
|
|
tercio@0
|
606 end
|
|
tercio@0
|
607
|
|
tercio@0
|
608 --> refresh existing
|
|
tercio@2
|
609 for Index, BarObject in ipairs (PVPScan.SpotBars) do
|
|
tercio@2
|
610 local y = (Index-1) * PVPScan.db.profile.SpotBarHeight * -1
|
|
tercio@2
|
611 --point
|
|
tercio@2
|
612 BarObject.TargetFrame:SetPoint ("topleft", PVPScanFrame, "bottomleft", 0, y)
|
|
tercio@2
|
613 BarObject.NonTargetFrame:SetPoint ("topleft", PVPScanFrame, "bottomleft", 0, y)
|
|
tercio@2
|
614 --size
|
|
tercio@2
|
615 BarObject.TargetFrame:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
616 BarObject.NonTargetFrame:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
617 --texture size
|
|
tercio@2
|
618 BarObject.TargetFrame.classtexture:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
619 BarObject.NonTargetFrame.classtexture:SetSize (PVPScan.db.profile.SpotBarWidth, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
620 --bar texture
|
|
tercio@2
|
621 BarObject.TargetFrame.classtexture:SetTexture (SharedMedia:Fetch ("statusbar", PVPScan.db.profile.SpotBarTexture) or [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
|
|
tercio@2
|
622 BarObject.NonTargetFrame.classtexture:SetTexture (SharedMedia:Fetch ("statusbar", PVPScan.db.profile.SpotBarTexture) or [[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
|
|
tercio@2
|
623 --icon size
|
|
tercio@2
|
624 BarObject.TargetFrame.classicon:SetSize (PVPScan.db.profile.SpotBarHeight, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@2
|
625 BarObject.NonTargetFrame.classicon:SetSize (PVPScan.db.profile.SpotBarHeight, PVPScan.db.profile.SpotBarHeight)
|
|
tercio@0
|
626 end
|
|
tercio@0
|
627
|
|
tercio@0
|
628 end
|
|
tercio@0
|
629
|
|
tercio@1
|
630 --> misc
|
|
tercio@0
|
631
|
|
tercio@0
|
632 function PVPScan:GuessClass (...)
|
|
tercio@0
|
633 local arg1, arg2, arg3, arg4 = select (1, ...)
|
|
tercio@0
|
634
|
|
tercio@0
|
635 if (type (arg1) == "number") then
|
|
tercio@3
|
636 return PVPScan.ClassSpellList [arg1]
|
|
tercio@0
|
637 end
|
|
tercio@0
|
638
|
|
tercio@0
|
639 return nil
|
|
tercio@0
|
640 end
|
|
tercio@0
|
641
|
|
tercio@1
|
642
|
|
tercio@1
|
643 ------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
tercio@1
|
644 --> battlegrounds
|
|
tercio@1
|
645
|