vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local sct_CRIT_FADEINTIME = 0.3;
2 local sct_CRIT_HOLDTIME = 2.0;
3 local sct_CRIT_FADEOUTTIME = 0.5;
4 local sct_CRIT_X_OFFSET = 100;
5 local sct_CRIT_Y_OFFSET = 75;
6 local sct_CRIT_SIZE_PERCENT = 1.25;
7 local sct_CRIT_FLASH_SIZE_PERCENT = 2;
8 local sct_MAX_SPEED = .025;
9 local sct_MIN_UPDATE_SPEED = .01;
10 local sct_SIDE_POINT = 210;
11 local sct_MAX_DISTANCE = 150;
12 local sct_DIRECTION = 1;
13 local sct_SPRINKLER_START = 18
14 local sct_SPRINKLER_STEP = -3;
15 local sct_SPRINKLER_RADIUS = 20;
16 local sct_SPRINKLER = sct_SPRINKLER_START;
17  
18 --Animation System variables
19 local sct_TEXTCOUNT = 30 -- Number of text that can animate
20 local arrAniData = {}; -- table to hold texts to animate
21 local arrAniData2 = {};
22 SCT.ArrayAniData = {arrAniData, arrAniData2};
23  
24 ----------------------
25 --Display the Text
26 function SCT:DisplayText(msg, color, iscrit, type, frame, anitype)
27 local adat, curDir;
28 local startpos, lastpos, textsize;
29  
30 --Set up text animation
31 adat = self:GetNextAniObj(frame);
32  
33 --set override animation
34 adat.anitype = anitype or adat.anitype;
35  
36 --If its a crit hit, increase the size
37 if (iscrit) then
38 adat.textsize = adat.textsize * sct_CRIT_SIZE_PERCENT;
39 if (self.db.profile["STICKYCRIT"]) then
40 adat.crit = true;
41 local critcount = self:CritCount(adat.frame);
42 adat.posY = (adat.toppoint + adat.posY)/2;
43 --if there are other Crits active, set offset.
44 if (critcount > 0) then
45 local randomposx = random(-1,1);
46 local randomposy = random(-1,1);
47 if randomposx == 0 and randomposy == 0 then randomposy = 1 end;
48 adat.posX = adat.posX + (randomposx*sct_CRIT_X_OFFSET);
49 adat.posY = adat.posY + (randomposy*sct_CRIT_Y_OFFSET);
50 end
51 --if flash crits are on
52 if (self.db.profile["FLASHCRIT"]) then
53 adat.critsize = adat.textsize * sct_CRIT_FLASH_SIZE_PERCENT;
54 if (adat.textsize > 32) then adat.textsize = 32 end;
55 end
56 end
57 end
58  
59 --if its not a sticky critm set up normal text start position
60 if (adat.crit ~= true) then
61 if (adat.anitype == 1) then
62 --get the last known point of active items
63 lastpos = self:MinPoint(adat.frame)
64 if (not adat.direction) then
65 --move the position down
66 if ((lastpos - adat.posY) <= adat.textsize) then
67 adat.posY = adat.posY - (adat.textsize - (lastpos - adat.posY));
68 end
69 --if its gone too far down, stop
70 if (adat.posY < (adat.bottompoint - sct_MAX_DISTANCE)) then
71 adat.posY = (adat.bottompoint - sct_MAX_DISTANCE)
72 adat.posX = adat.posX + (random(-1,1)*sct_CRIT_X_OFFSET)
73 end
74 adat.addY = self.db.profile["MOVEMENT"];
75 else
76 adat.posY = adat.toppoint
77 --move the position up
78 if ((adat.posY - lastpos) <= adat.textsize) then
79 adat.posY = adat.posY + (adat.textsize - (adat.posY - lastpos));
80 end
81 --if its gone too far up, stop
82 if (adat.posY > (adat.toppoint + sct_MAX_DISTANCE)) then
83 adat.posY = (adat.toppoint + sct_MAX_DISTANCE)
84 adat.posX = adat.posX + (random(-1,1)*sct_CRIT_X_OFFSET)
85 end
86 adat.addY = -1*self.db.profile["MOVEMENT"];
87 end
88 else
89 --get direction type
90 if (adat.sidedir == 1) then
91 sct_DIRECTION = sct_DIRECTION * -1;
92 curDir = sct_DIRECTION;
93 elseif (adat.sidedir == 2) then
94 if (type=="event") then curDir = -1 else curDir = 1 end
95 elseif (adat.sidedir == 3) then
96 if (type=="event") then curDir = 1 else curDir = -1 end
97 elseif (adat.sidedir == 4) then
98 curDir = 1;
99 elseif (adat.sidedir == 5) then
100 curDir = -1;
101 end
102 adat.sidedir = curDir;
103 --set animation start pos.
104 if (adat.anitype == 2) then
105 adat.addY = random(3,6);
106 adat.posX = adat.posX - (20 * adat.sidedir);
107 elseif (adat.anitype == 3) then
108 adat.posX = adat.posX - (55 * adat.sidedir);
109 adat.posY = adat.bottompoint + (random(0,200) - 100);
110 adat.addX = self.db.profile["MOVEMENT"];
111 elseif (adat.anitype == 4) then
112 adat.posX = adat.posX - (20 * adat.sidedir);
113 adat.addY = random(8,13);
114 adat.addX = random(8,13);
115 elseif (adat.anitype == 5) then
116 adat.posX = adat.posX - (20 * adat.sidedir);
117 adat.addY = random(10,15);
118 adat.addX = random(10,15);
119 elseif (adat.anitype == 6) then
120 adat.addX = sct_SPRINKLER;
121 adat.addY = math.sqrt((sct_SPRINKLER_RADIUS ^ 2) - math.abs((sct_SPRINKLER ^ 2)))
122 if ( adat.direction) then
123 adat.addY = adat.addY * -1;
124 end
125 sct_SPRINKLER = sct_SPRINKLER + sct_SPRINKLER_STEP;
126 if (sct_SPRINKLER < (sct_SPRINKLER_START * -1)) then
127 sct_SPRINKLER = sct_SPRINKLER_START;
128 end
129 end
130 end
131 end
132  
133 --set default color if none
134 if (not color) then color = {r = 1.0, g = 1.0, b = 1.0} end
135 --If they want to tag all self events
136 if (self.db.profile["SHOWSELF"]) then
137 msg = SCT.LOCALS.SelfFlag..msg..SCT.LOCALS.SelfFlag
138 end
139  
140 --set up text
141 self:SetFontSize(adat, adat.font, adat.textsize, adat.fontshadow);
142 adat:SetTextColor(color.r, color.g, color.b);
143 adat:SetAlpha(adat.alpha);
144 adat:SetPoint("CENTER", "UIParent", "CENTER", adat.posX, adat.posY);
145 adat:SetText(msg);
146 adat:Show();
147 tinsert(self.ArrayAniData[adat.frame], adat);
148 --Start up onUpdate
149 if (not SCT_ANIMATION_FRAME:IsVisible()) then
150 SCT_ANIMATION_FRAME:Show();
151 end
152 end
153  
154 ----------------------
155 -- Upate animations that are being used
156 function SCT:UpdateAnimation(elapsed)
157 local anyActive = false;
158 local i, key, value;
159 for i = 1, table.getn(self.ArrayAniData) do
160 for key, value in self.ArrayAniData[i] do
161 if (value:IsShown()) then
162 anyActive = true;
163 self:DoAnimation(value, elapsed);
164 end
165 end
166 end
167 --if none are active, stop onUpdate;
168 if ((anyActive ~= true) and (SCT_ANIMATION_FRAME:IsVisible())) then
169 SCT_ANIMATION_FRAME:Hide();
170 end
171 end
172  
173 ----------------------
174 --Move text to get the animation
175 function SCT:DoAnimation(aniData, elapsed)
176 local speed = self.db.profile["ANIMATIONSPEED"] / 1000;
177 --If a crit
178 aniData.lastupdate = aniData.lastupdate + elapsed;
179 if (aniData.crit) then
180 self:CritAnimation(aniData,speed);
181 --else normal text or event text
182 else
183 --if its time to update, move the text step positions
184 while (aniData.lastupdate > speed) do
185 --calculate animation
186 if (aniData.anitype == 1) then
187 self:VerticalAnimation(aniData);
188 elseif (aniData.anitype == 2) then
189 self:RainbowAnimation(aniData);
190 elseif (aniData.anitype == 3) then
191 self:HorizontalAnimation(aniData);
192 elseif (aniData.anitype == 4) then
193 self:AngledDownAnimation(aniData);
194 elseif (aniData.anitype == 5) then
195 self:AngledUpAnimation(aniData);
196 elseif (aniData.anitype == 6) then
197 self:SprinklerAnimation(aniData);
198 end
199 --set update on FPS mode
200 if (self.db.profile["FPSMODE"]) then
201 aniData.lastupdate = aniData.lastupdate - speed;
202 else
203 aniData.lastupdate = 0;
204 end
205 --move text
206 aniData:SetAlpha(aniData.alpha);
207 aniData:SetPoint("CENTER", "UIParent", "CENTER", aniData.posX, aniData.posY);
208 --reset when alpha is 0
209 if (aniData.alpha <= 0) then
210 self:AniReset(aniData);
211 end
212 end
213 end
214 end
215  
216 ----------------------
217 --Do Crit Animation
218 function SCT:CritAnimation(aniData,speed)
219 local elapsedTime = aniData.lastupdate;
220 local fadeInTime = sct_CRIT_FADEINTIME;
221 if ( elapsedTime < fadeInTime ) then
222 local alpha = (elapsedTime / fadeInTime);
223 alpha = alpha * aniData.alpha;
224 aniData:SetAlpha(alpha);
225 --if flash crits are on
226 if (aniData.critsize) then
227 local critsize = floor(aniData.critsize - ((aniData.critsize - aniData.textsize)*(elapsedTime/sct_CRIT_FADEINTIME)));
228 aniData:SetTextHeight(critsize);
229 end;
230 return;
231 end
232 --if flash crits are on, reset size to make sure its clean for display
233 if (aniData.critsize) then
234 aniData:SetTextHeight(aniData.textsize);
235 aniData.critsize = nil;
236 end
237 local holdTime = (sct_CRIT_HOLDTIME * (speed/sct_MAX_SPEED));
238 if ( elapsedTime < (fadeInTime + holdTime) ) then
239 aniData:SetAlpha(aniData.alpha);
240 return;
241 end
242 local fadeOutTime = sct_CRIT_FADEOUTTIME;
243 if ( elapsedTime < (fadeInTime + holdTime + fadeOutTime) ) then
244 local alpha = 1 - ((elapsedTime - holdTime - fadeInTime) / fadeOutTime);
245 alpha = alpha * aniData.alpha;
246 aniData:SetAlpha(alpha);
247 return;
248 end
249 --reset crit
250 self:AniReset(aniData);
251 end
252  
253 ----------------------
254 --Do Vertical Animation
255 function SCT:VerticalAnimation(aniData)
256 local step = math.abs(aniData.addY);
257 local alphastep = 0.01 * step;
258 local max = sct_MAX_DISTANCE*.66
259 aniData.delay = aniData.delay + 1;
260 if (aniData.delay > (max/step)) then
261 aniData.alpha = aniData.alpha - alphastep;
262 end
263 aniData.posY = aniData.posY + aniData.addY;
264 end
265  
266 ----------------------
267 --Do Rainbow Animation
268 function SCT:RainbowAnimation(aniData)
269 if (aniData.addY > 0) then
270 aniData.addY = aniData.addY - 0.22
271 else
272 aniData.addY = aniData.addY - (0.18 * (self.db.profile["MOVEMENT"]/2));
273 end
274 if aniData.addY < -7 then aniData.addY = -7 end ;
275 aniData.posY = aniData.posY + aniData.addY;
276 aniData.posX = aniData.posX - 2.2 * aniData.sidedir;
277 if ( aniData.posY < (aniData.bottompoint - sct_MAX_DISTANCE) ) then
278 aniData.alpha = aniData.alpha - 0.05;
279 end
280 end
281  
282 ----------------------
283 --Do Horizontal Animation
284 function SCT:HorizontalAnimation(aniData)
285 local step = math.abs(aniData.addX);
286 local alphastep = 0.01 * step;
287 local max = sct_SIDE_POINT*.5
288 aniData.delay = aniData.delay + 1;
289 if (aniData.delay > (max/step)) then
290 aniData.alpha = aniData.alpha - alphastep;
291 end
292 aniData.posX = aniData.posX - (aniData.addX * aniData.sidedir);
293 end
294  
295 ----------------------
296 --Do Angled Down Animation
297 function SCT:AngledDownAnimation(aniData)
298 if (aniData.delay <= 13) then
299 aniData.delay = aniData.delay + 1;
300 aniData.posY = aniData.posY - aniData.addY;
301 aniData.posX = aniData.posX - aniData.addX * aniData.sidedir;
302 elseif (aniData.delay <= 35) then
303 aniData.delay = aniData.delay + 1;
304 aniData.posY = aniData.posY + (random(0,70) - 35) * 0.02;
305 aniData.posX = aniData.posX + (random(0,70) - 35) * 0.02;
306 elseif (aniData.delay <= 50) then
307 aniData.delay = aniData.delay + 1;
308 else
309 aniData.posY = aniData.posY + self.db.profile["MOVEMENT"];
310 aniData.posX = aniData.posX - self.db.profile["MOVEMENT"] * aniData.sidedir;
311 aniData.alpha = aniData.alpha - 0.02;
312 end
313 end
314  
315 ----------------------
316 --Do Angled Up Animation
317 function SCT:AngledUpAnimation(aniData)
318 if (aniData.delay <= 13) then
319 aniData.delay = aniData.delay + 1;
320 aniData.posY = aniData.posY + aniData.addY;
321 aniData.posX = aniData.posX - aniData.addX * aniData.sidedir;
322 elseif (aniData.delay <= 35) then
323 aniData.delay = aniData.delay + 1;
324 aniData.posY = aniData.posY + (random(0,70) - 35) * 0.02;
325 aniData.posX = aniData.posX + (random(0,70) - 35) * 0.02;
326 elseif (aniData.delay <= 50) then
327 aniData.delay = aniData.delay + 1;
328 else
329 aniData.posY = aniData.posY + self.db.profile["MOVEMENT"];
330 aniData.alpha = aniData.alpha - 0.02;
331 end
332 end
333  
334 ----------------------
335 --Do Sprinkler Animation
336 function SCT:SprinklerAnimation(aniData)
337 if (aniData.delay <= (self.db.profile["MOVEMENT"] + 10)) then
338 aniData.delay = aniData.delay + 1;
339 aniData.posY = aniData.posY + aniData.addY;
340 aniData.posX = aniData.posX + aniData.addX;
341 elseif (aniData.delay <= 35) then
342 aniData.delay = aniData.delay + 1;
343 aniData.posY = aniData.posY + (random(0,70) - 35) * 0.02;
344 aniData.posX = aniData.posX + (random(0,70) - 35) * 0.02;
345 elseif (aniData.delay <= 55) then
346 aniData.delay = aniData.delay + 1;
347 else
348 aniData.posY = aniData.posY + (aniData.addY * .1);
349 aniData.posX = aniData.posX + (aniData.addX * .1);
350 aniData.alpha = aniData.alpha - 0.02;
351 end
352 end
353  
354 ----------------------
355 --count the number of crits active
356 function SCT:CritCount(frame)
357 local count = 0;
358 local key, value;
359 for key, value in self.ArrayAniData[frame] do
360 if (value.crit) and (value.source == "sct") then
361 count = count + 1;
362 end
363 end
364 return count;
365 end
366  
367 ----------------------
368 --get the min current min point
369 function SCT:MinPoint(frame)
370 local posY, key, value;
371 if (not self.db.profile[self.FRAMES_DATA_TABLE][frame]["DIRECTION"]) then
372 posY = self.db.profile[self.FRAMES_DATA_TABLE][frame]["YOFFSET"] + sct_MAX_DISTANCE;
373 for key, value in self.ArrayAniData[frame] do
374 if ((value:IsShown()) and (value.posY < posY) and (value.anitype == 1) and (not value.crit)) then
375 posY = value.posY;
376 end
377 end
378 else
379 posY = self.db.profile[self.FRAMES_DATA_TABLE][frame]["YOFFSET"];
380 for key, value in self.ArrayAniData[frame] do
381 if ((value:IsShown()) and (value.posY > posY) and (value.anitype == 1) and (not value.crit)) then
382 posY = value.posY;
383 end
384 end
385 end
386 return posY;
387 end
388  
389 -------------------------
390 --gets the next available animation object
391 --can be used by SCT addons since public
392 function SCT:GetNextAniObj(frame)
393 local adat, i;
394 local anyAvail = false;
395 --get first now shown
396 for i=1, sct_TEXTCOUNT do
397 adat = getglobal("SCTaniData"..i);
398 if ( not adat:IsShown() ) then
399 anyAvail = true;
400 break;
401 end
402 end
403 --if none availble, get oldest
404 if (not anyAvail) then
405 for i = 1, table.getn(self.ArrayAniData) do
406 adat = self.ArrayAniData[i][1];
407 if (adat) then break end;
408 end
409 self:AniReset(adat);
410 end
411 --set defaults based on frame
412 adat.frame = frame;
413 adat.posY = self.db.profile[self.FRAMES_DATA_TABLE][frame]["YOFFSET"];
414 adat.posX = self.db.profile[self.FRAMES_DATA_TABLE][frame]["XOFFSET"];
415 adat.bottompoint = adat.posY;
416 adat.toppoint = adat.posY + sct_MAX_DISTANCE;
417 adat.font = self.db.profile[self.FRAMES_DATA_TABLE][frame]["FONT"];
418 adat.fontshadow = self.db.profile[self.FRAMES_DATA_TABLE][frame]["FONTSHADOW"];
419 adat.textsize = self.db.profile[self.FRAMES_DATA_TABLE][frame]["TEXTSIZE"];
420 adat.alpha = self.db.profile[self.FRAMES_DATA_TABLE][frame]["ALPHA"]/100;
421 adat.anitype = self.db.profile[self.FRAMES_DATA_TABLE][frame]["ANITYPE"];
422 adat.anisidetype = self.db.profile[self.FRAMES_DATA_TABLE][frame]["ANISIDETYPE"];
423 adat.direction = self.db.profile[self.FRAMES_DATA_TABLE][frame]["DIRECTION"];
424 adat.sidedir = self.db.profile[self.FRAMES_DATA_TABLE][frame]["ANISIDETYPE"];
425 return adat
426 end
427  
428 ----------------------
429 --Rest the text animation
430 function SCT:AniReset(aniData)
431 local i, key, value
432 --remove it from display table
433 for i = 1, table.getn(self.ArrayAniData) do
434 for key, value in self.ArrayAniData[i] do
435 if ( value == aniData ) then
436 tremove(self.ArrayAniData[i], key);
437 break;
438 end
439 end
440 end
441 --reset all setings
442 aniData.crit = false;
443 aniData.critsize = nil;
444 aniData.posY = 0;
445 aniData.posX = 0;
446 aniData.addY = 0;
447 aniData.addX = 0;
448 aniData.alpha = 0;
449 aniData.lastupdate = 0;
450 aniData.delay = 0;
451 aniData.source = "sct";
452 aniData:SetAlpha(aniData.alpha);
453 aniData:Hide();
454 aniData:SetPoint("CENTER", "UIParent", "CENTER", aniData.posX, aniData.posY);
455 end
456  
457 ----------------------
458 --Rest all the text animations
459 function SCT:AniResetAll()
460 for i=1, sct_TEXTCOUNT do
461 local aniData = getglobal("SCTaniData"..i);
462 self:AniReset(aniData);
463 end
464 end
465  
466 ------------------------
467 --Initial animation settings
468 function SCT:AniInit()
469 self:AniResetAll();
470 self:SetMsgFont(SCT_MSG_FRAME);
471 SCT_MSG_FRAME:SetPoint("CENTER", "UIParent", "CENTER",
472 self.db.profile[self.FRAMES_DATA_TABLE][SCT.MSG]["MSGXOFFSET"],
473 self.db.profile[self.FRAMES_DATA_TABLE][SCT.MSG]["MSGYOFFSET"]);
474 SCT_MSG_FRAME:SetTimeVisible(self.db.profile[self.FRAMES_DATA_TABLE][SCT.MSG]["MSGFADE"]);
475 self:SetDmgFont();
476 end