vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- DHUD by Markus inger (Drathal)
2 -- Thanks to lozareth and andreasg for writing great addons ;)
3 -- i learned a lot from both of u
4  
5 -- modes
6 local DHUD_Casting = nil;
7 local DHUD_inCombat = nil;
8 local DHUD_Attacking = nil;
9 local DHUD_Regen = nil;
10 local DHUD_Target = nil;
11 local DHUD_needMana = nil;
12 local DHUD_needHealth = nil;
13 local DHUD_playerDead = nil;
14 local DHUD_PetneedHealth = nil;
15 local DHUD_PetneedMana = nil;
16 local DHUD_playerID = nil;
17 local DHUD_CastingAlpha = 1;
18 local DHUD_trennzeichen = "/";
19 local DHUD_defaultfont = "fonts\\FRIZQT__.TTF";
20 DHUD_version = "v0.86";
21  
22 -- default Config
23 local DHUD_Config_default = {
24 ["version"] = DHUD_version,
25 ["step"] = 0.005,
26 ["stepfast"] = 0.02,
27 ["combatAlpha"] = 0.8,
28 ["oocAlpha"] = 0,
29 ["selAlpha"] = 0.5,
30 ["regAlpha"] = 0.3,
31 ["scale"] = 0.8,
32 ["showclass"] = 1,
33 ["showlevel"] = 1,
34 ["showname"] = 1,
35 ["showelite"] = 1,
36 ["playerdisplaymode"] = 1,
37 ["targetdisplaymode"] = 1,
38 ["petdisplaymode"] = 4,
39 ["fontsizepet"] = 10,
40 ["fontsizeplayer"] = 10,
41 ["fontsizetarget"] = 10,
42 ["fontsizetargetname"] = 12,
43 ["fontsizecasttime"] = 10,
44 ["fontsizecastdelay"] = 10,
45 ["xoffset"] = 0,
46 ["yoffset"] = 0,
47 ["animatebars"] = 1,
48 ["barborders"] = 1,
49 ["showauras"] = 1,
50 ["btarget"] = 1,
51 ["bplayer"] = 1,
52 ["shownpc"] = 1,
53 ["showtarget"] = 1,
54 ["showpet"] = 1,
55 ["hudspacing"] = 170,
56 ["targettexty"] = -35,
57 ["playerhptextx"] = 190,
58 ["playerhptexty"] = -15,
59 ["playermanatextx"] = 160,
60 ["playermanatexty"] = -40,
61 ["targethptextx"] = 160,
62 ["targethptexty"] = -15,
63 ["targetmanatextx"] = -280,
64 ["targetmanatexty"] = -15,
65 ["pethptextx"] = 100,
66 ["pethptexty"] = 21,
67 ["petmanatextx"] = -100,
68 ["petmanatexty"] = 21,
69 ["minimapw"] = 0,
70 ["showmmb"] = 1,
71 ["castingbar"] = 1,
72 ["castingbartimer"] = 1,
73 ["casttimetextcolor"] = "FFFF00",
74 ["castdelaytextcolor"] = "DD0000",
75 ["playerhptextcolor"] = "FFFFFF",
76 ["playermanatextcolor"] = "FFFFFF",
77 ["targethptextcolor"] = "FFFFFF",
78 ["targetmanatextcolor"] = "FFFFFF",
79 ["pethptextcolor"] = "FFFFFF",
80 ["petmanatextcolor"] = "FFFFFF",
81 ["playerhpoutline"] = 1,
82 ["playermanaoutline"] = 1,
83 ["targethpoutline"] = 1,
84 ["targetmanaoutline"] = 1,
85 ["pethpoutline"] = 1,
86 ["petmanaoutline"] = 1,
87 ["casttimeoutline"] = 1,
88 ["castdelayoutline"] = 1,
89 ["targetoutline"] = 1,
90 }
91  
92 -- current mana / health values
93 local DHUD_bar = {
94 ["PlayerHealth"] = 1,
95 ["PlayerMana"] = 1,
96 ["TargetHealth"] = 1,
97 ["TargetMana"] = 1,
98 ["PetHealth"] = 1,
99 ["PetMana"] = 1,
100 }
101  
102 -- animated mana / health values
103 local DHUD_bar_anim = {
104 ["PlayerHealth"] = 1,
105 ["PlayerMana"] = 1,
106 ["TargetHealth"] = 1,
107 ["TargetMana"] = 1,
108 ["PetHealth"] = 1,
109 ["PetMana"] = 1,
110 }
111  
112 -- flag for animation
113 local DHUD_change = {
114 ["PlayerHealth"] = 0,
115 ["PlayerMana"] = 0,
116 ["TargetHealth"] = 0,
117 ["TargetMana"] = 0,
118 ["PetHealth"] = 0,
119 ["PetMana"] = 0,
120 }
121  
122 local DHUD_tex = {
123 ["PlayerMana"] = "PlayerManaBarTexture",
124 ["PlayerHealth"] = "PlayerHPBarTexture",
125 ["TargetMana"] = "TargetManaBarTexture",
126 ["TargetHealth"] = "TargetHPBarTexture",
127 ["PetMana"] = "PetManaBarTexture",
128 ["PetHealth"] = "PetHPBarTexture",
129 ["Castingbar"] = "DHUD_CastingBarTexture",
130 ["Channelbar"] = "DHUD_CastingBarTexture",
131 }
132  
133 local DHUD_attach = {
134 ["PlayerHealth"] = "DHUD_LeftFrame",
135 ["PlayerMana"] = "DHUD_LeftFrame",
136 ["TargetHealth"] = "DHUD_RightFrame",
137 ["TargetMana"] = "DHUD_RightFrame",
138 ["PetHealth"] = "DHUD_LeftFrame",
139 ["PetMana"] = "DHUD_RightFrame",
140 ["Castingbar"] = "DHUD_RightFrame",
141 ["Channelbar"] = "DHUD_RightFrame",
142 ["PlayerHealthText"] = "DHUD_LeftFrame",
143 ["TargetHealthText"] = "DHUD_RightFrame",
144 ["PlayerManaText"] = "DHUD_LeftFrame",
145 ["TargetManaText"] = "DHUD_RightFrame",
146 ["PetHealthText"] = "DHUD_LeftFrame",
147 ["PetManaText"] = "DHUD_RightFrame",
148 }
149  
150 local DHUD_texture_pos = { }
151  
152 local DHUD_texture_settings = {
153 ["PlayerHealth"] = {256,11,11},
154 ["PlayerMana"] = {256,11,11},
155 ["TargetHealth"] = {256,5,5},
156 ["TargetMana"] = {256,5,5},
157 ["PetHealth"] = {256,128,20},
158 ["PetMana"] = {256,128,20},
159 ["Castingbar"] = {256,11,11},
160 ["Channelbar"] = {256,11,11},
161 }
162  
163 -- bar colors
164 local DHUD_BarColor = {
165 ["health"] = {
166 ["start"] = { ["r"] = 0, ["g"] = 1 , ["b"] = 0},
167 ["middle"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0},
168 ["end"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
169 },
170 ["mana"] = {
171 ["start"] = { ["r"] = 0, ["g"] = 1 , ["b"] = 1},
172 ["middle"] = { ["r"] = 0, ["g"] = 0 , ["b"] = 1},
173 ["end"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 1},
174 },
175 ["rage"] = {
176 ["start"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
177 ["middle"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
178 ["end"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
179 },
180 ["energy"] = {
181 ["start"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0},
182 ["middle"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0},
183 ["end"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0},
184 },
185 ["focus"] = {
186 ["start"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
187 ["middle"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
188 ["end"] = { ["r"] = 1, ["g"] = 0 , ["b"] = 0},
189 },
190 ["tapped"] = {
191 ["start"] = { ["r"] = 0.5, ["g"] = 0.5 , ["b"] = 0.5},
192 ["middle"] = { ["r"] = 0.6, ["g"] = 0.6 , ["b"] = 0.6},
193 ["end"] = { ["r"] = 0.7, ["g"] = 0.7 , ["b"] = 0.7},
194 },
195 ["castbar"] = {
196 ["start"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 1},
197 ["middle"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0.5},
198 ["end"] = { ["r"] = 1, ["g"] = 1 , ["b"] = 0},
199 },
200 ["channelbar"] = {
201 ["start"] = { ["r"] = 0.8, ["g"] = 0.8 , ["b"] = 1},
202 ["middle"] = { ["r"] = 0.7, ["g"] = 0.7 , ["b"] = 1},
203 ["end"] = { ["r"] = 0.6, ["g"] = 0.6 , ["b"] = 1},
204 },
205 }
206  
207 -- used for hex conversion
208 local DHUD_HexTable = {
209 ["0"] = 0,
210 ["1"] = 1,
211 ["2"] = 2,
212 ["3"] = 3,
213 ["4"] = 4,
214 ["5"] = 5,
215 ["6"] = 6,
216 ["7"] = 7,
217 ["8"] = 8,
218 ["9"] = 9,
219 ["a"] = 10,
220 ["b"] = 11,
221 ["c"] = 12,
222 ["d"] = 13,
223 ["e"] = 14,
224 ["f"] = 15
225 }
226  
227 -- OUTLINE
228 local DHUD_Outline = {
229 [0] = "",
230 [1] = "OUTLINE",
231 [2] = "THICKOUTLINE"
232 }
233  
234 -- slash commands
235 local DHUD_CommandList = {
236 ["scale"] = {
237 ["type"] = "range",
238 ["command"] = "scale",
239 ["minvalue"] = 0.5,
240 ["maxvalue"] = 2,
241 ["output"] = "DHUD: /dhud %s %s - %s",
242 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
243 },
244 ["fontsizecasttime"] = {
245 ["type"] = "range",
246 ["command"] = "fontsizecasttime",
247 ["minvalue"] = 1,
248 ["maxvalue"] = 30,
249 ["output"] = "DHUD: /dhud %s %s - %s",
250 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
251 },
252 ["fontsizecastdelay"] = {
253 ["type"] = "range",
254 ["command"] = "fontsizecastdelay",
255 ["minvalue"] = 1,
256 ["maxvalue"] = 30,
257 ["output"] = "DHUD: /dhud %s %s - %s",
258 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
259 },
260 ["fontsizetargetname"] = {
261 ["type"] = "range",
262 ["command"] = "fontsizetargetname",
263 ["minvalue"] = 1,
264 ["maxvalue"] = 30,
265 ["output"] = "DHUD: /dhud %s %s - %s",
266 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
267 },
268 ["fontsizetarget"] = {
269 ["type"] = "range",
270 ["command"] = "fontsizetarget",
271 ["minvalue"] = 1,
272 ["maxvalue"] = 30,
273 ["output"] = "DHUD: /dhud %s %s - %s",
274 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
275 },
276 ["fontsizeplayer"] = {
277 ["type"] = "range",
278 ["command"] = "fontsizeplayer",
279 ["minvalue"] = 1,
280 ["maxvalue"] = 30,
281 ["output"] = "DHUD: /dhud %s %s - %s",
282 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
283 },
284 ["fontsizepet"] = {
285 ["type"] = "range",
286 ["command"] = "fontsizepet",
287 ["minvalue"] = 1,
288 ["maxvalue"] = 30,
289 ["output"] = "DHUD: /dhud %s %s - %s",
290 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
291 },
292 ["combatAlpha"] = {
293 ["type"] = "range",
294 ["command"] = "combatalpha",
295 ["minvalue"] = 0,
296 ["maxvalue"] = 1,
297 ["output"] = "DHUD: /dhud %s %s - %s",
298 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
299 },
300 ["oocAlpha"] = {
301 ["type"] = "range",
302 ["command"] = "nocombatalpha",
303 ["minvalue"] = 0,
304 ["maxvalue"] = 1,
305 ["output"] = "DHUD: /dhud %s %s - %s",
306 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
307 },
308 ["selAlpha"] = {
309 ["type"] = "range",
310 ["command"] = "selectalpha",
311 ["minvalue"] = 0,
312 ["maxvalue"] = 1,
313 ["output"] = "DHUD: /dhud %s %s - %s",
314 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
315 },
316 ["regAlpha"] = {
317 ["type"] = "range",
318 ["command"] = "regalpha",
319 ["minvalue"] = 0,
320 ["maxvalue"] = 1,
321 ["output"] = "DHUD: /dhud %s %s - %s",
322 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
323 },
324 ["playerdisplaymode"] = {
325 ["type"] = "range",
326 ["command"] = "playerdisplaymode",
327 ["minvalue"] = 1,
328 ["maxvalue"] = 4,
329 ["output"] = "DHUD: /dhud %s %s - %s",
330 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
331 },
332 ["targetdisplaymode"] = {
333 ["type"] = "range",
334 ["command"] = "targetdisplaymode",
335 ["minvalue"] = 1,
336 ["maxvalue"] = 4,
337 ["output"] = "DHUD: /dhud %s %s - %s",
338 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
339 },
340 ["petdisplaymode"] = {
341 ["type"] = "range",
342 ["command"] = "petdisplaymode",
343 ["minvalue"] = 1,
344 ["maxvalue"] = 4,
345 ["output"] = "DHUD: /dhud %s %s - %s",
346 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
347 },
348 ["xoffset"] = {
349 ["type"] = "range",
350 ["command"] = "xoffset",
351 ["minvalue"] = -1000,
352 ["maxvalue"] = 1000,
353 ["output"] = "DHUD: /dhud %s %s - %s",
354 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
355 },
356 ["yoffset"] = {
357 ["type"] = "range",
358 ["command"] = "yoffset",
359 ["minvalue"] = -1000,
360 ["maxvalue"] = 1000,
361 ["output"] = "DHUD: /dhud %s %s - %s",
362 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
363 },
364 ["showclass"] = {
365 ["type"] = "toggle",
366 ["command"] = "showclass",
367 ["output"] = "DHUD: /dhud %s",
368 ["response"] = "DHUD: %s is now %s",
369 },
370 ["showelite"] = {
371 ["type"] = "toggle",
372 ["command"] = "showelite",
373 ["output"] = "DHUD: /dhud %s",
374 ["response"] = "DHUD: %s is now %s",
375 },
376 ["showname"] = {
377 ["type"] = "toggle",
378 ["command"] = "showname",
379 ["output"] = "DHUD: /dhud %s",
380 ["response"] = "DHUD: %s is now %s",
381 },
382 ["showlevel"] = {
383 ["type"] = "toggle",
384 ["command"] = "showlevel",
385 ["output"] = "DHUD: /dhud %s",
386 ["response"] = "DHUD: %s is now %s",
387 },
388 ["castingbar"] = {
389 ["type"] = "toggle",
390 ["command"] = "castingbar",
391 ["output"] = "DHUD: /dhud %s",
392 ["response"] = "DHUD: %s is now %s",
393 },
394 ["castingbartimer"] = {
395 ["type"] = "toggle",
396 ["command"] = "castingbartimer",
397 ["output"] = "DHUD: /dhud %s",
398 ["response"] = "DHUD: %s is now %s",
399 },
400 ["animatebars"] = {
401 ["type"] = "toggle",
402 ["command"] = "animatebars",
403 ["output"] = "DHUD: /dhud %s",
404 ["response"] = "DHUD: %s is now %s",
405 },
406 ["reset"] = {
407 ["type"] = "reset",
408 ["command"] = "reset",
409 ["output"] = "DHUD: /dhud reset",
410 ["response"] = "DHUD: default settings loaded",
411 },
412 ["barborders"] = {
413 ["type"] = "toggle",
414 ["command"] = "barborders",
415 ["output"] = "DHUD: /dhud %s",
416 ["response"] = "DHUD: %s is now %s",
417 },
418 ["showauras"] = {
419 ["type"] = "toggle",
420 ["command"] = "showauras",
421 ["output"] = "DHUD: /dhud %s",
422 ["response"] = "DHUD: %s is now %s",
423 },
424 ["showtarget"] = {
425 ["type"] = "toggle",
426 ["command"] = "showtarget",
427 ["output"] = "DHUD: /dhud %s",
428 ["response"] = "DHUD: %s is now %s",
429 },
430 ["showpet"] = {
431 ["type"] = "toggle",
432 ["command"] = "showpet",
433 ["output"] = "DHUD: /dhud %s",
434 ["response"] = "DHUD: %s is now %s",
435 },
436 ["menu"] = {
437 ["type"] = "menu",
438 ["command"] = "menu",
439 ["output"] = "DHUD: /dhud menu",
440 ["response"] = "DHUD: menu",
441 },
442 ["btarget"] = {
443 ["type"] = "toggle",
444 ["command"] = "btarget",
445 ["output"] = "DHUD: /dhud %s (hide / show Blizzard Targetframe)",
446 ["response"] = "DHUD: %s is now %s",
447 },
448 ["bplayer"] = {
449 ["type"] = "toggle",
450 ["command"] = "bplayer",
451 ["output"] = "DHUD: /dhud %s (hide / show Blizzard Playerframeframe)",
452 ["response"] = "DHUD: %s is now %s",
453 },
454 ["shownpc"] = {
455 ["type"] = "toggle",
456 ["command"] = "shownpc",
457 ["output"] = "DHUD: /dhud %s",
458 ["response"] = "DHUD: %s is now %s",
459 },
460 ["showmmb"] = {
461 ["type"] = "toggle",
462 ["command"] = "showmmb",
463 ["output"] = "DHUD: /dhud %s",
464 ["response"] = "DHUD: %s is now %s",
465 },
466 ["hudspacing"] = {
467 ["type"] = "range",
468 ["command"] = "hudspacing",
469 ["minvalue"] = -500,
470 ["maxvalue"] = 500,
471 ["output"] = "DHUD: /dhud %s %s - %s",
472 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
473 },
474 ["targettexty"] = {
475 ["type"] = "range",
476 ["command"] = "targettexty",
477 ["minvalue"] = -500,
478 ["maxvalue"] = 500,
479 ["output"] = "DHUD: /dhud %s %s - %s",
480 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
481 },
482 ["playerhptextx"] = {
483 ["type"] = "range",
484 ["command"] = "playerhptextx",
485 ["minvalue"] = -300,
486 ["maxvalue"] = 300,
487 ["output"] = "DHUD: /dhud %s %s - %s",
488 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
489 },
490 ["playerhptexty"] = {
491 ["type"] = "range",
492 ["command"] = "playerhptexty",
493 ["minvalue"] = -300,
494 ["maxvalue"] = 300,
495 ["output"] = "DHUD: /dhud %s %s - %s",
496 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
497 },
498 ["playermanatextx"] = {
499 ["type"] = "range",
500 ["command"] = "playermanatextx",
501 ["minvalue"] = -300,
502 ["maxvalue"] = 300,
503 ["output"] = "DHUD: /dhud %s %s - %s",
504 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
505 },
506 ["playermanatexty"] = {
507 ["type"] = "range",
508 ["command"] = "playermanatexty",
509 ["minvalue"] = -300,
510 ["maxvalue"] = 300,
511 ["output"] = "DHUD: /dhud %s %s - %s",
512 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
513 },
514 ["casttimetextcolor"] = {
515 ["type"] = "color",
516 ["command"] = "casttimetextcolor",
517 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
518 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
519 },
520 ["castdelaytextcolor"] = {
521 ["type"] = "color",
522 ["command"] = "castdelaytextcolor",
523 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
524 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
525 },
526 ["playerhptextcolor"] = {
527 ["type"] = "color",
528 ["command"] = "playerhptextcolor",
529 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
530 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
531 },
532 ["playermanatextcolor"] = {
533 ["type"] = "color",
534 ["command"] = "playermanatextcolor",
535 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
536 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
537 },
538 ["targethptextcolor"] = {
539 ["type"] = "color",
540 ["command"] = "targethptextcolor",
541 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
542 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
543 },
544 ["targetmanatextcolor"] = {
545 ["type"] = "color",
546 ["command"] = "targetmanatextcolor",
547 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
548 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
549 },
550 ["pethptextcolor"] = {
551 ["type"] = "color",
552 ["command"] = "pethptextcolor",
553 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
554 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
555 },
556 ["petmanatextcolor"] = {
557 ["type"] = "color",
558 ["command"] = "petmanatextcolor",
559 ["output"] = "DHUD: /dhud %s 000000 - FFFFFF",
560 ["response"] = "DHUD: %s set to: |cff%s%s|r ",
561 },
562 ["playerhpoutline"] = {
563 ["type"] = "range",
564 ["command"] = "playerhpoutline",
565 ["minvalue"] = 0,
566 ["maxvalue"] = 2,
567 ["output"] = "DHUD: /dhud %s %s - %s",
568 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
569 },
570 ["playermanaoutline"] = {
571 ["type"] = "range",
572 ["command"] = "playermanaoutline",
573 ["minvalue"] = 0,
574 ["maxvalue"] = 2,
575 ["output"] = "DHUD: /dhud %s %s - %s",
576 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
577 },
578 ["targethpoutline"] = {
579 ["type"] = "range",
580 ["command"] = "targethpoutline",
581 ["minvalue"] = 0,
582 ["maxvalue"] = 2,
583 ["output"] = "DHUD: /dhud %s %s - %s",
584 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
585 },
586 ["targetmanaoutline"] = {
587 ["type"] = "range",
588 ["command"] = "targetmanaoutline",
589 ["minvalue"] = 0,
590 ["maxvalue"] = 2,
591 ["output"] = "DHUD: /dhud %s %s - %s",
592 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
593 },
594 ["pethpoutline"] = {
595 ["type"] = "range",
596 ["command"] = "pethpoutline",
597 ["minvalue"] = 0,
598 ["maxvalue"] = 2,
599 ["output"] = "DHUD: /dhud %s %s - %s",
600 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
601 },
602 ["petmanaoutline"] = {
603 ["type"] = "range",
604 ["command"] = "petmanaoutline",
605 ["minvalue"] = 0,
606 ["maxvalue"] = 2,
607 ["output"] = "DHUD: /dhud %s %s - %s",
608 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
609 },
610 ["casttimeoutline"] = {
611 ["type"] = "range",
612 ["command"] = "casttimeoutline",
613 ["minvalue"] = 0,
614 ["maxvalue"] = 2,
615 ["output"] = "DHUD: /dhud %s %s - %s",
616 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
617 },
618 ["castdelayoutline"] = {
619 ["type"] = "range",
620 ["command"] = "castdelayoutline",
621 ["minvalue"] = 0,
622 ["maxvalue"] = 2,
623 ["output"] = "DHUD: /dhud %s %s - %s",
624 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
625 },
626 ["targetoutline"] = {
627 ["type"] = "range",
628 ["command"] = "targetoutline",
629 ["minvalue"] = 0,
630 ["maxvalue"] = 2,
631 ["output"] = "DHUD: /dhud %s %s - %s",
632 ["response"] = "DHUD: %s set to: |cff00ff00%s|r |cffcccccc[%s - %s]|r",
633 },
634 }
635  
636 function DHUD_registerEvents()
637  
638 local f = DHUD_EventFrame;
639 f:RegisterEvent("UNIT_AURA");
640 f:RegisterEvent("UNIT_PET");
641 f:RegisterEvent("UNIT_HEALTH");
642 f:RegisterEvent("UNIT_HEALTHMAX");
643 f:RegisterEvent("UNIT_MANA");
644 f:RegisterEvent("UNIT_MANAMAX");
645 f:RegisterEvent("UNIT_FOCUS");
646 f:RegisterEvent("UNIT_FOCUSMAX");
647 f:RegisterEvent("UNIT_RAGE");
648 f:RegisterEvent("UNIT_RAGEMAX");
649 f:RegisterEvent("UNIT_ENERGY");
650 f:RegisterEvent("UNIT_ENERGYMAX");
651 f:RegisterEvent("UNIT_DISPLAYPOWER");
652 f:RegisterEvent("PLAYER_AURAS_CHANGED");
653 f:RegisterEvent("PLAYER_ENTER_COMBAT");
654 f:RegisterEvent("PLAYER_LEAVE_COMBAT");
655 f:RegisterEvent("PLAYER_REGEN_ENABLED");
656 f:RegisterEvent("PLAYER_REGEN_DISABLED");
657 f:RegisterEvent("PLAYER_TARGET_CHANGED");
658 f:RegisterEvent("PLAYER_COMBO_POINTS");
659 f:RegisterEvent("PLAYER_DEAD");
660 f:RegisterEvent("PLAYER_ALIVE");
661 f:RegisterEvent("SPELLCAST_CHANNEL_START");
662 f:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
663 f:RegisterEvent("SPELLCAST_DELAYED");
664 f:RegisterEvent("SPELLCAST_FAILED");
665 f:RegisterEvent("SPELLCAST_INTERRUPTED");
666 f:RegisterEvent("SPELLCAST_START");
667 f:RegisterEvent("SPELLCAST_STOP");
668 f:RegisterEvent("SPELLCAST_CHANNEL_STOP");
669  
670 end
671  
672 function DHUD_unregisterEvents()
673  
674 local f = DHUD_EventFrame;
675 f:UnregisterEvent("UNIT_AURA");
676 f:UnregisterEvent("UNIT_PET");
677 f:UnregisterEvent("UNIT_HEALTH");
678 f:UnregisterEvent("UNIT_HEALTHMAX");
679 f:UnregisterEvent("UNIT_MANA");
680 f:UnregisterEvent("UNIT_MANAMAX");
681 f:UnregisterEvent("UNIT_FOCUS");
682 f:UnregisterEvent("UNIT_FOCUSMAX");
683 f:UnregisterEvent("UNIT_RAGE");
684 f:UnregisterEvent("UNIT_RAGEMAX");
685 f:UnregisterEvent("UNIT_ENERGY");
686 f:UnregisterEvent("UNIT_ENERGYMAX");
687 f:UnregisterEvent("UNIT_DISPLAYPOWER");
688 f:UnregisterEvent("PLAYER_AURAS_CHANGED");
689 f:UnregisterEvent("PLAYER_ENTER_COMBAT");
690 f:UnregisterEvent("PLAYER_LEAVE_COMBAT");
691 f:UnregisterEvent("PLAYER_REGEN_ENABLED");
692 f:UnregisterEvent("PLAYER_REGEN_DISABLED");
693 f:UnregisterEvent("PLAYER_TARGET_CHANGED");
694 f:UnregisterEvent("PLAYER_COMBO_POINTS");
695 f:UnregisterEvent("PLAYER_DEAD");
696 f:UnregisterEvent("PLAYER_ALIVE");
697 f:UnregisterEvent("SPELLCAST_CHANNEL_START");
698 f:UnregisterEvent("SPELLCAST_CHANNEL_UPDATE");
699 f:UnregisterEvent("SPELLCAST_DELAYED");
700 f:UnregisterEvent("SPELLCAST_FAILED");
701 f:UnregisterEvent("SPELLCAST_INTERRUPTED");
702 f:UnregisterEvent("SPELLCAST_START");
703 f:UnregisterEvent("SPELLCAST_STOP");
704 f:UnregisterEvent("SPELLCAST_CHANNEL_STOP");
705  
706 end
707  
708 function DHUD_OnLoad()
709  
710 -- Events
711 this:RegisterEvent("VARIABLES_LOADED");
712 this:RegisterEvent("PLAYER_ENTERING_WORLD");
713 this:RegisterEvent("PLAYER_LEAVING_WORLD");
714 DHUD_registerEvents();
715  
716 -- slash handler
717 SLASH_DHUD1 = "/dhud";
718 SlashCmdList["DHUD"] = function(msg)
719 DHUD_SCommandHandler(msg);
720 end
721  
722 end;
723  
724 function DHUD_OnEvent(event, arg1, arg2, arg3)
725  
726 -- init
727 if (event == "VARIABLES_LOADED") then
728  
729 -- set player ID
730 DHUD_playerID = GetRealmName()..":"..UnitName("player");
731  
732 -- set default Values
733 if( not DHUD_Config ) then
734 DHUD_Config = { };
735 end
736  
737 for k, v in DHUD_Config_default do
738 DHUD_defaultConfig(k);
739 end
740  
741 -- MyAddonsSupport
742 DHUD_myAddons();
743  
744 -- minimap button
745 DHUD_createMMB();
746  
747 -- init HUD
748 DHUD_init();
749  
750 -- Tell
751 DEFAULT_CHAT_FRAME:AddMessage("Drathal's HUD: Loaded "..DHUD_version);
752  
753 -- unregister after first load
754 DHUD_EventFrame:UnregisterEvent("VARIABLES_LOADED");
755  
756 return;
757 end
758  
759 -- shapeshift etc
760 if (event == "PLAYER_AURAS_CHANGED" or event == "UNIT_DISPLAYPOWER") and arg1 == "player" then
761 DHUD_updatePlayerMana();
762 return;
763 end
764  
765 -- buffs / debuffs
766 if event == "UNIT_AURA" and arg1 == "target" then
767 DHUD_Auras();
768 return;
769 end
770  
771 -- update Combos
772 if event == "PLAYER_COMBO_POINTS" then
773 DHUD_UpdateCombos();
774 return;
775 end
776  
777 -- Hat sich Spieler Health verändert?
778 if ( ( event == "UNIT_HEALTH" or event == "UNIT_HEALTHMAX" ) and arg1 == "player" ) then
779 DHUD_updatePlayerHealth();
780 return;
781 end
782  
783 -- Hat sich Spieler Mana/Rage etc verändert?
784 if ( (event == "UNIT_MANA" or
785 event == "UNIT_MANAMAX" or
786 event == "UNIT_FOCUS" or
787 event == "UNIT_FOCUSMAX" or
788 event == "UNIT_RAGE" or
789 event == "UNIT_RAGEMAX" or
790 event == "UNIT_ENERGY" or
791 event == "UNIT_ENERGYMAX" ) and arg1 == "player" ) then
792 DHUD_updatePlayerMana();
793 return;
794 end
795  
796 -- Hat sich Target Health verändert?
797 if ( (event == "UNIT_HEALTH" or event == "UNIT_HEALTHMAX") and arg1 == "target" ) then
798 if DHUD_Config["showtarget"] == 1 then
799 DHUD_updateTargetHealth();
800 end
801 return;
802 end
803  
804 -- Hat sich Target Mana/Rage etc verändert?
805 if ( (event == "UNIT_MANA" or
806 event == "UNIT_MANAMAX" or
807 event == "UNIT_FOCUS" or
808 event == "UNIT_FOCUSMAX" or
809 event == "UNIT_RAGE" or
810 event == "UNIT_RAGEMAX" or
811 event == "UNIT_ENERGY" or
812 event == "UNIT_ENERGYMAX") and arg1 == "target" ) then
813 if DHUD_Config["showtarget"] == 1 then
814 DHUD_updateTargetMana();
815 end
816 return;
817 end
818  
819 -- Pet?
820 if ( event == "UNIT_PET" ) then
821 if DHUD_Config["showpet"] == 1 then
822 DHUD_changeBackgroundTexture();
823 DHUD_updatePetHealth();
824 DHUD_updatePetMana();
825 end;
826 return;
827 end
828  
829 -- Hat sich Pet Health verändert?
830 if ( (event == "UNIT_HEALTH" or event == "UNIT_HEALTHMAX") and arg1 == "pet" ) then
831 if DHUD_Config["showpet"] == 1 then
832 DHUD_updatePetHealth();
833 end
834 return;
835 end
836  
837 -- Hat sich Pet Mana/Rage etc verändert?
838 if ( (event == "UNIT_MANA" or
839 event == "UNIT_MANAMAX" or
840 event == "UNIT_FOCUS" or
841 event == "UNIT_FOCUSMAX" or
842 event == "UNIT_RAGE" or
843 event == "UNIT_RAGEMAX" or
844 event == "UNIT_ENERGY" or
845 event == "UNIT_ENERGYMAX") and arg1 == "pet" ) then
846 if DHUD_Config["showpet"] == 1 then
847 DHUD_updatePetMana();
848 end
849 return;
850 end
851  
852 -- Target wechsel
853 if event == "PLAYER_TARGET_CHANGED" then
854 DHUD_updateTargetChanged();
855 return;
856 end
857  
858 -- Combat / Regen / Attack check
859 if (event == "PLAYER_ENTER_COMBAT") then
860 DHUD_Attacking = true;
861 DHUD_inCombat = true;
862 DHUD_updateAlpha();
863 return;
864 elseif (event == "PLAYER_LEAVE_COMBAT") then
865 DHUD_Attacking = nil;
866 if (DHUD_Regen) then
867 DHUD_inCombat = nil;
868 end
869 DHUD_updateAlpha();
870 return;
871 elseif (event == "PLAYER_REGEN_ENABLED") then
872 DHUD_Regen = true;
873 if (not DHUD_Attacking) then
874 DHUD_inCombat = nil;
875 end
876 DHUD_updateAlpha();
877 return;
878 elseif (event == "PLAYER_REGEN_DISABLED") then
879 DHUD_Regen = nil;
880 DHUD_inCombat = true;
881 DHUD_updateAlpha();
882 return;
883 end
884  
885 if (event == "PLAYER_DEAD") then
886 DHUD_playerDead = 1;
887 DHUD_updateAlpha();
888 return;
889 end
890  
891 if (event == "PLAYER_ALIVE") then
892 DHUD_playerDead = 0;
893 DHUD_updateAlpha();
894 return;
895 end
896  
897 if DHUD_Config["castingbar"] == 1 then
898  
899 -- start castbar
900 if (event == "SPELLCAST_START") then
901 this.startTime = GetTime();
902 this.maxValue = this.startTime + (arg2 / 1000);
903 this.holdTime = 0;
904 this.casting = 1;
905 this.delay = 0;
906 this.channeling = nil;
907 this.fadeOut = nil;
908 this.flash = nil;
909 this.duration = floor(arg2 / 100) / 10;
910  
911 DHUD_Casting = true;
912 DHUD_updateAlpha();
913  
914 DHUD_Casttime_Text:SetText("");
915 DHUD_Casttime:Show();
916 DHUD_Castdelay_Text:SetText("");
917 DHUD_Castdelay:Show();
918  
919 DHUD_SetBar("Castingbar", 0 );
920 DHUD_CastingBarTexture:Show();
921 DHUD_CastingBarTexture:SetAlpha(DHUD_CastingAlpha);
922 return;
923 end
924  
925 -- failed
926 if (event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED") then
927  
928 if (DHUD_CastingBarTexture:IsShown()) then
929 DHUD_CastingBarTexture:SetVertexColor(1, 0, 0);
930 DHUD_SetBar("Castingbar", 1 , 1);
931 this.casting = nil;
932 this.channeling = nil;
933 this.fadeOut = 1;
934 this.flash = nil;
935 this.holdTime = GetTime() + CASTING_BAR_HOLD_TIME;
936 DHUD_CastingBarTextureHigh:Hide();
937 end
938 return;
939  
940 end
941  
942 -- stop
943 if ( event == "SPELLCAST_STOP" or event == "SPELLCAST_CHANNEL_STOP") then
944  
945 if (not DHUD_CastingBarTexture:IsVisible()) then
946 DHUD_CastingBarTexture:Hide();
947 end
948  
949 if (DHUD_CastingBarTexture:IsShown()) then
950 if ( event == "SPELLCAST_STOP" and this.casting == 1) then
951 this.casting = nil;
952 this.channeling = nil;
953 this.flash = 1;
954 this.fadeOut = 1;
955 DHUD_CastingBarTexture:SetVertexColor(0, 1, 0);
956 DHUD_SetBar("Castingbar", 1 ,1);
957 DHUD_CastingBarTextureHigh:SetAlpha(0);
958 DHUD_CastingBarTextureHigh:Show();
959 elseif ( event == "SPELLCAST_CHANNEL_STOP" and this.channeling == 1) then
960 this.casting = nil;
961 this.channeling = nil;
962 this.flash = nil;
963 this.fadeOut = 1;
964 DHUD_Casting = nil;
965 DHUD_updateAlpha();
966 DHUD_SetBar("Castingbar", 0 );
967 end
968 end
969  
970 return;
971 end
972  
973 -- delayed
974 if (event == "SPELLCAST_DELAYED") then
975  
976 if(DHUD_CastingBarTexture:IsShown()) then
977 this.startTime = this.startTime + (arg1 / 1000);
978 this.maxValue = this.maxValue + (arg1 / 1000);
979 this.delay = this.delay + (arg1 / 1000);
980  
981 local time = GetTime();
982 if (time > this.endTime) then
983 time = this.endTime
984 end
985  
986 local barValue = this.startTime + (this.endTime - time);
987 local sparkPosition = ((barValue - this.startTime) / (this.endTime - this.startTime));
988 DHUD_SetBar("Castingbar", sparkPosition );
989 end
990 return;
991 end
992  
993 -- channel start
994 if (event == "SPELLCAST_CHANNEL_START") then
995 this.maxValue = 1;
996 this.startTime = GetTime();
997 this.endTime = this.startTime + (arg1 / 1000);
998 this.duration = string.format( "%.1f",arg1 / 1000);
999 this.holdTime = 0;
1000 this.casting = nil;
1001 this.channeling = 1;
1002 this.fadeOut = nil;
1003 this.delay = 0;
1004 DHUD_Casting = true;
1005 DHUD_updateAlpha();
1006 DHUD_SetBar("Channelbar", 1 );
1007 DHUD_CastingBarTexture:Show();
1008 DHUD_CastingBarTexture:SetAlpha(DHUD_CastingAlpha);
1009 DHUD_Casttime_Text:SetText("");
1010 DHUD_Casttime:Show();
1011 DHUD_Castdelay_Text:SetText("");
1012 DHUD_Castdelay:Show();
1013 return;
1014 end
1015  
1016 -- channel update
1017 if (event == "SPELLCAST_CHANNEL_UPDATE") then
1018  
1019 if arg1 == 0 then
1020 this.channeling = nil;
1021 elseif (DHUD_CastingBarTexture:IsShown()) then
1022 local origDuration = this.endTime - this.startTime
1023 local elapsedTime = GetTime() - this.startTime;
1024 this.delay = (origDuration - elapsedTime) - (arg1/1000);
1025 this.endTime = GetTime() + (arg1 / 1000);
1026 end
1027  
1028 return;
1029 end
1030  
1031 end
1032  
1033 -- zoned?
1034 if (event == "PLAYER_ENTERING_WORLD") then
1035 DHUD_registerEvents();
1036 DHUD_init();
1037 return;
1038 end
1039  
1040 if (event == "PLAYER_LEAVING_WORLD") then
1041 DHUD_unregisterEvents();
1042 return;
1043 end
1044  
1045 end;
1046  
1047 function DHUD_Auras()
1048  
1049 -- wenn auras aus nicht zeigen
1050 if DHUD_Config["showauras"] == 0 then
1051 return;
1052 end
1053  
1054 if DHUD_Config["showtarget"] == 0 then
1055 return;
1056 end;
1057  
1058 -- wenn NPC anzeige aus keine aura zeigen
1059 if DHUD_checkShowNPC() then
1060 DHUD_hideAuras();
1061 return;
1062 end;
1063  
1064 local i, icon, buff, debuff, debuffborder, debuffcount;
1065  
1066 -- Buffs
1067 for i = 1, 16 do
1068 buff = UnitBuff("target", i);
1069 button = getglobal("DHUDBuff"..i);
1070 if (buff) then
1071 icon = getglobal(button:GetName().."Icon");
1072 icon:SetTexture(buff);
1073 button:Show();
1074 button.unit = "target";
1075 else
1076 button:Hide();
1077 end
1078  
1079 debuff, debuffC = UnitDebuff("target", i);
1080 button = getglobal("DHUDDeBuff"..i);
1081 if (debuff) then
1082 icon = getglobal(button:GetName().."Icon");
1083 icon:SetTexture(debuff);
1084  
1085 button.hasdebuff = 1;
1086 button.unit = "target";
1087  
1088 debuffborder = getglobal(button:GetName().."Border");
1089 debuffcount = getglobal(button:GetName().."Count");
1090  
1091 debuffborder:Show();
1092 button:Show();
1093  
1094 if (debuffC <= 0) then
1095 debuffcount:Hide()
1096 elseif debuffC > 1 then
1097 debuffcount:SetText(debuffC);
1098 debuffcount:Show();
1099 else
1100 debuffcount:SetText("");
1101 debuffcount:Show();
1102 end
1103  
1104 else
1105 button:Hide();
1106 end
1107 end
1108 end
1109  
1110 function DHUD_setAlpha(mode)
1111  
1112 local texture = getglobal("DHUD_LeftFrameTexture");
1113 texture:SetAlpha(DHUD_Config[mode]);
1114  
1115 local texture = getglobal("DHUD_RightFrameTexture");
1116 texture:SetAlpha(DHUD_Config[mode]);
1117  
1118 local texture = getglobal(DHUD_tex["PlayerHealth"]);
1119 texture:SetAlpha(DHUD_Config[mode]);
1120  
1121 local texture = getglobal(DHUD_tex["PlayerMana"]);
1122 texture:SetAlpha(DHUD_Config[mode]);
1123  
1124 if DHUD_Config["showtarget"] == 1 then
1125 local texture = getglobal(DHUD_tex["TargetHealth"]);
1126 texture:SetAlpha(DHUD_Config[mode]);
1127  
1128 local texture = getglobal(DHUD_tex["TargetMana"]);
1129 texture:SetAlpha(DHUD_Config[mode]);
1130 end
1131  
1132 if DHUD_Config["showpet"] == 1 then
1133 local texture = getglobal(DHUD_tex["PetHealth"]);
1134 texture:SetAlpha(DHUD_Config[mode]);
1135  
1136 local texture = getglobal(DHUD_tex["PetMana"]);
1137 texture:SetAlpha(DHUD_Config[mode]);
1138 end
1139  
1140 DHUD_CastingAlpha = DHUD_Config[mode];
1141  
1142 end
1143  
1144 function DHUD_changeBackgroundTexture()
1145  
1146 local has_target_health = nil;
1147 local has_target_mana = nil;
1148 local has_pet_health = nil;
1149 local has_pet_mana = nil;
1150 local texture_name_left = "Interface\\AddOns\\DHUD\\textures\\standard\\bg_left_";
1151 local texture_name_right = "Interface\\AddOns\\DHUD\\textures\\standard\\bg_right_";
1152 local tex_left = "";
1153 local tex_right = "";
1154  
1155 -- check target
1156 if DHUD_Config["showtarget"] == 1 then
1157 if ( UnitName("target") ) then
1158  
1159 -- npc anzeigen?
1160 if DHUD_checkShowNPC() then
1161 has_target_health = nil;
1162 has_target_mana = nil;
1163 else
1164 if UnitHealthMax("target") then
1165 has_target_health = 1;
1166 else
1167 has_target_health = nil;
1168 end
1169  
1170 if UnitManaMax("target") > 0 then
1171 has_target_mana = 1;
1172 else
1173 has_target_mana = nil;
1174 end
1175  
1176 -- Update Text Display
1177 DHUD_updateTargetHealth();
1178 DHUD_updateTargetMana();
1179 end
1180 end
1181 end
1182  
1183 -- check pet
1184 if DHUD_Config["showpet"] == 1 then
1185 if ( UnitName("pet") ) then
1186 if UnitHealthMax("pet") then
1187 has_pet_health = 1;
1188 else
1189 has_pet_health = nil;
1190 end
1191  
1192 if UnitManaMax("pet") > 0 then
1193 has_pet_mana = 1;
1194 else
1195 has_pet_mana = nil;
1196 end
1197  
1198 -- Update Text Display
1199 DHUD_updatePetHealth();
1200 DHUD_updatePetMana();
1201 end
1202 end
1203  
1204 -- showing borders?
1205 if DHUD_Config["barborders"] == 1 then
1206  
1207 -- left Target?
1208 if has_target_health then
1209 tex_left = "Target";
1210 end
1211  
1212 -- Player
1213 tex_left = tex_left .. "Player";
1214  
1215 -- left Pet
1216 if has_pet_health then
1217 tex_left = tex_left .. "Pet";
1218 end
1219  
1220 -- right Target?
1221 if has_target_mana then
1222 tex_right = "Target";
1223 end
1224  
1225 -- Player
1226 tex_right = tex_right .. "Player";
1227  
1228 -- left Pet
1229 if has_pet_mana then
1230 tex_right = tex_right .. "Pet";
1231 end
1232  
1233 -- set Left texture
1234 DHUD_LeftFrameTexture:SetTexture(texture_name_left..tex_left);
1235 if DHUD_playerDead ~= 1 then
1236 DHUD_LeftFrameTexture:Show();
1237 end
1238  
1239 -- set Right texture
1240 DHUD_RightFrameTexture:SetTexture(texture_name_right..tex_right);
1241 if DHUD_playerDead ~= 1 then
1242 DHUD_RightFrameTexture:Show();
1243 end
1244 else
1245 -- set Left texture
1246 DHUD_LeftFrameTexture:Hide();
1247  
1248 -- set Right texture
1249 DHUD_RightFrameTexture:Hide();
1250 end
1251  
1252 -- show / hide Target Health Text / Bar
1253 if has_target_health then
1254 local texture = getglobal(DHUD_tex["TargetHealth"]);
1255 texture:Show();
1256 getglobal("DHUD_TargetHealth"):Show();
1257 else
1258 local texture = getglobal(DHUD_tex["TargetHealth"]);
1259 texture:Hide();
1260 getglobal("DHUD_TargetHealth"):Hide();
1261 end;
1262  
1263 -- show / hide Target Mana Text / Bar
1264 if has_target_mana then
1265 local texture = getglobal(DHUD_tex["TargetMana"]);
1266 texture:Show();
1267 getglobal("DHUD_TargetMana"):Show();
1268 else
1269 local texture = getglobal(DHUD_tex["TargetMana"]);
1270 texture:Hide();
1271 getglobal("DHUD_TargetMana"):Hide();
1272 end;
1273  
1274 -- show / hide Pet Health Text / Bar
1275 if has_pet_health then
1276 local texture = getglobal(DHUD_tex["PetHealth"]);
1277 texture:Show();
1278 else
1279 local texture = getglobal(DHUD_tex["PetHealth"]);
1280 texture:Hide();
1281 end;
1282  
1283 -- show / hide pet Mana Text / Bar
1284 if has_pet_mana then
1285 local texture = getglobal(DHUD_tex["PetMana"]);
1286 texture:Show();
1287 else
1288 local texture = getglobal(DHUD_tex["PetMana"]);
1289 texture:Hide();
1290 end;
1291  
1292 end
1293  
1294 function DHUD_updateTargetChanged()
1295  
1296 -- NPC anzeigen ?
1297 if DHUD_checkShowNPC() then
1298 DHUD_Target = nil;
1299 DHUD_TargetName:SetText("");
1300  
1301 -- sonst normal weiter
1302 else
1303  
1304 -- update TargetText
1305 if DHUD_Config["showtarget"] == 1 then
1306 DHUD_setTargetInfoText();
1307 else
1308 DHUD_TargetName:SetText("");
1309 end
1310  
1311 -- update Combopoints
1312 DHUD_UpdateCombos();
1313  
1314 -- changeBackgroundTexture
1315 DHUD_changeBackgroundTexture();
1316  
1317 -- Target selected?
1318 if UnitLevel("target") and UnitName("target") and DHUD_Config["showtarget"] == 1 then
1319 DHUD_Target = 1;
1320 else
1321 DHUD_Target = nil;
1322 end
1323  
1324 -- update Target Health
1325 if DHUD_Config["showtarget"] == 1 then
1326 DHUD_updateTargetHealth();
1327  
1328 if DHUD_Config["animatebars"] == 1 then
1329 DHUD_bar_anim["TargetHealth"] = DHUD_bar["TargetHealth"];
1330 DHUD_SetBar("TargetHealth",DHUD_bar["TargetHealth"]);
1331 end
1332  
1333 -- update Target Mana
1334 DHUD_updateTargetMana();
1335  
1336 if DHUD_Config["animatebars"] == 1 then
1337 DHUD_bar_anim["TargetMana"] = DHUD_bar["TargetMana"];
1338 DHUD_SetBar("TargetMana",DHUD_bar["TargetMana"]);
1339 end
1340  
1341 -- make name clickable?
1342 if ( UnitIsUnit("target", "player") and GetNumPartyMembers() > 0) or
1343 ( UnitIsPlayer("target") and not UnitIsEnemy("player", "target") and not UnitIsUnit("target", "player") ) then
1344 getglobal("DHUD_Target"):EnableMouse(1);
1345 else
1346 getglobal("DHUD_Target"):EnableMouse(0);
1347 end
1348 end
1349  
1350 end
1351  
1352 -- Auras
1353 DHUD_Auras();
1354  
1355 -- change Buttonwith
1356 DHUD_resizeText();
1357  
1358 -- set new alpha
1359 DHUD_updateAlpha();
1360  
1361 end
1362  
1363 function DHUD_resizeText()
1364  
1365 local wb = DHUD_TargetName:GetWidth();
1366 local hb = DHUD_TargetName:GetHeight();
1367 local f = getglobal("DHUD_Target");
1368  
1369 if wb < 5 then
1370 f:SetWidth(1);
1371 f:SetHeight(1);
1372 f:Hide();
1373 else
1374 f:SetWidth(wb+5);
1375 f:SetHeight(hb+5);
1376 f:Show();
1377 end
1378  
1379 end
1380  
1381 function DHUD_setTargetInfoText()
1382  
1383 -- target Name
1384 local unitname = "";
1385 local unitlevel = "";
1386 local targetclass = "";
1387 local eclass = "";
1388 local color = "";
1389 local whitecolor = "|r";
1390 local targetelite = "";
1391 local targetlevel = "";
1392  
1393 if UnitLevel("target") and UnitName("target") then
1394  
1395 -- set level
1396 unitlevel = UnitLevel("target");
1397  
1398 -- set name
1399 unitname = UnitName("target").." ";
1400  
1401 -- if level eg -1 then boss
1402 if unitlevel < 0 then
1403 unitlevel = 99;
1404 end
1405  
1406 -- get diff color
1407 color = GetDifficultyColor(unitlevel);
1408  
1409 -- show ?? for boss and hide then level = 0
1410 if unitlevel == 99 then
1411 unitlevel = "??";
1412 elseif unitlevel == 0 then
1413 unitlevel = "";
1414 end;
1415  
1416 -- build colorcoded levelstring
1417 local levelcolor = "|cff"..DHUD_DecToHex(color.r,color.g,color.b);
1418 targetlevel = levelcolor..unitlevel..whitecolor.." ";
1419  
1420 -- is Elite?
1421 targetelite = DHUD_CheckElite();
1422  
1423 -- set class
1424 if UnitClass("target") then
1425 targetclass, eclass = UnitClass("target");
1426  
1427 -- color classname
1428 if targetclass then
1429 local colorx = RAID_CLASS_COLORS[eclass or ""];
1430 color = DHUD_DecToHex(colorx.r,colorx.g,colorx.b);
1431  
1432 if (color) then
1433 classcolor = "|cff"..color;
1434 else
1435 classcolor = "|cffffffff";
1436 end
1437  
1438 -- is Unit pet?
1439 if not UnitIsPlayer("target") and not UnitCanAttack("player", "target") and UnitPlayerControlled("target") then
1440 targetclass = "Pet";
1441 -- is Unit NPC?
1442 elseif not UnitIsPlayer("target") and not UnitCanAttack("player", "target") and not UnitPlayerControlled("target") then
1443 targetclass = "NPC";
1444 end
1445  
1446 targetclass = "["..classcolor..targetclass..whitecolor.."]";
1447 end
1448 end
1449 end
1450  
1451 -- hide parts of text
1452 if DHUD_Config["showclass"] == 0 then
1453 targetclass = "";
1454 end
1455  
1456 if DHUD_Config["showname"] == 0 or not UnitLevel("target") then
1457 unitname = "";
1458 end
1459  
1460 if DHUD_Config["showelite"] == 0 then
1461 targetelite = nil;
1462 end
1463  
1464 if DHUD_Config["showlevel"] == 0 then
1465 targetlevel = "";
1466 end
1467  
1468 -- set target infos
1469 local fulltext = targetlevel..unitname..targetclass;
1470  
1471 if targetelite then
1472 fulltext = fulltext..targetelite
1473 end
1474  
1475 DHUD_TargetName:SetText(fulltext);
1476  
1477 end
1478  
1479 function DHUD_setAlphaCombat()
1480  
1481 DHUD_setAlpha("combatAlpha");
1482 DHUD_PlayerHealth:Show();
1483 DHUD_PlayerMana:Show();
1484 DHUD_TargetName:Show();
1485 if UnitHealth("pet") > 0 then
1486 DHUD_PetMana:Show();
1487 DHUD_PetHealth:Show();
1488 end
1489  
1490 end
1491  
1492 function DHUD_setAlphaSelect()
1493  
1494 -- hide npc is on and target is friendly NPC
1495 if DHUD_checkShowNPC() then
1496 DHUD_setAlpha("oocAlpha");
1497 DHUD_PlayerHealth:Hide();
1498 DHUD_PlayerMana:Hide();
1499 DHUD_PetMana:Hide();
1500 DHUD_PetHealth:Hide();
1501 DHUD_TargetHealth:Hide();
1502 DHUD_TargetMana:Hide();
1503  
1504 if DHUD_needHealth or DHUD_needMana or DHUD_PetneedHealth or DHUD_PetneedMana then
1505 DHUD_setAlphaRegen();
1506 end
1507  
1508 DHUD_TargetName:Hide();
1509 else
1510 DHUD_setAlpha("selAlpha");
1511 DHUD_PlayerHealth:Show();
1512 DHUD_PlayerMana:Show();
1513 DHUD_TargetName:Show();
1514 if UnitHealth("pet") > 0 then
1515 DHUD_PetMana:Show();
1516 DHUD_PetHealth:Show();
1517 end
1518 end
1519  
1520 end
1521  
1522 function DHUD_setAlphaRegen()
1523  
1524 DHUD_setAlpha("regAlpha");
1525 DHUD_TargetName:Show();
1526 DHUD_TargetHealth:Hide();
1527 DHUD_TargetMana:Hide();
1528  
1529 if (DHUD_needHealth or DHUD_needMana) and DHUD_Config["regAlpha"] > 0 then
1530 DHUD_PlayerHealth:Show();
1531 DHUD_PlayerMana:Show();
1532 else
1533 DHUD_PlayerHealth:Hide();
1534 DHUD_PlayerMana:Hide();
1535 end
1536  
1537 if (DHUD_PetneedHealth or DHUD_PetneedMana) and DHUD_Config["regAlpha"] > 0 then
1538 DHUD_PetMana:Show();
1539 DHUD_PetHealth:Show();
1540 else
1541 DHUD_PetMana:Hide();
1542 DHUD_PetHealth:Hide();
1543 end
1544  
1545 end
1546  
1547 function DHUD_setAlphaStandard()
1548  
1549 DHUD_setAlpha("oocAlpha");
1550 DHUD_PlayerHealth:Hide();
1551 DHUD_PlayerMana:Hide();
1552 DHUD_TargetHealth:Hide();
1553 DHUD_TargetMana:Hide();
1554 DHUD_PetMana:Hide();
1555 DHUD_PetHealth:Hide();
1556 DHUD_TargetName:Hide();
1557  
1558 end
1559  
1560 function DHUD_updateAlpha()
1561  
1562 -- dead ? then hide frame around bars
1563 -- TODO überarbeiten
1564 if DHUD_playerDead == 1 then
1565 DHUD_LeftFrameTexture:Hide();
1566 DHUD_RightFrameTexture:Hide();
1567 DHUD_CastingBarTexture:Hide();
1568 DHUD_CastingBarTextureHigh:Hide();
1569 DHUD_Castdelay:Hide();
1570 DHUD_Casttime:Hide();
1571 DHUD_TargetHealth:Hide();
1572 DHUD_TargetMana:Hide();
1573 DHUD_PlayerHealth:Hide();
1574 DHUD_PlayerMana:Hide();
1575 DHUD_PetMana:Hide();
1576 DHUD_PetHealth:Hide();
1577 DHUD_TargetName:Show();
1578 return;
1579 else
1580 if DHUD_Config["barborders"] == 1 then
1581 DHUD_LeftFrameTexture:Show();
1582 DHUD_RightFrameTexture:Show();
1583 end
1584 DHUD_PlayerHealth:Show();
1585 DHUD_PlayerMana:Show();
1586 DHUD_TargetName:Show();
1587 if UnitHealth("pet") > 0 then
1588 DHUD_PetMana:Show();
1589 DHUD_PetHealth:Show();
1590 end
1591 end
1592  
1593 -- Combat Mode
1594 if DHUD_inCombat then
1595  
1596 DHUD_setAlphaCombat();
1597 return;
1598  
1599 -- target selected
1600 elseif DHUD_Target then
1601  
1602 DHUD_setAlphaSelect();
1603 return;
1604  
1605 -- Player / Pet reg
1606 elseif DHUD_needHealth or DHUD_needMana or DHUD_PetneedHealth or DHUD_PetneedMana then
1607  
1608 DHUD_setAlphaRegen();
1609 return;
1610  
1611 -- Casting
1612 elseif DHUD_Casting then
1613  
1614 DHUD_setAlphaRegen();
1615 return;
1616  
1617 -- standard mode
1618 else
1619  
1620 DHUD_setAlphaStandard();
1621 return;
1622  
1623 end
1624  
1625 end
1626  
1627 function DHUD_OnUpdate()
1628  
1629 -- animate bars?
1630 if DHUD_Config["animatebars"] == 1 then
1631 -- Player HP Anim
1632 DHUD_Animate("PlayerHealth");
1633  
1634 -- Player Mana Anim
1635 DHUD_Animate("PlayerMana");
1636  
1637 if DHUD_Config["showtarget"] == 1 then
1638 -- Target HP Anim
1639 DHUD_Animate("TargetHealth");
1640  
1641 -- Target Mana Anim
1642 DHUD_Animate("TargetMana");
1643 end
1644  
1645 if DHUD_Config["showpet"] == 1 then
1646 -- Pet HP Anim
1647 DHUD_Animate("PetHealth");
1648  
1649 -- Pet Mana Anim
1650 DHUD_Animate("PetMana");
1651 end
1652 end
1653  
1654 -- castingbar
1655 if DHUD_Config["castingbar"] == 1 then
1656  
1657 if this.holdTime == nil then
1658 this.holdTime = 0;
1659 end
1660  
1661 -- casting
1662 if (this.casting) then
1663  
1664 local status = GetTime();
1665 if (status > this.maxValue) then
1666 status = this.maxValue
1667 end
1668 DHUD_CastingBarTextureHigh:Hide();
1669 DHUD_SetBar("Castingbar", ((status - this.startTime) / (this.maxValue - this.startTime)) );
1670  
1671 if DHUD_Config["castingbartimer"] == 1 then
1672 local display_time = string.format( "%.1f", (status + this.delay) - this.startTime );
1673 DHUD_Casttime_Text:SetText(display_time);
1674  
1675 if ( this.delay > 0 ) then
1676 DHUD_Castdelay_Text:SetText( "+"..string.format( "%.1f", this.delay) );
1677 else
1678 DHUD_Castdelay_Text:SetText("");
1679 end
1680  
1681 DHUD_Castdelay:SetAlpha(1);
1682 DHUD_Casttime:SetAlpha(1);
1683 end
1684  
1685 -- channeling
1686 elseif (this.channeling) then
1687  
1688 local time = GetTime();
1689 if (time > this.endTime) then
1690 time = this.endTime
1691 end
1692  
1693 local barValue = this.startTime + (this.endTime - time);
1694 local sparkPosition = ((barValue - this.startTime) / (this.endTime - this.startTime));
1695 DHUD_SetBar("Channelbar", sparkPosition );
1696 DHUD_CastingBarTextureHigh:Hide();
1697  
1698 if DHUD_Config["castingbartimer"] == 1 then
1699 local display_time = string.format( "%.1f",this.duration -((time + this.delay) - this.startTime)) ;
1700 DHUD_Casttime_Text:SetText( display_time );
1701  
1702 if ( this.delay > 0 ) then
1703 DHUD_Castdelay_Text:SetText( "-"..string.format( "%.1f", this.delay) );
1704 else
1705 DHUD_Castdelay_Text:SetText("");
1706 end
1707  
1708 DHUD_Castdelay:SetAlpha(1);
1709 DHUD_Casttime:SetAlpha(1);
1710 end
1711  
1712 if (time == this.endTime) then
1713 this.channeling = nil;
1714 this.casting = nil;
1715 this.fadeOut = 1;
1716 this.flash = nil;
1717 DHUD_Casting = nil;
1718 DHUD_updateAlpha();
1719 DHUD_SetBar("Channelbar", 0 );
1720 DHUD_CastingBarTexture:Hide();
1721 DHUD_CastingBarTextureHigh:Hide();
1722 return;
1723 end
1724  
1725 return;
1726  
1727 -- hold
1728 elseif ( GetTime() < this.holdTime) then
1729  
1730 return;
1731  
1732 -- flash
1733 elseif (this.flash) then
1734  
1735 local alpha = DHUD_CastingBarTextureHigh:GetAlpha() + CASTING_BAR_FLASH_STEP;
1736 if (alpha < 1) then
1737 DHUD_CastingBarTextureHigh:SetAlpha(alpha);
1738 else
1739 this.flash = nil;
1740 DHUD_CastingBarTextureHigh:SetAlpha(0);
1741 DHUD_CastingBarTextureHigh:Hide();
1742 end
1743  
1744 -- fade
1745 elseif (this.fadeOut) then
1746  
1747 local alpha = DHUD_CastingBarTexture:GetAlpha() - CASTING_BAR_ALPHA_STEP;
1748 if (alpha > 0) then
1749 DHUD_CastingBarTexture:SetAlpha(alpha);
1750 DHUD_Castdelay:SetAlpha(alpha);
1751 DHUD_Casttime:SetAlpha(alpha);
1752 else
1753 this.fadeOut = nil;
1754 DHUD_CastingBarTexture:Hide();
1755 DHUD_Castdelay:Hide();
1756 DHUD_Casttime:Hide();
1757 DHUD_Casting = nil;
1758 DHUD_updateAlpha();
1759 end
1760  
1761 end
1762  
1763  
1764 end
1765  
1766 end
1767  
1768 function DHUD_UpdateCombos()
1769 local points = GetComboPoints()
1770 if points == 0 then
1771 DHUD_TargetCombo1Texture:Hide();
1772 DHUD_TargetCombo2Texture:Hide();
1773 DHUD_TargetCombo3Texture:Hide();
1774 DHUD_TargetCombo4Texture:Hide();
1775 DHUD_TargetCombo5Texture:Hide();
1776 elseif points == 1 then
1777 DHUD_TargetCombo1Texture:Show();
1778 DHUD_TargetCombo2Texture:Hide();
1779 DHUD_TargetCombo3Texture:Hide();
1780 DHUD_TargetCombo4Texture:Hide();
1781 DHUD_TargetCombo5Texture:Hide();
1782 elseif points == 2 then
1783 DHUD_TargetCombo1Texture:Show();
1784 DHUD_TargetCombo2Texture:Show();
1785 DHUD_TargetCombo3Texture:Hide();
1786 DHUD_TargetCombo4Texture:Hide();
1787 DHUD_TargetCombo5Texture:Hide();
1788 elseif points == 3 then
1789 DHUD_TargetCombo1Texture:Show();
1790 DHUD_TargetCombo2Texture:Show();
1791 DHUD_TargetCombo3Texture:Show();
1792 DHUD_TargetCombo4Texture:Hide();
1793 DHUD_TargetCombo5Texture:Hide();
1794 elseif points == 4 then
1795 DHUD_TargetCombo1Texture:Show();
1796 DHUD_TargetCombo2Texture:Show();
1797 DHUD_TargetCombo3Texture:Show();
1798 DHUD_TargetCombo4Texture:Show();
1799 DHUD_TargetCombo5Texture:Hide();
1800 elseif points == 5 then
1801 DHUD_TargetCombo1Texture:Show();
1802 DHUD_TargetCombo2Texture:Show();
1803 DHUD_TargetCombo3Texture:Show();
1804 DHUD_TargetCombo4Texture:Show();
1805 DHUD_TargetCombo5Texture:Show();
1806 end
1807 end
1808  
1809 function DHUD_Animate(bar)
1810  
1811 -- base ändern
1812 local ph = math.floor(DHUD_bar[bar] * 100);
1813 local pha = math.floor(DHUD_bar_anim[bar] * 100);
1814  
1815 -- Abwärts animieren
1816 if ph < pha then
1817 DHUD_change[bar] = 1;
1818  
1819 if pha - ph > 10 then
1820 DHUD_bar_anim[bar] = DHUD_bar_anim[bar] - DHUD_Config["stepfast"];
1821 else
1822 DHUD_bar_anim[bar] = DHUD_bar_anim[bar] - DHUD_Config["step"];
1823 end
1824  
1825 -- Aufwärts animieren
1826 elseif ph > pha then
1827 DHUD_change[bar] = 1;
1828  
1829 if ph - pha > 10 then
1830 DHUD_bar_anim[bar] = DHUD_bar_anim[bar] + DHUD_Config["stepfast"];
1831 else
1832 DHUD_bar_anim[bar] = DHUD_bar_anim[bar] + DHUD_Config["step"];
1833 end
1834  
1835 end
1836  
1837 -- Anim
1838 if DHUD_change[bar] == 1 then
1839 DHUD_SetBar(bar,DHUD_bar_anim[bar]);
1840 DHUD_change[bar] = 0;
1841 end
1842  
1843 end;
1844  
1845 function DHUD_SetBar(bar,p,nocolor)
1846  
1847 local texture = getglobal(DHUD_tex[bar]);
1848  
1849 -- Hide when Bar empty
1850 if math.floor(p * 100) == 0 or DHUD_playerDead == 1 then
1851 texture:Hide();
1852 return;
1853 end
1854  
1855 -- Textur Settings laden
1856 local tex_height, tex_gap_top, tex_gap_bottom;
1857 tex_height, tex_gap_top, tex_gap_bottom = unpack(DHUD_texture_settings[bar]);
1858  
1859 -- offsets setzen wenn Balken nicht die ganze höhe ausfüllt
1860 local tex_gap_top_p = tex_gap_top / tex_height;
1861 local tex_gap_bottom_p = tex_gap_bottom / tex_height;
1862 local h = (tex_height - tex_gap_top - tex_gap_bottom) * p;
1863  
1864 -- Textursettings ändern
1865 local frame = getglobal(DHUD_attach[bar]);
1866 local top = 1-(p-(tex_gap_top_p));
1867 local bottom = 1-tex_gap_bottom_p;
1868  
1869 top = top - ((tex_gap_top_p+tex_gap_bottom_p)*(1-p));
1870  
1871 texture:Show();
1872 texture:SetHeight(h);
1873 texture:SetTexCoord(0, 1, top, bottom );
1874 texture:SetPoint("BOTTOM", frame, "BOTTOM", 0, tex_gap_bottom);
1875  
1876 if nocolor == nil then
1877 -- Farbe TODO: optimize that
1878 local colortype;
1879 local playerpower;
1880  
1881 -- healthcolor
1882 if ( bar == "PlayerHealth" or bar == "TargetHealth" or bar == "PetHealth" ) then
1883 colortype = "health";
1884  
1885 -- Castingbar
1886 elseif bar == "Castingbar" then
1887 colortype = "castbar";
1888  
1889 elseif bar == "Channelbar" then
1890 colortype = "channelbar";
1891  
1892 -- manacolor
1893 else
1894 if bar == "PlayerMana" then
1895 playerpower = UnitPowerType("player");
1896 elseif bar == "TargetMana" then
1897 playerpower = UnitPowerType("target");
1898 else
1899 playerpower = UnitPowerType("pet");
1900 end
1901  
1902 if (playerpower == 1) then
1903 colortype = "rage";
1904 elseif (playerpower == 2) then
1905 colortype = "focus";
1906 elseif (playerpower == 3) then
1907 colortype = "energy";
1908 else
1909 colortype = "mana";
1910 end
1911 end
1912  
1913 -- what uhit?
1914 local unit;
1915  
1916 if ( bar == "PlayerHealth" or bar == "PlayerMana") then
1917 unit = "player";
1918 elseif ( bar == "TargetHealth" or bar == "TargetMana") then
1919 unit = "target";
1920 elseif ( bar == "PettHealth" or bar == "PetMana") then
1921 unit = "pet";
1922 end
1923  
1924 -- set values
1925 local r, g, b = Get_HColor( p, colortype, unit );
1926 texture:SetVertexColor(r, g, b);
1927 end
1928  
1929 end;
1930  
1931 function DHUD_CheckElite()
1932 local el = UnitClassification("target");
1933  
1934 local ret = "";
1935 if ( el == "worldboss" ) then
1936 ret = "Boss";
1937 elseif ( el == "rareelite" ) then
1938 ret = "Rare Elite";
1939 elseif ( el == "elite" ) then
1940 ret = "Elite";
1941 elseif ( el == "rare" ) then
1942 ret = "rare";
1943 else
1944 return nil;
1945 end
1946  
1947 return "|cffaaaaaa"..ret.."|r";
1948 end
1949  
1950 function DHUD_updatePlayerMana()
1951  
1952 DHUD_bar["PlayerMana"] = UnitMana("player")/UnitManaMax("player");
1953  
1954 local playerpower = UnitPowerType("player");
1955  
1956 -- krieger
1957 if (playerpower == 1) then
1958 DHUD_PlayerMana_Text:SetText( UnitMana("player") );
1959  
1960 if UnitMana("player") == 0 then
1961 DHUD_needMana = nil;
1962 else
1963 DHUD_needMana = true;
1964 end
1965  
1966 -- rogue
1967 elseif (playerpower == 3) then
1968  
1969 -- display player mana depends on mode
1970 if DHUD_Config["playerdisplaymode"] == 1 then
1971 DHUD_PlayerMana_Text:SetText( UnitMana("player") );
1972 elseif DHUD_Config["playerdisplaymode"] == 2 then
1973 DHUD_PlayerMana_Text:SetText( UnitMana("player") );
1974 elseif DHUD_Config["playerdisplaymode"] == 3 then
1975 DHUD_PlayerMana_Text:SetText( UnitMana("player")..DHUD_trennzeichen..UnitManaMax("player") );
1976 else
1977 DHUD_PlayerMana_Text:SetText("");
1978 end
1979  
1980 if math.floor(DHUD_bar["PlayerMana"] * 100) >= 100 then
1981 DHUD_needMana = nil;
1982 else
1983 DHUD_needMana = true;
1984 end
1985  
1986 -- other
1987 else
1988  
1989 -- display player mana depends on mode
1990 if DHUD_Config["playerdisplaymode"] == 1 then
1991 DHUD_PlayerMana_Text:SetText( math.floor(DHUD_bar["PlayerMana"] * 100) .. "%");
1992 elseif DHUD_Config["playerdisplaymode"] == 2 then
1993 DHUD_PlayerMana_Text:SetText( UnitMana("player") );
1994 elseif DHUD_Config["playerdisplaymode"] == 3 then
1995 DHUD_PlayerMana_Text:SetText( UnitMana("player")..DHUD_trennzeichen..UnitManaMax("player") );
1996 else
1997 DHUD_PlayerMana_Text:SetText("");
1998 end
1999  
2000 if math.floor(DHUD_bar["PlayerMana"] * 100) == 100 then
2001 DHUD_needMana = nil;
2002 else
2003 DHUD_needMana = true;
2004 end
2005  
2006 end
2007  
2008 DHUD_updateAlpha();
2009  
2010 if DHUD_playerDead == 1 then
2011 DHUD_PlayerMana_Text:SetText("");
2012 end
2013  
2014 -- set values to bar when no animation
2015 if DHUD_Config["animatebars"] == 0 then
2016 DHUD_SetBar("PlayerMana",DHUD_bar["PlayerMana"]);
2017 end
2018  
2019 end
2020  
2021 function DHUD_updatePlayerHealth()
2022  
2023 DHUD_bar["PlayerHealth"] = tonumber(UnitHealth("player")/UnitHealthMax("player"));
2024  
2025 -- display player health depends on mode
2026 if DHUD_Config["playerdisplaymode"] == 1 then
2027 DHUD_PlayerHealth_Text:SetText( math.floor(DHUD_bar["PlayerHealth"] * 100) .. "%");
2028 elseif DHUD_Config["playerdisplaymode"] == 2 then
2029 DHUD_PlayerHealth_Text:SetText( UnitHealth("player") );
2030 elseif DHUD_Config["playerdisplaymode"] == 3 then
2031 DHUD_PlayerHealth_Text:SetText( UnitHealth("player")..DHUD_trennzeichen..UnitHealthMax("player") );
2032 else
2033 DHUD_PlayerHealth_Text:SetText("");
2034 end
2035  
2036 if math.floor(DHUD_bar["PlayerHealth"] * 100) == 100 then
2037 DHUD_needHealth = nil;
2038 else
2039 DHUD_needHealth = true;
2040 end
2041  
2042 -- unit dead?
2043 if (UnitIsGhost("player")) then
2044 DHUD_playerDead = 1;
2045 elseif (UnitIsDead("player")) then
2046 DHUD_playerDead = 1;
2047 elseif (not UnitName("player")) then
2048 DHUD_playerDead = 1;
2049 else
2050 DHUD_playerDead = nil;
2051 end
2052  
2053 if DHUD_playerDead == 1 then
2054 DHUD_PlayerHealth_Text:SetText("");
2055 end
2056  
2057 DHUD_updateAlpha();
2058  
2059 -- set values to bar when no animation
2060 if DHUD_Config["animatebars"] == 0 then
2061 DHUD_SetBar("PlayerHealth",DHUD_bar["PlayerHealth"]);
2062 end
2063  
2064 end
2065  
2066 function DHUD_updateTargetHealth()
2067  
2068 local targethealth;
2069 local targethealthmax;
2070  
2071 DHUD_bar["TargetHealth"] = UnitHealth("target")/UnitHealthMax("target");
2072  
2073 if UnitHealth("target") == 0 then
2074 DHUD_bar["TargetHealth"] = 0;
2075 end
2076  
2077 -- display target health depends on mode
2078 if DHUD_Config["targetdisplaymode"] == 1 then
2079 DHUD_TargetHealth_Text:SetText( math.floor(DHUD_bar["TargetHealth"] * 100) .. "%");
2080 elseif DHUD_Config["targetdisplaymode"] == 2 then
2081 targethealth = DHUD_getTargetHealth();
2082 DHUD_TargetHealth_Text:SetText( targethealth );
2083 elseif DHUD_Config["targetdisplaymode"] == 3 then
2084 targethealth = DHUD_getTargetHealth();
2085 targethealthmax = DHUD_getTargetMaxHealth();
2086 DHUD_TargetHealth_Text:SetText( targethealth..DHUD_trennzeichen..targethealthmax );
2087 else
2088 DHUD_TargetHealth_Text:SetText("");
2089 end
2090  
2091 -- set values to bar when no animation
2092 if DHUD_Config["animatebars"] == 0 then
2093 DHUD_SetBar("TargetHealth",DHUD_bar["TargetHealth"]);
2094 end
2095  
2096 end
2097  
2098 function DHUD_updateTargetMana()
2099  
2100 DHUD_bar["TargetMana"] = UnitMana("target")/UnitManaMax("target");
2101  
2102 if UnitMana("target") == 0 then
2103 DHUD_bar["TargetMana"] = 0;
2104 end
2105  
2106 -- display target health depends on mode
2107 if DHUD_Config["targetdisplaymode"] == 1 then
2108 local percent = "%";
2109 local upt;
2110  
2111 upt = UnitPowerType("target");
2112  
2113 if upt == 1 or upt == 3 then
2114 percent = "";
2115 end
2116  
2117 DHUD_TargetMana_Text:SetText( math.floor(DHUD_bar["TargetMana"] * 100) .. percent);
2118 elseif DHUD_Config["targetdisplaymode"] == 2 then
2119 DHUD_TargetMana_Text:SetText( UnitMana("target") );
2120 elseif DHUD_Config["targetdisplaymode"] == 3 then
2121 DHUD_TargetMana_Text:SetText( UnitMana("target")..DHUD_trennzeichen..UnitManaMax("target") );
2122 else
2123 DHUD_TargetMana_Text:SetText("");
2124 end
2125  
2126 -- set values to bar when no animation
2127 if DHUD_Config["animatebars"] == 0 then
2128 DHUD_SetBar("TargetMana",DHUD_bar["TargetMana"]);
2129 end
2130  
2131 end
2132  
2133 function DHUD_updatePetHealth()
2134  
2135 if UnitHealth("pet") <= 0 then
2136 DHUD_PetHealth:Hide();
2137 DHUD_PetneedHealth = nil;
2138 DHUD_SetBar("PetHealth",0);
2139 return;
2140 end
2141  
2142 DHUD_bar["PetHealth"] = UnitHealth("pet")/UnitHealthMax("pet");
2143  
2144 if UnitHealth("pet") == 0 then
2145 DHUD_bar["PetHealth"] = 0;
2146 end
2147  
2148 -- display target health depends on mode
2149 if DHUD_Config["petdisplaymode"] == 1 then
2150 DHUD_PetHealth_Text:SetText( math.floor(DHUD_bar["PetHealth"] * 100) .. "%");
2151 elseif DHUD_Config["petdisplaymode"] == 2 then
2152 DHUD_PetHealth_Text:SetText( UnitHealth("pet") );
2153 elseif DHUD_Config["petdisplaymode"] == 3 then
2154 DHUD_PetHealth_Text:SetText( UnitHealth("pet")..DHUD_trennzeichen..UnitHealthMax("pet") );
2155 else
2156 DHUD_PetHealth_Text:SetText("");
2157 end
2158  
2159 -- does pet have full health?
2160 if math.floor(DHUD_bar["PetHealth"] * 100) == 100 then
2161 DHUD_PetneedHealth = nil;
2162 else
2163 DHUD_PetneedHealth = true;
2164 end
2165  
2166 DHUD_updateAlpha();
2167  
2168 -- set values to bar when no animation
2169 if DHUD_Config["animatebars"] == 0 then
2170 DHUD_SetBar("PetHealth",DHUD_bar["PetHealth"]);
2171 end
2172  
2173 end
2174  
2175 function DHUD_updatePetMana()
2176  
2177 if UnitHealth("pet") <= 0 then
2178 DHUD_PetMana:Hide();
2179 DHUD_PetneedMana = nil;
2180 DHUD_SetBar("PetMana",0);
2181 return;
2182 end
2183  
2184 DHUD_bar["PetMana"] = UnitMana("pet")/UnitManaMax("pet");
2185  
2186 if UnitMana("pet") == 0 then
2187 DHUD_bar["PetMana"] = 0;
2188 end
2189  
2190 -- display target health depends on mode
2191 if DHUD_Config["petdisplaymode"] == 1 then
2192 DHUD_PetMana_Text:SetText( math.floor(DHUD_bar["PetMana"] * 100) .. "%");
2193 elseif DHUD_Config["petdisplaymode"] == 2 then
2194 DHUD_PetMana_Text:SetText( UnitMana("pet") );
2195 elseif DHUD_Config["petdisplaymode"] == 3 then
2196 DHUD_PetMana_Text:SetText( UnitMana("pet")..DHUD_trennzeichen..UnitManaMax("pet") );
2197 else
2198 DHUD_PetMana_Text:SetText("");
2199 end
2200  
2201 -- does pet have full mana?
2202 if math.floor(DHUD_bar["PetMana"] * 100) >= 100 then
2203 DHUD_PetneedMana = nil;
2204 else
2205 DHUD_PetneedMana = true;
2206 end
2207  
2208 DHUD_updateAlpha();
2209  
2210 -- set values to bar when no animation
2211 if DHUD_Config["animatebars"] == 0 then
2212 DHUD_SetBar("PetMana",DHUD_bar["PetMana"]);
2213 end
2214  
2215 end
2216  
2217 -- range command
2218 function DHUD_CommandRange(command,rest)
2219  
2220 local num = tonumber(rest);
2221 if num == nil then
2222 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[command]["output"],
2223 command,
2224 DHUD_CommandList[command]["minvalue"],
2225 DHUD_CommandList[command]["maxvalue"]));
2226 return;
2227 end
2228 if num >= DHUD_CommandList[command]["minvalue"] and num <= DHUD_CommandList[command]["maxvalue"] then
2229 DHUD_SetConfig(command,num);
2230 DHUD_init();
2231 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[command]["response"],
2232 command,
2233 num,
2234 DHUD_CommandList[command]["minvalue"],
2235 DHUD_CommandList[command]["maxvalue"]));
2236 return;
2237 else
2238 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[command]["output"],
2239 command,
2240 DHUD_CommandList[command]["minvalue"],
2241 DHUD_CommandList[command]["maxvalue"]));
2242 return;
2243 end
2244  
2245  
2246 end
2247  
2248 function DHUD_OptionsFrame_Toggle()
2249 if(DHUDOptionsFrame:IsVisible()) then
2250 DHUDOptionsFrame:Hide();
2251 else
2252 DHUDOptionsFrame:Show();
2253 end
2254 end
2255  
2256 function DHUD_SCommandHandler(msg)
2257  
2258 if msg then
2259 local b,e,command,rest = string.find(msg, "^%s*([^%s]+)%s*(.*)$");
2260  
2261 if b then
2262 for var , commandStrings in DHUD_CommandList do
2263 if ( command == commandStrings["command"] ) then
2264 if commandStrings["type"] == "range" then
2265 DHUD_CommandRange(var,rest);
2266 return;
2267 elseif commandStrings["type"] == "toggle" then
2268 DHUD_ToggleConfig(var);
2269 return;
2270 elseif commandStrings["type"] == "reset" then
2271 DHUD_reset();
2272 DEFAULT_CHAT_FRAME:AddMessage(DHUD_CommandList[var]["response"]);
2273 return;
2274 elseif commandStrings["type"] == "color" then
2275 DHUD_SetColor(var, rest);
2276 return;
2277 elseif commandStrings["type"] == "menu" then
2278 DHUD_OptionsFrame_Toggle();
2279 DEFAULT_CHAT_FRAME:AddMessage(DHUD_CommandList[var]["response"]);
2280 return;
2281 end
2282 end
2283 end
2284 end
2285  
2286 -- ausgabe der slash befehle
2287 for var , commandStrings in DHUD_CommandList do
2288 if commandStrings["type"] == "range" then
2289 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[var]["output"],DHUD_CommandList[var]["command"],DHUD_CommandList[var]["minvalue"],DHUD_CommandList[var]["maxvalue"]));
2290 elseif commandStrings["type"] == "toggle" then
2291 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[var]["output"],DHUD_CommandList[var]["command"]));
2292 elseif commandStrings["type"] == "reset" then
2293 DEFAULT_CHAT_FRAME:AddMessage(DHUD_CommandList[var]["output"]);
2294 elseif commandStrings["type"] == "color" then
2295 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[var]["output"],DHUD_CommandList[var]["command"]));
2296 elseif commandStrings["type"] == "menu" then
2297 DEFAULT_CHAT_FRAME:AddMessage(DHUD_CommandList[var]["output"]);
2298 end
2299 end
2300 end
2301  
2302 end
2303  
2304 function DHUD_SetConfig(key, value)
2305 if (DHUD_Config[key] ~= value) then
2306 DHUD_Config[key] = value;
2307 end
2308 end
2309  
2310 function DHUD_SetColor(key, value)
2311 if (DHUD_Config[key] ~= value) then
2312 DHUD_Config[key] = value;
2313 DEFAULT_CHAT_FRAME:AddMessage( string.format(DHUD_CommandList[key]["response"], key, value , value) );
2314 end
2315 end
2316  
2317 function DHUD_defaultConfig(key)
2318 if (not DHUD_Config[key]) then
2319 DHUD_Config[key] = DHUD_Config_default[key];
2320 end
2321 end
2322  
2323 function DHUD_resetConfig(key)
2324 DHUD_Config[key] = DHUD_Config_default[key];
2325 end
2326  
2327 function DHUD_commandColor(key, value)
2328 if (DHUD_Config[key] == nil) then
2329 DHUD_Config[key] = "ffffff";
2330 end
2331  
2332 DHUD_Config[key] = value;
2333  
2334 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[key]["response"],
2335 key,
2336 "|cffff0000"..value.."|r"));
2337 end
2338  
2339 function DHUD_ToggleConfig(key)
2340 if (DHUD_Config[key] == nil) then
2341 DHUD_Config[key] = 0;
2342 end
2343  
2344 if (DHUD_Config[key] == 1) then
2345 DHUD_Config[key] = 0;
2346 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[key]["response"],
2347 key,
2348 "|cffff0000OFF|r"));
2349 else
2350 DHUD_Config[key] = 1;
2351 DEFAULT_CHAT_FRAME:AddMessage(string.format(DHUD_CommandList[key]["response"],
2352 key,
2353 "|cff00ff00ON|r"));
2354 end
2355  
2356 DHUD_init();
2357  
2358 end
2359  
2360 function DHUD_init()
2361  
2362 -- set scale
2363 DHUD:SetScale(DHUD_Config["scale"]);
2364  
2365 -- Set default bars
2366 if UnitPowerType("player") == 1 then
2367 DHUD_SetBar("PlayerMana" ,0);
2368 else
2369 DHUD_SetBar("PlayerMana" ,1);
2370 end
2371 DHUD_SetBar("PlayerHealth" ,1);
2372 DHUD_SetBar("TargetMana" ,0);
2373 DHUD_SetBar("TargetHealth" ,0);
2374 DHUD_SetBar("PetMana" ,1);
2375 DHUD_SetBar("PetHealth" ,1);
2376  
2377 -- setcombo position
2378 local DHUD_layer_pos;
2379 if DHUD_Config["showtarget"] == 1 then
2380 DHUD_layer_pos = {
2381 ["DHUD_TargetCombo1Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , 17 , 40 },
2382 ["DHUD_TargetCombo2Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , 7 , 61 },
2383 ["DHUD_TargetCombo3Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -1 , 83 },
2384 ["DHUD_TargetCombo4Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -6 , 105 },
2385 ["DHUD_TargetCombo5Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -7 , 127 },
2386 }
2387 else
2388 DHUD_layer_pos = {
2389 ["DHUD_TargetCombo1Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , 17 , 40 },
2390 ["DHUD_TargetCombo2Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , 7 , 61 },
2391 ["DHUD_TargetCombo3Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -1 , 83 },
2392 ["DHUD_TargetCombo4Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -6 , 105 },
2393 ["DHUD_TargetCombo5Texture"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , -7 , 127 },
2394  
2395 }
2396 end
2397  
2398 local texname;
2399 local v;
2400 for texname, v in DHUD_layer_pos do
2401 local point, frame, relativePoint , x, y = unpack(v);
2402 local texture = getglobal(texname);
2403 texture:ClearAllPoints();
2404 texture:SetPoint(point, frame, relativePoint , x, y);
2405 end
2406  
2407 -- pos textures
2408 local DHUD_texture_pos = {
2409 ["DHUD"] = { "CENTER", "UIParent" , "CENTER" , DHUD_Config["xoffset"] , DHUD_Config["yoffset"] },
2410 ["DHUD_LeftFrame"] = { "TOP" , "DHUD" , "TOP" , 0 - DHUD_Config["hudspacing"] , 0 },
2411 ["DHUD_RightFrame"] = { "TOP" , "DHUD" , "TOP" , DHUD_Config["hudspacing"] , 0 },
2412 ["DHUD_Target"] = { "BOTTOM", "DHUD" , "BOTTOM" , 0 , DHUD_Config["targettexty"] },
2413 ["DHUD_PlayerHealth"] = { "BOTTOM", "DHUD_LeftFrame" , "BOTTOM" , DHUD_Config["playerhptextx"] , DHUD_Config["playerhptexty"] },
2414 ["DHUD_PlayerMana"] = { "BOTTOM", "DHUD_LeftFrame", "BOTTOM" , DHUD_Config["playermanatextx"], DHUD_Config["playermanatexty"] },
2415 ["DHUD_TargetHealth"] = { "BOTTOM", "DHUD_RightFrame" , "BOTTOM" , DHUD_Config["targethptextx"] , DHUD_Config["targethptexty"] },
2416 ["DHUD_TargetMana"] = { "BOTTOM", "DHUD_RightFrame", "BOTTOM" , DHUD_Config["targetmanatextx"], DHUD_Config["targetmanatexty"] },
2417 ["DHUD_PetHealth"] = { "BOTTOM", "DHUD_LeftFrame" , "BOTTOM" , DHUD_Config["pethptextx"] , DHUD_Config["pethptexty"] },
2418 ["DHUD_PetMana"] = { "BOTTOM", "DHUD_RightFrame", "BOTTOM" , DHUD_Config["petmanatextx"] , DHUD_Config["petmanatexty"] },
2419 }
2420  
2421 local texname;
2422 local v;
2423 for texname, v in DHUD_texture_pos do
2424 local point, frame, relativePoint , x, y = unpack(v);
2425 local texture = getglobal(texname);
2426 texture:ClearAllPoints();
2427 texture:SetPoint(point, frame, relativePoint , x, y);
2428 texture:EnableMouse(0);
2429 end
2430  
2431 -- set fonts
2432 DHUD_setFont("DHUD_PetHealth_Text", DHUD_Config["fontsizepet"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["pethpoutline"] ]);
2433 DHUD_setFont("DHUD_PetMana_Text", DHUD_Config["fontsizepet"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["petmanaoutline"] ]);
2434 DHUD_setFont("DHUD_PlayerHealth_Text", DHUD_Config["fontsizeplayer"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["playerhpoutline"] ]);
2435 DHUD_setFont("DHUD_PlayerMana_Text", DHUD_Config["fontsizeplayer"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["playermanaoutline"] ]);
2436 DHUD_setFont("DHUD_TargetHealth_Text", DHUD_Config["fontsizetarget"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["targethpoutline"] ]);
2437 DHUD_setFont("DHUD_TargetMana_Text", DHUD_Config["fontsizetarget"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["targetmanaoutline"] ]);
2438 DHUD_setFont("DHUD_TargetName", DHUD_Config["fontsizetargetname"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["targetoutline"] ]);
2439 DHUD_setFont("DHUD_Casttime_Text", DHUD_Config["fontsizecasttime"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["casttimeoutline"] ]);
2440 DHUD_setFont("DHUD_Castdelay_Text", DHUD_Config["fontsizecastdelay"] / DHUD_Config["scale"] , DHUD_Outline[ DHUD_Config["castdelayoutline"] ]);
2441  
2442 -- font colors
2443 DHUD_Castdelay_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["castdelaytextcolor"]));
2444 DHUD_Casttime_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["casttimetextcolor"]));
2445 DHUD_PlayerHealth_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["playerhptextcolor"]));
2446 DHUD_PlayerMana_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["playermanatextcolor"]));
2447 DHUD_TargetHealth_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["targethptextcolor"]));
2448 DHUD_TargetMana_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["targetmanatextcolor"]));
2449 DHUD_PetHealth_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["pethptextcolor"]));
2450 DHUD_PetMana_Text:SetVertexColor(DHUD_hextodec(DHUD_Config["petmanatextcolor"]));
2451  
2452 -- set combopoints
2453 DHUD_UpdateCombos();
2454  
2455 -- hide Auras
2456 DHUD_hideAuras();
2457  
2458 --
2459 DHUD_changeBackgroundTexture();
2460  
2461 -- reset target settings
2462 DHUD_updateTargetChanged();
2463  
2464 --
2465 DHUD_updatePetHealth();
2466 DHUD_updatePetMana();
2467 DHUD_updatePlayerMana();
2468 DHUD_updatePlayerHealth();
2469  
2470 -- update alpha
2471 DHUD_updateAlpha();
2472  
2473 -- DUF / Perl Installed? Dont show Blizz frames
2474 if (DUF_INITIALIZED or Perl_Config or Perl_Config_Config) then
2475 DHUD_Config["btarget"] = 0;
2476 end
2477  
2478 -- Hide Blizz Target Frames
2479 if DHUD_Config["btarget"] == 0 then
2480 TargetFrame:UnregisterEvent("PLAYER_TARGET_CHANGED")
2481 TargetFrame:UnregisterEvent("UNIT_HEALTH")
2482 TargetFrame:UnregisterEvent("UNIT_LEVEL")
2483 TargetFrame:UnregisterEvent("UNIT_FACTION")
2484 TargetFrame:UnregisterEvent("UNIT_CLASSIFICATION_CHANGED")
2485 TargetFrame:UnregisterEvent("UNIT_AURA")
2486 TargetFrame:UnregisterEvent("PLAYER_FLAGS_CHANGED")
2487 TargetFrame:UnregisterEvent("PARTY_MEMBERS_CHANGED")
2488 TargetFrame:Hide()
2489 ComboFrame:UnregisterEvent("PLAYER_TARGET_CHANGED")
2490 ComboFrame:UnregisterEvent("PLAYER_COMBO_POINTS")
2491 else
2492 TargetFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
2493 TargetFrame:RegisterEvent("UNIT_HEALTH")
2494 TargetFrame:RegisterEvent("UNIT_LEVEL")
2495 TargetFrame:RegisterEvent("UNIT_FACTION")
2496 TargetFrame:RegisterEvent("UNIT_CLASSIFICATION_CHANGED")
2497 TargetFrame:RegisterEvent("UNIT_AURA")
2498 TargetFrame:RegisterEvent("PLAYER_FLAGS_CHANGED")
2499 TargetFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
2500 if UnitExists("target") then TargetFrame:Show() end
2501 ComboFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
2502 ComboFrame:RegisterEvent("PLAYER_COMBO_POINTS")
2503 end
2504  
2505 if DHUD_Config["bplayer"] == 0 then
2506 PlayerFrame:UnregisterEvent("UNIT_LEVEL")
2507 PlayerFrame:UnregisterEvent("UNIT_COMBAT")
2508 PlayerFrame:UnregisterEvent("UNIT_SPELLMISS")
2509 PlayerFrame:UnregisterEvent("UNIT_PVP_UPDATE")
2510 PlayerFrame:UnregisterEvent("UNIT_MAXMANA")
2511 PlayerFrame:UnregisterEvent("PLAYER_ENTER_COMBAT")
2512 PlayerFrame:UnregisterEvent("PLAYER_LEAVE_COMBAT")
2513 PlayerFrame:UnregisterEvent("PLAYER_UPDATE_RESTING")
2514 PlayerFrame:UnregisterEvent("PARTY_MEMBERS_CHANGED")
2515 PlayerFrame:UnregisterEvent("PARTY_LEADER_CHANGED")
2516 PlayerFrame:UnregisterEvent("PARTY_LOOT_METHOD_CHANGED")
2517 PlayerFrame:UnregisterEvent("PLAYER_ENTERING_WORLD")
2518 PlayerFrame:UnregisterEvent("PLAYER_REGEN_DISABLED")
2519 PlayerFrame:UnregisterEvent("PLAYER_REGEN_ENABLED")
2520 PlayerFrameHealthBar:UnregisterEvent("UNIT_HEALTH")
2521 PlayerFrameHealthBar:UnregisterEvent("UNIT_MAXHEALTH")
2522 PlayerFrameManaBar:UnregisterEvent("UNIT_MANA")
2523 PlayerFrameManaBar:UnregisterEvent("UNIT_RAGE")
2524 PlayerFrameManaBar:UnregisterEvent("UNIT_FOCUS")
2525 PlayerFrameManaBar:UnregisterEvent("UNIT_ENERGY")
2526 PlayerFrameManaBar:UnregisterEvent("UNIT_HAPPINESS")
2527 PlayerFrameManaBar:UnregisterEvent("UNIT_MAXMANA")
2528 PlayerFrameManaBar:UnregisterEvent("UNIT_MAXRAGE")
2529 PlayerFrameManaBar:UnregisterEvent("UNIT_MAXFOCUS")
2530 PlayerFrameManaBar:UnregisterEvent("UNIT_MAXENERGY")
2531 PlayerFrameManaBar:UnregisterEvent("UNIT_MAXHAPPINESS")
2532 PlayerFrameManaBar:UnregisterEvent("UNIT_DISPLAYPOWER")
2533 PlayerFrame:UnregisterEvent("UNIT_NAME_UPDATE")
2534 PlayerFrame:UnregisterEvent("UNIT_PORTRAIT_UPDATE")
2535 PlayerFrame:UnregisterEvent("UNIT_DISPLAYPOWER")
2536 PlayerFrame:Hide()
2537 else
2538 PlayerFrame:RegisterEvent("UNIT_LEVEL")
2539 PlayerFrame:RegisterEvent("UNIT_COMBAT")
2540 PlayerFrame:RegisterEvent("UNIT_SPELLMISS")
2541 PlayerFrame:RegisterEvent("UNIT_PVP_UPDATE")
2542 PlayerFrame:RegisterEvent("UNIT_MAXMANA")
2543 PlayerFrame:RegisterEvent("PLAYER_ENTER_COMBAT")
2544 PlayerFrame:RegisterEvent("PLAYER_LEAVE_COMBAT")
2545 PlayerFrame:RegisterEvent("PLAYER_UPDATE_RESTING")
2546 PlayerFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
2547 PlayerFrame:RegisterEvent("PARTY_LEADER_CHANGED")
2548 PlayerFrame:RegisterEvent("PARTY_LOOT_METHOD_CHANGED")
2549 PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
2550 PlayerFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
2551 PlayerFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
2552 PlayerFrameHealthBar:RegisterEvent("UNIT_HEALTH")
2553 PlayerFrameHealthBar:RegisterEvent("UNIT_MAXHEALTH")
2554 PlayerFrameManaBar:RegisterEvent("UNIT_MANA")
2555 PlayerFrameManaBar:RegisterEvent("UNIT_RAGE")
2556 PlayerFrameManaBar:RegisterEvent("UNIT_FOCUS")
2557 PlayerFrameManaBar:RegisterEvent("UNIT_ENERGY")
2558 PlayerFrameManaBar:RegisterEvent("UNIT_HAPPINESS")
2559 PlayerFrameManaBar:RegisterEvent("UNIT_MAXMANA")
2560 PlayerFrameManaBar:RegisterEvent("UNIT_MAXRAGE")
2561 PlayerFrameManaBar:RegisterEvent("UNIT_MAXFOCUS")
2562 PlayerFrameManaBar:RegisterEvent("UNIT_MAXENERGY")
2563 PlayerFrameManaBar:RegisterEvent("UNIT_MAXHAPPINESS")
2564 PlayerFrameManaBar:RegisterEvent("UNIT_DISPLAYPOWER")
2565 PlayerFrame:RegisterEvent("UNIT_NAME_UPDATE")
2566 PlayerFrame:RegisterEvent("UNIT_PORTRAIT_UPDATE")
2567 PlayerFrame:RegisterEvent("UNIT_DISPLAYPOWER")
2568 PlayerFrame:Show()
2569 end
2570  
2571 -- hide mobhealth frame?
2572 if DHUD_Config["btarget"] == 0 then
2573 if (MI2_MobHealthFrame) then
2574 MI2_MobHealthFrame:Hide();
2575 end
2576 if (MobHealthFrame) then
2577 MobHealthFrame:Hide();
2578 end
2579 else
2580 if (MI2_MobHealthFrame) then
2581 MI2_MobHealthFrame:Show();
2582 end
2583 if (MobHealthFrame) then
2584 MobHealthFrame:Show();
2585 end
2586 end
2587  
2588 -- hide minimap button=
2589 if DHUD_Config["showmmb"] == 1 then
2590 DHUD_MinimapButton:Show();
2591 else
2592 DHUD_MinimapButton:Hide();
2593 end
2594  
2595 -- set minimab button angle
2596 local where = DHUD_Config["minimapw"];
2597 local mx = 52 - (80 * cos(where));
2598 local my = (80 * sin(where)) - 52;
2599 DHUD_MinimapButton:ClearAllPoints();
2600 DHUD_MinimapButton:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", mx,my);
2601  
2602 -- init castbar
2603 this.casting = nil;
2604 this.channeling = nil;
2605 this.holdTime = 1;
2606 this.maxValue = 0;
2607 this.endTime = 0;
2608 this.startTime = 0;
2609 this.delay = 0;
2610  
2611 -- hide blizz castbar
2612 if DHUD_Config["castingbar"] == 1 then
2613 CastingBarFrame:UnregisterEvent("SPELLCAST_START");
2614 CastingBarFrame:UnregisterEvent("SPELLCAST_STOP");
2615 CastingBarFrame:UnregisterEvent("SPELLCAST_FAILED");
2616 CastingBarFrame:UnregisterEvent("SPELLCAST_INTERRUPTED");
2617 CastingBarFrame:UnregisterEvent("SPELLCAST_DELAYED");
2618 CastingBarFrame:UnregisterEvent("SPELLCAST_CHANNEL_START");
2619 CastingBarFrame:UnregisterEvent("SPELLCAST_CHANNEL_UPDATE");
2620 CastingBarFrame:UnregisterEvent("SPELLCAST_CHANNEL_STOP");
2621 CastingBarFrame:Hide();
2622 else
2623 CastingBarFrame:RegisterEvent("SPELLCAST_START");
2624 CastingBarFrame:RegisterEvent("SPELLCAST_STOP");
2625 CastingBarFrame:RegisterEvent("SPELLCAST_FAILED");
2626 CastingBarFrame:RegisterEvent("SPELLCAST_INTERRUPTED");
2627 CastingBarFrame:RegisterEvent("SPELLCAST_DELAYED");
2628 CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_START");
2629 CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
2630 CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_STOP");
2631 end;
2632  
2633 end
2634  
2635 function DHUD_hideAuras()
2636 -- hide Auras
2637 local i, button;
2638  
2639 for i = 1, 16 do
2640 button = getglobal("DHUDBuff"..i);
2641 button:Hide();
2642  
2643 button = getglobal("DHUDDeBuff"..i);
2644 button:Hide();
2645 end
2646 end
2647  
2648 function DHUD_reset()
2649  
2650 for k, v in DHUD_Config_default do
2651 DHUD_resetConfig(k);
2652 end
2653  
2654 DHUD_init();
2655  
2656 end
2657  
2658 function DHUD_getTargetHealth()
2659  
2660 local h;
2661  
2662 -- get health from mobinfo / mobhealth
2663 if MobHealth_GetTargetCurHP then
2664 -- mobhealth2
2665 h = MobHealth_GetTargetCurHP();
2666 elseif MobHealth_PPP and UnitName("target") and UnitLevel("target") then
2667 -- mobinfo
2668 local mi = UnitName("target")..":"..UnitLevel("target");
2669 local p = MobHealth_PPP(mi);
2670 h = math.floor(UnitHealth("target") * p + 0.5);
2671 elseif MobHealthDB and UnitName("target") and UnitLevel("target") then
2672 -- telos mobhealth
2673 local mi = UnitName("target")..":"..UnitLevel("target");
2674 local p = DHUD_MobHealth_PPP(mi);
2675 h = math.floor(UnitHealth("target") * p + 0.5);
2676 else
2677 -- nu values
2678 h = UnitHealth("target");
2679 end
2680  
2681 -- we have no values? ok lets do it the old way
2682 if ((not h) or h == 0) then
2683 h = UnitHealth("target");
2684 end
2685  
2686 return tonumber(h);
2687  
2688 end
2689  
2690  
2691 function DHUD_getTargetMaxHealth()
2692  
2693 local h;
2694  
2695 -- get Maxhealth from mobinfo / mobhealth
2696 if (MobHealth_GetTargetMaxHP and UnitHealth("target") > 0) then
2697 h = MobHealth_GetTargetMaxHP();
2698 elseif (MobHealth_PPP and UnitName("target") and UnitLevel("target")) then
2699 local mi = UnitName("target")..":"..UnitLevel("target");
2700 local p = MobHealth_PPP(mi);
2701 h = math.floor(100 * p + 0.5);
2702 elseif MobHealthDB and UnitName("target") and UnitLevel("target") then
2703 -- telos mobhealth
2704 local mi = UnitName("target")..":"..UnitLevel("target");
2705 local p = DHUD_MobHealth_PPP(mi);
2706 h = math.floor(100 * p + 0.5);
2707 else
2708 -- no values
2709 h = UnitHealthMax("target");
2710 end
2711  
2712 -- we have no values? ok lets do it the old way
2713 if ((not h) or h == 0) then
2714 h = UnitHealthMax("target");
2715 end
2716  
2717 return tonumber(h);
2718 end
2719  
2720  
2721 function DHUD_checkShowNPC()
2722  
2723 if UnitName("target") and DHUD_Config["shownpc"] == 0 and not UnitIsPlayer("target") and not UnitCanAttack("player", "target") and not UnitPlayerControlled("target") then
2724 return true;
2725 else
2726 return false;
2727 end
2728  
2729 end
2730  
2731 -- colorize
2732 function Get_HColor( percent, typ, unit )
2733  
2734 local r, g, b, diff,dcolor, color1, color2;
2735 local threshold1 = 0.6;
2736 local threshold2 = 0.3;
2737  
2738 -- omly tap target bars
2739 if unit == "target" then
2740 if (UnitIsTapped("target") and (not UnitIsTappedByPlayer("target"))) then
2741 typ = "tapped";
2742 end
2743 end
2744  
2745 dcolor = DHUD_BarColor[typ]["start"];
2746 color1 = DHUD_BarColor[typ]["middle"];
2747 color2 = DHUD_BarColor[typ]["end"];
2748  
2749 if ( percent <= threshold2 ) then
2750 r = color2["r"];
2751 g = color2["g"];
2752 b = color2["b"];
2753 elseif ( percent <= threshold1) then
2754 diff = 1 - (percent - threshold2) / (threshold1 - threshold2);
2755 r = color1["r"] - (color1["r"] - color2["r"]) * diff;
2756 g = color1["g"] - (color1["g"] - color2["g"]) * diff;
2757 b = color1["b"] - (color1["b"] - color2["b"]) * diff;
2758 elseif ( percent < 1) then
2759 diff = 1 - (percent - threshold1) / (1 - threshold1);
2760 r = dcolor["r"] - (dcolor["r"] - color1["r"]) * diff;
2761 g = dcolor["g"] - (dcolor["g"] - color1["g"]) * diff;
2762 b = dcolor["b"] - (dcolor["b"] - color1["b"]) * diff;
2763 else
2764 return dcolor["r"], dcolor["g"], dcolor["b"];
2765 end
2766  
2767 if (r < 0) then r = 0; end
2768 if (r > 1) then r = 1; end
2769 if (g < 0) then g = 0; end
2770 if (g > 1) then g = 1; end
2771 if (b < 0) then b = 0; end
2772 if (b > 1) then b = 1; end
2773  
2774 return r, g, b;
2775  
2776 end
2777  
2778 -- decimal to hex
2779 function DHUD_DecToHex(red,green,blue)
2780 if ( not red or not green or not blue ) then
2781 return "ffffff"
2782 end
2783  
2784 red = floor(red * 255)
2785 green = floor(green * 255)
2786 blue = floor(blue * 255)
2787  
2788 local a,b,c,d,e,f
2789  
2790 a = DHUD_GiveHex(floor(red / 16))
2791 b = DHUD_GiveHex(math.mod(red,16))
2792 c = DHUD_GiveHex(floor(green / 16))
2793 d = DHUD_GiveHex(math.mod(green,16))
2794 e = DHUD_GiveHex(floor(blue / 16))
2795 f = DHUD_GiveHex(math.mod(blue,16))
2796  
2797 return a..b..c..d..e..f
2798 end
2799  
2800 function DHUD_GiveHex(dec)
2801 for key, value in DHUD_HexTable do
2802 if ( dec == value ) then
2803 return key
2804 end
2805 end
2806 return ""..dec
2807 end
2808  
2809 -- telos mobhealth support
2810 function DHUD_MobHealth_PPP(index)
2811 if( index and MobHealthDB[index] ) then
2812 local s, e;
2813 local pts;
2814 local pct;
2815  
2816 s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$");
2817 if( pts and pct ) then
2818 pts = pts + 0;
2819 pct = pct + 0;
2820 if( pct ~= 0 ) then
2821 return pts / pct;
2822 end
2823 end
2824 end
2825 return 0;
2826 end
2827  
2828 -- create minimap button
2829 function DHUD_createMMB()
2830  
2831 local f = CreateFrame("Button", "DHUD_MinimapButton", Minimap );
2832 f:SetWidth(31);
2833 f:SetHeight(31);
2834 f:SetFrameStrata("HIGH");
2835 f:SetPoint("TOPLEFT", MinimapCluster, "TOPLEFT");
2836 f:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight");
2837 if f.SetTopLevel then
2838 f:SetTopLevel(1)
2839 end
2840  
2841 local bgt = f:CreateTexture("DHUD_MMBGTexture","BACKGROUND");
2842 bgt:SetTexture("Interface\\Icons\\Ability_Druid_TravelForm");
2843 bgt:SetPoint("TOPLEFT", f, "TOPLEFT", 6, -5);
2844 bgt:SetHeight(20);
2845 bgt:SetWidth(20);
2846  
2847 local t = f:CreateTexture("DHUD_MMTexture","OVERLAY");
2848 t:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder");
2849 t:SetPoint("TOPLEFT", f, "TOPLEFT");
2850 t:SetHeight(53);
2851 t:SetWidth(53);
2852  
2853 local DHUD_MMBClick = function()
2854 if DHUDOptionsFrame:IsVisible() then
2855 DHUDOptionsFrame:Hide();
2856 else
2857 DHUDOptionsFrame:Show();
2858 end
2859 end
2860  
2861 f:RegisterForClicks("LeftButtonUp");
2862 f:SetScript("OnClick", DHUD_MMBClick );
2863  
2864 end
2865  
2866 -- MyAddonsSupport
2867 function DHUD_myAddons()
2868  
2869 if (myAddOnsFrame_Register) then
2870  
2871 -- myAddOns Support
2872 local DHUD_mya = {
2873 ["name"] = "DHUD",
2874 ["version"] = DHUD_version,
2875 ["author"] = "Drathal/Silberklinge (Markus Inger)",
2876 ["category"] = MYADDONS_CATEGORY_COMBAT,
2877 ["email"] = "dhud@markus-inger.de",
2878 ["website"] = "http://www.markus-inger.de",
2879 ["optionsframe"] = "DHUDOptionsFrame",
2880 };
2881  
2882 myAddOnsFrame_Register(DHUD_mya);
2883  
2884 end
2885  
2886 end
2887  
2888 -- dropdown functions (player/target)
2889 function DHUD_Player_DropDown_OnLoad()
2890 UIDropDownMenu_Initialize(this, DHUD_Player_DropDown_Initialize, "MENU");
2891 end
2892  
2893 function DHUD_Player_DropDown_Initialize()
2894 UnitPopup_ShowMenu(DHUD_Player_DropDown, "SELF", "player");
2895 end
2896  
2897 function DHUD_Target_DropDown_OnLoad()
2898 UIDropDownMenu_Initialize(this, DHUD_Target_DropDown_Initialize, "MENU");
2899 end
2900  
2901 function DHUD_Target_DropDown_Initialize()
2902 local menu = nil;
2903 if (UnitIsEnemy("target", "player")) then
2904 return;
2905 end
2906 if (UnitIsUnit("target", "player")) then
2907 menu = "SELF";
2908 elseif (UnitIsUnit("target", "pet")) then
2909 menu = "PET";
2910 elseif (UnitIsPlayer("target")) then
2911 if (UnitInParty("target")) then
2912 menu = "PARTY";
2913 else
2914 menu = "PLAYER";
2915 end
2916 end
2917  
2918 if (menu) then
2919 UnitPopup_ShowMenu( DHUD_Target_DropDown, menu, "target" );
2920 end
2921 end
2922  
2923 function DHUD_Target_OnClick()
2924  
2925 if ( IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown() ) then
2926 if (GetNumPartyMembers() > 0) then
2927 ToggleDropDownMenu(1, nil, DHUD_Player_DropDown, "DHUD_Target", 25, 10);
2928 else
2929 DEFAULT_CHAT_FRAME:AddMessage("DHUD: You are not in a Party.");
2930 end
2931 else
2932 ToggleDropDownMenu(1, nil, DHUD_Target_DropDown, "DHUD_Target", 25, 10);
2933 end
2934  
2935 end
2936  
2937 -- set font
2938 function DHUD_setFont(frame,size,outline)
2939  
2940 local font = getglobal(frame);
2941 font:SetFont(DHUD_defaultfont, size, outline);
2942  
2943 end
2944  
2945 -- hexcolor to rgb
2946 function DHUD_hextodec(hex)
2947  
2948 local r1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,1,1)) ] * 16);
2949 local r2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,2,2)) ]);
2950 local r = (r1 + r2) / 255;
2951  
2952 local g1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,3,3)) ] * 16);
2953 local g2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,4,4)) ]);
2954 local g = (g1 + g2) / 255;
2955  
2956 local b1 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,5,5)) ] * 16);
2957 local b2 = tonumber(DHUD_HexTable[ string.lower(string.sub(hex,6,6)) ]);
2958 local b = (b1 + b2) / 255;
2959  
2960 return r,g,b
2961 end