diff 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
line wrap: on
line diff
--- a/Turok/Modules/Combat/CombatLog.lua	Sun Feb 21 08:49:34 2016 -0500
+++ b/Turok/Modules/Combat/CombatLog.lua	Sun Feb 21 13:08:30 2016 -0500
@@ -12,7 +12,7 @@
 local cText, cNum, cKey, cWord, cPink, cType, cBool = cText, cNum, cKey, cWord, cPink, cType, cBool
 local print = function(...)
   if _G.Devian and _G.DevianDB.workspace ~= 1 then
-    _G.print('CombatText', ...)
+    _G.print('CT', ...)
   end
 end
 
@@ -41,13 +41,13 @@
     anchor = 'BOTTOMLEFT', anchorTo = 'BOTTOM', parent = 'UIParent',
     x = 80, y = 400,
   },
-  defaultFont = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", 18, 'OUTLINE'},
   defaultAnimation = 'slide',
-
+  defaultFont = 'font0',
   textFonts = {
+    font0 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf", 18, 'OUTLINE'},
     font1 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 30, 'OUTLINE'},
     font2 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 24, 'OUTLINE'},
-    font3 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Bold.ttf" , 20, 'OUTLINE'},
+    font3 = {"Interface\\Addons\\Turok\\Media\\font\\ArchivoNarrow-Regular.ttf" , 20, 'OUTLINE'},
   },
 
   --- [(string) combatEvent] = {[1] = (string) format [, [2] = fontKey]}
@@ -67,10 +67,10 @@
   textModifiers ={
     critical = {'%s!', 'pop'},
     overKill = {'%s |cFF0088FFKilling Blow!|r', 'slide'},
-    multistrike = {'<%s>', 'lateralSlide', 'font3'},
+    multistrike = {'%s', 'slide', 'font3'},
     absorbed = {'%s (%d)', 'slide'},
     blocked = {'%s {%d}', 'slide'},
-    pet = {'(%s)', 'lateralSlide'},
+    pet = {'(%s)', 'slide'},
     grouped = {'%s (%d hit)', 'slide'},
   },
   --- [AnimationGroup key] = {[XML attrib] = [value], d[x/y] = (number) 0-1 }
@@ -232,6 +232,9 @@
   ct.x = 0
   ct.y = 0
   ct.point = 'BOTTOMLEFT'
+
+  ct.string:SetFont(unpack(textFonts[defaultFont]))
+  ct.fontKey = 'font0'
   return ct
 end
 
@@ -304,17 +307,16 @@
   else
     currentFrame.icon:Hide()
   end
-  if fontKey  then
+  if fontKey and fontKey ~= currentFrame.fontKey then
     local newFont = fontKey and textFonts[fontKey] or defaultFont
 
     local path, size, flags = currentFrame.string:GetFont()
     path = newFont[1] or path
     size = newFont[2] or size
     flags = newFont[3] or flags
-    print(cText('font ('..cWord(fontKey)..'):'), path, size, flags)
-    local result = currentFrame.string:SetFont(path, size, flags)
-    print(cNum('     result:'), cNum(result), currentFrame.string:GetFont())
-    --currentFrame.fontKey = fontKey
+    print(cText('swapping font to "'..cWord(fontKey)..')":'), path, size, flags)
+    currentFrame.string:SetFont(path, size, flags)
+    currentFrame.fontKey = fontKey
   end
 
   currentFrame.animationType = animationType
@@ -361,8 +363,7 @@
     return
   end
 
-
-  local fontKey = 'font1'
+  local fontKey = defaultFont
   local icon = GetSpellTexture(spellID)
   local animationType = defaultAnimation
   local text = amount
@@ -378,7 +379,6 @@
     print("** font override:", '"'..cText(tString)..'",', cPink(font), cNum(size), cWord(outline))
   end
 
-  print('** getting color data', cText(spellName))
   if type(effectSchool) == 'number' then
     text = SpellSchoolColor(effectSchool) ..text..'|r'
   end
@@ -408,8 +408,6 @@
     animationType = multistrikeAnimation
     fontKey = multistrikeFont or fontKey
   end
-
-  print(ticks)
   if ticks then
     text = groupedModifier:format(text, ticks)
     animationType = groupedAnimation
@@ -417,7 +415,7 @@
   end
 
 
-  print('** sending format to SCT:', text, icon, animationType, fontKey)
+  print(cText('** AddCombatMessage(')..cKey(frame:GetName())..cText('):'), text, cWord(tostring(icon):sub(-20,-1)), cWord(animationType), cKey(fontKey))
 
 
   mod.AddCombatMessage(frame, text .. '|r', icon, animationType, fontKey)
@@ -530,16 +528,15 @@
   local isVisible
 
   local timestamp, combatEvent = ...
-  print(cText('* CT'), cKey(combatEvent))
+  print(cText('OnDamage'), cKey(combatEvent))
   if combatEvent == 'UNIT_DIED' then
     return
   end
   local sourceGUID, sourceName, sourceFlags, _, destGUID, destName, destFlags, _, spellID, spellName, spellSchool = select(4, ...)
-  print('  from', cPink(sourceGUID), 'spell', cNum(spellID), cText(spellName), '->', cKey(destGUID))
+  --print('  from', cPink(sourceGUID), 'spell', cNum(spellID), cText(spellName), '->', cKey(destGUID))
 
   -- SWING starts at arg 10, SPELL/RANGE start at arg 13, ENVIRONMENTAL starts at arg 8
   local offset = 15
-  print(combatEvent:sub(0,3))
   if combatEvent:sub(0,3) == 'SWI' then
     offset = 10
   elseif combatEvent:sub(0,3) == 'ENV' then
@@ -547,7 +544,6 @@
   end
   local amount, overKill, effectSchool, resisted, blocked, absorbed, critical, glancing, crushing, isOffHand, multistrike = select(offset, ...)
 
-  print('  dmg', amount, overKill)
 
   local sc = SpellSchoolColors[effectSchool]
   if groupedSpells[spellName] then
@@ -634,7 +630,6 @@
 
   --- Same as above, but for specific table values, key is determined by the combat event
   defaultAnimation = mod.db.defaultAnimation
-  defaultFont = mod.db.defaultFont
   for k,v in pairs(mod.db.textFormat) do
     textFormat[k] = {v[1], v[2]}
     print('imported textFormat.'..k, cText(textFormat[k][1]), cNum(textFormat[k][2]))
@@ -643,6 +638,7 @@
     textFonts[k] = {v[1] or defaultFont[1], v[2] or defaultFont[2], v[3] or defaultFont[3]}
     print('imported font.'..k, cText(textFonts[k][1]), cNum(textFonts[k][2]), cWord(textFonts[k][3]))
   end
+  defaultFont = mod.db.defaultFont
 
   for k,v in pairs(mod.db.animation) do
     animation[k] = {}
@@ -663,6 +659,7 @@
 function mod:OnEnable()
   T:RegisterChatCommand('tkc', CT_Unlock)
 
+  local fontPath, fontSize, fontFlags = unpack(db.textFonts.font0)
   --- Populate CT frames
   for name, CT in pairs(mod.CombatTextFrames) do
     print('create CT', name)