Mercurial > wow > turok
comparison Turok/Modules/Combat/CombatLog.lua @ 9:9400a0ff8540
Ugh
Timer:
- container update directionality
- talent update iterates over a non-volatile table to carry out updates
- index management steps organized
- talentRow status implemented, returns the spell associated with the talent chosen from that row
CombatLog:
- sort out font controls and unbork arguments
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 13:08:30 -0500 |
parents | a9b8b0866ece |
children | 0b1a2f3dbfc4 |
comparison
equal
deleted
inserted
replaced
8:7790dff0fe13 | 9:9400a0ff8540 |
---|---|
10 local GetSpellTexture, CreateFrame, GetTime, unpack, floor = GetSpellTexture, CreateFrame, GetTime, unpack, floor | 10 local GetSpellTexture, CreateFrame, GetTime, unpack, floor = GetSpellTexture, CreateFrame, GetTime, unpack, floor |
11 local db | 11 local db |
12 local cText, cNum, cKey, cWord, cPink, cType, cBool = cText, cNum, cKey, cWord, cPink, cType, cBool | 12 local cText, cNum, cKey, cWord, cPink, cType, cBool = cText, cNum, cKey, cWord, cPink, cType, cBool |
13 local print = function(...) | 13 local print = function(...) |
14 if _G.Devian and _G.DevianDB.workspace ~= 1 then | 14 if _G.Devian and _G.DevianDB.workspace ~= 1 then |
15 _G.print('CombatText', ...) | 15 _G.print('CT', ...) |
16 end | 16 end |
17 end | 17 end |
18 | 18 |
19 | 19 |
20 --- performance constants | 20 --- performance constants |
39 }, | 39 }, |
40 DoTTracker = { | 40 DoTTracker = { |
41 anchor = 'BOTTOMLEFT', anchorTo = 'BOTTOM', parent = 'UIParent', | 41 anchor = 'BOTTOMLEFT', anchorTo = 'BOTTOM', parent = 'UIParent', |
42 x = 80, y = 400, | 42 x = 80, y = 400, |
43 }, | 43 }, |
44 defaultFont = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", 18, 'OUTLINE'}, | |
45 defaultAnimation = 'slide', | 44 defaultAnimation = 'slide', |
46 | 45 defaultFont = 'font0', |
47 textFonts = { | 46 textFonts = { |
47 font0 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", 18, 'OUTLINE'}, | |
48 font1 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 30, 'OUTLINE'}, | 48 font1 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 30, 'OUTLINE'}, |
49 font2 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 24, 'OUTLINE'}, | 49 font2 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 24, 'OUTLINE'}, |
50 font3 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Bold.ttf" , 20, 'OUTLINE'}, | 50 font3 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 20, 'OUTLINE'}, |
51 }, | 51 }, |
52 | 52 |
53 --- [(string) combatEvent] = {[1] = (string) format [, [2] = fontKey]} | 53 --- [(string) combatEvent] = {[1] = (string) format [, [2] = fontKey]} |
54 --- Substitution values | 54 --- Substitution values |
55 -- %d [1] amount [2] overkill [3] absorbed [4] blocked | 55 -- %d [1] amount [2] overkill [3] absorbed [4] blocked |
65 }, | 65 }, |
66 }, | 66 }, |
67 textModifiers ={ | 67 textModifiers ={ |
68 critical = {'%s!', 'pop'}, | 68 critical = {'%s!', 'pop'}, |
69 overKill = {'%s |cFF0088FFKilling Blow!|r', 'slide'}, | 69 overKill = {'%s |cFF0088FFKilling Blow!|r', 'slide'}, |
70 multistrike = {'<%s>', 'lateralSlide', 'font3'}, | 70 multistrike = {'%s', 'slide', 'font3'}, |
71 absorbed = {'%s (%d)', 'slide'}, | 71 absorbed = {'%s (%d)', 'slide'}, |
72 blocked = {'%s {%d}', 'slide'}, | 72 blocked = {'%s {%d}', 'slide'}, |
73 pet = {'(%s)', 'lateralSlide'}, | 73 pet = {'(%s)', 'slide'}, |
74 grouped = {'%s (%d hit)', 'slide'}, | 74 grouped = {'%s (%d hit)', 'slide'}, |
75 }, | 75 }, |
76 --- [AnimationGroup key] = {[XML attrib] = [value], d[x/y] = (number) 0-1 } | 76 --- [AnimationGroup key] = {[XML attrib] = [value], d[x/y] = (number) 0-1 } |
77 -- d[x/y] indicates the proportional relevance of each FontString dimension when frames are displaced by a new event | 77 -- d[x/y] indicates the proportional relevance of each FontString dimension when frames are displaced by a new event |
78 -- x/y indicates the ranges of movement made by an animation, and are also considered when calculating displacement | 78 -- x/y indicates the ranges of movement made by an animation, and are also considered when calculating displacement |
230 frame.active[#frame.active+1] = ct | 230 frame.active[#frame.active+1] = ct |
231 ct.index = #frame.active | 231 ct.index = #frame.active |
232 ct.x = 0 | 232 ct.x = 0 |
233 ct.y = 0 | 233 ct.y = 0 |
234 ct.point = 'BOTTOMLEFT' | 234 ct.point = 'BOTTOMLEFT' |
235 | |
236 ct.string:SetFont(unpack(textFonts[defaultFont])) | |
237 ct.fontKey = 'font0' | |
235 return ct | 238 return ct |
236 end | 239 end |
237 | 240 |
238 --- frame interaction logic | 241 --- frame interaction logic |
239 mod.AddCombatMessage = function(frame, text, icon, animationType, fontKey) | 242 mod.AddCombatMessage = function(frame, text, icon, animationType, fontKey) |
302 currentFrame.icon:Show() | 305 currentFrame.icon:Show() |
303 currentFrame.icon:SetTexture(icon) | 306 currentFrame.icon:SetTexture(icon) |
304 else | 307 else |
305 currentFrame.icon:Hide() | 308 currentFrame.icon:Hide() |
306 end | 309 end |
307 if fontKey then | 310 if fontKey and fontKey ~= currentFrame.fontKey then |
308 local newFont = fontKey and textFonts[fontKey] or defaultFont | 311 local newFont = fontKey and textFonts[fontKey] or defaultFont |
309 | 312 |
310 local path, size, flags = currentFrame.string:GetFont() | 313 local path, size, flags = currentFrame.string:GetFont() |
311 path = newFont[1] or path | 314 path = newFont[1] or path |
312 size = newFont[2] or size | 315 size = newFont[2] or size |
313 flags = newFont[3] or flags | 316 flags = newFont[3] or flags |
314 print(cText('font ('..cWord(fontKey)..'):'), path, size, flags) | 317 print(cText('swapping font to "'..cWord(fontKey)..')":'), path, size, flags) |
315 local result = currentFrame.string:SetFont(path, size, flags) | 318 currentFrame.string:SetFont(path, size, flags) |
316 print(cNum(' result:'), cNum(result), currentFrame.string:GetFont()) | 319 currentFrame.fontKey = fontKey |
317 --currentFrame.fontKey = fontKey | |
318 end | 320 end |
319 | 321 |
320 currentFrame.animationType = animationType | 322 currentFrame.animationType = animationType |
321 currentFrame.string:SetText(text) | 323 currentFrame.string:SetText(text) |
322 local cHeight = currentFrame.string:GetStringHeight() | 324 local cHeight = currentFrame.string:GetStringHeight() |
359 end | 361 end |
360 if not combatEvent:match('DAMAGE') then | 362 if not combatEvent:match('DAMAGE') then |
361 return | 363 return |
362 end | 364 end |
363 | 365 |
364 | 366 local fontKey = defaultFont |
365 local fontKey = 'font1' | |
366 local icon = GetSpellTexture(spellID) | 367 local icon = GetSpellTexture(spellID) |
367 local animationType = defaultAnimation | 368 local animationType = defaultAnimation |
368 local text = amount | 369 local text = amount |
369 if textFormat[combatEvent] then | 370 if textFormat[combatEvent] then |
370 local tString, fontKey = unpack(textFormat[combatEvent]) | 371 local tString, fontKey = unpack(textFormat[combatEvent]) |
376 | 377 |
377 text = tString:gsub('%%[doabsnt]', GetTextFormatFunc(amount, overKill, absorbed, blocked, multistrike, spellName, sourceName, destName)) | 378 text = tString:gsub('%%[doabsnt]', GetTextFormatFunc(amount, overKill, absorbed, blocked, multistrike, spellName, sourceName, destName)) |
378 print("** font override:", '"'..cText(tString)..'",', cPink(font), cNum(size), cWord(outline)) | 379 print("** font override:", '"'..cText(tString)..'",', cPink(font), cNum(size), cWord(outline)) |
379 end | 380 end |
380 | 381 |
381 print('** getting color data', cText(spellName)) | |
382 if type(effectSchool) == 'number' then | 382 if type(effectSchool) == 'number' then |
383 text = SpellSchoolColor(effectSchool) ..text..'|r' | 383 text = SpellSchoolColor(effectSchool) ..text..'|r' |
384 end | 384 end |
385 | 385 |
386 if overKill > 0 then | 386 if overKill > 0 then |
406 if multistrike then | 406 if multistrike then |
407 text = multistrikeModifier:format(text, multistrike) | 407 text = multistrikeModifier:format(text, multistrike) |
408 animationType = multistrikeAnimation | 408 animationType = multistrikeAnimation |
409 fontKey = multistrikeFont or fontKey | 409 fontKey = multistrikeFont or fontKey |
410 end | 410 end |
411 | |
412 print(ticks) | |
413 if ticks then | 411 if ticks then |
414 text = groupedModifier:format(text, ticks) | 412 text = groupedModifier:format(text, ticks) |
415 animationType = groupedAnimation | 413 animationType = groupedAnimation |
416 fontKey = groupedFont or fontKey | 414 fontKey = groupedFont or fontKey |
417 end | 415 end |
418 | 416 |
419 | 417 |
420 print('** sending format to SCT:', text, icon, animationType, fontKey) | 418 print(cText('** AddCombatMessage(')..cKey(frame:GetName())..cText('):'), text, cWord(tostring(icon):sub(-20,-1)), cWord(animationType), cKey(fontKey)) |
421 | 419 |
422 | 420 |
423 mod.AddCombatMessage(frame, text .. '|r', icon, animationType, fontKey) | 421 mod.AddCombatMessage(frame, text .. '|r', icon, animationType, fontKey) |
424 end | 422 end |
425 | 423 |
528 local queue = {} | 526 local queue = {} |
529 mod.OnDamage = function(self, event, ...) | 527 mod.OnDamage = function(self, event, ...) |
530 local isVisible | 528 local isVisible |
531 | 529 |
532 local timestamp, combatEvent = ... | 530 local timestamp, combatEvent = ... |
533 print(cText('* CT'), cKey(combatEvent)) | 531 print(cText('OnDamage'), cKey(combatEvent)) |
534 if combatEvent == 'UNIT_DIED' then | 532 if combatEvent == 'UNIT_DIED' then |
535 return | 533 return |
536 end | 534 end |
537 local sourceGUID, sourceName, sourceFlags, _, destGUID, destName, destFlags, _, spellID, spellName, spellSchool = select(4, ...) | 535 local sourceGUID, sourceName, sourceFlags, _, destGUID, destName, destFlags, _, spellID, spellName, spellSchool = select(4, ...) |
538 print(' from', cPink(sourceGUID), 'spell', cNum(spellID), cText(spellName), '->', cKey(destGUID)) | 536 --print(' from', cPink(sourceGUID), 'spell', cNum(spellID), cText(spellName), '->', cKey(destGUID)) |
539 | 537 |
540 -- SWING starts at arg 10, SPELL/RANGE start at arg 13, ENVIRONMENTAL starts at arg 8 | 538 -- SWING starts at arg 10, SPELL/RANGE start at arg 13, ENVIRONMENTAL starts at arg 8 |
541 local offset = 15 | 539 local offset = 15 |
542 print(combatEvent:sub(0,3)) | |
543 if combatEvent:sub(0,3) == 'SWI' then | 540 if combatEvent:sub(0,3) == 'SWI' then |
544 offset = 10 | 541 offset = 10 |
545 elseif combatEvent:sub(0,3) == 'ENV' then | 542 elseif combatEvent:sub(0,3) == 'ENV' then |
546 offset = 8 | 543 offset = 8 |
547 end | 544 end |
548 local amount, overKill, effectSchool, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand, multistrike = select(offset, ...) | 545 local amount, overKill, effectSchool, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand, multistrike = select(offset, ...) |
549 | 546 |
550 print(' dmg', amount, overKill) | |
551 | 547 |
552 local sc = SpellSchoolColors[effectSchool] | 548 local sc = SpellSchoolColors[effectSchool] |
553 if groupedSpells[spellName] then | 549 if groupedSpells[spellName] then |
554 print('* ', cText(spellName), 'to consolidator') | 550 print('* ', cText(spellName), 'to consolidator') |
555 CT_ConsolidateText(self, timestamp, sourceGUID, destGUID, sourceName, destName, spellID, spellName, effectSchool, amount, overKill, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand, multistrike) | 551 CT_ConsolidateText(self, timestamp, sourceGUID, destGUID, sourceName, destName, spellID, spellName, effectSchool, amount, overKill, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand, multistrike) |
632 groupedAnimation = m.grouped[2] or 'slide' | 628 groupedAnimation = m.grouped[2] or 'slide' |
633 groupedFont = m.grouped[3] | 629 groupedFont = m.grouped[3] |
634 | 630 |
635 --- Same as above, but for specific table values, key is determined by the combat event | 631 --- Same as above, but for specific table values, key is determined by the combat event |
636 defaultAnimation = mod.db.defaultAnimation | 632 defaultAnimation = mod.db.defaultAnimation |
637 defaultFont = mod.db.defaultFont | |
638 for k,v in pairs(mod.db.textFormat) do | 633 for k,v in pairs(mod.db.textFormat) do |
639 textFormat[k] = {v[1], v[2]} | 634 textFormat[k] = {v[1], v[2]} |
640 print('imported textFormat.'..k, cText(textFormat[k][1]), cNum(textFormat[k][2])) | 635 print('imported textFormat.'..k, cText(textFormat[k][1]), cNum(textFormat[k][2])) |
641 end | 636 end |
642 for k,v in pairs(mod.db.textFonts) do | 637 for k,v in pairs(mod.db.textFonts) do |
643 textFonts[k] = {v[1] or defaultFont[1], v[2] or defaultFont[2], v[3] or defaultFont[3]} | 638 textFonts[k] = {v[1] or defaultFont[1], v[2] or defaultFont[2], v[3] or defaultFont[3]} |
644 print('imported font.'..k, cText(textFonts[k][1]), cNum(textFonts[k][2]), cWord(textFonts[k][3])) | 639 print('imported font.'..k, cText(textFonts[k][1]), cNum(textFonts[k][2]), cWord(textFonts[k][3])) |
645 end | 640 end |
641 defaultFont = mod.db.defaultFont | |
646 | 642 |
647 for k,v in pairs(mod.db.animation) do | 643 for k,v in pairs(mod.db.animation) do |
648 animation[k] = {} | 644 animation[k] = {} |
649 animation[k].x = v.x | 645 animation[k].x = v.x |
650 animation[k].y = v.y | 646 animation[k].y = v.y |
661 end | 657 end |
662 | 658 |
663 function mod:OnEnable() | 659 function mod:OnEnable() |
664 T:RegisterChatCommand('tkc', CT_Unlock) | 660 T:RegisterChatCommand('tkc', CT_Unlock) |
665 | 661 |
662 local fontPath, fontSize, fontFlags = unpack(db.textFonts.font0) | |
666 --- Populate CT frames | 663 --- Populate CT frames |
667 for name, CT in pairs(mod.CombatTextFrames) do | 664 for name, CT in pairs(mod.CombatTextFrames) do |
668 print('create CT', name) | 665 print('create CT', name) |
669 -- make frame | 666 -- make frame |
670 CT.frame = CT.frame or CreateFrame('Frame', SCT_NAME:format(name), UIParent, SCT_TEMPLATE) | 667 CT.frame = CT.frame or CreateFrame('Frame', SCT_NAME:format(name), UIParent, SCT_TEMPLATE) |