annotate 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
rev   line source
Nenue@6 1 --- Turok - Aura.lua
Nenue@6 2 -- @file-author@
Nenue@6 3 -- @project-revision@ @project-hash@
Nenue@6 4 -- @file-revision@ @file-hash@
Nenue@6 5 -- Created: 12/25/2015 5:58 AM
Nenue@6 6 -- Aura data collection
Nenue@6 7 local GetTime, UnitAura, GetSpellDescription, GetSpellInfo = GetTime, UnitAura, GetSpellDescription, GetSpellInfo
Nenue@6 8 local T, _G, tinsert = Turok, _G, tinsert
Nenue@6 9 local mod = T:GetModule("TimerControl")
Nenue@6 10
Nenue@6 11 --@debug@
Nenue@6 12 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool
Nenue@6 13 local print = function(...)
Nenue@6 14 if _G.Devian and _G.DevianDB.workspace ~= 1 then
Nenue@6 15 _G.print('Aura', ...)
Nenue@6 16 end
Nenue@6 17 end
Nenue@6 18 print('Peep!', ...)
Nenue@6 19 --@end-debug@
Nenue@6 20
Nenue@6 21 T.defaults.spirit.aura = {
Nenue@6 22 counterText = "%p",
Nenue@6 23 subCounterText = "%.p",
Nenue@6 24 chargesText = "%s",
Nenue@6 25 justifyH = 'CENTER',
Nenue@6 26 justifyV = 'TOP',
Nenue@6 27 leftText = "%p",
Nenue@6 28 rightText = "%n",
Nenue@6 29
Nenue@6 30 passive = {
Nenue@6 31 icon = {
Nenue@6 32 desaturated = false,
Nenue@6 33 color = {1, 1, 1, 1},
Nenue@6 34 blend = 'BLEND'
Nenue@6 35 }
Nenue@6 36 },
Nenue@6 37 active = {
Nenue@6 38 icon = {
Nenue@6 39 desaturated = false,
Nenue@6 40 color = {1, 1, 1, 1},
Nenue@6 41 blend = 'BLEND'
Nenue@6 42 }
Nenue@6 43 },
Nenue@6 44 }
Nenue@6 45
Nenue@6 46 local p = mod.prototype.trigger.aura
Nenue@6 47 p.class = 'trigger' -- identifier values that are visible from function scope
Nenue@6 48 p.type = 'aura'
Nenue@6 49 p.cvars = { -- only define things that could break the frame here
Nenue@6 50 }
Nenue@6 51 p.events = {
Nenue@6 52 ['UNIT_AURA'] = true,
Nenue@6 53 }
Nenue@6 54
Nenue@6 55 --- takes user supplied values or fills itself with the cvar values provided
Nenue@6 56 p.Init = function(self, auraName, auraFilters, auraUnit)
Nenue@6 57
Nenue@6 58 _G.print('Prototype', 'Aura.Init')
Nenue@6 59 self.unit = auraUnit and auraUnit or self.dvars.unit
Nenue@6 60 self.spellName = auraName and auraName or self.spellName
Nenue@6 61 self.filters = auraFilters and auraFilters or self.dvars.filters
Nenue@6 62 -- set inversion states, states 0 and 1 are only processed when prevState differs
Nenue@6 63 if self.cvars.inverse then
Nenue@6 64 self.flags = {
Nenue@6 65 active = 0,
Nenue@6 66 active_prev = 2,
Nenue@6 67 passive = 0,
Nenue@6 68 passive_prev = 1,
Nenue@6 69 hidden = 1,
Nenue@6 70 hidden_prev = 0,
Nenue@6 71 }
Nenue@6 72 self.duration = 1
Nenue@6 73 self.expires = 1
Nenue@6 74 else
Nenue@6 75 self.flags = {
Nenue@6 76 active = 2,
Nenue@6 77 active_prev = 0,
Nenue@6 78 passive = 1,
Nenue@6 79 passive_prev = 0,
Nenue@6 80 hidden = 0,
Nenue@6 81 hidden_prev = 1}
Nenue@6 82 end
Nenue@6 83 print(cWord('Load:'),cNum(self.spellID or self.inventoryID or self.itemID), cText(self.spellName))
Nenue@6 84 end
Nenue@6 85
Nenue@6 86 p.Unload = function(self)
Nenue@6 87 print('unloading events')
Nenue@6 88 for k,v in pairs(p.events) do
Nenue@6 89 self:UnregisterEvent(k)
Nenue@6 90 end
Nenue@6 91 end
Nenue@6 92
Nenue@6 93 --- Return current status data
Nenue@6 94 p.Query = function(self)
Nenue@6 95 print( ' Q:', self.unit , self.spellName, nil, self.filters)
Nenue@6 96 return UnitAura(self.unit , self.spellName, nil, self.filters)
Nenue@6 97 end
Nenue@6 98
Nenue@6 99 p.SetText = mod.SetText
Nenue@6 100
Nenue@6 101 --- Set supplied status data, using the list returned by p.Query()
Nenue@6 102 p.Set = function(self, ...)
Nenue@6 103 self.active, self.rank, _, self.count, self.dispelType, self.duration, self.expires, self.caster,
Nenue@6 104 self.isStealable, self.shouldConsolidate, self.spellID, self.canApplyAura, self.isBossDebuff = ...
Nenue@6 105 if self.active then
Nenue@6 106 if self.cvars.duration then
Nenue@6 107 self.duration = self.cvars.duration
Nenue@6 108 print(cKey('force duration ='), cNum(self.cvars.duration))
Nenue@6 109 end
Nenue@6 110 self.start = self.expires - self.duration
Nenue@6 111 end
Nenue@6 112 end
Nenue@6 113
Nenue@6 114 --- Handle in the frame itself to limit collateral from bugs
Nenue@6 115 function p.Event(self, event, unit)
Nenue@6 116 self.event = event
Nenue@6 117 if not event then
Nenue@6 118 print(' DRY FIRE')
Nenue@6 119 elseif unit ~= self.unit then
Nenue@6 120 return
Nenue@6 121 end
Nenue@6 122
Nenue@6 123 --- 3 states: nil, 0, >0
Nenue@6 124
Nenue@6 125 local active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff = self:Query()
Nenue@6 126 local state
Nenue@6 127 if self.cvars.duration and active ~= self.active then
Nenue@6 128 print('passive aura with forced duration')
Nenue@6 129 state = self.flags.active
Nenue@6 130 duration = self.cvars.duration
Nenue@6 131 expires = GetTime() + self.cvars.duration
Nenue@6 132 elseif (not self.cvars.duration and (duration ~= self.duration or expires ~= self.expires)) or active ~= self.active then
Nenue@6 133 if not active then
Nenue@6 134 if (not self.untriggerFunc) or self:untriggerFunc() then
Nenue@6 135 state = self.flags.hidden
Nenue@6 136 end
Nenue@6 137 else
Nenue@6 138 if (not self.triggerFunc) or self:triggerFunc() then
Nenue@6 139 if duration == 0 then
Nenue@6 140 print('passive aura')
Nenue@6 141 state = self.flags.passive
Nenue@6 142 else
Nenue@6 143 print('updating an active aura')
Nenue@6 144 state = self.flags.active
Nenue@6 145 end
Nenue@6 146 self.start = expires - duration
Nenue@6 147 end
Nenue@6 148 end
Nenue@6 149 end
Nenue@6 150
Nenue@6 151 if state then
Nenue@6 152 T:Dispatch('TK_AURA_UPDATE', self.spellID, self.filters, state, self.displayState)
Nenue@6 153 self:Set(active, rank, _, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff)
Nenue@6 154 self:SetState(state)
Nenue@6 155 print(cText('push state'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', self.timerName, cText(active), cKey(duration), cNum(expires), cBool(self.cvars.inverse))
Nenue@6 156 else
Nenue@6 157 print(cText('no changes'), cNum(self.displayState).. ' (prev: '.. cNum(self.prevState)..')', cText(self.timerName))
Nenue@6 158 end
Nenue@6 159 end
Nenue@6 160
Nenue@6 161 p.Value = function(self)
Nenue@6 162 return (self.charges and self.charges < self.maxCharges) and ((GetTime() - self.chargeStart) / self.chargeDuration) or ((GetTime() - self.start) / self.duration)
Nenue@6 163 end