Mercurial > wow > turok
diff Turok/Modules/Timer/Cooldown.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/Cooldown.lua Sun Feb 21 08:49:34 2016 -0500 +++ b/Turok/Modules/Timer/Cooldown.lua Sun Feb 21 13:08:30 2016 -0500 @@ -30,7 +30,12 @@ local FADE_TIME = 0.2 --@debug@ local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool -local print = function(...) print('Cooldown', ...) end + +local print = function(...) + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('Cooldown', ...) + end +end local function GetPrint (trace) return trace and print or function() end end @@ -50,7 +55,7 @@ desaturated = false, fill_inverse = true, size = 24, - counterText = "%p", + counterText = "%i", subCounterText = "%.p", chargesText = "%s", justifyH = 'CENTER', @@ -63,20 +68,19 @@ icon = { desaturated = false, color = {1, 1, 1, 1}, - blend = 'BLEND' } }, active = { icon = { - desaturated = false, + desaturated = true, color = {1, 1, 1, .6}, - blend = 'ADD' } }, --- control displays of aura information in cooldown displays - showAura = false, - cooldownAura = { + overrideAura = false, + overrideDuration = false, + override = { icon = { desaturated = true, color = {0,1,0,1}, @@ -100,6 +104,19 @@ self.minValue = minValue and minValue or tonumber(self.minValue) self.maxValue = maxValue and maxValue or tonumber(self.maxValue) + self.start = 0 + self.duration = 0 + self.expires = 0 + self.charges = nil + self.charges_max = 0 + self.charge_start = 0 + self.charge_duration = 0 + self.charge_expires = 0 + self.override = false + self.override_start = 0 + self.override_duration = 0 + self.override_expires = 0 + --- current and last state values need to be flipped for inverted conditional --- last state is defined in case it needs to be overridden to ensure proper frame update print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName or GetItemSpell('player', self.inventoryID or self.itemID)) ) @@ -132,7 +149,8 @@ p.Query = function(self) local print = GetPrint(self.trace) local id = self.inventoryID or self.itemID or self.spellID - local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count + local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration = nil, false, 0, 0, nil, nil, nil, 0, 0 + local override, overrideStart, overrideDuration = false, 0, 0 --- checked in order of precedence if self.inventoryID then @@ -140,7 +158,6 @@ self.cooldownType = CD_SLOT start, duration, enabled = GetInventoryItemCooldown('player', id) charges, maxCharges, chargeStart, chargeDuration = nil, nil, nil, nil - count = GetInventoryItemCount('player', id) usable = name and true or false elseif self.itemID then self.cooldownType = CD_ITEM @@ -154,7 +171,6 @@ name = GetSpellInfo(self.spellID) start, duration, enabled = GetSpellCooldown(self.spellID) charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(self.spellID) - count = GetSpellCount(self.spellID) usable = true -- they still exist even when dead else self.unit = 'notaunit' @@ -166,8 +182,25 @@ self.maxCharges = maxCharges end - print('cooldown.Query(',id,')', name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration) - return name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count + if self.spellName and self.cvars.overrideAura then + local name, _, _, _, _, d, e = UnitAura(self.unit , self.spellName, nil, 'HELPFUL') + if name then + override = true + overrideDuration = d + overrideStart = e - d + end + end + + if self.overrideDuration and start > 0 then + override = true + overrideDuration = self.overrideDuration + overrideStart = start + end + + print('cooldown.Query(',id,')', 'name:'..cText(name), 'usable:'..cBool(usable), 'start:'..cNum(start), 'duration:'..cNum(duration), 'enabled:'..cWord(enabled), + 'charges:'.. cNum(charges), 'charge_start:'.. cNum(chargeStart), 'charge_duration:'.. cNum(chargeDuration), + 'override:' .. cBool(override), 'override_start'..cNum(overrideStart), 'override_duration:'.. cNum(overrideDuration)) + return name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration end p.Set = function(self, ...) @@ -175,7 +208,7 @@ --name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count local name - name, self.usable, self.start, self.duration, self.enabled, self.charges, self.chargeStart, self.chargeDuration, self.count = ... + name, self.usable, self.start, self.duration, self.enabled, self.charges, self.charges_max, self.charge_start, self.charge_duration, self.override, self.override_start, self.override_duration = ... if name then self.spellName = name end @@ -185,6 +218,14 @@ else self.expires = 0 end + + if self.charges then + self.charge_expires = self.charge_start + self.charge_duration + end + if self.override then + self.override_expires = self.override_start + self.override_duration + end + end p.Value = function(self) @@ -208,27 +249,15 @@ end local diff = 'start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration) - local name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count = self:Query() - - -- If we want and can, pull aura data and use that in place of cooldown information - local expires, hasAura, _ - if self.cvars.showAura then - print(cText('UnitAura'), self.unit, self.spellName, nil, 'HELPFUL') - local name, _, _, count, _, auraDuration, auraExpires = UnitAura(self.unit , self.spellName, nil, 'HELPFUL') - if name and (auraDuration ~= self.auraDuration or auraExpires ~= self.auraExpires) then - - print(cText('aura check ='), cBool(name), 's='..cNum(count), 'd='..cNum(auraDuration), 'e='..cNum(auraExpires)) - start = auraExpires - auraDuration - duration = auraDuration - expires = auraExpires - end - end + local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration = self:Query() -- print(name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count) if duration ~= self.duration or start ~= self.start or - chargeStart ~= self.chargeStart - or charges ~= self.charges then + chargeStart ~= self.charge_start or + charges ~= self.charges or + override ~= self.override + then print('a variable has changed') local state @@ -261,37 +290,36 @@ self:Stats(state) end - - -- form ID, id type, displayState, prevState - --T:Dispatch('TK_COOLDOWN_UPDATE', self.spellID, self.cooldownType, state, self.displayState) if state then - self:Set(name, usable, start, duration, enabled, charges, chargeStart, chargeDuration, count) + self:Set(name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, override, overrideStart, overrideDuration) self.expires = charges and (self.chargeStart + self.chargeDuration) or (self.start + self.duration) self:SetState(state) - --print(' ', cText('SetState'), cNum(self.displayState), 'from', cNum(self.prevState), cWord(self.timerName)) print(' ',diff) print(' start='..cText(self.start)..' duration='..cText(self.duration)..' charges='.. cText(self.charges).. ' chargeStart='..cText(self.chargeStart).. ' chargeDuration='..cText(self.chargeDuration)) end - elseif self.cooldownType == CD_SPELL then - if duration == 0 and charges == self.maxCharges and self.displayState == HIDDEN then - print(cKey(self.timerName), cText('post-framescript clean-up')) - self.triggerState = nil + else + if self.cooldownType == CD_SPELL then + if duration == 0 and charges == self.maxCharges and self.displayState == HIDDEN then + print(cKey(self.timerName), cText('post-framescript clean-up')) + self.triggerState = nil + end end end end - --self:DumpMessages() - end p.Stats = function(self, state) print(self.unit, self.spellName) - local auraName, _, _, auraCharges, _, auraDuration, auraExpires = UnitAura(self.unit, self.spellName, nil, 'HELPFUL') + if self.spellName then + local auraName, _, _, auraCharges, _, auraDuration, auraExpires = UnitAura(self.unit, self.spellName, nil, 'HELPFUL') + print(' # Aura', auraName and 'yes' or 'no', auraName and ('d='..cNum(auraDuration)) or '', auraName and ('e='..auraExpires)) + end + local name, usable, start, duration, enabled, charges, maxCharges, chargeStart, chargeDuration, count = self:Query() - print('# GCD =', T.GCD) - print('# SpellCooldown', 's =', start, 'd =', duration, 's =', charges and (charges..'/'..maxCharges) or 'NA') - print('# Aura', auraName and 'yes' or 'no', auraName and ('d='..cNum(auraDuration)) or '', auraName and ('e='..auraExpires)) - print('# Frame', 'state1 =', self.displayState, 'state2 =', self.previousState, state and ('change to '..cWord(state)) or '') + print(' # GCD =', T.GCD) + print(' # SpellCooldown', 's =', start, 'd =', duration, 's =', charges and (charges..'/'..maxCharges) or 'NA') + print(' # Frame', 'state1 =', self.displayState, 'state2 =', self.previousState, state and ('change to '..cWord(state)) or '') end