vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- ArcHUDRingTemplate_ Ring Template |
2 | ---------------------------------------------------------------------- |
||
3 | -- |
||
4 | -- Template code for partial ring display |
||
5 | -- |
||
6 | -- Divides the ring up into four quadrants: |
||
7 | -- Q1-TopRight Q2-BottomRight Q3-BottomLeft Q4-TopLeft |
||
8 | -- |
||
9 | -- Other terminology: |
||
10 | -- self.radius - The outer radius of the ring (Also the texture width) |
||
11 | -- self.ringFactor - The ratio of inner radius/outer radius |
||
12 | |||
13 | --------------------------------------------------------------------------- |
||
14 | -- QUADRANT MAPPING FUNCTIONS |
||
15 | -- The subsetting code is all written relative to the first quandrant, but |
||
16 | -- each quadrant has a pair of functions to manage mapping location and |
||
17 | -- texture operations from that 'normalized' coordinate system into the |
||
18 | -- appropriate one for the quadrant in question |
||
19 | -- |
||
20 | -- SUBSET FUNCTION |
||
21 | -- self function displays a subset of a quadrant, using a subset of a |
||
22 | -- texture (The texture subsetting is optional, so the same function |
||
23 | -- can be used for slice stretching). Note self does not issue a |
||
24 | -- ClearAllPoints. |
||
25 | -- |
||
26 | -- setSubsetFuncs[quadrant](tex, parname, radius, xlo, xhi, ylo, yhi, notex) |
||
27 | -- |
||
28 | -- Parameters: |
||
29 | -- tex - The texture object |
||
30 | -- parname - The name of the texture's parent (for SetPoint use) |
||
31 | -- radius - The outer radius of the ring (i.e. texture width & height) |
||
32 | -- xlo, xhi - X Coordinate bounds (from center of the ring) |
||
33 | -- ylo, yhi - Y Coordinate bounds (From center of the ring) |
||
34 | -- notex - (OPTIONAL) If present and true, do not set texture coords. |
||
35 | -- just change points. |
||
36 | -- |
||
37 | -- SLICE FUNCTION |
||
38 | -- self function sets the texture coordinates for a slice texture, so that |
||
39 | -- it's correctly oriented for the quadrant. |
||
40 | -- |
||
41 | -- setSliceFuncs[quadrant](tex) |
||
42 | -- |
||
43 | -- Parameters: |
||
44 | -- tex - The slice texture object |
||
45 | -- |
||
46 | local setSubsetFuncs = {} |
||
47 | local setSliceFuncs = {} |
||
48 | ArcHUDRingTemplate = {} |
||
49 | |||
50 | -- Q3: BOTTOM LEFT |
||
51 | setSubsetFuncs[1] = function(tex, parname, radius, xlo, xhi, ylo, yhi, notex) |
||
52 | if (not notex) then |
||
53 | tex:SetTexCoord(xhi, xlo, ylo, yhi) |
||
54 | end |
||
55 | tex:SetPoint("BOTTOMRIGHT", parname, "BOTTOMLEFT", -xlo*radius, -yhi*radius) |
||
56 | tex:SetPoint("TOPLEFT", parname, "BOTTOMLEFT", -xhi*radius, -ylo*radius) |
||
57 | end |
||
58 | |||
59 | -- Q4: TOP LEFT |
||
60 | setSubsetFuncs[2] = function(tex, parname, radius, xlo, xhi, ylo, yhi, notex) |
||
61 | if (not notex) then |
||
62 | tex:SetTexCoord(yhi, ylo, xhi, xlo) |
||
63 | end |
||
64 | tex:SetPoint("BOTTOMLEFT", parname, "BOTTOMLEFT", -yhi*radius, xlo*radius) |
||
65 | tex:SetPoint("TOPRIGHT", parname, "BOTTOMLEFT", -ylo*radius, xhi*radius) |
||
66 | end |
||
67 | |||
68 | -- Q1: TOP RIGHT |
||
69 | setSubsetFuncs[3] = function(tex, parname, radius, xlo, xhi, ylo, yhi, notex) |
||
70 | if (not notex) then |
||
71 | tex:SetTexCoord(xlo, xhi, yhi, ylo) |
||
72 | end |
||
73 | tex:SetPoint("TOPLEFT", parname, "BOTTOMLEFT", xlo*radius, yhi*radius) |
||
74 | tex:SetPoint("BOTTOMRIGHT", parname, "BOTTOMLEFT", xhi*radius, ylo*radius) |
||
75 | end |
||
76 | |||
77 | -- Q2: BOTTOM RIGHT |
||
78 | setSubsetFuncs[4] = function(tex, parname, radius, xlo, xhi, ylo, yhi, notex) |
||
79 | if (not notex) then |
||
80 | tex:SetTexCoord(ylo, yhi, xlo, xhi) |
||
81 | end |
||
82 | tex:SetPoint("TOPRIGHT", parname, "BOTTOMLEFT", yhi*radius, -xlo*radius) |
||
83 | tex:SetPoint("BOTTOMLEFT", parname, "BOTTOMLEFT", ylo*radius, -xhi*radius) |
||
84 | end |
||
85 | |||
86 | -- Slice text coord setting funcs |
||
87 | setSliceFuncs[1] = function(tex) tex:SetTexCoord(0, 1, 1, 0) end |
||
88 | setSliceFuncs[2] = function(tex) tex:SetTexCoord(1, 0, 1, 0) end |
||
89 | setSliceFuncs[3] = function(tex) tex:SetTexCoord(1, 0, 0, 1) end |
||
90 | setSliceFuncs[4] = function(tex) tex:SetTexCoord(0, 1, 0, 1) end |
||
91 | |||
92 | -- The 'Work' function, which handles subset rendering for a single |
||
93 | -- quadrant (normalized to Q1) |
||
94 | -- |
||
95 | -- Params: |
||
96 | -- self - The ring template instance |
||
97 | -- A - The angle within the quadrant (degrees, 0 <= A < 90) |
||
98 | -- T - The main texture for the quadrant |
||
99 | -- SS - The texture subset mapping function for the quadrant |
||
100 | |||
101 | function ArcHUDRingTemplate:DoQuadrantReversed(A, T, SS) |
||
102 | -- Grab local references to important textures |
||
103 | local C = self.chip |
||
104 | local S = self.slice |
||
105 | |||
106 | -- If no part of self quadrant is visible, just hide all the textures |
||
107 | -- and be done. |
||
108 | if (A == 0) then |
||
109 | T:Hide() |
||
110 | C:Hide() |
||
111 | S:Hide() |
||
112 | return |
||
113 | end |
||
114 | |||
115 | -- More local references, grab the ring dimensions, and the frame name. |
||
116 | local RF = self.ringFactor |
||
117 | local OR = self.radius |
||
118 | --local name = self.name |
||
119 | |||
120 | -- Drawing scheme uses three locations |
||
121 | -- E (Ex,Ey) - The 'End' position (Nx=1, Ny=0) |
||
122 | -- O (Ox,Oy) - Intersection of angle line with Outer edge |
||
123 | -- I (Ix,Iy) - Intersection of angle line with Inner edge |
||
124 | |||
125 | -- Calculated locations: |
||
126 | -- Arad - Angle in radians |
||
127 | -- Ox,Oy - O coordinates |
||
128 | -- Ix,Iy - I coordinates |
||
129 | local Arad = math.rad(A) |
||
130 | local Ox = math.cos(Arad) |
||
131 | local Oy = math.sin(Arad) |
||
132 | local Ix = Ox * RF |
||
133 | local Iy = Oy * RF |
||
134 | |||
135 | -- Treat first and last halves differently to maximize size of main |
||
136 | -- texture subset. |
||
137 | if (A <= 45) then |
||
138 | -- Main subset is from N to I |
||
139 | SS(T, self, OR, Ix, 1, 0, Iy) |
||
140 | -- Chip is subset from (Ix,Oy) to (Ox,Ny) (Right edge of main) |
||
141 | SS(C, self, OR, Ox, 1, Iy, Oy) |
||
142 | else |
||
143 | -- Main subset is from N to O |
||
144 | SS(T, self, OR, Ox, 1, 0, Oy) |
||
145 | -- Chip is subset from (Nx,Iy) to (Ix,Oy) (Bottom edge of main) |
||
146 | SS(C, self, OR, Ix, Ox, 0, Iy) |
||
147 | end |
||
148 | -- Strech slice between I and O |
||
149 | SS(S, self, OR, Ix, Ox, Iy, Oy, 1) |
||
150 | -- All three textures are visible |
||
151 | T:Show() |
||
152 | C:Show() |
||
153 | S:Show() |
||
154 | end |
||
155 | |||
156 | function ArcHUDRingTemplate:DoQuadrant(A, T, SS) |
||
157 | -- Grab local references to important textures |
||
158 | local C = self.chip |
||
159 | local S = self.slice |
||
160 | |||
161 | -- If no part of self quadrant is visible, just hide all the textures |
||
162 | -- and be done. |
||
163 | if (A == 0) then |
||
164 | T:Hide() |
||
165 | C:Hide() |
||
166 | S:Hide() |
||
167 | return |
||
168 | end |
||
169 | |||
170 | -- More local references, grab the ring dimensions, and the frame name. |
||
171 | local RF = self.ringFactor |
||
172 | local OR = self.radius |
||
173 | --local name = self.name |
||
174 | |||
175 | -- Drawing scheme uses three locations |
||
176 | -- N (Nx,Ny) - The 'Noon' position (Nx=0, Ny=1) |
||
177 | -- O (Ox,Oy) - Intersection of angle line with Outer edge |
||
178 | -- I (Ix,Iy) - Intersection of angle line with Inner edge |
||
179 | |||
180 | -- Calculated locations: |
||
181 | -- Arad - Angle in radians |
||
182 | -- Ox,Oy - O coordinates |
||
183 | -- Ix,Iy - I coordinates |
||
184 | local Arad = math.rad(A) |
||
185 | local Ox = math.sin(Arad) |
||
186 | local Oy = math.cos(Arad) |
||
187 | local Ix = Ox * RF |
||
188 | local Iy = Oy * RF |
||
189 | |||
190 | -- Treat first and last halves differently to maximize size of main |
||
191 | -- texture subset. |
||
192 | if (A <= 45) then |
||
193 | -- Main subset is from N to I |
||
194 | SS(T, self, OR, 0, Ix, Iy, 1) |
||
195 | -- Chip is subset from (Ix,Oy) to (Ox,Ny) (Right edge of main) |
||
196 | SS(C, self, OR, Ix, Ox, Oy, 1) |
||
197 | else |
||
198 | -- Main subset is from N to O |
||
199 | SS(T, self, OR, 0, Ox, Oy, 1) |
||
200 | -- Chip is subset from (Nx,Iy) to (Ix,Oy) (Bottom edge of main) |
||
201 | SS(C, self, OR, 0, Ix, Iy, Oy) |
||
202 | end |
||
203 | -- Strech slice between I and O |
||
204 | SS(S, self, OR, Ix, Ox, Iy, Oy, 1) |
||
205 | -- All three textures are visible |
||
206 | T:Show() |
||
207 | C:Show() |
||
208 | S:Show() |
||
209 | end |
||
210 | |||
211 | -- Method function to set the angle to display |
||
212 | -- |
||
213 | -- Param: |
||
214 | -- self - The ring template instance |
||
215 | -- angle - The angle in degrees (0 <= angle <= 180) |
||
216 | |||
217 | function ArcHUDRingTemplate:SetAngle(angle) |
||
218 | |||
219 | -- Bounds checking on the angle so that it's between 0 and 180 (inclusive) |
||
220 | if (angle < 0) then |
||
221 | angle = 0 |
||
222 | end |
||
223 | if (angle > 180) then |
||
224 | angle = 180 |
||
225 | end |
||
226 | |||
227 | -- Avoid duplicate work |
||
228 | if (self.angle == angle and not self.dirty) then |
||
229 | return |
||
230 | end |
||
231 | |||
232 | -- Determine the quadrant, and angle within the quadrant |
||
233 | -- (Quadrant 5 means 'all quadrants filled') |
||
234 | local quad = math.floor(angle / 90) + 1 |
||
235 | local A = math.mod(angle, 90) |
||
236 | local quadOfs = self.quadOffset or 0 |
||
237 | local effQuad |
||
238 | if (self.reversed) then |
||
239 | effQuad = math.mod((4-quad)+quadOfs, 4)+1 |
||
240 | else |
||
241 | effQuad = math.mod(quad+quadOfs-1, 4)+1 |
||
242 | end |
||
243 | |||
244 | -- Check to see if we've changed quandrants since the last time we were |
||
245 | -- called. Quadrant changes re-configure some textures. |
||
246 | if (quad ~= self.lastQuad or self.dirty) then |
||
247 | -- Loop through all quadrants |
||
248 | for i=1,2 do |
||
249 | T=self.quadrants[i] |
||
250 | if (self.reversed) then |
||
251 | qi = math.mod((4-i)+quadOfs, 4)+1 |
||
252 | else |
||
253 | qi = math.mod(i+quadOfs-1, 4)+1 |
||
254 | end |
||
255 | if (i < quad) then |
||
256 | -- If self quadrant is full shown, then show all of the texture |
||
257 | T:ClearAllPoints() |
||
258 | --if (self.reversed) then |
||
259 | --setSubsetFuncs[i+2](T, self.name, self.radius, 0.0, 1.0, 0.0, 1.0) |
||
260 | --else |
||
261 | setSubsetFuncs[qi](T, self, self.radius, 0.0, 1.0, 0.0, 1.0) |
||
262 | --end |
||
263 | |||
264 | T:Show() |
||
265 | elseif (i == quad) then |
||
266 | -- If self quadrant is partially or fully shown, begin by |
||
267 | -- showing all of the texture. Also configure the slice |
||
268 | -- texture's orientation. |
||
269 | T:ClearAllPoints() |
||
270 | setSubsetFuncs[qi](T, self, self.radius, 0.0, 0.8, 0.4, 1.0) |
||
271 | --[[ |
||
272 | if (self.reversed) then |
||
273 | setSubsetFuncs[qi](T, self.name, self.radius, 0.0, 0.8, 0.4, 1.0) |
||
274 | else |
||
275 | setSubsetFuncs[i](T, self.name, self.radius, 0.0, 0.8, 0.4, 1.0) |
||
276 | end |
||
277 | ]] |
||
278 | T:Show() |
||
279 | if (self.reversed) then |
||
280 | setSliceFuncs[math.mod(qi+1,4)+1](self.slice) |
||
281 | else |
||
282 | setSliceFuncs[qi](self.slice) |
||
283 | end |
||
284 | --[[ |
||
285 | if (self.reversed) then |
||
286 | setSliceFuncs[i+2](self.slice) |
||
287 | else |
||
288 | setSliceFuncs[i](self.slice) |
||
289 | end |
||
290 | ]] |
||
291 | else |
||
292 | -- If self quadrant is not shown at all, hide it. |
||
293 | T:Hide() |
||
294 | end |
||
295 | end |
||
296 | |||
297 | -- Hide the chip and slice textures, and de-anchor them (They'll be |
||
298 | -- re-anchored as necessary later). |
||
299 | self.chip:Hide() |
||
300 | self.chip:ClearAllPoints() |
||
301 | self.slice:Hide() |
||
302 | self.slice:ClearAllPoints() |
||
303 | |||
304 | -- Remember self for next time |
||
305 | self.lastQuad = quad |
||
306 | end |
||
307 | |||
308 | -- Remember the angle for next time |
||
309 | self.angle = angle |
||
310 | |||
311 | -- Extra bounds check for paranoia (also handles quad 5 case) |
||
312 | if ((quad < 1) or (quad > 2)) then |
||
313 | return |
||
314 | end |
||
315 | |||
316 | -- Get quadrant-specific elements |
||
317 | local T = self.quadrants[quad] |
||
318 | --local SS = setSubsetFuncs[quad] |
||
319 | local SS = setSubsetFuncs[effQuad] |
||
320 | |||
321 | -- Call the quadrant function to do the work |
||
322 | if SS ~= nil then |
||
323 | if (self.reversed) then |
||
324 | self:DoQuadrantReversed(A, T, SS) |
||
325 | else |
||
326 | self:DoQuadrant(A, T, SS) |
||
327 | end |
||
328 | end |
||
329 | self.dirty = false |
||
330 | end |
||
331 | |||
332 | |||
333 | |||
334 | --------------------------------------------------------------------------- |
||
335 | -- Some handy method functions |
||
336 | |||
337 | -- StatsRingRingTemplate:CallTextureMethod(method, ...) |
||
338 | -- |
||
339 | -- Invokes the named method on all of the textures in the ring, |
||
340 | -- passing in whatever arguments are given. |
||
341 | -- |
||
342 | -- e.g. ring:CallTextureMethod("SetVertexColor", 1.0, 0.5, 0.2, 1.0) |
||
343 | |||
344 | function ArcHUDRingTemplate:CallTextureMethod(method, ...) |
||
345 | self.quadrants[1][method](self.quadrants[1], unpack(arg)) |
||
346 | self.quadrants[2][method](self.quadrants[2], unpack(arg)) |
||
347 | self.chip[method](self.chip, unpack(arg)) |
||
348 | self.slice[method](self.slice, unpack(arg)) |
||
349 | end |
||
350 | |||
351 | |||
352 | -- StatsRingRingTemplate:SetRingTextures(ringFactor,ringTexFile,sliceTexFile) |
||
353 | -- |
||
354 | -- Sets the textures to use for self ring |
||
355 | -- |
||
356 | -- Param: |
||
357 | -- ringFactor - The ring factor (Inner Radius / Outer Radius) |
||
358 | -- ringTexFile - The ring texture filename |
||
359 | -- sliceTexFile - The slice texture filename |
||
360 | |||
361 | function ArcHUDRingTemplate:SetRingTextures(ringFactor, |
||
362 | ringTexture, |
||
363 | sliceTexture) |
||
364 | DEFAULT_CHAT_FRAME:AddMessage("called setringtextures") |
||
365 | local savedAngle = self.angle |
||
366 | self.angle = nil |
||
367 | self.lastQuad = nil |
||
368 | |||
369 | self.ringFactor = ringFactor |
||
370 | |||
371 | for i=1,2 do |
||
372 | self.quadrants[i]:SetTexture(ringTexture) |
||
373 | end |
||
374 | self.chip:SetTexture(ringTexture) |
||
375 | self.slice:SetTexture(sliceTexture) |
||
376 | |||
377 | if (savedAngle) then |
||
378 | self:SetAngle(savedAngle) |
||
379 | end |
||
380 | end |
||
381 | |||
382 | -- Method function to set whether or not ring growth is reversed. |
||
383 | -- |
||
384 | -- Param: |
||
385 | -- self - The ring template instance |
||
386 | -- isReversed - Whether to reverse or not |
||
387 | function ArcHUDRingTemplate:SetReversed(isReversed) |
||
388 | if (isReversed) then |
||
389 | isReversed = true |
||
390 | else |
||
391 | isReversed = nil |
||
392 | end |
||
393 | if (isReversed == self.reversed) then |
||
394 | return |
||
395 | end |
||
396 | self.reversed = isReversed |
||
397 | self.dirty = true |
||
398 | end |
||
399 | |||
400 | function ArcHUDRingTemplate:SetMax(max) |
||
401 | if max == nil then max = 1 end |
||
402 | self.maxValue = max |
||
403 | end |
||
404 | |||
405 | function ArcHUDRingTemplate:SetValue(value) |
||
406 | if value == nil then value = 0 end |
||
407 | if value == 0 then |
||
408 | value = self.maxValue / 10000 |
||
409 | end |
||
410 | if self.casting == 1 then |
||
411 | self.startValue = value end |
||
412 | self.endValue = value |
||
413 | self.fadeTime = 0 |
||
414 | end |
||
415 | |||
416 | function ArcHUDRingTemplate:DoFadeUpdate(tdelta) |
||
417 | tdelta = arg1 |
||
418 | if self.fadeTime < self.maxFadeTime then |
||
419 | self.fadeTime = self.fadeTime + tdelta |
||
420 | if self.fadeTime > self.maxFadeTime then |
||
421 | self.fadeTime = self.maxFadeTime |
||
422 | end |
||
423 | local delta = self.endValue - self.startValue |
||
424 | local diff = delta * (self.fadeTime / self.maxFadeTime) |
||
425 | self.startValue = self.startValue + diff |
||
426 | local angle = self.startValue / self.maxValue * 180 |
||
427 | if angle <= 90 then |
||
428 | self.ringFactor = 0.9 + ((90 - angle) / (90/0.1)) |
||
429 | elseif angle <= 180 then |
||
430 | self.ringFactor = 0.9 + ((angle - 90) / (90/0.1)) |
||
431 | --[[ |
||
432 | elseif angle <= 270 then |
||
433 | self.ringFactor = 0.9 + ((270 - angle) / (90/0.1)) |
||
434 | elseif angle > 270 then |
||
435 | self.ringFactor = 0.9 + ((angle - 270) / (90/0.1)) |
||
436 | ]] |
||
437 | end |
||
438 | self:SetAngle((self.startValue / self.maxValue) * 180) |
||
439 | end |
||
440 | end |
||
441 | |||
442 | function ArcHUDRingTemplate:AlphaUpdate() |
||
443 | --[[ |
||
444 | if getglobal(self:GetName() .. "MoveAnchor"):IsVisible() then |
||
445 | self:SetAlpha(0.8) |
||
446 | self:SetAngle(180) |
||
447 | return |
||
448 | end |
||
449 | ]] |
||
450 | if(not self.fadeIn) then |
||
451 | self.fadeIn = 1 |
||
452 | end |
||
453 | if(not self.fadeOut) then |
||
454 | self.fadeOut = 1 |
||
455 | end |
||
456 | local destAlpha = self.destAlpha |
||
457 | if (not destAlpha) then |
||
458 | return |
||
459 | end |
||
460 | local nowAlpha = self:GetAlpha() |
||
461 | if (nowAlpha < destAlpha) then |
||
462 | nowAlpha = nowAlpha + (arg1/self.fadeIn) |
||
463 | if (nowAlpha > destAlpha) then |
||
464 | nowAlpha = destAlpha |
||
465 | end |
||
466 | elseif (nowAlpha > destAlpha) then |
||
467 | nowAlpha = nowAlpha - (arg1/self.fadeOut) |
||
468 | if (nowAlpha < destAlpha) then |
||
469 | nowAlpha = destAlpha |
||
470 | end |
||
471 | end |
||
472 | |||
473 | self:SetAlpha(nowAlpha) |
||
474 | |||
475 | if (destAlpha == nowAlpha) then |
||
476 | self.destAlpha = nil |
||
477 | end |
||
478 | end |
||
479 | |||
480 | function ArcHUDRingTemplate:SetRingAlpha(destAlpha, instant) |
||
481 | |||
482 | if (destAlpha < 0) then |
||
483 | destAlpha = 0.0 |
||
484 | elseif (destAlpha > 1) then |
||
485 | destAlpha = 1.0 |
||
486 | end |
||
487 | |||
488 | if (instant) then |
||
489 | self:SetAlpha(destAlpha) |
||
490 | self.destAlpha = nil |
||
491 | return |
||
492 | end |
||
493 | |||
494 | if (self:GetAlpha() == destAlpha) then |
||
495 | return |
||
496 | end |
||
497 | if (self.destAlpha == destAlpha) then |
||
498 | return |
||
499 | end |
||
500 | |||
501 | self.destAlpha = destAlpha |
||
502 | end |
||
503 | |||
504 | function ArcHUDRingTemplate:UpdateColor(color) |
||
505 | if color == nil then |
||
506 | color = {["r"] = 1, ["g"] = 0.6, ["b"] = 0.1} |
||
507 | end |
||
508 | if (color) then |
||
509 | self:CallTextureMethod("SetVertexColor",color.r, color.g, color.b,1) |
||
510 | end |
||
511 | end |
||
512 | |||
513 | function ArcHUDRingTemplate:UpdateAlpha() |
||
514 | |||
515 | local isInCombat = false |
||
516 | |||
517 | if(self == self.parent:GetModule("PetHealth") or self == self.parent:GetModule("PetMana")) then |
||
518 | isInCombat = self.parent.PetIsInCombat |
||
519 | elseif(string.find(self.name, "Party")) then |
||
520 | isInCombat = self.isInCombat or false |
||
521 | else |
||
522 | isInCombat = self.parent.PlayerIsInCombat |
||
523 | end |
||
524 | |||
525 | if(self.f.pulse) then |
||
526 | self.f.alphaPulse = self.f.alphaPulse + (arg1/2) |
||
527 | local camt = math.cos(self.f.alphaPulse * self.f.twoPi) * 0.3 |
||
528 | self.f:SetAlpha(0.5-camt) |
||
529 | else |
||
530 | if(self.parent.db.profile.RingVisibility == 1 or self.parent.db.profile.RingVisibility == 3) then |
||
531 | |||
532 | if(self.parent.db.profile.RingVisibility == 3 and isInCombat) then |
||
533 | if(self == self.parent:GetModule("TargetHealth") and UnitIsDead("target")) then |
||
534 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
535 | elseif(self == self.parent:GetModule("TargetMana") and (UnitIsDead("target") or self.f.maxValue == 0)) then |
||
536 | self.f:SetRingAlpha(0) |
||
537 | elseif((self == self.parent:GetModule("TargetHealth") or self == self.parent:GetModule("TargetMana")) and not UnitExists("target")) then |
||
538 | self.f:SetRingAlpha(0) |
||
539 | elseif((self == self.parent:GetModule("PetHealth") or self == self.parent:GetModule("PetMana")) and not UnitExists("pet")) then |
||
540 | self.f:SetRingAlpha(0) |
||
541 | else |
||
542 | self.f:SetRingAlpha(self.parent.db.profile.FadeIC) |
||
543 | end |
||
544 | else |
||
545 | if(string.find(self.name, "Mana") and self ~= self.parent:GetModule("PetMana") and UnitPowerType(self.unit or self:GetParent().unit or "player") == 1 and self.f.maxValue > 0) then |
||
546 | if(math.floor(self.f.startValue) > 0) then |
||
547 | self.f:SetRingAlpha(self.parent.db.profile.FadeOOC) |
||
548 | elseif(math.floor(self.f.startValue) == 0) then |
||
549 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
550 | end |
||
551 | else |
||
552 | if(self == self.parent:GetModule("TargetHealth") and UnitIsDead("target")) then |
||
553 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
554 | elseif(self == self.parent:GetModule("TargetMana") and (UnitIsDead("target") or self.f.maxValue == 0)) then |
||
555 | self.f:SetRingAlpha(0) |
||
556 | elseif((self == self.parent:GetModule("TargetHealth") or self == self.parent:GetModule("TargetMana")) and not UnitExists("target")) then |
||
557 | self.f:SetRingAlpha(0) |
||
558 | elseif((self == self.parent:GetModule("PetHealth") or self == self.parent:GetModule("PetMana")) and not UnitExists("pet")) then |
||
559 | self.f:SetRingAlpha(0) |
||
560 | else |
||
561 | if(self.f.startValue < self.f.maxValue) then |
||
562 | self.f:SetRingAlpha(self.parent.db.profile.FadeOOC) |
||
563 | elseif(self.f.startValue == self.f.maxValue) then |
||
564 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
565 | end |
||
566 | end |
||
567 | end |
||
568 | end |
||
569 | |||
570 | elseif(self.parent.db.profile.RingVisibility == 2) then |
||
571 | |||
572 | if(self == self.parent:GetModule("TargetHealth") and UnitIsDead("target")) then |
||
573 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
574 | elseif(self == self.parent:GetModule("TargetMana") and (UnitIsDead("target") or self.f.maxValue == 0)) then |
||
575 | self.f:SetRingAlpha(0) |
||
576 | elseif((self == self.parent:GetModule("TargetHealth") or self == self.parent:GetModule("TargetMana")) and not UnitExists("target")) then |
||
577 | self.f:SetRingAlpha(0) |
||
578 | elseif((self == self.parent:GetModule("PetHealth") or self == self.parent:GetModule("PetMana")) and not UnitExists("pet")) then |
||
579 | self.f:SetRingAlpha(0) |
||
580 | else |
||
581 | if(isInCombat) then |
||
582 | self.f:SetRingAlpha(self.parent.db.profile.FadeIC) |
||
583 | else |
||
584 | self.f:SetRingAlpha(self.parent.db.profile.FadeFull) |
||
585 | end |
||
586 | end |
||
587 | end |
||
588 | end |
||
589 | end |
||
590 | |||
591 | function ArcHUDRingTemplate:GhostMode(state, unit) |
||
592 | local color = {["r"] = 0.75, ["g"] = 0.75, ["b"] = 0.75} |
||
593 | local fh, fm |
||
594 | if(unit == "player") then |
||
595 | fh, fm = ArcHUD:GetModule("Health"), ArcHUD:GetModule("Mana") |
||
596 | else |
||
597 | fh, fm = ArcHUD:GetModule("TargetHealth"), ArcHUD:GetModule("TargetMana") |
||
598 | end |
||
599 | if(state) then |
||
600 | -- Prepare health ring |
||
601 | if(fh and not fh.f.pulse) then |
||
602 | fh.f:UpdateColor(color) |
||
603 | fh.f.alphaPulse = 0 |
||
604 | fh.f:SetMax(1) |
||
605 | fh.f:SetValue(1) |
||
606 | if(unit == "player") then |
||
607 | fh.HPText:SetText("Dead") |
||
608 | fh.HPText:SetTextColor(1, 0, 0) |
||
609 | fh.HPPerc:SetText("") |
||
610 | else |
||
611 | fh.HPPerc:SetText("Dead") |
||
612 | end |
||
613 | -- Enable pulsing |
||
614 | fh.f.pulse = true |
||
615 | end |
||
616 | |||
617 | -- Prepare mana ring |
||
618 | if(fm and unit == "player" and not fm.f.pulse) then |
||
619 | fm.f:UpdateColor(color) |
||
620 | fm.f.alphaPulse = 0 |
||
621 | fm.f:SetMax(1) |
||
622 | fm.f:SetValue(1) |
||
623 | fm.MPText:SetText("") |
||
624 | fm.MPPerc:SetText("") |
||
625 | -- Enable pulsing |
||
626 | fm.f.pulse = true |
||
627 | end |
||
628 | else |
||
629 | if(fh and fh.f.pulse) then |
||
630 | fh.f.pulse = false |
||
631 | fh.f:SetMax(UnitHealthMax(unit)) |
||
632 | fh.f:SetValue(UnitHealth(unit)) |
||
633 | end |
||
634 | if(fm and fm.f.pulse) then |
||
635 | fm.f.pulse = false |
||
636 | fm.f:SetMax(UnitManaMax(unit)) |
||
637 | fm.f:SetValue(UnitMana(unit)) |
||
638 | fm.f:UpdateColor(ManaBarColor[UnitPowerType(unit)]) |
||
639 | end |
||
640 | end |
||
641 | end |
||
642 | |||
643 | -- The OnLoad method, call self for each template object to set it up and |
||
644 | -- get things going |
||
645 | function ArcHUDRingTemplate:OnLoad(frame) |
||
646 | -- Just do global self resolution once. |
||
647 | --local self = self |
||
648 | |||
649 | -- Grab texture references and frame name |
||
650 | --frame.name = frame |
||
651 | if(not frame.quadrants) then |
||
652 | frame.quadrants = {} |
||
653 | frame.quadrants[1] = getglobal(frame.name .. "TQ1") |
||
654 | frame.quadrants[2] = getglobal(frame.name .. "TQ2") |
||
655 | frame.chip = getglobal(frame.name .. "TC") |
||
656 | frame.slice = getglobal(frame.name .. "TS") |
||
657 | end |
||
658 | |||
659 | -- Initialize size and default texture ringFactor |
||
660 | frame.radius = (frame:GetWidth() * 0.5) |
||
661 | frame.ringFactor = 0.94 |
||
662 | |||
663 | -- Add ring methods |
||
664 | frame.DoQuadrant = self.DoQuadrant |
||
665 | frame.DoQuadrantReversed = self.DoQuadrantReversed |
||
666 | frame.SetAngle = self.SetAngle |
||
667 | frame.CallTextureMethod = self.CallTextureMethod |
||
668 | frame.SetRingTextures = self.SetRingTextures |
||
669 | frame.SetMax = self.SetMax |
||
670 | frame.SetValue = self.SetValue |
||
671 | frame.Update = self.Update |
||
672 | frame.AddUpdateFunction = self.AddUpdateFunction |
||
673 | frame.RemoveUpdateFunction = self.RemoveUpdateFunction |
||
674 | frame.UpdateColor = self.UpdateColor |
||
675 | frame.SetReversed = self.SetReversed |
||
676 | frame.SetRingAlpha = self.SetRingAlpha |
||
677 | frame.GhostMode = self.GhostMode |
||
678 | |||
679 | frame.startValue = 0 |
||
680 | frame.endValue = 0 |
||
681 | frame.maxValue = 0 |
||
682 | frame.fadeTime = 0 |
||
683 | frame.maxFadeTime = 1 |
||
684 | frame.alphaState = -1 |
||
685 | frame.PI = 3.14159265 |
||
686 | frame.twoPi = (frame.PI * 2) |
||
687 | frame.pulse = false |
||
688 | frame.alphaPulse = 0 |
||
689 | |||
690 | |||
691 | -- Set angle to zero (initializes texture visibility) |
||
692 | frame:SetAngle(0) |
||
693 | end |
||
694 | |||
695 | function ArcHUDRingTemplate:OnLoadBG(frame) |
||
696 | -- Grab texture references and frame name |
||
697 | --frame.name = frame |
||
698 | -- frame.name = frame |
||
699 | if(not frame.quadrants) then |
||
700 | frame.quadrants = {} |
||
701 | frame.quadrants[1] = getglobal(frame.name .. "TQ1") |
||
702 | frame.quadrants[2] = getglobal(frame.name .. "TQ2") |
||
703 | frame.chip = getglobal(frame.name .. "TC") |
||
704 | frame.slice = getglobal(frame.name .. "TS") |
||
705 | end |
||
706 | |||
707 | -- Initialize size and default texture ringFactor |
||
708 | frame.radius = (frame:GetWidth() * 0.5) |
||
709 | frame.ringFactor = 0.94 |
||
710 | |||
711 | -- Add ring methods |
||
712 | frame.DoQuadrant = self.DoQuadrant |
||
713 | frame.DoQuadrantReversed = self.DoQuadrantReversed |
||
714 | frame.SetAngle = self.SetAngle |
||
715 | frame.CallTextureMethod = self.CallTextureMethod |
||
716 | frame.UpdateColor = self.UpdateColor |
||
717 | frame.SetReversed = self.SetReversed |
||
718 | |||
719 | -- Set angle to 180 degrees (initializes texture visibility) |
||
720 | frame:SetAngle(180) |
||
721 | |||
722 | -- Set color and then remove the method again |
||
723 | frame:UpdateColor({r = 0, g = 0, b = 0}) |
||
724 | frame.UpdateColor = nil |
||
725 | frame.CallTextureMethod = nil |
||
726 | |||
727 | end |