vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | |||
3 | local parser = ParserLib:GetInstance("1.1") |
||
4 | local dewdrop = DewdropLib:GetInstance("1.0") |
||
5 | local version = "0.4.7" |
||
6 | |||
7 | |||
8 | |||
9 | SimpleCombatLog = {} |
||
10 | local self = SimpleCombatLog |
||
11 | |||
12 | |||
13 | -- Unnamed frame for events. |
||
14 | if not self.frame then |
||
15 | self.frame = CreateFrame("Frame"); |
||
16 | self.frame:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
17 | self.frame:SetScript("OnEvent", function() self:OnEvent() end ); |
||
18 | end |
||
19 | |||
20 | |||
21 | -- Event handler for ParserLib. |
||
22 | local function OnCombatEvent(event, info) |
||
23 | self:OnCombatEvent(event, info) |
||
24 | end |
||
25 | |||
26 | |||
27 | |||
28 | -- Search for the event in eventList. |
||
29 | local function SearchList(list, text) |
||
30 | for i in list do |
||
31 | for j in list[i] do |
||
32 | if list[i][j] == text then return true end |
||
33 | end |
||
34 | end |
||
35 | end |
||
36 | |||
37 | |||
38 | |||
39 | |||
40 | self.eventTypes = { |
||
41 | "selfhit", |
||
42 | "otherhit", |
||
43 | "selfspell", |
||
44 | "otherspell", |
||
45 | "selfdot", |
||
46 | "otherdot", |
||
47 | "death", |
||
48 | "aura", |
||
49 | "enchant", |
||
50 | "trade", |
||
51 | "experience", |
||
52 | "honor", |
||
53 | "reputation", |
||
54 | "fail", |
||
55 | } |
||
56 | |||
57 | |||
58 | |||
59 | self.eventList = { |
||
60 | |||
61 | otherhit = { |
||
62 | "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_HITS", |
||
63 | "CHAT_MSG_COMBAT_CREATURE_VS_CREATURE_MISSES", |
||
64 | "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_HITS", |
||
65 | "CHAT_MSG_COMBAT_CREATURE_VS_PARTY_MISSES", |
||
66 | "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS", |
||
67 | "CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES", |
||
68 | "CHAT_MSG_COMBAT_FRIENDLYPLAYER_HITS", |
||
69 | "CHAT_MSG_COMBAT_FRIENDLYPLAYER_MISSES", |
||
70 | "CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS", |
||
71 | "CHAT_MSG_COMBAT_HOSTILEPLAYER_MISSES", |
||
72 | "CHAT_MSG_COMBAT_PARTY_HITS", |
||
73 | "CHAT_MSG_COMBAT_PARTY_MISSES", |
||
74 | }, |
||
75 | |||
76 | reputation = { |
||
77 | "CHAT_MSG_COMBAT_FACTION_CHANGE", |
||
78 | }, |
||
79 | |||
80 | death = { |
||
81 | "CHAT_MSG_COMBAT_FRIENDLY_DEATH", |
||
82 | "CHAT_MSG_COMBAT_HOSTILE_DEATH", |
||
83 | }, |
||
84 | |||
85 | honor = { |
||
86 | "CHAT_MSG_COMBAT_HONOR_GAIN", |
||
87 | }, |
||
88 | |||
89 | selfhit = { |
||
90 | "CHAT_MSG_COMBAT_PET_HITS", |
||
91 | "CHAT_MSG_COMBAT_PET_MISSES", |
||
92 | "CHAT_MSG_COMBAT_SELF_HITS", |
||
93 | "CHAT_MSG_COMBAT_SELF_MISSES", |
||
94 | |||
95 | }, |
||
96 | |||
97 | experience = { |
||
98 | "CHAT_MSG_COMBAT_XP_GAIN", |
||
99 | }, |
||
100 | |||
101 | aura = { |
||
102 | "CHAT_MSG_SPELL_AURA_GONE_OTHER", |
||
103 | "CHAT_MSG_SPELL_AURA_GONE_SELF", |
||
104 | "CHAT_MSG_SPELL_AURA_GONE_PARTY", |
||
105 | "CHAT_MSG_SPELL_BREAK_AURA", |
||
106 | }, |
||
107 | |||
108 | otherspell = { |
||
109 | "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF", |
||
110 | "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE", |
||
111 | "CHAT_MSG_SPELL_CREATURE_VS_PARTY_BUFF", |
||
112 | "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", |
||
113 | "CHAT_MSG_SPELL_CREATURE_VS_SELF_BUFF", |
||
114 | "CHAT_MSG_SPELL_CREATURE_VS_SELF_DAMAGE", |
||
115 | "CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF", |
||
116 | "CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE", |
||
117 | "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF", |
||
118 | "CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE", |
||
119 | "CHAT_MSG_SPELL_PARTY_BUFF", |
||
120 | "CHAT_MSG_SPELL_PARTY_DAMAGE", |
||
121 | }, |
||
122 | |||
123 | |||
124 | fail = { |
||
125 | "CHAT_MSG_SPELL_FAILED_LOCALPLAYER", |
||
126 | }, |
||
127 | |||
128 | enchant = { |
||
129 | "CHAT_MSG_SPELL_ITEM_ENCHANTMENTS", |
||
130 | }, |
||
131 | |||
132 | otherdot = { |
||
133 | "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS", |
||
134 | "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE", |
||
135 | "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS", |
||
136 | "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE", |
||
137 | "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS", |
||
138 | "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE", |
||
139 | "CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS", |
||
140 | "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE", |
||
141 | "CHAT_MSG_SPELL_DAMAGESHIELDS_ON_OTHERS", |
||
142 | }, |
||
143 | |||
144 | |||
145 | selfdot = { |
||
146 | "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS", |
||
147 | "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE", |
||
148 | "CHAT_MSG_SPELL_DAMAGESHIELDS_ON_SELF", |
||
149 | }, |
||
150 | |||
151 | selfspell = { |
||
152 | "CHAT_MSG_SPELL_PET_BUFF", |
||
153 | "CHAT_MSG_SPELL_PET_DAMAGE", |
||
154 | "CHAT_MSG_SPELL_SELF_BUFF", |
||
155 | "CHAT_MSG_SPELL_SELF_DAMAGE", |
||
156 | }, |
||
157 | |||
158 | trade = { |
||
159 | "CHAT_MSG_SPELL_TRADESKILLS", |
||
160 | } |
||
161 | } |
||
162 | |||
163 | |||
164 | |||
165 | |||
166 | function SimpleCombatLog:Colorize(value, valueType) |
||
167 | local c = self:GetColor(valueType) |
||
168 | |||
169 | if not c then return value end |
||
170 | |||
171 | if not c.b or not c.g or not c.r then |
||
172 | self:Print("Invalid color field for value " .. valueType, 1, true, 1, 0, 0) |
||
173 | end |
||
174 | |||
175 | return string.format("|cff%02x%02x%02x%s|r", (c.r*255), (c.g*255), (c.b*255), value) |
||
176 | |||
177 | end |
||
178 | |||
179 | function SimpleCombatLog:GetColor(valueType) |
||
180 | if not self.savedVars.colors or not self.savedVars.colors[valueType] then |
||
181 | return self.defaultColors[valueType] |
||
182 | else |
||
183 | return self.savedVars.colors[valueType] |
||
184 | end |
||
185 | end |
||
186 | |||
187 | |||
188 | |||
189 | |||
190 | |||
191 | function SimpleCombatLog:OnEvent() |
||
192 | if event == "PLAYER_ENTERING_WORLD" then |
||
193 | self:Initialize() |
||
194 | end |
||
195 | end |
||
196 | |||
197 | function SimpleCombatLog:Initialize() |
||
198 | |||
199 | if self.initialized then return end |
||
200 | |||
201 | |||
202 | -- Checking saved variables. |
||
203 | if not SCL_Config then self:LoadDefaultSettings() else self.savedVars = SCL_Config end |
||
204 | |||
205 | -- Check for old version saved variables. |
||
206 | if self.savedVars and not self.savedVars.events then self:LoadDefaultSettings() end |
||
207 | |||
208 | if not self.savedVars.minimapButton then self.savedVars.minimapButton = {} end |
||
209 | |||
210 | |||
211 | -- Slash commands. |
||
212 | SLASH_SCL1 = "/scl"; |
||
213 | SlashCmdList["SCL"] = function (msg) self:SlashCommand(msg) end |
||
214 | |||
215 | MyMinimapButton:Create("SimpleCombatLog", self.savedVars.minimapButton) |
||
216 | MyMinimapButton:SetIcon("SimpleCombatLog","Interface\\Icons\\INV_Misc_Food_66") |
||
217 | MyMinimapButton:SetTooltip("SimpleCombatLog", self.loc.buttonTooltip) |
||
218 | |||
219 | dewdrop:Register(SimpleCombatLogMinimapButton, 'children', function(level, value) self:OptionOpen(level, value) end ) |
||
220 | |||
221 | self.needRefreshChatEvent = true |
||
222 | |||
223 | self:RefreshSettings() |
||
224 | |||
225 | self.frame:UnregisterEvent("PLAYER_ENTERING_WORLD") |
||
226 | |||
227 | |||
228 | self.initialized = true |
||
229 | |||
230 | |||
231 | end |
||
232 | |||
233 | |||
234 | |||
235 | function SimpleCombatLog:SlashCommand(msg) |
||
236 | |||
237 | if msg == "suppress" then |
||
238 | self.savedVars.nosuppress = not self.savedVars.nosuppress |
||
239 | self.needRefreshChatEvent = true |
||
240 | self:RefreshSettings() |
||
241 | self:PrintHelp() |
||
242 | elseif msg == "optionbutton" then |
||
243 | self.savedVars.nooptionbutton = not self.savedVars.nooptionbutton |
||
244 | self:RefreshSettings() |
||
245 | elseif msg == "defaults" then |
||
246 | self:Print(self.loc.loaddefault, 1, true) |
||
247 | self:LoadDefaultSettings() |
||
248 | elseif msg == "option" then |
||
249 | dewdrop:Open(SimpleCombatLogMinimapButton) |
||
250 | self:PrintHelp() |
||
251 | else |
||
252 | self:PrintHelp() |
||
253 | end |
||
254 | |||
255 | |||
256 | |||
257 | end |
||
258 | |||
259 | function SimpleCombatLog:PrintHelp() |
||
260 | |||
261 | local on |
||
262 | |||
263 | if self.savedVars.nooptionbutton then on = "Off" else on = "On" end |
||
264 | |||
265 | self:Print(string.format( "optionbutton (|cff3333ff%s|r) : %s", on, self.loc.help.optionbutton), 1) |
||
266 | |||
267 | if self.savedVars.nosuppress then on = "Off" else on = "On" end |
||
268 | |||
269 | self:Print(string.format( "suppress (|cff3333ff%s|r) : %s", on, self.loc.help.suppress), 1 ) |
||
270 | self:Print(string.format( "defaults : %s", self.loc.help.defaults), 1) |
||
271 | self:Print(string.format( "option : %s", self.loc.help.option), 1) |
||
272 | |||
273 | end |
||
274 | |||
275 | |||
276 | function SimpleCombatLog:RefreshSettings() |
||
277 | |||
278 | |||
279 | if self.savedVars.nooptionbutton then |
||
280 | -- MyMinimapButton:Disable("SimpleCombatLog") |
||
281 | else |
||
282 | -- MyMinimapButton:Enable("SimpleCombatLog") |
||
283 | end |
||
284 | |||
285 | if self.needRefreshChatEvent then |
||
286 | if self.savedVars.nosuppress then |
||
287 | self:RefreshChatFrameEvents(true) |
||
288 | else |
||
289 | self:RefreshChatFrameEvents(false) |
||
290 | end |
||
291 | self.needRefreshChatEvent = nil |
||
292 | end |
||
293 | |||
294 | for i, v in self.eventTypes do |
||
295 | if self.savedVars.events[v] and not parser:IsEventRegistered("SimpleCombatLog", self.eventList[v][1]) then |
||
296 | for j in self.eventList[v] do |
||
297 | parser:RegisterEvent("SimpleCombatLog", self.eventList[v][j], OnCombatEvent) |
||
298 | end |
||
299 | elseif not self.savedVars.events[v] and parser:IsEventRegistered("SimpleCombatLog", self.eventList[v][1]) then |
||
300 | for j in self.eventList[v] do |
||
301 | parser:UnregisterEvent("SimpleCombatLog", self.eventList[v][j], OnCombatEvent) |
||
302 | end |
||
303 | end |
||
304 | end |
||
305 | |||
306 | |||
307 | |||
308 | end |
||
309 | |||
310 | |||
311 | |||
312 | function SimpleCombatLog:OnCombatEvent(event, info) |
||
313 | |||
314 | |||
315 | |||
316 | |||
317 | if not self:FilterCheck(info) then return end |
||
318 | |||
319 | if info.source == ParserLib_SELF then info.source = self.loc.you end |
||
320 | if info.victim == ParserLib_SELF then info.victim = self.loc.you end |
||
321 | if info.sourceGained == ParserLib_SELF then info.sourceGained = self.loc.you end |
||
322 | |||
323 | info.source = self:ColorizeName(info.source) |
||
324 | info.victim = self:ColorizeName(info.victim) |
||
325 | info.sourceGained = self:ColorizeName(info.sourceGained) |
||
326 | |||
327 | local extra, trailer |
||
328 | |||
329 | if info.skill == ParserLib_MELEE then info.skill = "melee" end |
||
330 | if info.skill == ParserLib_DAMAGESHIELD then info.skill = "damage shield" end |
||
331 | |||
332 | if info.isCrit then info.amount = string.format("*%s*", info.amount) end |
||
333 | if info.isDOT then info.amount = string.format("~%s~", info.amount) end |
||
334 | |||
335 | if info.skill then |
||
336 | info.skill = self:Colorize(info.skill, "skill") |
||
337 | end |
||
338 | |||
339 | |||
340 | if info.type == "hit" then |
||
341 | |||
342 | |||
343 | if info.element then |
||
344 | info.amount = self:Colorize(info.amount, self:GetElementType(info.element)) |
||
345 | else |
||
346 | info.amount = self:Colorize(info.amount, "physical") |
||
347 | end |
||
348 | |||
349 | |||
350 | if info.isCrit then |
||
351 | extra = "crit" |
||
352 | elseif info.isDOT then |
||
353 | extra = "dot" |
||
354 | else |
||
355 | extra = "hit" |
||
356 | end |
||
357 | |||
358 | trailer = self:GetTrailerString(info) |
||
359 | self:Print(string.format(self.patterns.hit, info.source, info.skill, extra, info.victim, info.amount) .. trailer) |
||
360 | |||
361 | elseif info.type == "heal" then |
||
362 | |||
363 | info.amount = self:Colorize(info.amount, "heal") |
||
364 | self:Print(string.format(self.patterns.heal, info.source, info.skill, info.victim, info.amount)) |
||
365 | |||
366 | elseif info.type == "debuff" then |
||
367 | |||
368 | extra = self:Colorize("++", "debuff") |
||
369 | if info.amountRank then |
||
370 | info.skill = string.format("%s(%s)", info.skill, info.amountRank) |
||
371 | end |
||
372 | |||
373 | self:Print(string.format(self.patterns.debuff, info.victim, extra, info.skill)) |
||
374 | |||
375 | elseif info.type == "buff" then |
||
376 | |||
377 | extra = self:Colorize("++", "buff") |
||
378 | if info.amountRank then |
||
379 | info.skill = string.format("%s(%s)", info.skill, info.amountRank) |
||
380 | end |
||
381 | self:Print(string.format(self.patterns.buff, info.victim, extra, info.skill)) |
||
382 | |||
383 | |||
384 | elseif info.type == "fade" then |
||
385 | |||
386 | self:Print(string.format(self.patterns.fade, info.victim, info.skill)) |
||
387 | |||
388 | elseif info.type == "dispel" then |
||
389 | |||
390 | if not info.isFailed then |
||
391 | self:Print(string.format(self.patterns.fade, info.victim, info.skill)) -- Use the same pattern |
||
392 | else |
||
393 | self:Print(string.format(self.patterns.failDispel, info.source, info.victim, info.skill)) |
||
394 | end |
||
395 | |||
396 | elseif info.type == "gain" then |
||
397 | self:Print(string.format(self.patterns.gain, info.source, info.skill, info.victim, info.amount, info.attribute)) |
||
398 | |||
399 | elseif info.type == "extraattack" then |
||
400 | |||
401 | self:Print(string.format(self.patterns.extraattack, info.victim, info.amount, info.skill)) |
||
402 | |||
403 | elseif info.type == "honor" then |
||
404 | |||
405 | if info.isDishonor then |
||
406 | self:Print(string.format(self.patterns.dishonor, info.source)) |
||
407 | else |
||
408 | |||
409 | if info.source then |
||
410 | trailer = string.format(" (%s %s)", info.sourceRank, info.source) |
||
411 | else |
||
412 | trailer = "" |
||
413 | end |
||
414 | |||
415 | self:Print(string.format(self.patterns.honor, info.amount)..trailer) |
||
416 | |||
417 | end |
||
418 | |||
419 | elseif info.type == "experience" then |
||
420 | |||
421 | trailer = "" |
||
422 | if info.source then trailer = string.format("%s(%s)", trailer, info.source) end |
||
423 | if info.bonusAmount then trailer = string.format("%s(%s%s)", trailer, info.bonusType, info.bonusAmount) end |
||
424 | if info.penaltyAmount then trailer = string.format("%s(%s%s)", trailer, info.penaltyType, info.penaltyAmount) end |
||
425 | if info.amountGroupBonus then trailer = string.format("%s(G+%s)", trailer, info.amountGroupBonus) end |
||
426 | if info.amountRaidPenalty then trailer = string.format("%s(R-%s)", trailer, info.amountRaidPenalty) end |
||
427 | self:Print(string.format(self.patterns.experience, info.amount).. trailer) |
||
428 | |||
429 | elseif info.type == "reputation" then |
||
430 | |||
431 | |||
432 | if not info.amount then |
||
433 | trailer = info.rank |
||
434 | else |
||
435 | if info.isNegative then |
||
436 | trailer = string.format("-%s", info.amount) |
||
437 | else |
||
438 | trailer = string.format("+%s", info.amount) |
||
439 | end |
||
440 | end |
||
441 | |||
442 | self:Print(string.format(self.patterns.reputation, info.faction, trailer)) |
||
443 | |||
444 | |||
445 | elseif info.type == "feedpet" then |
||
446 | |||
447 | self:Print(string.format(self.patterns.feedpet, info.victim, info.item)) |
||
448 | |||
449 | elseif info.type == "enchant" then |
||
450 | |||
451 | self:Print(string.format(self.patterns.enchant, info.source, info.skill, info.victim, info.item)) |
||
452 | |||
453 | elseif info.type == "miss" then |
||
454 | |||
455 | self:Print(string.format(self.patterns.miss, info.source, info.skill, self:Colorize(info.missType, "miss"), info.victim)) |
||
456 | |||
457 | elseif info.type == "cast" then |
||
458 | |||
459 | if info.isBegin then |
||
460 | self:Print(string.format(self.patterns.beginCast, info.source, info.skill)) |
||
461 | else |
||
462 | if info.victim then |
||
463 | self:Print(string.format(self.patterns.castTargetted, info.source, info.skill, info.victim)) |
||
464 | else |
||
465 | self:Print(string.format(self.patterns.cast, info.source, info.skill)) |
||
466 | end |
||
467 | end |
||
468 | |||
469 | elseif info.type == "interrupt" then |
||
470 | |||
471 | self:Print(string.format(self.patterns.interrupt, info.source, info.victim, info.skill)) |
||
472 | |||
473 | elseif info.type == "death" then |
||
474 | |||
475 | if info.source then trailer = string.format("(%s)", info.source) else trailer = "" end |
||
476 | self:Print(string.format(self.patterns.death, info.victim)..trailer) |
||
477 | |||
478 | elseif info.type == "environment" then |
||
479 | |||
480 | trailer = self:GetTrailerString(info) |
||
481 | self:Print(string.format(self.patterns.environment, info.victim, info.damageType, info.amount)..trailer) |
||
482 | |||
483 | elseif info.type == "create" then |
||
484 | |||
485 | self:Print(string.format(self.patterns.create, info.source, info.item)) |
||
486 | |||
487 | elseif info.type == "fail" and self.savedVars.showfailure then |
||
488 | |||
489 | self:Print(string.format(self.patterns.fail, info.skill, info.reason)) |
||
490 | |||
491 | elseif info.type == "drain" then |
||
492 | |||
493 | self:Print(string.format(self.patterns.drain, info.source, info.skill, info.victim, info.amount, info.attribute)) |
||
494 | |||
495 | |||
496 | elseif info.type == "leech" then |
||
497 | |||
498 | self:Print(string.format(self.patterns.leech, info.source, info.skill, info.victim, info.amount, info.attribute, info.sourceGained, info.amountGained, info.attributeGained)) |
||
499 | |||
500 | end |
||
501 | |||
502 | end |
||
503 | |||
504 | function SimpleCombatLog:GetElementType(element) |
||
505 | if element == SPELL_SCHOOL0_CAP then return 'physical' |
||
506 | elseif element == SPELL_SCHOOL1_CAP then return 'holy' |
||
507 | elseif element == SPELL_SCHOOL2_CAP then return 'fire' |
||
508 | elseif element == SPELL_SCHOOL3_CAP then return 'nature' |
||
509 | elseif element == SPELL_SCHOOL4_CAP then return 'frost' |
||
510 | elseif element == SPELL_SCHOOL5_CAP then return 'shadow' |
||
511 | elseif element == SPELL_SCHOOL6_CAP then return 'arcane' |
||
512 | else return element end |
||
513 | end |
||
514 | |||
515 | |||
516 | function SimpleCombatLog:GetTrailerString(info) |
||
517 | local trailer = "" |
||
518 | if info.isCrushing then trailer = trailer .. self.patterns.crushing end |
||
519 | if info.isGlancing then trailer = trailer .. self.patterns.glancing end |
||
520 | if info.amountAbsorb then trailer = trailer .. format(self.patterns.absorb, info.amountAbsorb) end |
||
521 | if info.amountResist then trailer = trailer .. format(self.patterns.resist, info.amountResist) end |
||
522 | if info.amountBlock then trailer = trailer .. format(self.patterns.block, info.amountBlock) end |
||
523 | if info.amountVulnerable then trailer = trailer .. format(self.patterns.vulnerable, info.amountVulnerable) end |
||
524 | return trailer |
||
525 | end |
||
526 | |||
527 | function SimpleCombatLog:FilterCheck(info) |
||
528 | |||
529 | local f = self.savedVars.filters |
||
530 | |||
531 | if info.type == "hit" then |
||
532 | if f.hit then return false end |
||
533 | elseif info.type == "heal" then |
||
534 | if f.heal then return false end |
||
535 | elseif info.type == "miss" then |
||
536 | if f.miss then return false end |
||
537 | elseif info.type == "gain" then |
||
538 | if f.gain then return false end |
||
539 | elseif info.type == "drain" or info.type == "leech" then |
||
540 | if f.drain then return false end |
||
541 | elseif info.type == "cast" then |
||
542 | if f.cast then return false end |
||
543 | end |
||
544 | |||
545 | if not ( info.source or info.victim ) then return true end |
||
546 | |||
547 | if info.source and not f[self:SearchName(info.source)] then return true end |
||
548 | if info.victim and not f[self:SearchName(info.victim)] then return true end |
||
549 | |||
550 | return false |
||
551 | |||
552 | end |
||
553 | |||
554 | function SimpleCombatLog:RefreshChatFrameEvents(enable) |
||
555 | for index, value in ChatFrame2.messageTypeList do |
||
556 | for eventIndex, eventValue in ChatTypeGroup[value] do |
||
557 | if SearchList(self.eventList, eventValue) then |
||
558 | if enable then |
||
559 | ChatFrame2:RegisterEvent(eventValue); |
||
560 | else |
||
561 | ChatFrame2:UnregisterEvent(eventValue); |
||
562 | end |
||
563 | end |
||
564 | end |
||
565 | end |
||
566 | end |
||
567 | |||
568 | |||
569 | |||
570 | function SimpleCombatLog:SearchName(name) |
||
571 | if name == ParserLib_SELF then return "player" end |
||
572 | if name == UnitName("player") then return "player" end |
||
573 | if name == UnitName("pet") then return "pet" end |
||
574 | for i=1, GetNumPartyMembers() do |
||
575 | if name == UnitName("party"..i) then return "party" end |
||
576 | end |
||
577 | for i=1, GetNumRaidMembers() do |
||
578 | if name == UnitName("raid"..i) then return "raid" end |
||
579 | end |
||
580 | if name == UnitName("target") then return "target" end |
||
581 | |||
582 | return 'other' |
||
583 | end |
||
584 | |||
585 | function SimpleCombatLog:ColorizeName(name) |
||
586 | if not name then return end |
||
587 | if name == self.loc.you then return self:Colorize(name, "player") end |
||
588 | |||
589 | return self:Colorize(name, self:SearchName(name) ) |
||
590 | end |
||
591 | |||
592 | function SimpleCombatLog:Print(msg, id, title, r,g,b) |
||
593 | if not id then id = self.savedVars.outputframe end |
||
594 | |||
595 | if title then |
||
596 | msg = "SimpleCombatLog " .. version .. " : " .. msg |
||
597 | end |
||
598 | |||
599 | getglobal("ChatFrame"..id):AddMessage(msg,r,g,b) |
||
600 | end |
||
601 | |||
602 | |||
603 | function SimpleCombatLog:OptionOpen(level, value) |
||
604 | |||
605 | if level == 1 then |
||
606 | |||
607 | dewdrop:AddLine( |
||
608 | 'text', self.loc.title .. version, |
||
609 | 'isTitle', true |
||
610 | ) |
||
611 | |||
612 | dewdrop:AddLine() |
||
613 | |||
614 | dewdrop:AddLine( |
||
615 | 'text', self.loc.color, |
||
616 | 'hasArrow', true, |
||
617 | 'value', "color" |
||
618 | ) |
||
619 | |||
620 | dewdrop:AddLine( |
||
621 | 'text', self.loc.filter, |
||
622 | 'hasArrow', true, |
||
623 | 'value', "filter" |
||
624 | ) |
||
625 | |||
626 | dewdrop:AddLine( |
||
627 | 'text', self.loc.event, |
||
628 | 'hasArrow', true, |
||
629 | 'value', "event" |
||
630 | ) |
||
631 | |||
632 | dewdrop:AddLine() |
||
633 | |||
634 | dewdrop:AddLine( |
||
635 | 'text', self.loc.suppress, |
||
636 | 'func', |
||
637 | function() |
||
638 | self.savedVars.nosuppress = not self.savedVars.nosuppress |
||
639 | self.needRefreshChatEvent = true |
||
640 | self:RefreshSettings() |
||
641 | end, |
||
642 | 'checked', not self.savedVars.nosuppress |
||
643 | ) |
||
644 | |||
645 | dewdrop:AddLine() |
||
646 | |||
647 | dewdrop:AddLine( |
||
648 | 'text', self.loc.default, |
||
649 | 'notCheckable', true, |
||
650 | 'func', function() self:LoadDefaultSettings() end |
||
651 | ) |
||
652 | |||
653 | |||
654 | elseif level == 2 then |
||
655 | |||
656 | |||
657 | if value == "color" then |
||
658 | |||
659 | local c |
||
660 | |||
661 | c = self:GetColor('player') |
||
662 | dewdrop:AddLine( |
||
663 | 'text', self.loc.player, |
||
664 | 'hasColorSwatch', true, |
||
665 | 'r', c.r, |
||
666 | 'g', c.g, |
||
667 | 'b', c.b, |
||
668 | 'swatchFunc', function(r,g,b) self:OptionColorChange('player',r,g,b) end |
||
669 | ) |
||
670 | |||
671 | c = self:GetColor('pet') |
||
672 | dewdrop:AddLine( |
||
673 | 'text', self.loc.pet, |
||
674 | 'hasColorSwatch', true, |
||
675 | 'r', c.r, |
||
676 | 'g', c.g, |
||
677 | 'b', c.b, |
||
678 | 'swatchFunc', function(r,g,b) self:OptionColorChange('pet',r,g,b) end |
||
679 | ) |
||
680 | |||
681 | c = self:GetColor('party') |
||
682 | dewdrop:AddLine( |
||
683 | 'text', self.loc.party, |
||
684 | 'hasColorSwatch', true, |
||
685 | 'r', c.r, |
||
686 | 'g', c.g, |
||
687 | 'b', c.b, |
||
688 | 'swatchFunc', function(r,g,b) self:OptionColorChange('party',r,g,b) end |
||
689 | ) |
||
690 | |||
691 | c = self:GetColor('raid') |
||
692 | dewdrop:AddLine( |
||
693 | 'text', self.loc.raid, |
||
694 | 'hasColorSwatch', true, |
||
695 | 'r', c.r, |
||
696 | 'g', c.g, |
||
697 | 'b', c.b, |
||
698 | 'swatchFunc', function(r,g,b) self:OptionColorChange('raid',r,g,b) end |
||
699 | ) |
||
700 | |||
701 | c = self:GetColor('target') |
||
702 | dewdrop:AddLine( |
||
703 | 'text', self.loc.target, |
||
704 | 'hasColorSwatch', true, |
||
705 | 'r', c.r, |
||
706 | 'g', c.g, |
||
707 | 'b', c.b, |
||
708 | 'swatchFunc', function(r,g,b) self:OptionColorChange('target',r,g,b) end |
||
709 | ) |
||
710 | |||
711 | c = self:GetColor('other') |
||
712 | dewdrop:AddLine( |
||
713 | 'text', self.loc.other, |
||
714 | 'hasColorSwatch', true, |
||
715 | 'r', c.r, |
||
716 | 'g', c.g, |
||
717 | 'b', c.b, |
||
718 | 'swatchFunc', function(r,g,b) self:OptionColorChange('other',r,g,b) end |
||
719 | ) |
||
720 | |||
721 | dewdrop:AddLine() |
||
722 | |||
723 | |||
724 | c = self:GetColor('skill') |
||
725 | dewdrop:AddLine( |
||
726 | 'text', self.loc.skill, |
||
727 | 'hasColorSwatch', true, |
||
728 | 'r', c.r, |
||
729 | 'g', c.g, |
||
730 | 'b', c.b, |
||
731 | 'swatchFunc', function(r,g,b) self:OptionColorChange('skill',r,g,b) end |
||
732 | ) |
||
733 | |||
734 | |||
735 | c = self:GetColor('buff') |
||
736 | dewdrop:AddLine( |
||
737 | 'text', self.loc.buff, |
||
738 | 'hasColorSwatch', true, |
||
739 | 'r', c.r, |
||
740 | 'g', c.g, |
||
741 | 'b', c.b, |
||
742 | 'swatchFunc', function(r,g,b) self:OptionColorChange('buff',r,g,b) end |
||
743 | ) |
||
744 | |||
745 | c = self:GetColor('debuff') |
||
746 | dewdrop:AddLine( |
||
747 | 'text', self.loc.debuff, |
||
748 | 'hasColorSwatch', true, |
||
749 | 'r', c.r, |
||
750 | 'g', c.g, |
||
751 | 'b', c.b, |
||
752 | 'swatchFunc', function(r,g,b) self:OptionColorChange('debuff',r,g,b) end |
||
753 | ) |
||
754 | |||
755 | c = self:GetColor('heal') |
||
756 | dewdrop:AddLine( |
||
757 | 'text', self.loc.heal, |
||
758 | 'hasColorSwatch', true, |
||
759 | 'r', c.r, |
||
760 | 'g', c.g, |
||
761 | 'b', c.b, |
||
762 | 'swatchFunc', function(r,g,b) self:OptionColorChange('heal',r,g,b) end |
||
763 | ) |
||
764 | |||
765 | c = self:GetColor('miss') |
||
766 | dewdrop:AddLine( |
||
767 | 'text', self.loc.miss, |
||
768 | 'hasColorSwatch', true, |
||
769 | 'r', c.r, |
||
770 | 'g', c.g, |
||
771 | 'b', c.b, |
||
772 | 'swatchFunc', function(r,g,b) self:OptionColorChange('miss',r,g,b) end |
||
773 | ) |
||
774 | |||
775 | c = self:GetColor('physical') |
||
776 | dewdrop:AddLine( |
||
777 | 'text', self.loc.physical, |
||
778 | 'hasColorSwatch', true, |
||
779 | 'r', c.r, |
||
780 | 'g', c.g, |
||
781 | 'b', c.b, |
||
782 | 'swatchFunc', function(r,g,b) self:OptionColorChange('physical',r,g,b) end |
||
783 | ) |
||
784 | |||
785 | c = self:GetColor('holy') |
||
786 | dewdrop:AddLine( |
||
787 | 'text', self.loc.holy, |
||
788 | 'hasColorSwatch', true, |
||
789 | 'r', c.r, |
||
790 | 'g', c.g, |
||
791 | 'b', c.b, |
||
792 | 'swatchFunc', function(r,g,b) self:OptionColorChange('holy',r,g,b) end |
||
793 | ) |
||
794 | |||
795 | c = self:GetColor('fire') |
||
796 | dewdrop:AddLine( |
||
797 | 'text', self.loc.fire, |
||
798 | 'hasColorSwatch', true, |
||
799 | 'r', c.r, |
||
800 | 'g', c.g, |
||
801 | 'b', c.b, |
||
802 | 'swatchFunc', function(r,g,b) self:OptionColorChange('fire',r,g,b) end |
||
803 | ) |
||
804 | |||
805 | c = self:GetColor('nature') |
||
806 | dewdrop:AddLine( |
||
807 | 'text', self.loc.nature, |
||
808 | 'hasColorSwatch', true, |
||
809 | 'r', c.r, |
||
810 | 'g', c.g, |
||
811 | 'b', c.b, |
||
812 | 'swatchFunc', function(r,g,b) self:OptionColorChange('nature',r,g,b) end |
||
813 | ) |
||
814 | |||
815 | c = self:GetColor('frost') |
||
816 | dewdrop:AddLine( |
||
817 | 'text', self.loc.frost, |
||
818 | 'hasColorSwatch', true, |
||
819 | 'r', c.r, |
||
820 | 'g', c.g, |
||
821 | 'b', c.b, |
||
822 | 'swatchFunc', function(r,g,b) self:OptionColorChange('frost',r,g,b) end |
||
823 | ) |
||
824 | |||
825 | c = self:GetColor('shadow') |
||
826 | dewdrop:AddLine( |
||
827 | 'text', self.loc.shadow, |
||
828 | 'hasColorSwatch', true, |
||
829 | 'r', c.r, |
||
830 | 'g', c.g, |
||
831 | 'b', c.b, |
||
832 | 'swatchFunc', function(r,g,b) self:OptionColorChange('shadow',r,g,b) end |
||
833 | ) |
||
834 | |||
835 | c = self:GetColor('arcane') |
||
836 | dewdrop:AddLine( |
||
837 | 'text', self.loc.arcane, |
||
838 | 'hasColorSwatch', true, |
||
839 | 'r', c.r, |
||
840 | 'g', c.g, |
||
841 | 'b', c.b, |
||
842 | 'swatchFunc', function(r,g,b) self:OptionColorChange('arcane',r,g,b) end |
||
843 | ) |
||
844 | |||
845 | |||
846 | |||
847 | elseif value == 'filter' then |
||
848 | |||
849 | dewdrop:AddLine( |
||
850 | 'text', self.loc.player, |
||
851 | 'func', function() self.savedVars.filters.player = not self.savedVars.filters.player end, |
||
852 | 'checked', not self.savedVars.filters.player |
||
853 | ) |
||
854 | dewdrop:AddLine( |
||
855 | 'text', self.loc.pet, |
||
856 | 'func', function() self.savedVars.filters.pet = not self.savedVars.filters.pet end, |
||
857 | 'checked', not self.savedVars.filters.pet |
||
858 | ) |
||
859 | dewdrop:AddLine( |
||
860 | 'text', self.loc.party, |
||
861 | 'func', function() self.savedVars.filters.party = not self.savedVars.filters.party end, |
||
862 | 'checked', not self.savedVars.filters.party |
||
863 | ) |
||
864 | dewdrop:AddLine( |
||
865 | 'text', self.loc.raid, |
||
866 | 'func', function() self.savedVars.filters.raid = not self.savedVars.filters.raid end, |
||
867 | 'checked', not self.savedVars.filters.raid |
||
868 | ) |
||
869 | dewdrop:AddLine( |
||
870 | 'text', self.loc.target, |
||
871 | 'func', function() self.savedVars.filters.target = not self.savedVars.filters.target end, |
||
872 | 'checked', not self.savedVars.filters.target |
||
873 | ) |
||
874 | dewdrop:AddLine( |
||
875 | 'text', self.loc.other, |
||
876 | 'func', function() self.savedVars.filters.other = not self.savedVars.filters.other end, |
||
877 | 'checked', not self.savedVars.filters.other |
||
878 | ) |
||
879 | |||
880 | dewdrop:AddLine() |
||
881 | |||
882 | dewdrop:AddLine( |
||
883 | 'text', self.loc.hit, |
||
884 | 'func', function() self.savedVars.filters.hit = not self.savedVars.filters.hit end, |
||
885 | 'checked', not self.savedVars.filters.hit |
||
886 | ) |
||
887 | dewdrop:AddLine( |
||
888 | 'text', self.loc.heal, |
||
889 | 'func', function() self.savedVars.filters.heal = not self.savedVars.filters.heal end, |
||
890 | 'checked', not self.savedVars.filters.heal |
||
891 | ) |
||
892 | dewdrop:AddLine( |
||
893 | 'text', self.loc.miss, |
||
894 | 'func', function() self.savedVars.filters.miss = not self.savedVars.filters.miss end, |
||
895 | 'checked', not self.savedVars.filters.miss |
||
896 | ) |
||
897 | dewdrop:AddLine( |
||
898 | 'text', self.loc.cast, |
||
899 | 'func', function() self.savedVars.filters.cast = not self.savedVars.filters.cast end, |
||
900 | 'checked', not self.savedVars.filters.cast |
||
901 | ) |
||
902 | dewdrop:AddLine( |
||
903 | 'text', self.loc.gain, |
||
904 | 'func', function() self.savedVars.filters.gain = not self.savedVars.filters.gain end, |
||
905 | 'checked', not self.savedVars.filters.gain |
||
906 | ) |
||
907 | dewdrop:AddLine( |
||
908 | 'text', self.loc.drain, |
||
909 | 'func', function() self.savedVars.filters.drain = not self.savedVars.filters.drain end, |
||
910 | 'checked', not self.savedVars.filters.drain |
||
911 | ) |
||
912 | |||
913 | |||
914 | |||
915 | elseif value == 'event' then |
||
916 | |||
917 | dewdrop:AddLine( |
||
918 | 'text', self.loc.selfhit, |
||
919 | 'func', function() self.savedVars.events.selfhit = not self.savedVars.events.selfhit; self:RefreshSettings() end, |
||
920 | 'checked', self.savedVars.events.selfhit |
||
921 | ) |
||
922 | dewdrop:AddLine( |
||
923 | 'text', self.loc.otherhit, |
||
924 | 'func', function() self.savedVars.events.otherhit = not self.savedVars.events.otherhit; self:RefreshSettings() end, |
||
925 | 'checked', self.savedVars.events.otherhit |
||
926 | ) |
||
927 | dewdrop:AddLine( |
||
928 | 'text', self.loc.selfspell, |
||
929 | 'func', function() self.savedVars.events.selfspell = not self.savedVars.events.selfspell; self:RefreshSettings() end, |
||
930 | 'checked', self.savedVars.events.selfspell |
||
931 | ) |
||
932 | dewdrop:AddLine( |
||
933 | 'text', self.loc.otherspell, |
||
934 | 'func', function() self.savedVars.events.otherspell = not self.savedVars.events.otherspell; self:RefreshSettings() end, |
||
935 | 'checked', self.savedVars.events.otherspell |
||
936 | ) |
||
937 | dewdrop:AddLine( |
||
938 | 'text', self.loc.selfdot, |
||
939 | 'func', function() self.savedVars.events.selfdot = not self.savedVars.events.selfdot; self:RefreshSettings() end, |
||
940 | 'checked', self.savedVars.events.selfdot |
||
941 | ) |
||
942 | dewdrop:AddLine( |
||
943 | 'text', self.loc.otherdot, |
||
944 | 'func', function() self.savedVars.events.otherdot = not self.savedVars.events.otherdot; self:RefreshSettings() end, |
||
945 | 'checked', self.savedVars.events.otherdot |
||
946 | ) |
||
947 | dewdrop:AddLine( |
||
948 | 'text', self.loc.death, |
||
949 | 'func', function() self.savedVars.events.death = not self.savedVars.events.death; self:RefreshSettings() end, |
||
950 | 'checked', self.savedVars.events.death |
||
951 | ) |
||
952 | dewdrop:AddLine( |
||
953 | 'text', self.loc.aura, |
||
954 | 'func', function() self.savedVars.events.aura = not self.savedVars.events.aura; self:RefreshSettings() end, |
||
955 | 'checked', self.savedVars.events.aura |
||
956 | ) |
||
957 | dewdrop:AddLine( |
||
958 | 'text', self.loc.enchant, |
||
959 | 'func', function() self.savedVars.events.enchant = not self.savedVars.events.enchant; self:RefreshSettings() end, |
||
960 | 'checked', self.savedVars.events.enchant |
||
961 | ) |
||
962 | dewdrop:AddLine( |
||
963 | 'text', self.loc.trade, |
||
964 | 'func', function() self.savedVars.events.trade = not self.savedVars.events.trade; self:RefreshSettings() end, |
||
965 | 'checked', self.savedVars.events.trade |
||
966 | ) |
||
967 | dewdrop:AddLine( |
||
968 | 'text', self.loc.experience, |
||
969 | 'func', function() self.savedVars.events.experience = not self.savedVars.events.experience; self:RefreshSettings() end, |
||
970 | 'checked', self.savedVars.events.experience |
||
971 | ) |
||
972 | dewdrop:AddLine( |
||
973 | 'text', self.loc.honor, |
||
974 | 'func', function() self.savedVars.events.honor = not self.savedVars.events.honor; self:RefreshSettings() end, |
||
975 | 'checked', self.savedVars.events.honor |
||
976 | ) |
||
977 | dewdrop:AddLine( |
||
978 | 'text', self.loc.reputation, |
||
979 | 'func', function() self.savedVars.events.reputation = not self.savedVars.events.reputation; self:RefreshSettings() end, |
||
980 | 'checked', self.savedVars.events.reputation |
||
981 | ) |
||
982 | dewdrop:AddLine( |
||
983 | 'text', self.loc.fail, |
||
984 | 'func', function() self.savedVars.events.fail = not self.savedVars.events.fail; self:RefreshSettings() end, |
||
985 | 'checked', self.savedVars.events.fail |
||
986 | ) |
||
987 | end |
||
988 | end |
||
989 | |||
990 | |||
991 | end |
||
992 | |||
993 | |||
994 | |||
995 | function SimpleCombatLog:OptionColorChange(item, r,g,b) |
||
996 | |||
997 | if not self.savedVars.colors[item] then self.savedVars.colors[item] = {} end |
||
998 | |||
999 | self.savedVars.colors[item].r = r |
||
1000 | self.savedVars.colors[item].g = g |
||
1001 | self.savedVars.colors[item].b = b |
||
1002 | end |
||
1003 | |||
1004 | |||
1005 | function SimpleCombatLog:LoadDefaultSettings() |
||
1006 | |||
1007 | SCL_Config = {} |
||
1008 | |||
1009 | self.savedVars = SCL_Config |
||
1010 | self.savedVars.colors = {} |
||
1011 | self.savedVars.filters = {} |
||
1012 | self.savedVars.minimapButton = {} |
||
1013 | |||
1014 | self.savedVars.events = {} |
||
1015 | for i, v in self.eventTypes do |
||
1016 | if v ~= 'fail' then |
||
1017 | self.savedVars.events[v] = true |
||
1018 | end |
||
1019 | end |
||
1020 | |||
1021 | self.savedVars.outputframe = 2 |
||
1022 | self.savedVars.nosuppress = nil |
||
1023 | self.savedVars.nooptionbutton = nil |
||
1024 | self:RefreshSettings() |
||
1025 | end |
||
1026 | |||
1027 | |||
1028 | if not GetParser then function GetParser() return parser end end |
||
1029 |