Mercurial > wow > turok
diff Turok/Modules/Timer/Timer.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 |
line wrap: on
line diff
--- a/Turok/Modules/Timer/Timer.lua Sun Feb 21 08:49:34 2016 -0500 +++ b/Turok/Modules/Timer/Timer.lua Sun Feb 21 13:08:30 2016 -0500 @@ -5,12 +5,12 @@ --- Defines common elements for the various timer HUDs local ADDON, _A = ... local _G, CreateFrame, tconcat, GetInventoryItemsForSlot, GetInventoryItemID = _G, CreateFrame, table.concat, GetInventoryItemsForSlot, GetInventoryItemID -local T, F, tostring, type, max, tinsert, unpack, UIParent, loadstring = _A.Addon, _A.LibFog, tostring, type, max, table.insert, unpack, _G.UIParent, loadstring +local T, F, tostring, type, max, tinsert, unpack, UIParent, loadstring, rawset = _A.Addon, _A.LibFog, tostring, type, max, table.insert, unpack, _G.UIParent, loadstring, rawset local mod = T.modules.TimerControl local P = mod.prototype local db -local pairs, ipairs, gsub, sub, setmetatable = pairs, ipairs, string.gsub, string.sub, setmetatable +local pairs, ipairs, gsub, sub, setmetatable, wipe = pairs, ipairs, string.gsub, string.sub, setmetatable, wipe local INVTYPE_FINGER, INVSLOT_FINGER1, INVSLOT_FINGER2, INVTYPE_TRINKET, INVSLOT_TRINKET1, INVSLOT_TRINKET2 = INVTYPE_FINGER, INVSLOT_FINGER1, INVSLOT_FINGER2, INVTYPE_TRINKET, INVSLOT_TRINKET1, INVSLOT_TRINKET2 --@debug@ @@ -23,12 +23,24 @@ _G.print('Timer', ...) end end +local teprint = function(...) + if not DEBUG then return end + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('TimerEvent',...) + end +end +local tfprint = function(...) + if not DEBUG then return end + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('TimerFocus',...) + end +end local Timer_GetPrintHandler = function(self) if self.trace then return function(...) print(...) - _G.print('TimerFocus', ...) + tfprint(...) end else return print end @@ -67,17 +79,17 @@ __mode = "v", __newindex = function(t,k,v) rawset(t,k,v) - _G.print('DB', 'TCMeta: adding leaf', k, '=', v) + --_G.print('DB', 'TCMeta: adding leaf', k, '=', v) end} local mt_double = { __index = function(t,k) t[k] = setmetatable({}, mt_single) - _G.print('DB', 'TCMeta: add layer', k, '=', t[k]) + --_G.print('DB', 'TCMeta: add layer', k, '=', t[k]) return t[k] end, __newindex = function(t,k,v) rawset(t,k,v) - _G.print('DB', 'TCMeta: adding to top layer', k, '=', v) + --_G.print('DB', 'TCMeta: adding to top layer', k, '=', v) end } local mt_error = { @@ -328,24 +340,23 @@ end function mod.InitTimers() - local print = function(...) _G.print('TimerEvent', ...) end - print('INIT TIMERS ====================') + teprint('INIT TIMERS ====================') for id, spirit in pairs(mod.timers) do if spirit.disable then - print(id, 'disabled:', tconcat(spirit.debug_info or {}, ', ')) + teprint(id, 'disabled:', tconcat(spirit.debug_info or {}, ', ')) else - print(cText('init'), cNum(id), cWord(spirit.name)) + teprint(cText('init'), cNum(id), cWord(spirit.name)) --- Throw a dry event to initialize values - print(cText(' *'), cWord('prototype.'..cKey(spirit.dvars.type)..'.'..cWord('Load'))) + teprint(cText(' *'), cWord('prototype.'..cKey(spirit.dvars.type)..'.'..cWord('Load'))) P.trigger[spirit.dvars.type].Event(spirit) --- Set loose - print(cText(' *'), cWord('prototype')..'.'..cKey('events')..'.'..cWord('Load')) + teprint(cText(' *'), cWord('prototype')..'.'..cKey('events')..'.'..cWord('Load')) mod.UpdateEvents(spirit, P.trigger[spirit.dvars.type].events) end end - print('INIT DONE =========================') + teprint('INIT DONE =========================') end function mod:DisableTimer(name, timer) @@ -387,7 +398,7 @@ local match_sub = { {'%%c', "' .. tostring(t.caster).. '"}, {'%%h', "' .. tostring((t.valueFull >= 60) and (math.floor(t.valueFull/60)) or t.value) .. '"}, - {'%%i', "' .. tostring((t.valueFull >= 60) and (t.value % 60) or ((t.valueFull < 6) and math.floor((t.ValueFull * 100) % 100) or '')) .. '"}, + {'%%i', "' .. tostring((t.valueFull >= 60) and (math.floor(t.valueFull/60) .. ':' .. ((t.value %% 60) < 10 and '0' or '').. (t.value %% 60)) or ((t.valueFull < 6) and (t.value .. '.' .. math.floor((t.valueFull * 10) %% 10)) or t.value)) .. '"}, {'%%n', "' .. tostring(t.spellName) .. '"}, {'%%p', "' .. tostring(t.value) .. '"}, {'%%d', "' .. tostring(t.chargeDuration or t.duration) .. '"}, @@ -516,12 +527,23 @@ end --- Same thing but for talent/spec-driven +local update_queue = {} +function mod.ResetTimers(heading) + print(cText('*** Flushing update queue for'), cWord(heading)) + for id, frame in pairs(update_queue) do + print(' ', cNum(id), cKey(frame.timerName)) + frame.disable = nil + wipe(frame.debug_info) + local res, msg = mod:EnableTimer(id, frame.dvars) + end + wipe(update_queue) +end + function mod:PLAYER_TALENT_UPDATE(e, unit) print('') print('') print(cText(e), T.specPage, T.specName) - local update_queue = {} for _, k in ipairs({'talentID', 'talentRow', 'specPage'}) do for value, frameSet in pairs(mod.frames.talentID) do for id, frame in ipairs(frameSet) do @@ -530,41 +552,31 @@ end end end - - for id, frame in pairs(update_queue) do - print('Refreshing spec-related frames', id, frame.timerName) - frame.disable = nil - table.wipe(frame.debug_info) - local res, msg = mod:EnableTimer(id, frame.dvars) - end - + mod.resetTimers('Talent') end function mod:PLAYER_EQUIPMENT_CHANGED(e, slot, hasItem) print(e, slot, hasItem) - local itemCheckList - if mod.frames.inventoryID and mod.frames.inventoryID[slot] then - print(' Inventory Frames:') - itemCheckList = GetInventoryItemsForSlot(slot, {}, false) - for id, slotFrame in pairs(mod.frames.inventoryID[slot]) do - print(' * Updating', cNum(id), cWord(slotFrame.timerName)) - local res, msg = mod:EnableTimer(slotFrame.timerID, slotFrame.dvars) - print(' ', cBool(res), cText(msg)) + if mod.frames.inventoryID and mod.frames.inventoryID[slot] then + print(' Inventory slot:', cNum(slot)) + for i, slotFrame in ipairs(mod.frames.inventoryID[slot]) do + print(' ', cNum(i), cText(slotFrame.timerName)) + update_queue[slotFrame.timerID] = slotFrame + if mod.frames.itemID then + local itemsForSlot = GetInventoryItemsForSlot(slot, {}, false) + for _, itemID in pairs(itemsForSlot) do + if mod.frames.itemID[itemID] then + print(' Frames for equippable item:', cNum(itemID)) + for j, itemFrame in ipairs(mod.frames.itemID[itemID]) do + print(' ', cNum(j), cText(itemFrame.timerName)) + update_queue[itemFrame.timerID] = itemFrame + end + end + end end - end - if itemCheckList then - print(unpack(itemCheckList)) - end - local itemID = GetInventoryItemID('player', slot) - if itemID and mod.frames.itemID[itemID] then - print(' Item ID Frames:') - for id, itemFrame in pairs(mod.frames.itemID[itemID]) do - print(' * Updating', cNum(id), cWord(itemFrame.timerName)) - - local res, msg = mod:EnableTimer(itemFrame.timerID, itemFrame.dvars) - print(' ', cBool(res), cText(msg)) end end + mod.ResetTimers('Equipment') end function mod:PET_BATTLE_OPENING_START () for i, v in pairs(mod.timers) do