Mercurial > wow > turok
comparison Turok/Modules/Timer/Icon.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 --- ${PACKAGE_NAME} | |
2 -- @file-author@ | |
3 -- @project-revision@ @project-hash@ | |
4 -- @file-revision@ @file-hash@ | |
5 -- Created: 1/15/2016 6:31 PM | |
6 local T, _G = Turok, _G | |
7 local mod = T.modules.TimerControl | |
8 local GetTime, floor, unpack, tconcat = GetTime, floor, unpack, table.concat | |
9 local HIDDEN, PASSIVE, ACTIVE = 0, 1,2 | |
10 --@debug@ | |
11 local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool | |
12 local print = function(...) | |
13 if _G.Devian and _G.DevianDB.workspace ~= 1 then | |
14 _G.print('Icon', ...) | |
15 end | |
16 end | |
17 print('Peep!', ...) | |
18 --@end-debug@ | |
19 local GetPrint = function(trace) | |
20 if trace then | |
21 return print | |
22 else | |
23 return function() end | |
24 end | |
25 end | |
26 | |
27 T.defaults.spirit.icon = { | |
28 combatFade = true, | |
29 alpha = 1, | |
30 alpha_passive = 1, | |
31 alpha_active = 1, | |
32 alpha_ooc_passive = 0, | |
33 alpha_ooc_active = 1, | |
34 alpha_ooc = 0.25, | |
35 size = 48, | |
36 container = 'default', | |
37 strata = 'LOW', | |
38 fade_in_time = 0.2, | |
39 fade_out_time = 0.3, | |
40 anchor = 'BOTTOM', anchorTo = 'BOTTOM', | |
41 parent = 1, | |
42 size = 48, | |
43 width = 48, height = 48, | |
44 x = 0, | |
45 y = 0, | |
46 strata = 'MEDIUM', | |
47 padding = 3, | |
48 spacing = 1, | |
49 foreground_inset= 0, | |
50 } | |
51 | |
52 local p = mod.prototype.display.icon | |
53 | |
54 p.type='display' | |
55 p.inherits = 'TurokIconTemplate' | |
56 | |
57 --- if config flags need to overrided | |
58 p.cvars = { | |
59 enableIcon = true | |
60 } | |
61 --- Negotiate the config differences between different display states | |
62 -- Hidden - display is or should (via fade-out) be hidden | |
63 -- Passive - display is visible, but no timing information is processed | |
64 -- Active - display is visible and counting time; on expiration, it will downgrade itself to passive or hidden | |
65 p.Init = function(self) | |
66 local print = GetPrint(self.trace) | |
67 | |
68 print('display.Icon.Load') | |
69 local c = self.cvars | |
70 if c.type == 'aura' then | |
71 self.spiral:SetReverse(true) | |
72 else | |
73 self.spiral:SetReverse(false) | |
74 end | |
75 | |
76 if not self.icon:IsShown() then | |
77 self.icon:Show() | |
78 end | |
79 print('icon texture=', self.spellIcon or self.itemIcon) | |
80 self.icon:SetTexture(self.spellIcon or self.itemIcon) | |
81 end | |
82 | |
83 | |
84 --- Advances the display state, applying any visual transitions as necessary; | |
85 -- @param self frame object | |
86 -- @param newState state value; 1 for inactive, 2 for untimed active, 3 for timed active | |
87 -- @param forcePrevious force the frame's lastState to this value to block off OnUpdate difference tests | |
88 -- even if forced, the actual history value will still be used for method scope | |
89 p.SetState = function(self, newState, forcePrevious) | |
90 | |
91 --print(cWord(self:GetName()), 'state change issued:', cNum(state), cType(previous)) | |
92 | |
93 local previous = self.displayState | |
94 self.prevState = forcePrevious and forcePrevious or previous | |
95 self.displayState = newState | |
96 print('SetState', cNum(newState), '(from '..cType(previous)..')', cText(self.timerName)) | |
97 --_G.print('Prototype.'..self.cvars.type, 'SetState', cNum(newState), '(from '..cType(previous)..')', cText(self.timerName)) | |
98 | |
99 --- Change transitions | |
100 if newState ~= previous then | |
101 print(cText(' Transition')) | |
102 if newState == HIDDEN then | |
103 print(cText(' to HIDDEN')) | |
104 -- to HIDDEN | |
105 if previous then | |
106 -- has to have been ACTIVE or PASSIVE at this point | |
107 if previous == ACTIVE then | |
108 print(' from ACTIVE') | |
109 self.spiral:StopAnimating() | |
110 else | |
111 print(' from PASSIVE') | |
112 end | |
113 | |
114 self.Intro:Stop() | |
115 if self.event then | |
116 print(' set by event script') | |
117 self.Outro:Play() | |
118 else | |
119 print(' non-event source') | |
120 self:Hide() | |
121 end | |
122 end | |
123 -- want to end here if HIDDEN from nil | |
124 else | |
125 -- to ACTIVE or PASSIVE | |
126 self.Outro:Stop() -- stop any running outro | |
127 | |
128 | |
129 if newState == ACTIVE then | |
130 | |
131 -- and is ACTIVE | |
132 self:Show() | |
133 self.spiral:Show() | |
134 self.spiral:SetCooldown(self.charges and self.chargeStart or self.start, self.charges and self.chargeDuration or self.duration) | |
135 print('spiral:Play() new', self.charges and self.chargeStart or self.start, self.charges and self.chargeDuration or self.duration) | |
136 end | |
137 | |
138 if previous and previous ~= HIDDEN then | |
139 print(cText(' from vis')) | |
140 -- from visible | |
141 if self.event then | |
142 self.refresh = true | |
143 self.Retro:Play() | |
144 end | |
145 else | |
146 print(cText(' from non-vis')) | |
147 if self.event then | |
148 self.Intro:Play() | |
149 else | |
150 self:Show() | |
151 end | |
152 end | |
153 end | |
154 else | |
155 --- No-change transitions | |
156 if newState == ACTIVE then | |
157 -- ACTIVE to ACTIVE | |
158 print(cText('')) | |
159 self.spiral:Show() | |
160 self.spiral:SetCooldown(self.charges and self.chargeStart or self.start, self.charges and self.chargeDuration or self.duration) | |
161 print('spiral:Play() new', self.charges and self.chargeStart or self.start, self.charges and self.chargeDuration or self.duration) | |
162 else | |
163 print(cPink('stopping spiral')) | |
164 self.spiral:Hide() | |
165 end | |
166 | |
167 -- non-HIDDEN to non-HIDDEN and not a dry fire | |
168 if self.event and newState ~= HIDDEN then | |
169 self.refresh = true | |
170 self.Retro:Play() | |
171 end | |
172 end | |
173 | |
174 if newState ~= HIDDEN then | |
175 print(cText(' CVars:')) | |
176 local c | |
177 if newState == ACTIVE then | |
178 print('apply active profile') | |
179 c = self.cvars.active | |
180 self.fillState = 1 | |
181 else | |
182 print('apply passive profile') | |
183 c = self.cvars.passive | |
184 self.fillState = 2 | |
185 end | |
186 | |
187 if self.icon and c.icon then | |
188 | |
189 print(cText(' '), cWord('desat=')..cBool(c.icon.desaturated), cWord('color=')..cNum(tconcat(c.icon.color, ', '))) | |
190 self.icon:SetVertexColor(unpack(c.icon.color)) | |
191 self.icon:SetDesaturated(c.icon.desaturated) | |
192 end | |
193 self:UpdateAlpha(T.inCombat, self.displayState, self.fillState) | |
194 end | |
195 end | |
196 | |
197 p.Update = function(self) | |
198 | |
199 if self.displayState == 0 and self.prevState ~= 0 then | |
200 print('flip to', self.displayState) | |
201 self.prevState = self.displayState -- quietly advance state | |
202 self.percent = 1 | |
203 self.valueFull = 0 | |
204 self.value = 0 | |
205 self:SetText() | |
206 elseif self.displayState == 1 and self.prevState ~= 1 then | |
207 print('flip to', self.displayState) | |
208 self.prevState = self.displayState -- quietly advance state | |
209 self.valueFull = 0 | |
210 self.value = 0 | |
211 self.percent = 1 | |
212 self:SetText() | |
213 print(self.percent, self.duration, self.start, self.expires) | |
214 elseif self.displayState == 2 then | |
215 if self.prevState ~= 2 or self.refresh then | |
216 print('flipped to', self.displayState) | |
217 self.prevState = self.displayState -- quietly advance state | |
218 self.refresh = nil | |
219 end | |
220 -- prevState is set externally | |
221 local time = GetTime() | |
222 if self.expires <= time and self.charges == self.maxCharges then | |
223 _G.print(self.cvars.type, 'timer expired, set to', (self.cvars.persist and self.flags.passive or self.flags.hidden)) | |
224 self.percent = 1 | |
225 self.duration = 0 | |
226 self.expires = 0 | |
227 self.start= 0 | |
228 self.valueFull = self.duration | |
229 self.value = self.duration | |
230 self.elapsed = self.duration | |
231 self.remaining = 0 | |
232 self:SetState(self.cvars.persist and self.flags.passive or self.flags.hidden) | |
233 else | |
234 self.percent = (self.charges and self.charges < self.maxCharges) and ((time - self.chargeStart) / self.chargeDuration) or ((time - self.start) / self.duration) | |
235 self.valueFull = self.expires - time | |
236 self.elapsed = time - self.start | |
237 self.remaining = self.duration - time | |
238 | |
239 self.value = floor(self.valueFull) | |
240 end | |
241 | |
242 --PlaySoundFile(self.cvars.sound_active) | |
243 self:SetText() | |
244 end | |
245 end |