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