Mercurial > wow > turok
diff Turok/Modules/Timer/Aura.lua @ 6:a9b8b0866ece
clear out log jam
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 08:32:53 -0500 |
parents | |
children | 9400a0ff8540 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Turok/Modules/Timer/Aura.lua Sun Feb 21 08:32:53 2016 -0500 @@ -0,0 +1,163 @@ +--- Turok - Aura.lua +-- @file-author@ +-- @project-revision@ @project-hash@ +-- @file-revision@ @file-hash@ +-- Created: 12/25/2015 5:58 AM +-- Aura data collection +local GetTime, UnitAura, GetSpellDescription, GetSpellInfo = GetTime, UnitAura, GetSpellDescription, GetSpellInfo +local T, _G, tinsert = Turok, _G, tinsert +local mod = T:GetModule("TimerControl") + +--@debug@ +local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool +local print = function(...) + if _G.Devian and _G.DevianDB.workspace ~= 1 then + _G.print('Aura', ...) + end +end +print('Peep!', ...) +--@end-debug@ + +T.defaults.spirit.aura = { + counterText = "%p", + subCounterText = "%.p", + chargesText = "%s", + justifyH = 'CENTER', + justifyV = 'TOP', + leftText = "%p", + rightText = "%n", + + passive = { + icon = { + desaturated = false, + color = {1, 1, 1, 1}, + blend = 'BLEND' + } + }, + active = { + icon = { + desaturated = false, + color = {1, 1, 1, 1}, + blend = 'BLEND' + } + }, +} + +local p = mod.prototype.trigger.aura +p.class = 'trigger' -- identifier values that are visible from function scope +p.type = 'aura' +p.cvars = { -- only define things that could break the frame here +} +p.events = { + ['UNIT_AURA'] = true, +} + +--- takes user supplied values or fills itself with the cvar values provided +p.Init = function(self, auraName, auraFilters, auraUnit) + + _G.print('Prototype', 'Aura.Init') + self.unit = auraUnit and auraUnit or self.dvars.unit + self.spellName = auraName and auraName or self.spellName + self.filters = auraFilters and auraFilters or self.dvars.filters + -- set inversion states, states 0 and 1 are only processed when prevState differs + if self.cvars.inverse then + self.flags = { + active = 0, + active_prev = 2, + passive = 0, + passive_prev = 1, + hidden = 1, + hidden_prev = 0, + } + self.duration = 1 + self.expires = 1 + else + self.flags = { + active = 2, + active_prev = 0, + passive = 1, + passive_prev = 0, + hidden = 0, + hidden_prev = 1} + end + print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName)) +end + +p.Unload = function(self) + print('unloading events') + for k,v in pairs(p.events) do + self:UnregisterEvent(k) + end +end + +--- Return current status data +p.Query = function(self) + print( ' Q:', self.unit , self.spellName, nil, self.filters) + return UnitAura(self.unit , self.spellName, nil, self.filters) +end + +p.SetText = mod.SetText + +--- Set supplied status data, using the list returned by p.Query() +p.Set = function(self, ...) + self.active, self.rank, _, self.count, self.dispelType, self.duration, self.expires, self.caster, + self.isStealable, self.shouldConsolidate, self.spellID, self.canApplyAura, self.isBossDebuff = ... + if self.active then + if self.cvars.duration then + self.duration = self.cvars.duration + print(cKey('force duration ='), cNum(self.cvars.duration)) + end + self.start = self.expires - self.duration + end +end + +--- Handle in the frame itself to limit collateral from bugs +function p.Event(self, event, unit) + self.event = event + if not event then + print(' DRY FIRE') + elseif unit ~= self.unit then + return + end + + --- 3 states: nil, 0, >0 + + local active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff = self:Query() + local state + if self.cvars.duration and active ~= self.active then + print('passive aura with forced duration') + state = self.flags.active + duration = self.cvars.duration + expires = GetTime() + self.cvars.duration + elseif (not self.cvars.duration and (duration ~= self.duration or expires ~= self.expires)) or active ~= self.active then + if not active then + if (not self.untriggerFunc) or self:untriggerFunc() then + state = self.flags.hidden + end + else + if (not self.triggerFunc) or self:triggerFunc() then + if duration == 0 then + print('passive aura') + state = self.flags.passive + else + print('updating an active aura') + state = self.flags.active + end + self.start = expires - duration + end + end + end + + if state then + T:Dispatch('TK_AURA_UPDATE', self.spellID, self.filters, state, self.displayState) + self:Set(active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff) + self:SetState(state) + print(cText('push state'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', self.timerName, cText(active), cKey(duration), cNum(expires), cBool(self.cvars.inverse)) + else + print(cText('no changes'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', cText(self.timerName)) + end +end + +p.Value = function(self) + return (self.charges and self.charges < self.maxCharges) and ((GetTime() - self.chargeStart) / self.chargeDuration) or ((GetTime() - self.start) / self.duration) +end \ No newline at end of file