vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ---------------
2 -- Variables --
3 ---------------
4 Perl_Target_Config = {};
5  
6 -- Default Saved Variables (also set in Perl_Target_GetVars)
7 local locked = 0; -- unlocked by default
8 local showcp = 1; -- combo points displayed by default
9 local showclassicon = 1; -- show the class icon
10 local showclassframe = 1; -- show the class frame
11 local showpvpicon = 1; -- show the pvp icon
12 local numbuffsshown = 16; -- buff row is 16 long
13 local numdebuffsshown = 16; -- debuff row is 16 long
14 local mobhealthsupport = 1; -- mobhealth support is on by default
15 local scale = 1; -- default scale
16 local showpvprank = 0; -- hide the pvp rank by default
17 local transparency = 1; -- transparency for frames
18 local buffdebuffscale = 1; -- default scale for buffs and debuffs
19 local showportrait = 0; -- portrait is hidden by default
20 local threedportrait = 0; -- 3d portraits are off by default
21 local portraitcombattext = 1; -- Combat text is enabled by default on the portrait frame
22 local showrareeliteframe = 0; -- rare/elite frame is hidden by default
23 local nameframecombopoints = 0; -- combo points are not displayed in the name frame by default
24 local comboframedebuffs = 0; -- combo point frame will not be used for debuffs by default
25 local framestyle = 1; -- default frame style is "classic"
26 local compactmode = 0; -- compact mode is disabled by default
27 local compactpercent = 0; -- percents are not shown in compact mode by default
28 local hidebuffbackground = 0; -- buff and debuff backgrounds are shown by default
29  
30 -- Default Local Variables
31 local Initialized = nil; -- waiting to be initialized
32  
33 -- Variables for position of the class icon texture.
34 local Perl_Target_ClassPosRight = {};
35 local Perl_Target_ClassPosLeft = {};
36 local Perl_Target_ClassPosTop = {};
37 local Perl_Target_ClassPosBottom = {};
38  
39  
40 ----------------------
41 -- Loading Function --
42 ----------------------
43 function Perl_Target_OnLoad()
44 -- Combat Text
45 CombatFeedback_Initialize(Perl_Target_HitIndicator, 30);
46  
47 -- Events
48 this:RegisterEvent("ADDON_LOADED");
49 this:RegisterEvent("PARTY_LEADER_CHANGED");
50 this:RegisterEvent("PARTY_MEMBER_DISABLE");
51 this:RegisterEvent("PARTY_MEMBER_ENABLE");
52 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
53 this:RegisterEvent("PLAYER_COMBO_POINTS");
54 this:RegisterEvent("PLAYER_ENTERING_WORLD");
55 this:RegisterEvent("PLAYER_TARGET_CHANGED");
56 this:RegisterEvent("UNIT_AURA");
57 this:RegisterEvent("UNIT_COMBAT");
58 this:RegisterEvent("UNIT_DISPLAYPOWER");
59 this:RegisterEvent("UNIT_DYNAMIC_FLAGS");
60 this:RegisterEvent("UNIT_ENERGY");
61 this:RegisterEvent("UNIT_FOCUS");
62 this:RegisterEvent("UNIT_HEALTH");
63 this:RegisterEvent("UNIT_LEVEL");
64 this:RegisterEvent("UNIT_MANA");
65 this:RegisterEvent("UNIT_MAXENERGY");
66 this:RegisterEvent("UNIT_MAXFOCUS");
67 this:RegisterEvent("UNIT_MAXHEALTH");
68 this:RegisterEvent("UNIT_MAXMANA");
69 this:RegisterEvent("UNIT_MAXRAGE");
70 this:RegisterEvent("UNIT_PORTRAIT_UPDATE");
71 this:RegisterEvent("UNIT_PVP_UPDATE");
72 this:RegisterEvent("UNIT_RAGE");
73 this:RegisterEvent("UNIT_SPELLMISS");
74 this:RegisterEvent("VARIABLES_LOADED");
75  
76 -- Button Click Overlays (in order of occurrence in XML)
77 Perl_Target_NameFrame_CastClickOverlay:SetFrameLevel(Perl_Target_NameFrame:GetFrameLevel() + 2);
78 Perl_Target_Name:SetFrameLevel(Perl_Target_NameFrame:GetFrameLevel() + 1);
79 Perl_Target_LevelFrame_CastClickOverlay:SetFrameLevel(Perl_Target_LevelFrame:GetFrameLevel() + 1);
80 Perl_Target_RareEliteFrame_CastClickOverlay:SetFrameLevel(Perl_Target_RareEliteFrame:GetFrameLevel() + 1);
81 Perl_Target_PortraitFrame_CastClickOverlay:SetFrameLevel(Perl_Target_PortraitFrame:GetFrameLevel() + 2);
82 Perl_Target_ClassNameFrame_CastClickOverlay:SetFrameLevel(Perl_Target_ClassNameFrame:GetFrameLevel() + 1);
83 Perl_Target_CivilianFrame_CastClickOverlay:SetFrameLevel(Perl_Target_CivilianFrame:GetFrameLevel() + 1);
84 Perl_Target_CPFrame_CastClickOverlay:SetFrameLevel(Perl_Target_CPFrame:GetFrameLevel() + 1);
85 Perl_Target_StatsFrame_CastClickOverlay:SetFrameLevel(Perl_Target_StatsFrame:GetFrameLevel() + 1);
86  
87 if (DEFAULT_CHAT_FRAME) then
88 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Perl Classic: Target loaded successfully.");
89 end
90 end
91  
92  
93 -------------------
94 -- Event Handler --
95 -------------------
96 function Perl_Target_OnEvent(event)
97 if ((event == "PLAYER_TARGET_CHANGED") or (event == "PARTY_MEMBERS_CHANGED") or (event == "PARTY_LEADER_CHANGED") or (event == "PARTY_MEMBER_ENABLE") or (event == "PARTY_MEMBER_DISABLE")) then
98 if (UnitExists("target")) then
99 Perl_Target_Update_Once(); -- Set the unchanging info for the target
100 else
101 Perl_Target_Frame:Hide(); -- There is no target, hide the frame
102 end
103 return;
104 elseif (event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH") then
105 if (arg1 == "target") then
106 Perl_Target_Update_Health(); -- Update health values
107 end
108 return;
109 elseif ((event == "UNIT_ENERGY") or (event == "UNIT_MANA") or (event == "UNIT_RAGE") or (event == "UNIT_FOCUS") or (event == "UNIT_MAXMANA") or (event == "UNIT_MAXENERGY") or (event == "UNIT_MAXRAGE") or (event == "UNIT_MAXFOCUS")) then
110 if (arg1 == "target") then
111 Perl_Target_Update_Mana(); -- Update energy/mana/rage values
112 end
113 return;
114 elseif (event == "UNIT_AURA") then
115 if (arg1 == "target") then
116 Perl_Target_Buff_UpdateAll(); -- Update the buffs
117 end
118 return;
119 elseif (event == "UNIT_DYNAMIC_FLAGS") then
120 if (arg1 == "target") then
121 Perl_Target_Update_Text_Color(); -- Has the target been tapped by someone else?
122 end
123 return;
124 elseif (event == "UNIT_COMBAT") then
125 if (arg1 == "target") then
126 CombatFeedback_OnCombatEvent(arg2, arg3, arg4, arg5);
127 end
128 return;
129 elseif (event == "UNIT_SPELLMISS") then
130 if (arg1 == "target") then
131 CombatFeedback_OnSpellMissEvent(arg2);
132 end
133 return;
134 elseif (event == "UNIT_PVP_UPDATE") then
135 Perl_Target_Update_Text_Color(); -- Is the character PvP flagged?
136 Perl_Target_Update_PvP_Status_Icon(); -- Set pvp status icon
137 return;
138 elseif (event == "UNIT_PORTRAIT_UPDATE") then
139 if (arg1 == "target") then
140 Perl_Target_Update_Portrait();
141 end
142 return;
143 elseif (event == "UNIT_LEVEL") then
144 if (arg1 == "target") then
145 Perl_Target_Frame_Set_Level(); -- What level is it and is it rare/elite/boss
146 end
147 return;
148 elseif (event == "PLAYER_COMBO_POINTS") then
149 Perl_Target_Update_Combo_Points(); -- How many combo points are we at?
150 return;
151 elseif (event == "UNIT_DISPLAYPOWER") then
152 if (arg1 == "target") then
153 Perl_Target_Update_Mana_Bar(); -- What type of energy are they using now?
154 Perl_Target_Update_Mana(); -- Update the energy info immediately
155 end
156 return;
157 elseif (event == "VARIABLES_LOADED") or (event=="PLAYER_ENTERING_WORLD") then
158 Perl_Target_Initialize();
159 return;
160 elseif (event == "ADDON_LOADED") then
161 if (arg1 == "Perl_Target") then
162 Perl_Target_myAddOns_Support(); -- Attempt to load MyAddOns support
163 end
164 return;
165 else
166 return;
167 end
168 end
169  
170  
171 -------------------------------
172 -- Loading Settings Function --
173 -------------------------------
174 function Perl_Target_Initialize()
175 if (Initialized) then
176 Perl_Target_Set_Scale();
177 return;
178 end
179  
180 -- Check if a previous exists, if not, enable by default.
181 if (type(Perl_Target_Config[UnitName("player")]) == "table") then
182 Perl_Target_GetVars();
183 else
184 Perl_Target_UpdateVars();
185 end
186  
187 -- Major config options.
188 Perl_Target_Initialize_Frame_Color();
189 Perl_Target_Frame_Style();
190 Perl_Target_Buff_Debuff_Background();
191 Perl_Target_Frame:Hide();
192  
193 Perl_Target_Set_Localized_ClassIcons();
194  
195 -- Unregister the Blizzard frames via the 1.8 function
196 TargetFrame:UnregisterAllEvents();
197 TargetFrameHealthBar:UnregisterAllEvents();
198 TargetFrameManaBar:UnregisterAllEvents();
199 ComboFrame:UnregisterAllEvents();
200  
201 Initialized = 1;
202 end
203  
204 function Perl_Target_Initialize_Frame_Color()
205 Perl_Target_StatsFrame:SetBackdropColor(0, 0, 0, 1);
206 Perl_Target_StatsFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
207 Perl_Target_NameFrame:SetBackdropColor(0, 0, 0, 1);
208 Perl_Target_NameFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
209 Perl_Target_ClassNameFrame:SetBackdropColor(0, 0, 0, 1);
210 Perl_Target_ClassNameFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
211 Perl_Target_CivilianFrame:SetBackdropColor(1, 1, 1, 1);
212 Perl_Target_CivilianFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
213 Perl_Target_LevelFrame:SetBackdropColor(0, 0, 0, 1);
214 Perl_Target_LevelFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
215 Perl_Target_BuffFrame:SetBackdropColor(0, 0, 0, 1);
216 Perl_Target_BuffFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
217 Perl_Target_DebuffFrame:SetBackdropColor(0, 0, 0, 1);
218 Perl_Target_DebuffFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
219 Perl_Target_CPFrame:SetBackdropColor(0, 0, 0, 1);
220 Perl_Target_CPFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
221 Perl_Target_PortraitFrame:SetBackdropColor(0, 0, 0, 1);
222 Perl_Target_PortraitFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
223 Perl_Target_RareEliteFrame:SetBackdropColor(0, 0, 0, 1);
224 Perl_Target_RareEliteFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
225  
226 Perl_Target_HealthBarText:SetTextColor(1, 1, 1, 1);
227 Perl_Target_ManaBarText:SetTextColor(1, 1, 1, 1);
228 Perl_Target_ClassNameBarText:SetTextColor(1, 1, 1);
229 end
230  
231  
232 --------------------------
233 -- The Update Functions --
234 --------------------------
235 function Perl_Target_Update_Once()
236 if (UnitExists("target")) then
237 Perl_Target_Frame:Show(); -- Show frame
238 Perl_Target_Set_Scale(); -- Set the scale (easier ways exist, but this is the safest)
239 Perl_Target_Set_Transparency(); -- Set the transparency (fix this method along with scale)
240 ComboFrame:Hide(); -- Hide default Combo Points
241 Perl_Target_Update_Combo_Points(); -- Do we have any combo points (we shouldn't)
242 Perl_Target_Frame_Set_Name(); -- Set the target's name
243 Perl_Target_Update_Portrait(); -- Set the target's portrait and adjust the combo point frame
244 Perl_Target_Update_Text_Color(); -- Has the target been tapped by someone else?
245 Perl_Target_Update_Health(); -- Set the target's health
246 Perl_Target_Update_Mana_Bar(); -- What type of mana bar is it?
247 Perl_Target_Update_Mana(); -- Set the target's mana
248 Perl_Target_Update_PvP_Status_Icon(); -- Set pvp status icon
249 Perl_Target_Frame_Set_PvPRank(); -- Set the pvp rank icon
250 Perl_Target_Frame_Set_Level(); -- What level is it and is it rare/elite/boss
251 Perl_Target_Set_Character_Class_Icon(); -- Draw the class icon?
252 Perl_Target_Set_Target_Class(); -- Set the target's class in the class frame
253 Perl_Target_Buff_UpdateAll(); -- Update the buffs
254 end
255 end
256  
257 function Perl_Target_Update_Health()
258 local targethealth = UnitHealth("target");
259 local targethealthmax = UnitHealthMax("target");
260 local targethealthpercent = floor(targethealth/targethealthmax*100+0.5);
261  
262 if (UnitIsDead("target") or UnitIsGhost("target")) then -- This prevents negative health
263 targethealth = 0;
264 targethealthpercent = 0;
265 end
266  
267 -- Set Dead Icon
268 if (UnitIsDead("target") or UnitIsGhost("target")) then
269 Perl_Target_DeadStatus:Show();
270 else
271 Perl_Target_DeadStatus:Hide();
272 end
273  
274 Perl_Target_HealthBar:SetMinMaxValues(0, targethealthmax);
275 Perl_Target_HealthBar:SetValue(targethealth);
276  
277 if (PCUF_COLORHEALTH == 1) then
278 if ((targethealthpercent <= 100) and (targethealthpercent > 75)) then
279 Perl_Target_HealthBar:SetStatusBarColor(0, 0.8, 0);
280 Perl_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25);
281 elseif ((targethealthpercent <= 75) and (targethealthpercent > 50)) then
282 Perl_Target_HealthBar:SetStatusBarColor(1, 1, 0);
283 Perl_Target_HealthBarBG:SetStatusBarColor(1, 1, 0, 0.25);
284 elseif ((targethealthpercent <= 50) and (targethealthpercent > 25)) then
285 Perl_Target_HealthBar:SetStatusBarColor(1, 0.5, 0);
286 Perl_Target_HealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25);
287 else
288 Perl_Target_HealthBar:SetStatusBarColor(1, 0, 0);
289 Perl_Target_HealthBarBG:SetStatusBarColor(1, 0, 0, 0.25);
290 end
291 else
292 Perl_Target_HealthBar:SetStatusBarColor(0, 0.8, 0);
293 Perl_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25);
294 end
295  
296 if (targethealthmax == 100) then
297 -- Begin Mobhealth support
298 if (mobhealthsupport == 1) then
299 if (MobHealthFrame) then
300 MobHealthFrame:Hide();
301  
302 local index;
303 if UnitIsPlayer("target") then
304 index = UnitName("target");
305 else
306 index = UnitName("target")..":"..UnitLevel("target");
307 end
308  
309 if ((MobHealthDB and MobHealthDB[index]) or (MobHealthPlayerDB and MobHealthPlayerDB[index])) then
310 local s, e;
311 local pts;
312 local pct;
313  
314 if MobHealthDB[index] then
315 if (type(MobHealthDB[index]) ~= "string") then
316 Perl_Target_HealthBarText:SetText(targethealth.."%");
317 end
318 s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$");
319 else
320 if (type(MobHealthPlayerDB[index]) ~= "string") then
321 Perl_Target_HealthBarText:SetText(targethealth.."%");
322 end
323 s, e, pts, pct = string.find(MobHealthPlayerDB[index], "^(%d+)/(%d+)$");
324 end
325  
326 if (pts and pct) then
327 pts = pts + 0;
328 pct = pct + 0;
329 if (pct ~= 0) then
330 pointsPerPct = pts / pct;
331 else
332 pointsPerPct = 0;
333 end
334 end
335  
336 local currentPct = UnitHealth("target");
337 if (pointsPerPct > 0) then
338 -- Stored unit info from the DB
339 if (framestyle == 1) then
340 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
341 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
342 Perl_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5).." | "..targethealth.."%");
343 elseif (framestyle == 2) then
344 if (compactmode == 0) then
345 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
346 if (tonumber(string.format("%d", (100 * pointsPerPct) + 0.5)) > 9999) then
347 Perl_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5));
348 Perl_Target_HealthBarTextRight:SetText(targethealth.."%");
349 else
350 Perl_Target_HealthBarText:SetText(targethealth.."%");
351 Perl_Target_HealthBarTextRight:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5));
352 end
353  
354 else
355 if (compactpercent == 0) then
356 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
357 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
358 Perl_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5));
359 else
360 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
361 Perl_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5));
362 Perl_Target_HealthBarTextCompactPercent:SetText(targethealth.."%");
363 end
364 end
365 end
366 end
367 else
368 -- Unit not in MobHealth DB
369 if (framestyle == 1) then -- This chunk of code is the same as the next two blocks in case you customize this
370 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
371 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
372 Perl_Target_HealthBarText:SetText(targethealth.."%");
373 elseif (framestyle == 2) then
374 if (compactmode == 0) then
375 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
376 Perl_Target_HealthBarText:SetText(targethealth.."%");
377 Perl_Target_HealthBarTextRight:SetText(targethealth.."%");
378 else
379 if (compactpercent == 0) then
380 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
381 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
382 Perl_Target_HealthBarText:SetText(targethealth.."%");
383 else
384 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
385 Perl_Target_HealthBarText:SetText(targethealth.."%");
386 Perl_Target_HealthBarTextCompactPercent:SetText(targethealth.."%");
387 end
388 end
389 end
390 end
391 -- End MobHealth Support
392 else
393 -- MobHealth isn't installed
394 if (framestyle == 1) then
395 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
396 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
397 Perl_Target_HealthBarText:SetText(targethealth.."%");
398 elseif (framestyle == 2) then
399 if (compactmode == 0) then
400 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
401 Perl_Target_HealthBarText:SetText(targethealth.."%");
402 Perl_Target_HealthBarTextRight:SetText(targethealth.."%");
403 else
404 if (compactpercent == 0) then
405 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
406 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
407 Perl_Target_HealthBarText:SetText(targethealth.."%");
408 else
409 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
410 Perl_Target_HealthBarText:SetText(targethealth.."%");
411 Perl_Target_HealthBarTextCompactPercent:SetText(targethealth.."%");
412 end
413 end
414 end
415 end
416 else -- mobhealthsupport == 0
417 if (MobHealthFrame) then
418 MobHealthFrame:Show();
419 end
420  
421 -- MobHealth support is disabled
422 if (framestyle == 1) then
423 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
424 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
425 Perl_Target_HealthBarText:SetText(targethealth.."%");
426 elseif (framestyle == 2) then
427 if (compactmode == 0) then
428 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
429 Perl_Target_HealthBarText:SetText(targethealth.."%");
430 Perl_Target_HealthBarTextRight:SetText(targethealth.."%");
431 else
432 if (compactpercent == 0) then
433 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
434 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
435 Perl_Target_HealthBarText:SetText(targethealth.."%");
436 else
437 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
438 Perl_Target_HealthBarText:SetText(targethealth.."%");
439 Perl_Target_HealthBarTextCompactPercent:SetText(targethealth.."%");
440 end
441 end
442 end
443 end
444 else
445 -- Self/Party/Raid member
446 if (framestyle == 1) then
447 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
448 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
449 Perl_Target_HealthBarText:SetText(targethealth.."/"..targethealthmax);
450 elseif (framestyle == 2) then
451 if (compactmode == 0) then
452 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
453 Perl_Target_HealthBarText:SetText(targethealthpercent.."%");
454 Perl_Target_HealthBarTextRight:SetText(targethealth.."/"..targethealthmax);
455 else
456 if (compactpercent == 0) then
457 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
458 Perl_Target_HealthBarTextCompactPercent:SetText(); -- Hide this text in this frame style
459 Perl_Target_HealthBarText:SetText(targethealth.."/"..targethealthmax);
460 else
461 Perl_Target_HealthBarTextRight:SetText(); -- Hide this text in this frame style
462 Perl_Target_HealthBarText:SetText(targethealth.."/"..targethealthmax);
463 Perl_Target_HealthBarTextCompactPercent:SetText(targethealthpercent.."%");
464 end
465 end
466 end
467 end
468 end
469  
470 function Perl_Target_Update_Mana()
471 local targetmana = UnitMana("target");
472 local targetmanamax = UnitManaMax("target");
473 local targetpower = UnitPowerType("target");
474  
475 if (UnitIsDead("target") or UnitIsGhost("target")) then -- This prevents negative mana
476 targetmana = 0;
477 end
478  
479 Perl_Target_ManaBar:SetMinMaxValues(0, targetmanamax);
480 Perl_Target_ManaBar:SetValue(targetmana);
481  
482 if (framestyle == 1) then
483 Perl_Target_ManaBarTextRight:SetText(); -- Hide this text in this frame style
484 Perl_Target_ManaBarTextCompactPercent:SetText(); -- Hide this text in this frame style
485  
486 if (targetpower == 1 or targetpower == 2) then
487 Perl_Target_ManaBarText:SetText(targetmana);
488 else
489 Perl_Target_ManaBarText:SetText(targetmana.."/"..targetmanamax);
490 end
491 elseif (framestyle == 2) then
492 local targetmanapercent = floor(targetmana/targetmanamax*100+0.5);
493  
494 if (compactmode == 0) then
495 Perl_Target_ManaBarTextCompactPercent:SetText(); -- Hide this text in this frame style
496  
497 if (targetpower == 1 or targetpower == 2) then
498 Perl_Target_ManaBarText:SetText(targetmana.."%");
499 Perl_Target_ManaBarTextRight:SetText(targetmana);
500 else
501 Perl_Target_ManaBarText:SetText(targetmanapercent.."%");
502 Perl_Target_ManaBarTextRight:SetText(targetmana.."/"..targetmanamax);
503 end
504 else
505 if (compactpercent == 0) then
506 Perl_Target_ManaBarTextRight:SetText(); -- Hide this text in this frame style
507 Perl_Target_ManaBarTextCompactPercent:SetText(); -- Hide this text in this frame style
508  
509 if (targetpower == 1 or targetpower == 2) then
510 Perl_Target_ManaBarText:SetText(targetmana);
511 else
512 Perl_Target_ManaBarText:SetText(targetmana.."/"..targetmanamax);
513 end
514 else
515 Perl_Target_ManaBarTextRight:SetText(); -- Hide this text in this frame style
516  
517 if (targetpower == 1 or targetpower == 2) then
518 Perl_Target_ManaBarText:SetText(targetmana);
519 Perl_Target_ManaBarTextCompactPercent:SetText(targetmana.."%");
520 else
521 Perl_Target_ManaBarText:SetText(targetmana.."/"..targetmanamax);
522 Perl_Target_ManaBarTextCompactPercent:SetText(targetmanapercent.."%");
523 end
524 end
525 end
526 end
527 end
528  
529 function Perl_Target_Update_Mana_Bar()
530 local targetmanamax = UnitManaMax("target");
531 local targetpower = UnitPowerType("target");
532  
533 -- Set mana bar color
534 if (targetmanamax == 0) then
535 Perl_Target_ManaBar:Hide();
536 Perl_Target_ManaBarBG:Hide();
537 Perl_Target_StatsFrame:SetHeight(30);
538 Perl_Target_StatsFrame_CastClickOverlay:SetHeight(30);
539 elseif (targetpower == 1) then
540 Perl_Target_ManaBar:SetStatusBarColor(1, 0, 0, 1);
541 Perl_Target_ManaBarBG:SetStatusBarColor(1, 0, 0, 0.25);
542 Perl_Target_ManaBar:Show();
543 Perl_Target_ManaBarBG:Show();
544 Perl_Target_StatsFrame:SetHeight(42);
545 Perl_Target_StatsFrame_CastClickOverlay:SetHeight(42);
546 elseif (targetpower == 2) then
547 Perl_Target_ManaBar:SetStatusBarColor(1, 0.5, 0, 1);
548 Perl_Target_ManaBarBG:SetStatusBarColor(1, 0.5, 0, 0.25);
549 Perl_Target_ManaBar:Show();
550 Perl_Target_ManaBarBG:Show();
551 Perl_Target_StatsFrame:SetHeight(42);
552 Perl_Target_StatsFrame_CastClickOverlay:SetHeight(42);
553 elseif (targetpower == 3) then
554 Perl_Target_ManaBar:SetStatusBarColor(1, 1, 0, 1);
555 Perl_Target_ManaBarBG:SetStatusBarColor(1, 1, 0, 0.25);
556 Perl_Target_ManaBar:Show();
557 Perl_Target_ManaBarBG:Show();
558 Perl_Target_StatsFrame:SetHeight(42);
559 Perl_Target_StatsFrame_CastClickOverlay:SetHeight(42);
560 else
561 Perl_Target_ManaBar:SetStatusBarColor(0, 0, 1, 1);
562 Perl_Target_ManaBarBG:SetStatusBarColor(0, 0, 1, 0.25);
563 Perl_Target_ManaBar:Show();
564 Perl_Target_ManaBarBG:Show();
565 Perl_Target_StatsFrame:SetHeight(42);
566 Perl_Target_StatsFrame_CastClickOverlay:SetHeight(42);
567 end
568 end
569  
570 function Perl_Target_Update_Combo_Points()
571 local combopoints = GetComboPoints(); -- How many Combo Points does the player have?
572 ComboFrame:Hide(); -- Hide default Combo Points
573  
574 if (showcp == 1) then
575 Perl_Target_CPText:SetText(combopoints);
576 Perl_Target_CPText:SetTextHeight(20);
577 if (combopoints == 5) then
578 Perl_Target_CPFrame:Show();
579 Perl_Target_CPText:SetTextColor(1, 0, 0); -- red text
580 elseif (combopoints == 4) then
581 Perl_Target_CPFrame:Show();
582 Perl_Target_CPText:SetTextColor(1, 0.5, 0); -- orange text
583 elseif (combopoints == 3) then
584 Perl_Target_CPFrame:Show();
585 Perl_Target_CPText:SetTextColor(1, 1, 0); -- yellow text
586 elseif (combopoints == 2) then
587 Perl_Target_CPFrame:Show();
588 Perl_Target_CPText:SetTextColor(0.5, 1, 0); -- yellow-green text
589 elseif (combopoints == 1) then
590 Perl_Target_CPFrame:Show();
591 Perl_Target_CPText:SetTextColor(0, 1, 0); -- green text
592 else
593 Perl_Target_CPFrame:Hide();
594 end
595 else
596 Perl_Target_CPFrame:Hide();
597 end
598  
599 if (nameframecombopoints == 1) then -- this isn't nested since you can have both combo point styles on at the same time
600 Perl_Target_NameFrame_CPMeter:SetMinMaxValues(0, 5);
601 Perl_Target_NameFrame_CPMeter:SetValue(combopoints);
602 if (combopoints == 5) then
603 Perl_Target_NameFrame_CPMeter:Show();
604  
605 elseif (combopoints == 4) then
606 Perl_Target_NameFrame_CPMeter:Show();
607 elseif (combopoints == 3) then
608 Perl_Target_NameFrame_CPMeter:Show();
609 elseif (combopoints == 2) then
610 Perl_Target_NameFrame_CPMeter:Show();
611 elseif (combopoints == 1) then
612 Perl_Target_NameFrame_CPMeter:Show();
613 else
614 Perl_Target_NameFrame_CPMeter:Hide();
615 end
616 else
617 Perl_Target_NameFrame_CPMeter:Hide();
618 end
619 end
620  
621 function Perl_Target_Update_PvP_Status_Icon()
622 if (showpvpicon == 1) then
623 local factionGroup = UnitFactionGroup("target");
624 if (UnitIsPVPFreeForAll("target")) then
625 Perl_Target_PVPStatus:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA");
626 Perl_Target_PVPStatus:Show();
627 elseif (factionGroup and UnitIsPVP("target")) then
628 Perl_Target_PVPStatus:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..factionGroup);
629 Perl_Target_PVPStatus:Show();
630 else
631 Perl_Target_PVPStatus:Hide();
632 end
633 else
634 Perl_Target_PVPStatus:Hide();
635 end
636 end
637  
638 function Perl_Target_Update_Text_Color()
639 if (UnitIsPlayer("target") or UnitPlayerControlled("target")) then -- is it a player
640 local r, g, b;
641 if (UnitCanAttack("target", "player")) then -- are we in an enemy controlled zone
642 -- Hostile players are red
643 if (not UnitCanAttack("player", "target")) then -- enemy is not pvp enabled
644 r = 0.5;
645 g = 0.5;
646 b = 1.0;
647 else -- enemy is pvp enabled
648 r = 1.0;
649 g = 0.0;
650 b = 0.0;
651 end
652 elseif (UnitCanAttack("player", "target")) then -- enemy in a zone controlled by friendlies or when we're a ghost
653 -- Players we can attack but which are not hostile are yellow
654 r = 1.0;
655 g = 1.0;
656 b = 0.0;
657 elseif (UnitIsPVP("target")) then -- friendly pvp enabled character
658 -- Players we can assist but are PvP flagged are green
659 r = 0.0;
660 g = 1.0;
661 b = 0.0;
662 else -- friendly non pvp enabled character
663 -- All other players are blue (the usual state on the "blue" server)
664 r = 0.5;
665 g = 0.5;
666 b = 1.0;
667 end
668 Perl_Target_NameBarText:SetTextColor(r, g, b);
669 elseif (UnitIsTapped("target") and not UnitIsTappedByPlayer("target")) then
670 Perl_Target_NameBarText:SetTextColor(0.5,0.5,0.5); -- not our tap
671 else
672 local reaction = UnitReaction("target", "player");
673 if (reaction) then
674 local r, g, b;
675 r = UnitReactionColor[reaction].r;
676 g = UnitReactionColor[reaction].g;
677 b = UnitReactionColor[reaction].b;
678 Perl_Target_NameBarText:SetTextColor(r, g, b);
679 else
680 Perl_Target_NameBarText:SetTextColor(0.5, 0.5, 1.0);
681 end
682 end
683 end
684  
685 function Perl_Target_Frame_Set_Name()
686 local targetname = UnitName("target");
687  
688 -- Set name
689 if (framestyle == 1) then
690 if (strlen(targetname) > 19) then
691 targetname = strsub(targetname, 1, 18).."...";
692 end
693 elseif (framestyle == 2) then
694 if (compactmode == 0) then
695 if (strlen(targetname) > 19) then
696 targetname = strsub(targetname, 1, 18).."...";
697 end
698 else
699 if (compactpercent == 1) then
700 if (strlen(targetname) > 15) then
701 targetname = strsub(targetname, 1, 14).."...";
702 end
703 else
704 if (strlen(targetname) > 11) then
705 targetname = strsub(targetname, 1, 10).."...";
706 end
707 end
708 end
709 end
710  
711 Perl_Target_NameBarText:SetText(targetname);
712 end
713  
714 function Perl_Target_Frame_Set_PvPRank()
715 if (showpvprank == 1) then
716 if (UnitIsPlayer("target")) then
717 local rankNumber = UnitPVPRank("target");
718 if (rankNumber == 0) then
719 Perl_Target_PVPRank:Hide();
720 elseif (rankNumber < 14) then
721 rankNumber = rankNumber - 4;
722 Perl_Target_PVPRank:SetTexture("Interface\\PvPRankBadges\\PvPRank0"..rankNumber);
723 Perl_Target_PVPRank:Show();
724 else
725 rankNumber = rankNumber - 4;
726 Perl_Target_PVPRank:SetTexture("Interface\\PvPRankBadges\\PvPRank"..rankNumber);
727 Perl_Target_PVPRank:Show();
728 end
729 else
730 Perl_Target_PVPRank:Hide();
731 end
732 else
733 Perl_Target_PVPRank:Hide();
734 end
735 end
736  
737 function Perl_Target_Frame_Set_Level()
738 local targetlevel = UnitLevel("target"); -- Get and store the level of the target
739 local targetlevelcolor = GetDifficultyColor(targetlevel); -- Get the "con color" of the target
740 local targetclassification = UnitClassification("target"); -- Get the type of character the target is (rare, elite, worldboss)
741 local targetclassificationframetext = nil; -- Variable set to nil so we can easily track if target is a player or not elite
742  
743 Perl_Target_LevelBarText:SetVertexColor(targetlevelcolor.r, targetlevelcolor.g, targetlevelcolor.b);
744 Perl_Target_RareEliteBarText:SetVertexColor(targetlevelcolor.r, targetlevelcolor.g, targetlevelcolor.b);
745  
746 if ((targetclassification == "worldboss") or (targetlevel < 0)) then
747 Perl_Target_LevelBarText:SetTextColor(1, 0, 0);
748 if (UnitIsPlayer("target")) then
749 targetclassificationframetext = nil;
750 else
751 Perl_Target_RareEliteBarText:SetTextColor(1, 0, 0);
752 targetclassificationframetext = "Boss";
753 end
754 targetlevel = "??";
755 end
756  
757 if (targetclassification == "rareelite") then
758 targetclassificationframetext = "Rare+";
759 targetlevel = targetlevel.."r+";
760 elseif (targetclassification == "elite") then
761 targetclassificationframetext = "Elite";
762 targetlevel = targetlevel.."+";
763 elseif (targetclassification == "rare") then
764 targetclassificationframetext = "Rare";
765 targetlevel = targetlevel.."r";
766 end
767  
768 Perl_Target_LevelBarText:SetText(targetlevel); -- Set level frame text
769  
770 if (showrareeliteframe == 1) then
771 if (targetclassificationframetext == nil) then
772 Perl_Target_RareEliteFrame:Hide(); -- RareElite is hidden if target is a player
773 else
774 Perl_Target_RareEliteFrame:Show(); -- RareElite is hidden if shown if target is a npc
775 Perl_Target_RareEliteBarText:SetText(targetclassificationframetext); -- Set the text
776 end
777 else
778 Perl_Target_RareEliteFrame:Hide(); -- RareElite is hidden if disabled
779 end
780 end
781  
782 function Perl_Target_Set_Character_Class_Icon()
783 if (showclassicon == 1) then
784 if (UnitIsPlayer("target")) then
785 local PlayerClass = UnitClass("target");
786 Perl_Target_ClassTexture:SetTexCoord(Perl_Target_ClassPosRight[PlayerClass], Perl_Target_ClassPosLeft[PlayerClass], Perl_Target_ClassPosTop[PlayerClass], Perl_Target_ClassPosBottom[PlayerClass]);
787 Perl_Target_ClassTexture:Show();
788 else
789 Perl_Target_ClassTexture:Hide();
790 end
791 else
792 Perl_Target_ClassTexture:Hide();
793 end
794 end
795  
796 function Perl_Target_Set_Target_Class()
797 if (showclassframe == 1) then
798 if (UnitIsPlayer("target")) then
799 local targetClass = UnitClass("target");
800 Perl_Target_ClassNameBarText:SetText(targetClass);
801 Perl_Target_ClassNameFrame:Show();
802 Perl_Target_CivilianFrame:Hide();
803 else
804 local targetCreatureType = UnitCreatureType("target");
805 if (targetCreatureType == PERL_LOCALIZED_NOTSPECIFIED) then
806 targetCreatureType = PERL_LOCALIZED_CREATURE;
807 end
808 Perl_Target_ClassNameBarText:SetText(targetCreatureType);
809 Perl_Target_ClassNameFrame:Show();
810  
811 if (UnitIsCivilian("target")) then
812 Perl_Target_CivilianBarText:SetText(PERL_LOCALIZED_CIVILIAN);
813 Perl_Target_CivilianBarText:SetTextColor(1, 0, 0);
814 Perl_Target_CivilianFrame:Show();
815 else
816 Perl_Target_CivilianFrame:Hide();
817 end
818 end
819 else
820 Perl_Target_ClassNameFrame:Hide();
821 Perl_Target_CivilianFrame:Hide();
822 end
823 end
824  
825 function Perl_Target_Update_Portrait()
826 if (showportrait == 1) then
827 local level = Perl_Target_PortraitFrame:GetFrameLevel(); -- Get the frame level of the main portrait frame
828 Perl_Target_PortraitTextFrame:SetFrameLevel(level + 1); -- Put the combat text above it so the portrait graphic doesn't go on top of it
829  
830 Perl_Target_CPFrame:SetPoint("TOPLEFT", Perl_Target_PortraitFrame, "TOPRIGHT", -4, -31); -- Reposition the combo point frame
831 Perl_Target_PortraitFrame:Show(); -- Show the main portrait frame
832  
833 if (threedportrait == 0) then
834 SetPortraitTexture(Perl_Target_Portrait, "target"); -- Load the correct 2d graphic
835 Perl_Target_PortraitFrame_TargetModel:Hide(); -- Hide the 3d graphic
836 Perl_Target_Portrait:Show(); -- Show the 2d graphic
837 else
838 if UnitIsVisible("target") then
839 Perl_Target_PortraitFrame_TargetModel:SetUnit("target"); -- Load the correct 3d graphic
840 Perl_Target_Portrait:Hide(); -- Hide the 2d graphic
841 Perl_Target_PortraitFrame_TargetModel:Show(); -- Show the 3d graphic
842 Perl_Target_PortraitFrame_TargetModel:SetCamera(0);
843 else
844 SetPortraitTexture(Perl_Target_Portrait, "target"); -- Load the correct 2d graphic
845 Perl_Target_PortraitFrame_TargetModel:Hide(); -- Hide the 3d graphic
846 Perl_Target_Portrait:Show(); -- Show the 2d graphic
847 end
848 end
849  
850 Perl_Target_PortraitTextFrame:Show(); -- Show the combat text frame
851 else
852 Perl_Target_CPFrame:SetPoint("TOPLEFT", Perl_Target_StatsFrame, "TOPRIGHT", -4, 0); -- Reposition the combo point frame
853 Perl_Target_PortraitFrame:Hide(); -- Hide the frame and 2d/3d portion
854 Perl_Target_PortraitTextFrame:Hide(); -- Hide the combat text
855 end
856 end
857  
858 function Perl_Target_Portrait_Combat_Text()
859 if (portraitcombattext == 1) then
860 CombatFeedback_OnUpdate(arg1);
861 end
862 end
863  
864 function Perl_Target_Buff_Debuff_Background()
865 if (hidebuffbackground == 0) then
866 Perl_Target_BuffFrame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }});
867 Perl_Target_DebuffFrame:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }});
868 Perl_Target_BuffFrame:SetBackdropColor(0, 0, 0, 1);
869 Perl_Target_BuffFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
870 Perl_Target_DebuffFrame:SetBackdropColor(0, 0, 0, 1);
871 Perl_Target_DebuffFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
872 else
873 Perl_Target_BuffFrame:SetBackdrop(nil);
874 Perl_Target_DebuffFrame:SetBackdrop(nil);
875 end
876 end
877  
878 function Perl_Target_Frame_Style()
879 Perl_Target_RareEliteFrame:SetPoint("TOPLEFT", "Perl_Target_CivilianFrame", "TOPRIGHT", -5, 0);
880  
881 if (framestyle == 1) then
882 Perl_Target_HealthBar:SetWidth(200);
883 Perl_Target_HealthBarBG:SetWidth(200);
884 Perl_Target_ManaBar:SetWidth(200);
885 Perl_Target_ManaBarBG:SetWidth(200);
886 Perl_Target_HealthBar:SetPoint("TOP", "Perl_Target_StatsFrame", "TOP", 0, -10);
887 Perl_Target_ManaBar:SetPoint("TOP", "Perl_Target_HealthBar", "BOTTOM", 0, -2);
888  
889 Perl_Target_CivilianFrame:SetWidth(95);
890 Perl_Target_ClassNameFrame:SetWidth(90);
891 Perl_Target_LevelFrame:SetWidth(46);
892 Perl_Target_Name:SetWidth(180);
893 Perl_Target_NameFrame:SetWidth(180);
894 Perl_Target_RareEliteFrame:SetWidth(46);
895 Perl_Target_StatsFrame:SetWidth(221);
896  
897 Perl_Target_NameFrame_CPMeter:SetWidth(170);
898  
899 Perl_Target_CivilianFrame_CastClickOverlay:SetWidth(95);
900 Perl_Target_NameFrame_CastClickOverlay:SetWidth(180);
901 Perl_Target_StatsFrame_CastClickOverlay:SetWidth(221);
902 elseif (framestyle == 2) then
903 Perl_Target_HealthBar:SetWidth(150);
904 Perl_Target_HealthBarBG:SetWidth(150);
905 Perl_Target_ManaBar:SetWidth(150);
906 Perl_Target_ManaBarBG:SetWidth(150);
907 Perl_Target_HealthBar:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "TOPLEFT", 10, -10);
908 Perl_Target_ManaBar:SetPoint("TOP", "Perl_Target_HealthBar", "BOTTOM", 0, -2);
909  
910 if (compactmode == 0) then
911 Perl_Target_CivilianFrame:SetWidth(114);
912 Perl_Target_ClassNameFrame:SetWidth(90);
913 Perl_Target_LevelFrame:SetWidth(46);
914 Perl_Target_Name:SetWidth(199);
915 Perl_Target_NameFrame:SetWidth(199);
916 Perl_Target_RareEliteFrame:SetWidth(46);
917 Perl_Target_StatsFrame:SetWidth(240);
918  
919 Perl_Target_NameFrame_CPMeter:SetWidth(189);
920  
921 Perl_Target_CivilianFrame_CastClickOverlay:SetWidth(114);
922 Perl_Target_NameFrame_CastClickOverlay:SetWidth(199);
923 Perl_Target_StatsFrame_CastClickOverlay:SetWidth(240);
924 else
925 if (compactpercent == 0) then
926 Perl_Target_CivilianFrame:SetWidth(85);
927 Perl_Target_ClassNameFrame:SetWidth(90);
928 Perl_Target_LevelFrame:SetWidth(46);
929 Perl_Target_Name:SetWidth(129);
930 Perl_Target_NameFrame:SetWidth(129);
931 Perl_Target_RareEliteFrame:SetWidth(46);
932 Perl_Target_StatsFrame:SetWidth(170);
933 Perl_Target_RareEliteFrame:SetPoint("TOPLEFT", "Perl_Target_CivilianFrame", "TOPRIGHT", -46, 0);
934  
935 Perl_Target_NameFrame_CPMeter:SetWidth(119);
936  
937 Perl_Target_CivilianFrame_CastClickOverlay:SetWidth(85);
938 Perl_Target_NameFrame_CastClickOverlay:SetWidth(129);
939 Perl_Target_StatsFrame_CastClickOverlay:SetWidth(170);
940 else
941 Perl_Target_CivilianFrame:SetWidth(79);
942 Perl_Target_ClassNameFrame:SetWidth(90);
943 Perl_Target_LevelFrame:SetWidth(46);
944 Perl_Target_Name:SetWidth(164);
945 Perl_Target_NameFrame:SetWidth(164);
946 Perl_Target_RareEliteFrame:SetWidth(46);
947 Perl_Target_StatsFrame:SetWidth(205);
948  
949 Perl_Target_NameFrame_CPMeter:SetWidth(154);
950  
951 Perl_Target_CivilianFrame_CastClickOverlay:SetWidth(79);
952 Perl_Target_NameFrame_CastClickOverlay:SetWidth(164);
953 Perl_Target_StatsFrame_CastClickOverlay:SetWidth(205);
954 end
955 end
956 end
957 end
958  
959 function Perl_Target_Set_Localized_ClassIcons()
960 Perl_Target_ClassPosRight = {
961 [PERL_LOCALIZED_DRUID] = 0.75,
962 [PERL_LOCALIZED_HUNTER] = 0,
963 [PERL_LOCALIZED_MAGE] = 0.25,
964 [PERL_LOCALIZED_PALADIN] = 0,
965 [PERL_LOCALIZED_PRIEST] = 0.5,
966 [PERL_LOCALIZED_ROGUE] = 0.5,
967 [PERL_LOCALIZED_SHAMAN] = 0.25,
968 [PERL_LOCALIZED_WARLOCK] = 0.75,
969 [PERL_LOCALIZED_WARRIOR] = 0,
970 };
971 Perl_Target_ClassPosLeft = {
972 [PERL_LOCALIZED_DRUID] = 1,
973 [PERL_LOCALIZED_HUNTER] = 0.25,
974 [PERL_LOCALIZED_MAGE] = 0.5,
975 [PERL_LOCALIZED_PALADIN] = 0.25,
976 [PERL_LOCALIZED_PRIEST] = 0.75,
977 [PERL_LOCALIZED_ROGUE] = 0.75,
978 [PERL_LOCALIZED_SHAMAN] = 0.5,
979 [PERL_LOCALIZED_WARLOCK] = 1,
980 [PERL_LOCALIZED_WARRIOR] = 0.25,
981 };
982 Perl_Target_ClassPosTop = {
983 [PERL_LOCALIZED_DRUID] = 0,
984 [PERL_LOCALIZED_HUNTER] = 0.25,
985 [PERL_LOCALIZED_MAGE] = 0,
986 [PERL_LOCALIZED_PALADIN] = 0.5,
987 [PERL_LOCALIZED_PRIEST] = 0.25,
988 [PERL_LOCALIZED_ROGUE] = 0,
989 [PERL_LOCALIZED_SHAMAN] = 0.25,
990 [PERL_LOCALIZED_WARLOCK] = 0.25,
991 [PERL_LOCALIZED_WARRIOR] = 0,
992  
993 };
994 Perl_Target_ClassPosBottom = {
995 [PERL_LOCALIZED_DRUID] = 0.25,
996 [PERL_LOCALIZED_HUNTER] = 0.5,
997 [PERL_LOCALIZED_MAGE] = 0.25,
998 [PERL_LOCALIZED_PALADIN] = 0.75,
999 [PERL_LOCALIZED_PRIEST] = 0.5,
1000 [PERL_LOCALIZED_ROGUE] = 0.25,
1001 [PERL_LOCALIZED_SHAMAN] = 0.5,
1002 [PERL_LOCALIZED_WARLOCK] = 0.5,
1003 [PERL_LOCALIZED_WARRIOR] = 0.25,
1004 };
1005 end
1006  
1007  
1008 --------------------------
1009 -- GUI Config Functions --
1010 --------------------------
1011 function Perl_Target_Set_Buffs(newbuffnumber)
1012 if (newbuffnumber == nil) then
1013 newbuffnumber = 16;
1014 end
1015 numbuffsshown = newbuffnumber;
1016 Perl_Target_UpdateVars();
1017 Perl_Target_Reset_Buffs(); -- Reset the buff icons
1018 Perl_Target_Buff_UpdateAll(); -- Repopulate the buff icons
1019 end
1020  
1021 function Perl_Target_Set_Debuffs(newdebuffnumber)
1022 if (newdebuffnumber == nil) then
1023 newdebuffnumber = 16;
1024 end
1025 numdebuffsshown = newdebuffnumber;
1026 Perl_Target_UpdateVars();
1027 Perl_Target_Reset_Buffs(); -- Reset the buff icons
1028 Perl_Target_Buff_UpdateAll(); -- Repopulate the buff icons
1029 end
1030  
1031 function Perl_Target_Set_Class_Icon(newvalue)
1032 showclassicon = newvalue;
1033 Perl_Target_UpdateVars();
1034 Perl_Target_Update_Once();
1035 end
1036  
1037 function Perl_Target_Set_PvP_Rank_Icon(newvalue)
1038 showpvprank = newvalue;
1039 Perl_Target_UpdateVars();
1040 Perl_Target_Update_Once();
1041 end
1042  
1043 function Perl_Target_Set_PvP_Status_Icon(newvalue)
1044 showpvpicon = newvalue;
1045 Perl_Target_UpdateVars();
1046 Perl_Target_Update_Once();
1047 end
1048  
1049 function Perl_Target_Set_Class_Frame(newvalue)
1050 showclassframe = newvalue;
1051 Perl_Target_UpdateVars();
1052 Perl_Target_Update_Once();
1053 end
1054  
1055 function Perl_Target_Set_Combo_Points(newvalue)
1056 showcp = newvalue;
1057 Perl_Target_UpdateVars();
1058 Perl_Target_Update_Once();
1059 end
1060  
1061 function Perl_Target_Set_MobHealth(newvalue)
1062 mobhealthsupport = newvalue;
1063 Perl_Target_UpdateVars();
1064 Perl_Target_Update_Once();
1065 end
1066  
1067 function Perl_Target_Set_Lock(newvalue)
1068 locked = newvalue;
1069 Perl_Target_UpdateVars();
1070 end
1071  
1072 function Perl_Target_Set_Portrait(newvalue)
1073 showportrait = newvalue;
1074 Perl_Target_UpdateVars();
1075 Perl_Target_Update_Once();
1076 end
1077  
1078 function Perl_Target_Set_3D_Portrait(newvalue)
1079 threedportrait = newvalue;
1080 Perl_Target_UpdateVars();
1081 Perl_Target_Update_Once();
1082 end
1083  
1084 function Perl_Target_Set_Rare_Elite(newvalue)
1085 showrareeliteframe = newvalue;
1086 Perl_Target_UpdateVars();
1087 Perl_Target_Update_Once();
1088 end
1089  
1090 function Perl_Target_Set_Portrait_Combat_Text(newvalue)
1091 portraitcombattext = newvalue;
1092 Perl_Target_UpdateVars();
1093 end
1094  
1095 function Perl_Target_Set_Combo_Name_Frame(newvalue)
1096 nameframecombopoints = newvalue;
1097 Perl_Target_UpdateVars();
1098 Perl_Target_Update_Once();
1099 end
1100  
1101 function Perl_Target_Set_Combo_Frame_Debuffs(newvalue)
1102 comboframedebuffs = newvalue;
1103 Perl_Target_UpdateVars();
1104 Perl_Target_Update_Once();
1105 end
1106  
1107 function Perl_Target_Set_Frame_Style(newvalue)
1108 framestyle = newvalue;
1109 Perl_Target_UpdateVars();
1110 Perl_Target_Frame_Style();
1111 Perl_Target_Update_Once();
1112 end
1113  
1114 function Perl_Target_Set_Compact_Mode(newvalue)
1115 compactmode = newvalue;
1116 Perl_Target_UpdateVars();
1117 Perl_Target_Frame_Style();
1118 Perl_Target_Update_Once();
1119 end
1120  
1121 function Perl_Target_Set_Compact_Percents(newvalue)
1122 compactpercent = newvalue;
1123 Perl_Target_UpdateVars();
1124 Perl_Target_Frame_Style();
1125 Perl_Target_Update_Once();
1126 end
1127  
1128 function Perl_Target_Set_Buff_Debuff_Background(newvalue)
1129 hidebuffbackground = newvalue;
1130 Perl_Target_UpdateVars();
1131 Perl_Target_Buff_Debuff_Background();
1132 end
1133  
1134 function Perl_Target_Set_Scale(number)
1135 local unsavedscale;
1136 if (number ~= nil) then
1137 scale = (number / 100); -- convert the user input to a wow acceptable value
1138 end
1139 unsavedscale = 1 - UIParent:GetEffectiveScale() + scale; -- run it through the scaling formula introduced in 1.9
1140 Perl_Target_Frame:SetScale(unsavedscale);
1141 Perl_Target_Set_BuffDebuff_Scale(buffdebuffscale*100); -- maintain the buff/debuff scale
1142 Perl_Target_UpdateVars();
1143 end
1144  
1145 function Perl_Target_Set_BuffDebuff_Scale(number)
1146 local unsavedscale;
1147 if (number ~= nil) then
1148 buffdebuffscale = (number / 100); -- convert the user input to a wow acceptable value
1149 end
1150 unsavedscale = 1 - UIParent:GetEffectiveScale() + buffdebuffscale; -- run it through the scaling formula introduced in 1.9
1151 Perl_Target_BuffFrame:SetScale(buffdebuffscale);
1152 Perl_Target_DebuffFrame:SetScale(buffdebuffscale);
1153 Perl_Target_UpdateVars();
1154 end
1155  
1156 function Perl_Target_Set_Transparency(number)
1157 if (number ~= nil) then
1158 transparency = (number / 100); -- convert the user input to a wow acceptable value
1159 end
1160 Perl_Target_Frame:SetAlpha(transparency);
1161 Perl_Target_UpdateVars();
1162 end
1163  
1164  
1165 ------------------------------
1166 -- Saved Variable Functions --
1167 ------------------------------
1168 function Perl_Target_GetVars()
1169 locked = Perl_Target_Config[UnitName("player")]["Locked"];
1170 showcp = Perl_Target_Config[UnitName("player")]["ComboPoints"];
1171 showclassicon = Perl_Target_Config[UnitName("player")]["ClassIcon"];
1172 showclassframe = Perl_Target_Config[UnitName("player")]["ClassFrame"];
1173 showpvpicon = Perl_Target_Config[UnitName("player")]["PvPIcon"];
1174 numbuffsshown = Perl_Target_Config[UnitName("player")]["Buffs"];
1175 numdebuffsshown = Perl_Target_Config[UnitName("player")]["Debuffs"];
1176 mobhealthsupport = Perl_Target_Config[UnitName("player")]["MobHealthSupport"];
1177 scale = Perl_Target_Config[UnitName("player")]["Scale"];
1178 showpvprank = Perl_Target_Config[UnitName("player")]["ShowPvPRank"];
1179 transparency = Perl_Target_Config[UnitName("player")]["Transparency"];
1180 buffdebuffscale = Perl_Target_Config[UnitName("player")]["BuffDebuffScale"];
1181 showportrait = Perl_Target_Config[UnitName("player")]["ShowPortrait"];
1182 threedportrait = Perl_Target_Config[UnitName("player")]["ThreeDPortrait"];
1183 portraitcombattext = Perl_Target_Config[UnitName("player")]["PortraitCombatText"];
1184 showrareeliteframe = Perl_Target_Config[UnitName("player")]["ShowRareEliteFrame"];
1185 nameframecombopoints = Perl_Target_Config[UnitName("player")]["NameFrameComboPoints"];
1186 comboframedebuffs = Perl_Target_Config[UnitName("player")]["ComboFrameDebuffs"];
1187 framestyle = Perl_Target_Config[UnitName("player")]["FrameStyle"];
1188 compactmode = Perl_Target_Config[UnitName("player")]["CompactMode"];
1189 compactpercent = Perl_Target_Config[UnitName("player")]["CompactPercent"];
1190 hidebuffbackground = Perl_Target_Config[UnitName("player")]["HideBuffBackground"];
1191  
1192 if (locked == nil) then
1193 locked = 0;
1194 end
1195 if (showcp == nil) then
1196 showcp = 1;
1197 end
1198 if (showclassicon == nil) then
1199 showclassicon = 1;
1200 end
1201 if (showclassframe == nil) then
1202 showclassframe = 1;
1203 end
1204 if (showpvpicon == nil) then
1205 showpvpicon = 1;
1206 end
1207 if (numbuffsshown == nil) then
1208 numbuffsshown = 16;
1209 end
1210 if (numdebuffsshown == nil) then
1211 numdebuffsshown = 16;
1212 end
1213 if (mobhealthsupport == nil) then
1214 mobhealthsupport = 1;
1215 end
1216 if (scale == nil) then
1217 scale = 1;
1218 end
1219 if (showpvprank == nil) then
1220 showpvprank = 0;
1221 end
1222 if (transparency == nil) then
1223 transparency = 1;
1224 end
1225 if (buffdebuffscale == nil) then
1226 buffdebuffscale = 1;
1227 end
1228 if (showportrait == nil) then
1229 showportrait = 0;
1230 end
1231 if (threedportrait == nil) then
1232 threedportrait = 0;
1233 end
1234 if (portraitcombattext == nil) then
1235 portraitcombattext = 1;
1236 end
1237 if (showrareeliteframe == nil) then
1238 showrareeliteframe = 0;
1239 end
1240 if (nameframecombopoints == nil) then
1241 nameframecombopoints = 0;
1242 end
1243 if (comboframedebuffs == nil) then
1244 comboframedebuffs = 0;
1245 end
1246 if (framestyle == nil) then
1247 framestyle = 1;
1248 end
1249 if (compactmode == nil) then
1250 compactmode = 0;
1251 end
1252 if (compactpercent == nil) then
1253 compactpercent = 0;
1254 end
1255 if (hidebuffbackground == nil) then
1256 hidebuffbackground = 0;
1257 end
1258  
1259 local vars = {
1260 ["locked"] = locked,
1261 ["showcp"] = showcp,
1262 ["showclassicon"] = showclassicon,
1263 ["showclassframe"] = showclassframe,
1264 ["showpvpicon"] = showpvpicon,
1265 ["numbuffsshown"] = numbuffsshown,
1266 ["numdebuffsshown"] = numdebuffsshown,
1267 ["mobhealthsupport"] = mobhealthsupport,
1268 ["scale"] = scale,
1269 ["showpvprank"] = showpvprank,
1270 ["transparency"] = transparency,
1271 ["buffdebuffscale"] = buffdebuffscale,
1272 ["showportrait"] = showportrait,
1273 ["threedportrait"] = threedportrait,
1274 ["portraitcombattext"] = portraitcombattext,
1275 ["showrareeliteframe"] = showrareeliteframe,
1276 ["nameframecombopoints"] = nameframecombopoints,
1277 ["comboframedebuffs"] = comboframedebuffs,
1278 ["framestyle"] = framestyle,
1279 ["compactmode"] = compactmode,
1280 ["compactpercent"] = compactpercent,
1281 ["hidebuffbackground"] = hidebuffbackground,
1282 }
1283 return vars;
1284 end
1285  
1286 function Perl_Target_UpdateVars(vartable)
1287 if (vartable ~= nil) then
1288 -- Sanity checks in case you use a load from an old version
1289 if (vartable["Global Settings"] ~= nil) then
1290 if (vartable["Global Settings"]["Locked"] ~= nil) then
1291 locked = vartable["Global Settings"]["Locked"];
1292 else
1293 locked = nil;
1294 end
1295 if (vartable["Global Settings"]["ComboPoints"] ~= nil) then
1296 showcp = vartable["Global Settings"]["ComboPoints"];
1297 else
1298 showcp = nil;
1299 end
1300 if (vartable["Global Settings"]["ClassIcon"] ~= nil) then
1301 showclassicon = vartable["Global Settings"]["ClassIcon"];
1302 else
1303 showclassicon = nil;
1304 end
1305 if (vartable["Global Settings"]["ClassFrame"] ~= nil) then
1306 showclassframe = vartable["Global Settings"]["ClassFrame"];
1307 else
1308 showclassframe = nil;
1309 end
1310 if (vartable["Global Settings"]["PvPIcon"] ~= nil) then
1311 showpvpicon = vartable["Global Settings"]["PvPIcon"];
1312 else
1313 showpvpicon = nil;
1314 end
1315 if (vartable["Global Settings"]["Buffs"] ~= nil) then
1316 numbuffsshown = vartable["Global Settings"]["Buffs"];
1317 else
1318 numbuffsshown = nil;
1319 end
1320 if (vartable["Global Settings"]["Debuffs"] ~= nil) then
1321 numdebuffsshown = vartable["Global Settings"]["Debuffs"];
1322 else
1323 numdebuffsshown = nil;
1324 end
1325 if (vartable["Global Settings"]["MobHealthSupport"] ~= nil) then
1326 mobhealthsupport = vartable["Global Settings"]["MobHealthSupport"];
1327 else
1328 mobhealthsupport = nil;
1329 end
1330 if (vartable["Global Settings"]["Scale"] ~= nil) then
1331 scale = vartable["Global Settings"]["Scale"];
1332 else
1333 scale = nil;
1334 end
1335 if (vartable["Global Settings"]["ShowPvPRank"] ~= nil) then
1336 showpvprank = vartable["Global Settings"]["ShowPvPRank"];
1337 else
1338 showpvprank = nil;
1339 end
1340 if (vartable["Global Settings"]["Transparency"] ~= nil) then
1341 transparency = vartable["Global Settings"]["Transparency"];
1342 else
1343 transparency = nil;
1344 end
1345 if (vartable["Global Settings"]["BuffDebuffScale"] ~= nil) then
1346 buffdebuffscale = vartable["Global Settings"]["BuffDebuffScale"];
1347 else
1348 buffdebuffscale = nil;
1349 end
1350 if (vartable["Global Settings"]["ShowPortrait"] ~= nil) then
1351 showportrait = vartable["Global Settings"]["ShowPortrait"];
1352 else
1353 showportrait = nil;
1354 end
1355 if (vartable["Global Settings"]["ThreeDPortrait"] ~= nil) then
1356 threedportrait = vartable["Global Settings"]["ThreeDPortrait"];
1357 else
1358 threedportrait = nil;
1359 end
1360 if (vartable["Global Settings"]["PortraitCombatText"] ~= nil) then
1361 portraitcombattext = vartable["Global Settings"]["PortraitCombatText"];
1362 else
1363 portraitcombattext = nil;
1364 end
1365 if (vartable["Global Settings"]["ShowRareEliteFrame"] ~= nil) then
1366 showrareeliteframe = vartable["Global Settings"]["ShowRareEliteFrame"];
1367 else
1368 showrareeliteframe = nil;
1369 end
1370 if (vartable["Global Settings"]["NameFrameComboPoints"] ~= nil) then
1371 nameframecombopoints = vartable["Global Settings"]["NameFrameComboPoints"];
1372 else
1373 nameframecombopoints = nil;
1374 end
1375 if (vartable["Global Settings"]["ComboFrameDebuffs"] ~= nil) then
1376 comboframedebuffs = vartable["Global Settings"]["ComboFrameDebuffs"];
1377 else
1378 comboframedebuffs = nil;
1379 end
1380 if (vartable["Global Settings"]["FrameStyle"] ~= nil) then
1381 framestyle = vartable["Global Settings"]["FrameStyle"];
1382 else
1383 framestyle = nil;
1384 end
1385 if (vartable["Global Settings"]["CompactMode"] ~= nil) then
1386 compactmode = vartable["Global Settings"]["CompactMode"];
1387 else
1388 compactmode = nil;
1389 end
1390 if (vartable["Global Settings"]["CompactPercent"] ~= nil) then
1391 compactpercent = vartable["Global Settings"]["CompactPercent"];
1392 else
1393 compactpercent = nil;
1394 end
1395 if (vartable["Global Settings"]["HideBuffBackground"] ~= nil) then
1396 hidebuffbackground = vartable["Global Settings"]["HideBuffBackground"];
1397 else
1398 hidebuffbackground = nil;
1399 end
1400 end
1401  
1402 -- Set the new values if any new values were found, same defaults as above
1403 if (locked == nil) then
1404 locked = 0;
1405 end
1406 if (showcp == nil) then
1407 showcp = 1;
1408 end
1409 if (showclassicon == nil) then
1410 showclassicon = 1;
1411 end
1412 if (showclassframe == nil) then
1413 showclassframe = 1;
1414 end
1415 if (showpvpicon == nil) then
1416 showpvpicon = 1;
1417 end
1418 if (numbuffsshown == nil) then
1419 numbuffsshown = 16;
1420 end
1421 if (numdebuffsshown == nil) then
1422 numdebuffsshown = 16;
1423 end
1424 if (mobhealthsupport == nil) then
1425 mobhealthsupport = 1;
1426 end
1427 if (scale == nil) then
1428 scale = 1;
1429 end
1430 if (showpvprank == nil) then
1431 showpvprank = 0;
1432 end
1433 if (transparency == nil) then
1434 transparency = 1;
1435 end
1436 if (buffdebuffscale == nil) then
1437 buffdebuffscale = 1;
1438 end
1439 if (showportrait == nil) then
1440 showportrait = 0;
1441 end
1442 if (threedportrait == nil) then
1443 threedportrait = 0;
1444 end
1445 if (portraitcombattext == nil) then
1446 portraitcombattext = 1;
1447 end
1448 if (showrareeliteframe == nil) then
1449 showrareeliteframe = 0;
1450 end
1451 if (nameframecombopoints == nil) then
1452 nameframecombopoints = 0;
1453 end
1454 if (comboframedebuffs == nil) then
1455 comboframedebuffs = 0;
1456 end
1457 if (framestyle == nil) then
1458 framestyle = 1;
1459 end
1460 if (compactmode == nil) then
1461 compactmode = 0;
1462 end
1463 if (compactpercent == nil) then
1464 compactpercent = 0;
1465 end
1466 if (hidebuffbackground == nil) then
1467 hidebuffbackground = 0;
1468 end
1469  
1470 -- Call any code we need to activate them
1471 Perl_Target_Reset_Buffs(); -- Reset the buff icons
1472 Perl_Target_Frame_Style(); -- Reposition the frames
1473 Perl_Target_Buff_Debuff_Background(); -- Hide/Show the background frame
1474 Perl_Target_Update_Once();
1475 end
1476  
1477 Perl_Target_Config[UnitName("player")] = {
1478 ["Locked"] = locked,
1479 ["ComboPoints"] = showcp,
1480 ["ClassIcon"] = showclassicon,
1481 ["ClassFrame"] = showclassframe,
1482 ["PvPIcon"] = showpvpicon,
1483 ["Buffs"] = numbuffsshown,
1484 ["Debuffs"] = numdebuffsshown,
1485 ["MobHealthSupport"] = mobhealthsupport,
1486 ["Scale"] = scale,
1487 ["ShowPvPRank"] = showpvprank,
1488 ["Transparency"] = transparency,
1489 ["BuffDebuffScale"] = buffdebuffscale,
1490 ["ShowPortrait"] = showportrait,
1491 ["ThreeDPortrait"] = threedportrait,
1492 ["PortraitCombatText"] = portraitcombattext,
1493 ["ShowRareEliteFrame"] = showrareeliteframe,
1494 ["NameFrameComboPoints"] = nameframecombopoints,
1495 ["ComboFrameDebuffs"] = comboframedebuffs,
1496 ["FrameStyle"] = framestyle,
1497 ["CompactMode"] = compactmode,
1498 ["CompactPercent"] = compactpercent,
1499 ["HideBuffBackground"] = hidebuffbackground,
1500 };
1501 end
1502  
1503  
1504 --------------------
1505 -- Buff Functions --
1506 --------------------
1507 function Perl_Target_Buff_UpdateAll()
1508 local friendly;
1509 if (UnitName("target")) then
1510 if (nameframecombopoints == 1 or comboframedebuffs == 1) then
1511 Perl_Target_Buff_UpdateCPMeter();
1512 end
1513  
1514 if (UnitIsFriend("player", "target")) then
1515 friendly = 1;
1516 else
1517 friendly = 0;
1518 end
1519  
1520 local buffmax = 0;
1521 for buffnum=1,numbuffsshown do
1522 local button = getglobal("Perl_Target_Buff"..buffnum);
1523 local icon = getglobal(button:GetName().."Icon");
1524 local debuff = getglobal(button:GetName().."DebuffBorder");
1525  
1526 if (UnitBuff("target", buffnum)) then
1527 icon:SetTexture(UnitBuff("target", buffnum));
1528 button.isdebuff = 0;
1529 debuff:Hide();
1530 button:Show();
1531 buffmax = buffnum;
1532 else
1533 button:Hide();
1534 end
1535 end
1536  
1537 local debuffmax = 0;
1538 local debuffCount, debuffTexture, debuffApplications;
1539 for debuffnum=1,numdebuffsshown do
1540 debuffTexture, debuffApplications = UnitDebuff("target", debuffnum);
1541 local button = getglobal("Perl_Target_Debuff"..debuffnum);
1542 local icon = getglobal(button:GetName().."Icon");
1543 local debuff = getglobal(button:GetName().."DebuffBorder");
1544  
1545 if (UnitDebuff("target", debuffnum)) then
1546 icon:SetTexture(debuffTexture);
1547 button.isdebuff = 1;
1548 debuff:Show();
1549 button:Show();
1550 debuffCount = getglobal("Perl_Target_Debuff"..debuffnum.."Count");
1551 if (debuffApplications > 1) then
1552 debuffCount:SetText(debuffApplications);
1553 debuffCount:Show();
1554 else
1555 debuffCount:Hide();
1556 end
1557 debuffmax = debuffnum;
1558 else
1559 button:Hide();
1560 end
1561 end
1562  
1563 if (buffmax == 0) then
1564 Perl_Target_BuffFrame:Hide();
1565 else
1566 if (friendly == 1) then
1567 Perl_Target_BuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, 5);
1568 else
1569 if (debuffmax > 8) then
1570 Perl_Target_BuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, -51);
1571 else
1572 Perl_Target_BuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, -25);
1573 end
1574 end
1575 Perl_Target_BuffFrame:Show();
1576 if (buffmax > 8) then
1577 Perl_Target_BuffFrame:SetWidth(221); -- 5 + 8 * (24 + 3) 5 = border gap, 8 buffs across, 24 = icon size + 3 for pixel alignment, only holds true for default size
1578 Perl_Target_BuffFrame:SetHeight(61);
1579 else
1580 Perl_Target_BuffFrame:SetWidth(5 + buffmax * 27);
1581 Perl_Target_BuffFrame:SetHeight(34);
1582 end
1583 end
1584  
1585 if (debuffmax == 0) then
1586 Perl_Target_DebuffFrame:Hide();
1587 else
1588 if (friendly == 1) then
1589 if (buffmax > 8) then
1590 Perl_Target_DebuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, -51);
1591 else
1592 Perl_Target_DebuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, -25);
1593 end
1594 else
1595 Perl_Target_DebuffFrame:SetPoint("TOPLEFT", "Perl_Target_StatsFrame", "BOTTOMLEFT", 0, 5);
1596 end
1597 Perl_Target_DebuffFrame:Show();
1598 if (debuffmax > 8) then
1599 Perl_Target_DebuffFrame:SetWidth(221); -- 5 + 8 * 27
1600 Perl_Target_DebuffFrame:SetHeight(61);
1601 else
1602 Perl_Target_DebuffFrame:SetWidth(5 + debuffmax * 27);
1603 Perl_Target_DebuffFrame:SetHeight(34);
1604 end
1605 end
1606 end
1607 end
1608  
1609 function Perl_Target_Buff_UpdateCPMeter()
1610 local debuffapplications;
1611 local playerclass = UnitClass("player");
1612  
1613 if (playerclass == PERL_LOCALIZED_MAGE) then
1614 debuffapplications = Perl_Target_Buff_GetApplications("Fire Vulnerability");
1615 elseif (playerclass == PERL_LOCALIZED_PRIEST) then
1616 debuffapplications = Perl_Target_Buff_GetApplications("Shadow Vulnerability");
1617 elseif (playerclass == PERL_LOCALIZED_WARRIOR) then
1618 debuffapplications = Perl_Target_Buff_GetApplications("Sunder Armor");
1619 elseif ((playerclass == PERL_LOCALIZED_ROGUE) or (playerclass == PERL_LOCALIZED_DRUID)) then
1620 return;
1621 else
1622 Perl_Target_NameFrame_CPMeter:Hide();
1623 return;
1624 end
1625  
1626 if (debuffapplications == 0) then
1627 Perl_Target_CPFrame:Hide();
1628 Perl_Target_NameFrame_CPMeter:Hide();
1629 else
1630 if (comboframedebuffs == 1) then
1631 Perl_Target_CPText:SetText(debuffapplications);
1632 Perl_Target_CPText:SetTextHeight(20);
1633 if (debuffapplications == 5) then
1634 Perl_Target_CPFrame:Show();
1635 Perl_Target_CPText:SetTextColor(1, 0, 0); -- red text
1636 elseif (debuffapplications == 4) then
1637 Perl_Target_CPFrame:Show();
1638 Perl_Target_CPText:SetTextColor(1, 0.5, 0); -- orange text
1639 elseif (debuffapplications == 3) then
1640 Perl_Target_CPFrame:Show();
1641 Perl_Target_CPText:SetTextColor(1, 1, 0); -- yellow text
1642 elseif (debuffapplications == 2) then
1643 Perl_Target_CPFrame:Show();
1644 Perl_Target_CPText:SetTextColor(0.5, 1, 0); -- yellow-green text
1645 elseif (debuffapplications == 1) then
1646 Perl_Target_CPFrame:Show();
1647 Perl_Target_CPText:SetTextColor(0, 1, 0); -- green text
1648 else
1649 Perl_Target_CPFrame:Hide();
1650 end
1651 else
1652 Perl_Target_CPFrame:Hide();
1653 end
1654  
1655 if (nameframecombopoints == 1) then -- this isn't nested since you can have both combo point styles on at the same time
1656 Perl_Target_NameFrame_CPMeter:SetMinMaxValues(0, 5);
1657 Perl_Target_NameFrame_CPMeter:SetValue(debuffapplications);
1658 if (debuffapplications == 5) then
1659 Perl_Target_NameFrame_CPMeter:Show();
1660 elseif (debuffapplications == 4) then
1661 Perl_Target_NameFrame_CPMeter:Show();
1662 elseif (debuffapplications == 3) then
1663 Perl_Target_NameFrame_CPMeter:Show();
1664 elseif (debuffapplications == 2) then
1665 Perl_Target_NameFrame_CPMeter:Show();
1666 elseif (debuffapplications == 1) then
1667 Perl_Target_NameFrame_CPMeter:Show();
1668 else
1669 Perl_Target_NameFrame_CPMeter:Hide();
1670 end
1671 else
1672 Perl_Target_NameFrame_CPMeter:Hide();
1673 end
1674 end
1675 end
1676  
1677 function Perl_Target_Buff_GetApplications(debuffname)
1678 local debuffApplications;
1679 local i = 1;
1680  
1681 while UnitDebuff("target", i) do
1682 Perl_Target_Tooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
1683 Perl_Target_Tooltip:SetUnitDebuff("target", i);
1684 if (Perl_Target_TooltipTextLeft1:GetText() == debuffname) then
1685 _, debuffApplications = UnitDebuff("target", i);
1686 Perl_Target_Tooltip:Hide();
1687 return debuffApplications;
1688 end
1689  
1690 i = i + 1;
1691 end
1692  
1693 Perl_Target_Tooltip:Hide();
1694 return 0;
1695 end
1696  
1697 function Perl_Target_Reset_Buffs()
1698 local button;
1699 for buffnum=1,16 do
1700 button = getglobal("Perl_Target_Buff"..buffnum);
1701 button:Hide();
1702 button = getglobal("Perl_Target_Debuff"..buffnum);
1703 button:Hide();
1704 end
1705 end
1706  
1707 function Perl_Target_SetBuffTooltip()
1708 local buffmapping = 0;
1709 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
1710 if (this.isdebuff == 1) then
1711 GameTooltip:SetUnitDebuff("target", this:GetID()-buffmapping);
1712 else
1713 GameTooltip:SetUnitBuff("target", this:GetID());
1714 end
1715 end
1716  
1717  
1718 --------------------
1719 -- Click Handlers --
1720 --------------------
1721 function Perl_TargetDropDown_OnLoad()
1722 UIDropDownMenu_Initialize(this, Perl_TargetDropDown_Initialize, "MENU");
1723 end
1724  
1725 function Perl_TargetDropDown_Initialize()
1726 local menu = nil;
1727 if (UnitIsEnemy("target", "player")) then
1728 return;
1729 end
1730 if (UnitIsUnit("target", "player")) then
1731 menu = "SELF";
1732 elseif (UnitIsUnit("target", "pet")) then
1733 menu = "PET";
1734 elseif (UnitIsPlayer("target")) then
1735 if (UnitInParty("target")) then
1736 menu = "PARTY";
1737 else
1738 menu = "PLAYER";
1739 end
1740 end
1741 if (menu) then
1742 UnitPopup_ShowMenu(Perl_Target_DropDown, menu, "target");
1743 end
1744 end
1745  
1746 function Perl_Target_MouseClick(button)
1747 if (CastPartyConfig and PCUF_CASTPARTYSUPPORT == 1) then
1748 if (not string.find(GetMouseFocus():GetName(), "Name")) then
1749 CastParty_OnClickByUnit(button, "target");
1750 end
1751 elseif (Genesis_data and PCUF_CASTPARTYSUPPORT == 1) then
1752 if (not string.find(GetMouseFocus():GetName(), "Name")) then
1753 Genesis_MouseHeal("target", button);
1754 end
1755 else
1756 if (SpellIsTargeting() and button == "RightButton") then
1757 SpellStopTargeting();
1758 return;
1759 end
1760  
1761 if (button == "LeftButton") then
1762 if (SpellIsTargeting()) then
1763 SpellTargetUnit("target");
1764 elseif (CursorHasItem()) then
1765 DropItemOnUnit("target");
1766 end
1767 end
1768 end
1769 end
1770  
1771 function Perl_Target_MouseDown(button)
1772 if (button == "LeftButton" and locked == 0) then
1773 Perl_Target_Frame:StartMoving();
1774 end
1775 end
1776  
1777 function Perl_Target_MouseUp(button)
1778 if (button == "RightButton") then
1779 if ((CastPartyConfig or Genesis_data) and PCUF_CASTPARTYSUPPORT == 1) then
1780 if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown()) and string.find(GetMouseFocus():GetName(), "Name")) then -- if alt, ctrl, or shift ARE NOT held AND we are clicking the name frame, show the menu
1781 ToggleDropDownMenu(1, nil, Perl_Target_DropDown, "Perl_Target_NameFrame", 40, 0);
1782 end
1783 else
1784 if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then -- if alt, ctrl, or shift ARE NOT held, show the menu
1785 ToggleDropDownMenu(1, nil, Perl_Target_DropDown, "Perl_Target_NameFrame", 40, 0);
1786 end
1787 end
1788 end
1789  
1790 Perl_Target_Frame:StopMovingOrSizing();
1791 end
1792  
1793 function Perl_Target_OnShow()
1794 if ( UnitIsEnemy("target", "player") ) then
1795 PlaySound("igCreatureAggroSelect");
1796 elseif ( UnitIsFriend("player", "target") ) then
1797 PlaySound("igCharacterNPCSelect");
1798 else
1799 PlaySound("igCreatureNeutralSelect");
1800 end
1801 end
1802  
1803  
1804 -------------
1805 -- Tooltip --
1806 -------------
1807 function Perl_Target_Tip()
1808 UnitFrame_Initialize("target")
1809 end
1810  
1811 function UnitFrame_Initialize(unit) -- Hopefully this doesn't break any mods
1812 this.unit = unit;
1813 end
1814  
1815  
1816 ----------------------
1817 -- myAddOns Support --
1818 ----------------------
1819 function Perl_Target_myAddOns_Support()
1820 -- Register the addon in myAddOns
1821 if (myAddOnsFrame_Register) then
1822 local Perl_Target_myAddOns_Details = {
1823 name = "Perl_Target",
1824 version = "Version 0.58",
1825 releaseDate = "April 15, 2006",
1826 author = "Perl; Maintained by Global",
1827 email = "global@g-ball.com",
1828 website = "http://www.curse-gaming.com/mod.php?addid=2257",
1829 category = MYADDONS_CATEGORY_OTHERS
1830 };
1831 Perl_Target_myAddOns_Help = {};
1832 Perl_Target_myAddOns_Help[1] = "/perl";
1833 myAddOnsFrame_Register(Perl_Target_myAddOns_Details, Perl_Target_myAddOns_Help);
1834 end
1835 end