vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ---------------
2 -- Variables --
3 ---------------
4 Perl_Party_Config = {};
5  
6 -- Default Saved Variables (also set in Perl_Party_GetVars)
7 local locked = 0; -- unlocked by default
8 local compactmode = 0; -- compact mode is disabled by default
9 local partyhidden = 0; -- party frame is set to always show by default
10 local partyspacing = -80; -- default spacing between party member frames
11 local scale = 1; -- default scale
12 local showpets = 1; -- show pets by default
13 local colorhealth = 0; -- progressively colored health bars are off by default
14 local healermode = 0; -- nurfed unit frame style
15 local transparency = 1.0; -- transparency for frames
16 local bufflocation = 4; -- default buff location
17 local debufflocation = 1; -- default debuff location
18 local verticalalign = 1; -- default alignment is vertically
19 local compactpercent = 0; -- percents are not shown in compact mode by default
20 local showportrait = 1; -- portrait is hidden by default
21 local showfkeys = 0; -- hide appropriate F key in the name frame by default
22 local displaycastablebuffs = 0; -- display all buffs by default
23 local threedportrait = 0; -- 3d portraits are off by default
24 local buffsize = 16; -- default buff size is 16
25 local debuffsize = 16; -- default debuff size is 16
26  
27 -- Default Local Variables
28 local Initialized = nil; -- waiting to be initialized
29 local mouseoverhealthflag = 0; -- is the mouse over the health bar for healer mode?
30 local mouseovermanaflag = 0; -- is the mouse over the mana bar for healer mode?
31 local mouseoverpethealthflag = 0; -- is the mouse over the pet health bar for healer mode?
32  
33 -- Variables for position of the class icon texture.
34 local Perl_Party_ClassPosRight = {};
35 local Perl_Party_ClassPosLeft = {};
36 local Perl_Party_ClassPosTop = {};
37 local Perl_Party_ClassPosBottom = {};
38  
39  
40 ----------------------
41 -- Loading Function --
42 ----------------------
43 function Perl_Party_Script_OnLoad()
44 this:RegisterEvent("PLAYER_ENTERING_WORLD");
45  
46 if (DEFAULT_CHAT_FRAME) then
47 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Perl Classic: Party loaded successfully.");
48 end
49 end
50  
51 function Perl_Party_OnLoad()
52 -- Events
53 this:RegisterEvent("ADDON_LOADED");
54 this:RegisterEvent("PARTY_LEADER_CHANGED");
55 this:RegisterEvent("PARTY_LOOT_METHOD_CHANGED");
56 this:RegisterEvent("PARTY_MEMBER_DISABLE");
57 this:RegisterEvent("PARTY_MEMBER_ENABLE");
58 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
59 this:RegisterEvent("PLAYER_ALIVE");
60 this:RegisterEvent("PLAYER_ENTERING_WORLD");
61 this:RegisterEvent("RAID_ROSTER_UPDATE");
62 this:RegisterEvent("UNIT_AURA");
63 this:RegisterEvent("UNIT_DISPLAYPOWER");
64 this:RegisterEvent("UNIT_ENERGY");
65 this:RegisterEvent("UNIT_HEALTH");
66 this:RegisterEvent("UNIT_LEVEL");
67 this:RegisterEvent("UNIT_MANA");
68 this:RegisterEvent("UNIT_MAXENERGY");
69 this:RegisterEvent("UNIT_MAXHEALTH");
70 this:RegisterEvent("UNIT_MAXMANA");
71 this:RegisterEvent("UNIT_MAXRAGE");
72 this:RegisterEvent("UNIT_MODEL_CHANGED");
73 this:RegisterEvent("UNIT_NAME_UPDATE");
74 this:RegisterEvent("UNIT_PET");
75 this:RegisterEvent("UNIT_PORTRAIT_UPDATE");
76 this:RegisterEvent("UNIT_PVP_UPDATE");
77 this:RegisterEvent("UNIT_RAGE");
78 this:RegisterEvent("VARIABLES_LOADED");
79  
80 HidePartyFrame();
81 ShowPartyFrame = HidePartyFrame; -- This is to fix the annoyance 1.9 introduced
82 end
83  
84  
85 -------------------
86 -- Event Handler --
87 -------------------
88 function Perl_Party_Script_OnEvent(event) -- All this just to ensure party frames are hidden/shown on zoning
89 if (event == "PLAYER_ENTERING_WORLD") then
90 if (Initialized) then
91 Perl_Party_Set_Hidden(); -- Are we running a hidden mode? (Another redundancy check because Blizzard sucks)
92 end
93 return;
94 else
95 return;
96 end
97 end
98  
99 function Perl_Party_OnEvent(event)
100 if (event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH") then
101 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
102 Perl_Party_Update_Health();
103 elseif ((arg1 == "partypet1") or (arg1 == "partypet2") or (arg1 == "partypet3") or (arg1 == "partypet4")) then
104 Perl_Party_Update_Pet_Health();
105 end
106 return;
107 elseif ((event == "UNIT_MANA") or (event == "UNIT_ENERGY") or (event == "UNIT_RAGE") or (event == "UNIT_MAXMANA") or (event == "UNIT_MAXENERGY") or (event == "UNIT_MAXRAGE")) then
108 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
109 Perl_Party_Update_Mana();
110 end
111 return;
112 elseif (event == "UNIT_AURA") then
113 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
114 Perl_Party_Buff_UpdateAll();
115 end
116 return;
117 elseif (event == "UNIT_DISPLAYPOWER") then
118 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
119 Perl_Party_Update_Mana_Bar(); -- What type of energy are we using now?
120 Perl_Party_Update_Mana(); -- Update the power info immediately
121 end
122 return;
123 elseif (event == "UNIT_PVP_UPDATE") then
124 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
125 Perl_Party_Update_PvP_Status(); -- Is the character PvP flagged?
126 end
127 return;
128 elseif (event == "UNIT_NAME_UPDATE") then
129 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
130 Perl_Party_Set_Name(); -- Set the player's name and class icon
131 end
132 return;
133 elseif (event == "UNIT_PET") then
134 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
135 Perl_Party_Update_Pet(); -- Set the player's level
136 end
137 return;
138 elseif (event == "UNIT_LEVEL") then
139 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
140 Perl_Party_Update_Level(); -- Set the player's level
141 end
142 return;
143 elseif (event == "PARTY_MEMBERS_CHANGED") then -- or (event == "RAID_ROSTER_UPDATE") or (event == "PARTY_MEMBER_ENABLE") or (event == "PARTY_MEMBER_DISABLE")
144 Perl_Party_MembersUpdate(); -- How many members are in the group and show the correct frames and do UpdateOnce things
145 return;
146 elseif (event == "RAID_ROSTER_UPDATE") then
147 Perl_Party_Check_Raid_Hidden(); -- Are we running a hidden mode?
148 return;
149 elseif (event == "PARTY_LEADER_CHANGED") then
150 Perl_Party_Update_Leader(); -- Who is the group leader
151 return;
152 elseif (event == "UNIT_PORTRAIT_UPDATE" or event == "UNIT_MODEL_CHANGED") then
153 if ((arg1 == "party1") or (arg1 == "party2") or (arg1 == "party3") or (arg1 == "party4")) then
154 Perl_Party_Update_Portrait();
155 end
156 return;
157 elseif (event == "PARTY_LOOT_METHOD_CHANGED") then
158 Perl_Party_Update_Loot_Method(); -- Who is the master looter if any
159 return;
160 elseif (event == "PLAYER_ALIVE") then
161 Perl_Party_Set_Hidden(); -- Are we running a hidden mode? (Hopefully the last check we need to add for this)
162 return;
163 elseif (event == "PLAYER_ENTERING_WORLD" or event == "VARIABLES_LOADED") then
164 Perl_Party_Initialize(); -- We also force update info here in case of a /console reloadui
165 return;
166 elseif (event == "ADDON_LOADED") then
167 if (arg1 == "Perl_Party") then
168 Perl_Party_myAddOns_Support();
169 end
170 return;
171 else
172 return;
173 end
174 end
175  
176  
177 -------------------------------
178 -- Loading Settings Function --
179 -------------------------------
180 function Perl_Party_Initialize()
181 -- Check if we loaded the mod already.
182 if (Initialized) then
183 Perl_Party_Set_Scale();
184 Perl_Party_Force_Update() -- Attempt to forcefully update information
185 Perl_Party_Set_Text_Positions(); -- Not called in the above
186 Perl_Party_Set_Pets(); -- Also not called
187 Perl_Party_Update_Health_Mana(); -- You know the drill
188 Perl_Party_Set_Hidden(); -- Are we running a hidden mode?
189 return;
190 end
191  
192 -- Check if a previous exists, if not, enable by default.
193 if (type(Perl_Party_Config[UnitName("player")]) == "table") then
194 Perl_Party_GetVars();
195 else
196 Perl_Party_UpdateVars();
197 end
198  
199 -- Major config options.
200 Perl_Party_Initialize_Frame_Color(); -- Color the frame borders
201 Perl_Party_Set_Localized_ClassIcons(); -- Do localization stuff
202 Perl_Party_Set_Transparency(); -- Set the frame transparency
203 Perl_Party_Reset_Buffs(); -- Set the buff sizing
204  
205 -- Unregister the Blizzard frames via the 1.8 function
206 for num = 1, 4 do
207 frame = getglobal("PartyMemberFrame"..num);
208 HealthBar = getglobal("PartyMemberFrame"..num.."HealthBar");
209 ManaBar = getglobal("PartyMemberFrame"..num.."ManaBar");
210  
211 frame:UnregisterAllEvents();
212 HealthBar:UnregisterAllEvents();
213 ManaBar:UnregisterAllEvents();
214 end
215  
216 -- Button Click Overlays (in order of occurrence in XML)
217 for num = 1, 4 do
218 getglobal("Perl_Party_MemberFrame"..num.."_NameFrame_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_NameFrame"):GetFrameLevel() + 1);
219 getglobal("Perl_Party_MemberFrame"..num.."_LevelFrame_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_LevelFrame"):GetFrameLevel() + 2);
220 getglobal("Perl_Party_MemberFrame"..num.."_PortraitFrame_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_PortraitFrame"):GetFrameLevel() + 2);
221 getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame"):GetFrameLevel() + 1);
222 getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame_HealthBar_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame"):GetFrameLevel() + 2);
223 getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame_ManaBar_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame"):GetFrameLevel() + 2);
224 getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame_PetHealthBar_CastClickOverlay"):SetFrameLevel(getglobal("Perl_Party_MemberFrame"..num.."_StatsFrame"):GetFrameLevel() + 2);
225 end
226  
227 Initialized = 1;
228 Perl_Party_MembersUpdate();
229 end
230  
231 function Perl_Party_Initialize_Frame_Color(flag)
232 if (flag == nil) then
233 getglobal(this:GetName().."_NameFrame"):SetBackdropColor(0, 0, 0, 1);
234 getglobal(this:GetName().."_NameFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
235 getglobal(this:GetName().."_LevelFrame"):SetBackdropColor(0, 0, 0, 1);
236 getglobal(this:GetName().."_LevelFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
237 getglobal(this:GetName().."_PortraitFrame"):SetBackdropColor(0, 0, 0, 1);
238 getglobal(this:GetName().."_PortraitFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
239 getglobal(this:GetName().."_StatsFrame"):SetBackdropColor(0, 0, 0, 1);
240 getglobal(this:GetName().."_StatsFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
241 else
242 for partynum=1,4 do
243 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame"):SetBackdropColor(0, 0, 0, 1);
244 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
245 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame"):SetBackdropColor(0, 0, 0, 1);
246 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
247 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame"):SetBackdropColor(0, 0, 0, 1);
248 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
249 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetBackdropColor(0, 0, 0, 1);
250 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetBackdropBorderColor(0.5, 0.5, 0.5, 1);
251 end
252 end
253 end
254  
255  
256 ----------------------
257 -- Update Functions --
258 ----------------------
259 function Perl_Party_MembersUpdate()
260 for partynum=1,4 do
261 local partyid = "party"..partynum;
262 local frame = getglobal("Perl_Party_MemberFrame"..partynum);
263 if (UnitName(partyid) ~= nil) then
264 if (partyhidden == 0) then
265 frame:Show();
266 else
267 if (partyhidden == 1) then
268 frame:Hide();
269 end
270 if (partyhidden == 2) then
271 if (UnitInRaid("player")) then
272 frame:Hide();
273 else
274 frame:Show();
275 end
276 end
277 end
278 else
279 frame:Hide();
280 end
281 end
282 Perl_Party_Set_Name();
283 Perl_Party_Set_Scale();
284 Perl_Party_Update_PvP_Status();
285 Perl_Party_Update_Level();
286 Perl_Party_Set_Compact(); -- Perl_Party_Set_Text_Positions is also called from here
287 Perl_Party_Update_Health();
288 Perl_Party_Update_Mana();
289 Perl_Party_Update_Mana_Bar();
290 Perl_Party_Update_Pet(); -- Call instead of Perl_Party_Set_Space to ensure spacing is correctly set for pets
291 Perl_Party_Update_Pet_Health();
292 Perl_Party_Update_Leader();
293 Perl_Party_Update_Loot_Method();
294 Perl_Party_Update_Portrait();
295 Perl_Party_Buff_UpdateAll();
296 end
297  
298 function Perl_Party_Update_Health()
299 local id = this:GetID();
300 local partyid = "party"..id;
301 local partyhealth = UnitHealth(partyid);
302 local partyhealthmax = UnitHealthMax(partyid);
303 local partyhealthpercent = floor(partyhealth/partyhealthmax*100+0.5);
304  
305 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then -- This prevents negative health
306 partyhealth = 0;
307 partyhealthpercent = 0;
308 end
309  
310 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetMinMaxValues(0, partyhealthmax);
311 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetValue(partyhealth);
312  
313 if (colorhealth == 1) then
314 if ((partyhealthpercent <= 100) and (partyhealthpercent > 75)) then
315 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetStatusBarColor(0, 0.8, 0);
316 getglobal(this:GetName().."_StatsFrame_HealthBarBG"):SetStatusBarColor(0, 0.8, 0, 0.25);
317 elseif ((partyhealthpercent <= 75) and (partyhealthpercent > 50)) then
318 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetStatusBarColor(1, 1, 0);
319 getglobal(this:GetName().."_StatsFrame_HealthBarBG"):SetStatusBarColor(1, 1, 0, 0.25);
320 elseif ((partyhealthpercent <= 50) and (partyhealthpercent > 25)) then
321 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetStatusBarColor(1, 0.5, 0);
322 getglobal(this:GetName().."_StatsFrame_HealthBarBG"):SetStatusBarColor(1, 0.5, 0, 0.25);
323 else
324 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetStatusBarColor(1, 0, 0);
325 getglobal(this:GetName().."_StatsFrame_HealthBarBG"):SetStatusBarColor(1, 0, 0, 0.25);
326 end
327 else
328 getglobal(this:GetName().."_StatsFrame_HealthBar"):SetStatusBarColor(0, 0.8, 0);
329 getglobal(this:GetName().."_StatsFrame_HealthBarBG"):SetStatusBarColor(0, 0.8, 0, 0.25);
330 end
331  
332 if (compactmode == 0) then
333 if (healermode == 1) then
334 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarText"):SetText("-"..partyhealthmax - partyhealth);
335 if (tonumber(mouseoverhealthflag) == tonumber(id)) then
336 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealth.."/"..partyhealthmax);
337 else
338 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText();
339 end
340 else
341 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarText"):SetText(partyhealth.."/"..partyhealthmax);
342 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealthpercent.."%");
343 end
344 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText(); -- Hide the compact mode percent text in full mode
345 else
346 if (healermode == 1) then
347 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarText"):SetText("-"..partyhealthmax - partyhealth);
348 if (tonumber(mouseoverhealthflag) == tonumber(id)) then
349 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealth.."/"..partyhealthmax);
350 else
351 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText();
352 end
353 else
354 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarText"):SetText();
355 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealth.."/"..partyhealthmax);
356 end
357  
358 if (compactpercent == 1) then
359 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText(partyhealthpercent.."%");
360 else
361 getglobal(this:GetName().."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText();
362 end
363 end
364  
365 -- Handle disconnected state
366 if (UnitIsConnected(partyid)) then
367 getglobal(this:GetName().."_NameFrame_DisconnectStatus"):Hide();
368 else
369 getglobal(this:GetName().."_NameFrame_DisconnectStatus"):Show();
370 end
371  
372 -- Handle death state
373 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then
374 getglobal(this:GetName().."_NameFrame_DeadStatus"):Show();
375 else
376 getglobal(this:GetName().."_NameFrame_DeadStatus"):Hide();
377 end
378 end
379  
380 function Perl_Party_Update_Mana()
381 local id = this:GetID();
382 local partyid = "party"..id;
383 local partymana = UnitMana(partyid);
384 local partymanamax = UnitManaMax(partyid);
385 local partymanapercent = floor(partymana/partymanamax*100+0.5);
386  
387 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then -- This prevents negative mana
388 partymana = 0;
389 partymanapercent = 0;
390 end
391  
392 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetMinMaxValues(0, partymanamax);
393 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetValue(partymana);
394  
395 if (compactmode == 0) then
396 if (healermode == 1) then
397 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarText"):SetText();
398 if (tonumber(mouseovermanaflag) == tonumber(id)) then
399 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana.."/"..partymanamax);
400 else
401 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText();
402 end
403 else
404 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarText"):SetText(partymana.."/"..partymanamax);
405 if (UnitPowerType(partyid) == 1) then
406 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana);
407 else
408 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymanapercent.."%");
409 end
410 end
411 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText(); -- Hide the compact mode percent text in full mode
412 else
413 if (healermode == 1) then
414 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarText"):SetText();
415 if (tonumber(mouseovermanaflag) == tonumber(id)) then
416 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana.."/"..partymanamax);
417 else
418 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText();
419 end
420 else
421 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarText"):SetText();
422 if (UnitPowerType(partyid) == 1) then
423 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana);
424 else
425 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana.."/"..partymanamax);
426 end
427 end
428  
429 if (compactpercent == 1) then
430 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText(partymanapercent.."%");
431 else
432 getglobal(this:GetName().."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText();
433 end
434 end
435 end
436  
437 function Perl_Party_Update_Mana_Bar()
438 local partyid = "party"..this:GetID();
439 local partypower = UnitPowerType(partyid);
440  
441 -- Set mana bar color
442 if (partypower == 1) then
443 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetStatusBarColor(1, 0, 0, 1);
444 getglobal(this:GetName().."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 0, 0, 0.25);
445 elseif (partypower == 2) then
446 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetStatusBarColor(1, 0.5, 0, 1);
447 getglobal(this:GetName().."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 0.5, 0, 0.25);
448 elseif (partypower == 3) then
449 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetStatusBarColor(1, 1, 0, 1);
450 getglobal(this:GetName().."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 1, 0, 0.25);
451 else
452 getglobal(this:GetName().."_StatsFrame_ManaBar"):SetStatusBarColor(0, 0, 1, 1);
453 getglobal(this:GetName().."_StatsFrame_ManaBarBG"):SetStatusBarColor(0, 0, 1, 0.25);
454 end
455 end
456  
457 function Perl_Party_Update_Pet()
458 local id = this:GetID();
459  
460 if (showpets == 1) then
461 if (UnitIsConnected("party"..id) and UnitExists("partypet"..id)) then
462 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):Show();
463 getglobal(this:GetName().."_StatsFrame_PetHealthBarBG"):Show();
464 getglobal(this:GetName().."_StatsFrame_PetHealthBar_CastClickOverlay"):Show();
465 getglobal(this:GetName().."_StatsFrame"):SetHeight(54);
466 getglobal(this:GetName().."_StatsFrame_CastClickOverlay"):SetHeight(54);
467  
468 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetMinMaxValues(0, 1); -- Set health to zero in order to keep the bars sane
469 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetValue(0); -- Info should be updated automatically anyway
470 if (colorhealth == 1) then
471 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(1, 0, 0);
472 else
473 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(0, 0.8, 0);
474 end
475 if (compactmode == 0) then
476 if (healermode == 1) then
477 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-0");
478 if (tonumber(mouseoverpethealthflag) == tonumber(id)) then
479 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText("0/0");
480 else
481 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
482 end
483 else
484 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("0/0");
485 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText("0%");
486 end
487 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText();
488 else
489 if (healermode == 1) then
490 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-0");
491 if (tonumber(mouseoverpethealthflag) == tonumber(id)) then
492 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText("0/0");
493 else
494 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
495 end
496 else
497 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText();
498 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText("0/0");
499 end
500  
501 if (compactpercent == 1) then
502 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText("0%");
503 else
504 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText();
505 end
506 end -- End waste of code to keep it sane
507  
508 if (verticalalign == 1) then
509 --local idspace = id + 1;
510 --local partypetspacing = partyspacing - 12;
511  
512 -- if (id == 1 or id == 2 or id == 3) then
513 -- local idspace = id + 1;
514 -- local partypetspacing;
515 -- if (partyspacing < 0) then -- Frames are normal
516 -- partypetspacing = partyspacing - 12;
517 -- else -- Frames are inverted
518 -- partypetspacing = partyspacing + 12;
519 -- end
520 -- getglobal("Perl_Party_MemberFrame"..idspace):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id, "TOPLEFT", 0, partypetspacing);
521 -- end
522  
523  
524  
525 local idspace = id + 1;
526 local partypetspacing;
527 if (partyspacing < 0) then -- Frames are normal
528 if (id == 1 or id == 2 or id == 3) then
529 partypetspacing = partyspacing - 12;
530 end
531 getglobal("Perl_Party_MemberFrame"..idspace):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id, "TOPLEFT", 0, partypetspacing);
532 else -- Frames are inverted
533 partypetspacing = partyspacing + 12;
534 getglobal("Perl_Party_MemberFrame"..id):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..(id-1), "TOPLEFT", 0, partypetspacing);
535 end
536  
537 else
538 local horizontalspacing;
539 if (partyspacing < 0) then
540 horizontalspacing = partyspacing - 195;
541 else
542 horizontalspacing = partyspacing + 195;
543 end
544 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
545 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
546 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
547 end
548 else
549 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):Hide();
550 getglobal(this:GetName().."_StatsFrame_PetHealthBarBG"):Hide();
551 getglobal(this:GetName().."_StatsFrame_PetHealthBar_CastClickOverlay"):Hide();
552 getglobal(this:GetName().."_StatsFrame"):SetHeight(42);
553 getglobal(this:GetName().."_StatsFrame_CastClickOverlay"):SetHeight(42);
554  
555 if (verticalalign == 1) then
556 if (id == 1) then
557 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partyspacing);
558 elseif (id == 2) then
559 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partyspacing);
560 elseif (id == 3) then
561 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partyspacing);
562 end
563 else
564 local horizontalspacing;
565 if (partyspacing < 0) then
566 horizontalspacing = partyspacing - 195;
567 else
568 horizontalspacing = partyspacing + 195;
569 end
570 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
571 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
572 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
573 end
574 end
575 else
576 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):Hide();
577 getglobal(this:GetName().."_StatsFrame_PetHealthBarBG"):Hide();
578 getglobal(this:GetName().."_StatsFrame_PetHealthBar_CastClickOverlay"):Hide();
579 getglobal(this:GetName().."_StatsFrame"):SetHeight(42);
580 getglobal(this:GetName().."_StatsFrame_CastClickOverlay"):SetHeight(42);
581  
582 if (verticalalign == 1) then
583 if (id == 1) then
584 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partyspacing);
585 elseif (id == 2) then
586 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partyspacing);
587 elseif (id == 3) then
588 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partyspacing);
589 end
590 else
591 local horizontalspacing;
592 if (partyspacing < 0) then
593 horizontalspacing = partyspacing - 195;
594 else
595 horizontalspacing = partyspacing + 195;
596 end
597 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
598 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
599 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
600 end
601 end
602 end
603  
604 function Perl_Party_Update_Pet_Health()
605 local id = this:GetID();
606  
607 if (UnitIsConnected("party"..id) and UnitExists("partypet"..id)) then
608 local partypethealth = UnitHealth("partypet"..id);
609 local partypethealthmax = UnitHealthMax("partypet"..id);
610 local partypethealthpercent = floor(partypethealth/partypethealthmax*100+0.5);
611  
612 if (UnitIsDead("partypet"..id) or UnitIsGhost("partypet"..id)) then -- This prevents negative health
613 partypethealth = 0;
614 partypethealthpercent = 0;
615 end
616  
617 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetMinMaxValues(0, partypethealthmax);
618 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetValue(partypethealth);
619  
620 if (colorhealth == 1) then
621 if ((partypethealthpercent <= 100) and (partypethealthpercent > 75)) then
622 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(0, 0.8, 0);
623 elseif ((partypethealthpercent <= 75) and (partypethealthpercent > 50)) then
624 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(1, 1, 0);
625 elseif ((partypethealthpercent <= 50) and (partypethealthpercent > 25)) then
626 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(1, 0.5, 0);
627 else
628 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(1, 0, 0);
629 end
630 else
631 getglobal(this:GetName().."_StatsFrame_PetHealthBar"):SetStatusBarColor(0, 0.8, 0);
632 end
633  
634 if (compactmode == 0) then
635 if (healermode == 1) then
636 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-"..partypethealthmax - partypethealth);
637 if (tonumber(mouseoverpethealthflag) == tonumber(id)) then
638 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
639 else
640 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
641 end
642 else
643 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText(partypethealth.."/"..partypethealthmax);
644 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealthpercent.."%");
645 end
646 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText(); -- Hide the compact mode percent text in full mode
647 else
648 if (healermode == 1) then
649 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-"..partypethealthmax - partypethealth);
650 if (tonumber(mouseoverpethealthflag) == tonumber(id)) then
651 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
652 else
653 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
654 end
655 else
656 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText();
657 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
658 end
659  
660 if (compactpercent == 1) then
661 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText(partypethealthpercent.."%");
662 else
663 getglobal(this:GetName().."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText();
664 end
665 end
666  
667 else
668 -- do nothing, should be hidden
669 end
670 end
671  
672 function Perl_Party_Set_Name()
673 local id = this:GetID();
674 local partyid = "party"..id;
675 local partyname = UnitName(partyid);
676  
677 -- Set name
678 if (UnitName(partyid) ~= nil) then
679 if (strlen(partyname) > 20) then
680 partyname = strsub(partyname, 1, 19).."...";
681 end
682 if (showfkeys == 1) then
683 getglobal(this:GetName().."_NameFrame_FKeyText"):SetText("F"..(id + 1));
684 else
685 getglobal(this:GetName().."_NameFrame_FKeyText"):SetText();
686 end
687 getglobal(this:GetName().."_NameFrame_NameBarText"):SetText(partyname);
688 end
689  
690 -- Set Class Icon
691 if (UnitIsPlayer(partyid)) then
692 local PlayerClass = UnitClass(partyid);
693 getglobal(this:GetName().."_LevelFrame_ClassTexture"):SetTexCoord(Perl_Party_ClassPosRight[PlayerClass], Perl_Party_ClassPosLeft[PlayerClass], Perl_Party_ClassPosTop[PlayerClass], Perl_Party_ClassPosBottom[PlayerClass]); -- Set the player's class icon
694 getglobal(this:GetName().."_LevelFrame_ClassTexture"):Show();
695 else
696 getglobal(this:GetName().."_LevelFrame_ClassTexture"):Hide();
697 end
698 end
699  
700 function Perl_Party_Update_PvP_Status() -- Modeled after 1.9 code
701 local partyid = "party"..this:GetID();
702 local factionGroup = UnitFactionGroup(partyid);
703 if (factionGroup == nil) then -- This check probably isn't needed since the changes in the code below in 0.48
704 factionGroup = UnitFactionGroup("player");
705 end
706 -- Color their name if PvP flagged
707 if (UnitIsPVPFreeForAll(partyid)) then
708 getglobal(this:GetName().."_NameFrame_NameBarText"):SetTextColor(0,1,0); -- FFA PvP will still use normal PvP coloring since you're grouped
709 getglobal(this:GetName().."_NameFrame_PVPStatus"):SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA"); -- Set the FFA PvP icon
710 getglobal(this:GetName().."_NameFrame_PVPStatus"):Show(); -- Show the icon
711 elseif (factionGroup and UnitIsPVP(partyid)) then
712 getglobal(this:GetName().."_NameFrame_NameBarText"):SetTextColor(0,1,0); -- Color the name for PvP
713 getglobal(this:GetName().."_NameFrame_PVPStatus"):SetTexture("Interface\\TargetingFrame\\UI-PVP-"..factionGroup); -- Set the correct team icon
714 getglobal(this:GetName().."_NameFrame_PVPStatus"):Show(); -- Show the icon
715 else
716 getglobal(this:GetName().."_NameFrame_NameBarText"):SetTextColor(0.5,0.5,1); -- Set the non PvP name color
717 getglobal(this:GetName().."_NameFrame_PVPStatus"):Hide(); -- Hide the icon
718 end
719 end
720  
721 function Perl_Party_Update_Level()
722 local id = this:GetID();
723 if (id ~= 0) then -- Do this check to prevent showing a player level of zero when the player is zoning or dead or cant have info received (linkdead)
724 getglobal(this:GetName().."_LevelFrame_LevelBarText"):SetText(UnitLevel("party"..id));
725 end
726 end
727  
728 function Perl_Party_Update_Leader()
729 local id = this:GetID();
730 local icon = getglobal(this:GetName().."_NameFrame_LeaderIcon");
731 if (GetPartyLeaderIndex() == id) then
732 icon:Show();
733 else
734 icon:Hide();
735 end
736 end
737  
738 function Perl_Party_Update_Loot_Method()
739 local lootMethod, lootMaster;
740 lootMethod, lootMaster = GetLootMethod();
741 if (this:GetID() == lootMaster) then
742 getglobal(this:GetName().."_NameFrame_MasterIcon"):Show();
743 else
744 getglobal(this:GetName().."_NameFrame_MasterIcon"):Hide();
745 end
746 end
747  
748 function Perl_Party_Check_Raid_Hidden()
749 if (partyhidden == 2) then
750 Perl_Party_MemberFrame1:Hide();
751 Perl_Party_MemberFrame2:Hide();
752 Perl_Party_MemberFrame3:Hide();
753 Perl_Party_MemberFrame4:Hide();
754 end
755 end
756  
757 function Perl_Party_Set_Text_Positions()
758 if (compactmode == 0) then
759 for partynum=1,4 do
760 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetPoint("RIGHT", 70, 0);
761 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetPoint("TOP", 0, 1);
762 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetPoint("RIGHT", 70, 0);
763 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetPoint("TOP", 0, 1);
764 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetPoint("RIGHT", 70, 0);
765 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetPoint("TOP", 0, 1);
766 end
767 else
768 if (healermode == 1) then
769 for partynum=1,4 do
770 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetPoint("RIGHT", -10, 0);
771 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetPoint("TOP", -40, 1);
772 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetPoint("RIGHT", -10, 0);
773 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetPoint("TOP", -40, 1);
774 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetPoint("RIGHT", -10, 0);
775 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetPoint("TOP", -40, 1);
776 end
777 else
778 for partynum=1,4 do
779 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetPoint("RIGHT", 70, 0);
780 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetPoint("TOP", 0, 1);
781 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetPoint("RIGHT", 70, 1);
782 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetPoint("TOP", 0, 1);
783 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetPoint("RIGHT", 70, 0);
784 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetPoint("TOP", 0, 1);
785 end
786 end
787 end
788 end
789  
790 function Perl_Party_HealthShow()
791 if (healermode == 1) then
792 local id = this:GetID();
793 if (id == 0) then
794 local name=this:GetName();
795 id = string.sub(name, 23, 23);
796 end
797 local partyid = "party"..id;
798 local partyhealth = UnitHealth(partyid);
799 local partyhealthmax = UnitHealthMax(partyid);
800  
801 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then -- This prevents negative health
802 partyhealth = 0;
803 end
804  
805 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealth.."/"..partyhealthmax);
806 mouseoverhealthflag = id;
807 end
808 end
809  
810 function Perl_Party_HealthHide()
811 if (healermode == 1) then
812 local id = this:GetID();
813 if (id == 0) then
814 local name=this:GetName();
815 id = string.sub(name, 23, 23);
816 end
817 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText();
818 mouseoverhealthflag = 0;
819 end
820 end
821  
822 function Perl_Party_ManaShow()
823 if (healermode == 1) then
824 local id = this:GetID();
825 if (id == 0) then
826 local name=this:GetName();
827 id = string.sub(name, 23, 23);
828 end
829 local partyid = "party"..id;
830 local partymana = UnitMana(partyid);
831 local partymanamax = UnitManaMax(partyid);
832  
833 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then -- This prevents negative mana
834 partymana = 0;
835 end
836  
837 if (UnitPowerType(partyid) == 1) then
838 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana);
839 else
840 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana.."/"..partymanamax);
841 end
842 mouseovermanaflag = id;
843 end
844 end
845  
846 function Perl_Party_ManaHide()
847 if (healermode == 1) then
848 local id = this:GetID();
849 if (id == 0) then
850 local name=this:GetName();
851 id = string.sub(name, 23, 23);
852 end
853 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText();
854 mouseovermanaflag = 0;
855 end
856 end
857  
858 function Perl_Party_Pet_HealthShow()
859 if (healermode == 1) then
860 local id = this:GetID();
861 if (id == 0) then
862 local name=this:GetName();
863 id = string.sub(name, 23, 23);
864 end
865 local partyid = "partypet"..id;
866 local partypethealth = UnitHealth(partyid);
867 local partypethealthmax = UnitHealthMax(partyid);
868  
869 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then -- This prevents negative health
870 partypethealth = 0;
871 end
872  
873 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
874 mouseoverpethealthflag = id;
875 end
876 end
877  
878 function Perl_Party_Pet_HealthHide()
879 if (healermode == 1) then
880 local id = this:GetID();
881 if (id == 0) then
882 local name=this:GetName();
883 id = string.sub(name, 23, 23);
884 end
885 getglobal("Perl_Party_MemberFrame"..id.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
886 mouseoverpethealthflag = 0;
887 end
888 end
889  
890 function Perl_Party_Update_Portrait(partymember)
891 local id;
892  
893 if (partymember == nil) then
894 id = this:GetID();
895 else
896 id = partymember;
897 end
898  
899 if (showportrait == 1) then
900 local partyid = "party"..id;
901  
902 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame"):Show(); -- Show the main portrait frame
903  
904 if (threedportrait == 0) then
905 SetPortraitTexture(getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_Portrait"), partyid); -- Load the correct 2d graphic
906 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_PartyModel"):Hide(); -- Hide the 3d graphic
907 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_Portrait"):Show(); -- Show the 2d graphic
908 else
909 if UnitIsVisible(partyid) then
910 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_PartyModel"):SetUnit(partyid); -- Load the correct 3d graphic
911 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_Portrait"):Hide(); -- Hide the 2d graphic
912 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_PartyModel"):Show(); -- Show the 3d graphic
913 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_PartyModel"):SetCamera(0);
914 else
915 SetPortraitTexture(getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_Portrait"), partyid); -- Load the correct 2d graphic
916 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_PartyModel"):Hide(); -- Hide the 3d graphic
917 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame_Portrait"):Show(); -- Show the 2d graphic
918 end
919 end
920 else
921 getglobal("Perl_Party_MemberFrame"..id.."_PortraitFrame"):Hide(); -- Hide the frame and 2d/3d portion
922 end
923 end
924  
925 function Perl_Party_Update_Health_Mana()
926 local partyhealth, partyhealthmax, partyhealthpercent, partymana, partymanamax, partymanapercent, partypethealth, partypethealthmax, partypethealthpercent;
927  
928 for partynum=1,4 do
929 local partyid = "party"..partynum;
930 if (UnitName(partyid) ~= nil) then
931 partyhealth = UnitHealth(partyid);
932 partyhealthmax = UnitHealthMax(partyid);
933 partyhealthpercent = floor(partyhealth/partyhealthmax*100+0.5);
934 partymana = UnitMana(partyid);
935 partymanamax = UnitManaMax(partyid);
936 partymanapercent = floor(partymana/partymanamax*100+0.5);
937 partypethealth = UnitHealth("partypet"..partynum);
938 partypethealthmax = UnitHealthMax("partypet"..partynum);
939 partypethealthpercent = floor(partypethealth/partypethealthmax*100+0.5);
940  
941 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar"):SetMinMaxValues(0, partyhealthmax);
942 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar"):SetValue(partyhealth);
943 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetMinMaxValues(0, partymanamax);
944 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetValue(partymana);
945 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):SetMinMaxValues(0, partypethealthmax);
946 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):SetValue(partypethealth);
947  
948 if (compactmode == 0) then
949 if (healermode == 1) then
950 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetText("-"..partyhealthmax - partyhealth);
951 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText();
952 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetText();
953 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText();
954 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-"..partypethealthmax - partypethealth);
955 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
956 else
957 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetText(partyhealth.."/"..partyhealthmax);
958 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealthpercent.."%");
959 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetText(partymana.."/"..partymanamax);
960 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymanapercent.."%");
961 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText(partypethealth.."/"..partypethealthmax);
962 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealthpercent.."%");
963 end
964 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText();
965 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText();
966 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText();
967 else
968 if (healermode == 1) then
969 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetText("-"..partyhealthmax - partyhealth);
970 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText();
971 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetText();
972 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText();
973 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText("-"..partypethealthmax - partypethealth);
974 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText();
975 else
976 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarText"):SetText();
977 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextPercent"):SetText(partyhealth.."/"..partyhealthmax);
978 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarText"):SetText();
979 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextPercent"):SetText(partymana.."/"..partymanamax);
980 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText();
981 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
982 end
983  
984 if (compactpercent == 1) then
985 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText(partyhealthpercent.."%");
986 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText(partymanapercent.."%");
987 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText(partypethealthpercent.."%");
988 else
989 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_HealthBar_HealthBarTextCompactPercent"):SetText();
990 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar_ManaBarTextCompactPercent"):SetText();
991 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextCompactPercent"):SetText();
992 end
993 end
994 else
995 -- Do nothing since it's hidden anyway
996 end
997 end
998 end
999  
1000 function Perl_Party_Force_Update()
1001 for partynum = 1, 4 do
1002 local partyid = "party"..partynum;
1003 local partyname = UnitName(partyid);
1004  
1005 -- Set name
1006 if (UnitName(partyid) ~= nil) then
1007 if (strlen(partyname) > 20) then
1008 partyname = strsub(partyname, 1, 19).."...";
1009 end
1010 if (showfkeys == 1) then
1011 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_FKeyText"):SetText("F"..(partynum + 1));
1012 else
1013 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_FKeyText"):SetText();
1014 end
1015 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_NameBarText"):SetText(partyname);
1016 end
1017  
1018 -- Set Class Icon
1019 if (UnitIsPlayer(partyid)) then
1020 local PlayerClass = UnitClass(partyid);
1021 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame_ClassTexture"):SetTexCoord(Perl_Party_ClassPosRight[PlayerClass], Perl_Party_ClassPosLeft[PlayerClass], Perl_Party_ClassPosTop[PlayerClass], Perl_Party_ClassPosBottom[PlayerClass]); -- Set the player's class icon
1022 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame_ClassTexture"):Show();
1023 else
1024 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame_ClassTexture"):Hide();
1025 end
1026  
1027 -- Set Level
1028 getglobal("Perl_Party_MemberFrame"..partynum.."_LevelFrame_LevelBarText"):SetText(UnitLevel(partyid));
1029  
1030 -- Handle disconnected state
1031 if (UnitIsConnected(partyid)) then
1032 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_DisconnectStatus"):Hide();
1033 else
1034 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_DisconnectStatus"):Show();
1035 end
1036  
1037 -- Handle death state
1038 if (UnitIsDead(partyid) or UnitIsGhost(partyid)) then
1039 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_DeadStatus"):Show();
1040 else
1041 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_DeadStatus"):Hide();
1042 end
1043  
1044 -- Set PvP info
1045 local factionGroup = UnitFactionGroup(partyid);
1046 if (factionGroup == nil) then
1047 factionGroup = UnitFactionGroup("player");
1048 end
1049  
1050 -- Color their name if PvP flagged
1051 if (UnitIsPVP(partyid)) then
1052 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_NameBarText"):SetTextColor(0,1,0);
1053 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_PVPStatus"):SetTexture("Interface\\TargetingFrame\\UI-PVP-"..factionGroup);
1054 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_PVPStatus"):Show();
1055 else
1056 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_NameBarText"):SetTextColor(0.5,0.5,1);
1057 getglobal("Perl_Party_MemberFrame"..partynum.."_NameFrame_PVPStatus"):Hide();
1058 end
1059  
1060 -- Set mana bar color
1061 local partypower = UnitPowerType(partyid);
1062 if (partypower == 1) then
1063 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetStatusBarColor(1, 0, 0, 1);
1064 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 0, 0, 0.25);
1065 elseif (partypower == 2) then
1066 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetStatusBarColor(1, 0.5, 0, 1);
1067 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 0.5, 0, 0.25);
1068 elseif (partypower == 3) then
1069 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetStatusBarColor(1, 1, 0, 1);
1070 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBarBG"):SetStatusBarColor(1, 1, 0, 0.25);
1071 else
1072 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBar"):SetStatusBarColor(0, 0, 1, 1);
1073 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_ManaBarBG"):SetStatusBarColor(0, 0, 1, 0.25);
1074 end
1075  
1076 -- Set portraits
1077 if (showportrait == 1) then
1078 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame"):Show(); -- Show the main portrait frame
1079  
1080 if (threedportrait == 0) then
1081 SetPortraitTexture(getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_Portrait"), partyid); -- Load the correct 2d graphic
1082 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_PartyModel"):Hide(); -- Hide the 3d graphic
1083 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_Portrait"):Show(); -- Show the 2d graphic
1084 else
1085 if UnitIsVisible(partyid) then
1086 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_PartyModel"):SetUnit(partyid); -- Load the correct 3d graphic
1087 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_Portrait"):Hide(); -- Hide the 2d graphic
1088 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_PartyModel"):Show(); -- Show the 3d graphic
1089 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_PartyModel"):SetCamera(0);
1090 else
1091 SetPortraitTexture(getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_Portrait"), partyid); -- Load the correct 2d graphic
1092 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_PartyModel"):Hide(); -- Hide the 3d graphic
1093 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame_Portrait"):Show(); -- Show the 2d graphic
1094 end
1095 end
1096  
1097 else
1098 getglobal("Perl_Party_MemberFrame"..partynum.."_PortraitFrame"):Hide(); -- Hide the frame and 2d/3d portion
1099 end
1100  
1101 -- Set pet bars
1102 local id = partynum; -- Easier than changing all variables below, I'll do it later
1103 if (showpets == 1) then
1104 if (UnitIsConnected("party"..id) and UnitExists("partypet"..id)) then
1105 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):Show();
1106 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBarBG"):Show();
1107 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_CastClickOverlay"):Show();
1108 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetHeight(54);
1109 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_CastClickOverlay"):SetHeight(54);
1110  
1111 if (verticalalign == 1) then
1112 if (id == 1 or id == 2 or id == 3) then
1113 local idspace = id + 1;
1114 local partypetspacing;
1115 if (partyspacing < 0) then -- Frames are normal
1116 partypetspacing = partyspacing - 12;
1117 else -- Frames are inverted
1118 partypetspacing = partyspacing + 12;
1119 end
1120 getglobal("Perl_Party_MemberFrame"..idspace):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id, "TOPLEFT", 0, partypetspacing);
1121 end
1122 else
1123 local horizontalspacing;
1124 if (partyspacing < 0) then
1125 horizontalspacing = partyspacing - 195;
1126 else
1127 horizontalspacing = partyspacing + 195;
1128 end
1129 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
1130 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
1131 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
1132 end
1133 else
1134 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):Hide();
1135 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBarBG"):Hide();
1136 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_CastClickOverlay"):Hide();
1137 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetHeight(42);
1138 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_CastClickOverlay"):SetHeight(42);
1139  
1140 if (verticalalign == 1) then
1141 if (id == 1) then
1142 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partyspacing);
1143 elseif (id == 2) then
1144 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partyspacing);
1145 elseif (id == 3) then
1146 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partyspacing);
1147 end
1148 else
1149 local horizontalspacing;
1150 if (partyspacing < 0) then
1151 horizontalspacing = partyspacing - 195;
1152 else
1153 horizontalspacing = partyspacing + 195;
1154 end
1155 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
1156 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
1157 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
1158 end
1159 end
1160 else
1161 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):Hide();
1162 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBarBG"):Hide();
1163 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_CastClickOverlay"):Hide();
1164 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetHeight(42);
1165 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_CastClickOverlay"):SetHeight(42);
1166  
1167 if (verticalalign == 1) then
1168 if (id == 1) then
1169 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partyspacing);
1170 elseif (id == 2) then
1171 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partyspacing);
1172 elseif (id == 3) then
1173 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partyspacing);
1174 end
1175 else
1176 local horizontalspacing;
1177 if (partyspacing < 0) then
1178 horizontalspacing = partyspacing - 195;
1179 else
1180 horizontalspacing = partyspacing + 195;
1181 end
1182 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
1183 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
1184 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
1185 end
1186 end
1187 end
1188 end
1189  
1190 function Perl_Party_Set_Localized_ClassIcons()
1191 Perl_Party_ClassPosRight = {
1192 [PERL_LOCALIZED_DRUID] = 0.75,
1193 [PERL_LOCALIZED_HUNTER] = 0,
1194 [PERL_LOCALIZED_MAGE] = 0.25,
1195 [PERL_LOCALIZED_PALADIN] = 0,
1196 [PERL_LOCALIZED_PRIEST] = 0.5,
1197 [PERL_LOCALIZED_ROGUE] = 0.5,
1198 [PERL_LOCALIZED_SHAMAN] = 0.25,
1199 [PERL_LOCALIZED_WARLOCK] = 0.75,
1200 [PERL_LOCALIZED_WARRIOR] = 0,
1201 };
1202 Perl_Party_ClassPosLeft = {
1203 [PERL_LOCALIZED_DRUID] = 1,
1204 [PERL_LOCALIZED_HUNTER] = 0.25,
1205 [PERL_LOCALIZED_MAGE] = 0.5,
1206 [PERL_LOCALIZED_PALADIN] = 0.25,
1207 [PERL_LOCALIZED_PRIEST] = 0.75,
1208 [PERL_LOCALIZED_ROGUE] = 0.75,
1209 [PERL_LOCALIZED_SHAMAN] = 0.5,
1210 [PERL_LOCALIZED_WARLOCK] = 1,
1211 [PERL_LOCALIZED_WARRIOR] = 0.25,
1212 };
1213 Perl_Party_ClassPosTop = {
1214 [PERL_LOCALIZED_DRUID] = 0,
1215 [PERL_LOCALIZED_HUNTER] = 0.25,
1216 [PERL_LOCALIZED_MAGE] = 0,
1217 [PERL_LOCALIZED_PALADIN] = 0.5,
1218 [PERL_LOCALIZED_PRIEST] = 0.25,
1219 [PERL_LOCALIZED_ROGUE] = 0,
1220 [PERL_LOCALIZED_SHAMAN] = 0.25,
1221 [PERL_LOCALIZED_WARLOCK] = 0.25,
1222 [PERL_LOCALIZED_WARRIOR] = 0,
1223  
1224 };
1225 Perl_Party_ClassPosBottom = {
1226 [PERL_LOCALIZED_DRUID] = 0.25,
1227 [PERL_LOCALIZED_HUNTER] = 0.5,
1228 [PERL_LOCALIZED_MAGE] = 0.25,
1229 [PERL_LOCALIZED_PALADIN] = 0.75,
1230 [PERL_LOCALIZED_PRIEST] = 0.5,
1231 [PERL_LOCALIZED_ROGUE] = 0.25,
1232 [PERL_LOCALIZED_SHAMAN] = 0.5,
1233 [PERL_LOCALIZED_WARLOCK] = 0.5,
1234 [PERL_LOCALIZED_WARRIOR] = 0.25,
1235 };
1236 end
1237  
1238  
1239 --------------------------
1240 -- GUI Config Functions --
1241 --------------------------
1242 function Perl_Party_Set_Space(number)
1243 if (number ~= nil) then
1244 partyspacing = -number;
1245 end
1246  
1247 if (verticalalign == 1) then
1248  
1249 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partyspacing);
1250 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partyspacing);
1251 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partyspacing);
1252  
1253 if (showpets == 1) then
1254 local partypetspacing;
1255 if (partyspacing < 0) then -- Frames are normal
1256 partypetspacing = partyspacing - 12;
1257 else -- Frames are inverted
1258 partypetspacing = partyspacing + 12;
1259 end
1260 for partynum=1,4 do
1261 local partyid = "party"..partynum;
1262 local frame = getglobal("Perl_Party_MemberFrame"..partynum);
1263 if (UnitName(partyid) ~= nil) then
1264 if (UnitIsConnected(partyid) and UnitExists("partypet"..partynum)) then
1265 if (partynum == 1) then
1266 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", 0, partypetspacing);
1267 elseif (partynum == 2) then
1268 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", 0, partypetspacing);
1269 elseif (partynum == 3) then
1270 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", 0, partypetspacing);
1271 end
1272 end
1273 else
1274 -- should be hidden, and will correctly adjust later when needed
1275 end
1276 end
1277 else
1278 -- do nothing, no spacing required
1279 end
1280  
1281 else
1282 local horizontalspacing;
1283 if (partyspacing < 0) then
1284 horizontalspacing = partyspacing - 195;
1285 else
1286 horizontalspacing = partyspacing + 195;
1287 end
1288 Perl_Party_MemberFrame2:SetPoint("TOPLEFT", "Perl_Party_MemberFrame1", "TOPLEFT", horizontalspacing, 0);
1289 Perl_Party_MemberFrame3:SetPoint("TOPLEFT", "Perl_Party_MemberFrame2", "TOPLEFT", horizontalspacing, 0);
1290 Perl_Party_MemberFrame4:SetPoint("TOPLEFT", "Perl_Party_MemberFrame3", "TOPLEFT", horizontalspacing, 0);
1291 end
1292  
1293 Perl_Party_UpdateVars();
1294 end
1295  
1296 function Perl_Party_Set_Hidden(newvalue)
1297 if (newvalue ~= nil) then
1298 partyhidden = newvalue;
1299 Perl_Party_UpdateVars();
1300 end
1301  
1302 if (partyhidden == 1) then -- copied from below sort of, delete below when slash commands are removed
1303 Perl_Party_MemberFrame1:Hide();
1304 Perl_Party_MemberFrame2:Hide();
1305 Perl_Party_MemberFrame3:Hide();
1306 Perl_Party_MemberFrame4:Hide();
1307 --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Party Frame is now |cffffffffAlways Hidden|cffffff00.");
1308 elseif (partyhidden == 2) then
1309 if (UnitInRaid("player")) then
1310 Perl_Party_MemberFrame1:Hide();
1311 Perl_Party_MemberFrame2:Hide();
1312 Perl_Party_MemberFrame3:Hide();
1313 Perl_Party_MemberFrame4:Hide();
1314 else
1315 for partynum=1,4 do
1316 local partyid = "party"..partynum;
1317 local frame = getglobal("Perl_Party_MemberFrame"..partynum);
1318 if (UnitName(partyid) ~= nil) then
1319 frame:Show();
1320 else
1321 frame:Hide();
1322 end
1323 end
1324 end
1325 --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Party Frame is now |cffffffffHidden in Raids|cffffff00.");
1326 else
1327 for partynum=1,4 do
1328 local partyid = "party"..partynum;
1329 local frame = getglobal("Perl_Party_MemberFrame"..partynum);
1330 if (UnitName(partyid) ~= nil) then
1331 frame:Show();
1332 else
1333 frame:Hide();
1334 end
1335 end
1336 --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Party Frame is now |cffffffffAlways Shown|cffffff00.");
1337 end
1338 end
1339  
1340 function Perl_Party_Set_Compact(newvalue)
1341 if (newvalue ~= nil) then
1342 compactmode = newvalue;
1343 Perl_Party_UpdateVars();
1344 end
1345  
1346 Perl_Party_Set_Text_Positions();
1347 if (compactmode == 0) then
1348 Perl_Party_MemberFrame1_StatsFrame:SetWidth(240);
1349 Perl_Party_MemberFrame2_StatsFrame:SetWidth(240);
1350 Perl_Party_MemberFrame3_StatsFrame:SetWidth(240);
1351 Perl_Party_MemberFrame4_StatsFrame:SetWidth(240);
1352 Perl_Party_MemberFrame1_StatsFrame_CastClickOverlay:SetWidth(240);
1353 Perl_Party_MemberFrame2_StatsFrame_CastClickOverlay:SetWidth(240);
1354 Perl_Party_MemberFrame3_StatsFrame_CastClickOverlay:SetWidth(240);
1355 Perl_Party_MemberFrame4_StatsFrame_CastClickOverlay:SetWidth(240);
1356 else
1357 if (compactpercent == 0) then
1358 Perl_Party_MemberFrame1_StatsFrame:SetWidth(170);
1359 Perl_Party_MemberFrame2_StatsFrame:SetWidth(170);
1360 Perl_Party_MemberFrame3_StatsFrame:SetWidth(170);
1361 Perl_Party_MemberFrame4_StatsFrame:SetWidth(170);
1362 Perl_Party_MemberFrame1_StatsFrame_CastClickOverlay:SetWidth(170);
1363 Perl_Party_MemberFrame2_StatsFrame_CastClickOverlay:SetWidth(170);
1364 Perl_Party_MemberFrame3_StatsFrame_CastClickOverlay:SetWidth(170);
1365 Perl_Party_MemberFrame4_StatsFrame_CastClickOverlay:SetWidth(170);
1366 else
1367 Perl_Party_MemberFrame1_StatsFrame:SetWidth(205);
1368 Perl_Party_MemberFrame2_StatsFrame:SetWidth(205);
1369 Perl_Party_MemberFrame3_StatsFrame:SetWidth(205);
1370 Perl_Party_MemberFrame4_StatsFrame:SetWidth(205);
1371 Perl_Party_MemberFrame1_StatsFrame_CastClickOverlay:SetWidth(205);
1372 Perl_Party_MemberFrame2_StatsFrame_CastClickOverlay:SetWidth(205);
1373 Perl_Party_MemberFrame3_StatsFrame_CastClickOverlay:SetWidth(205);
1374 Perl_Party_MemberFrame4_StatsFrame_CastClickOverlay:SetWidth(205);
1375 end
1376 end
1377 Perl_Party_Update_Health_Mana();
1378 Perl_Party_Update_Buffs();
1379 end
1380  
1381 function Perl_Party_Set_Healer(newvalue)
1382 healermode = newvalue;
1383 Perl_Party_UpdateVars();
1384 Perl_Party_Set_Text_Positions();
1385 Perl_Party_Update_Health_Mana();
1386 end
1387  
1388 function Perl_Party_Set_Pets(newvalue)
1389 if (newvalue ~= nil) then
1390 showpets = newvalue;
1391 Perl_Party_UpdateVars();
1392 end
1393  
1394 if (showpets == 0) then -- copied from below sort of, delete below when slash commands are removed
1395 Perl_Party_MemberFrame1_StatsFrame_PetHealthBar:Hide();
1396 Perl_Party_MemberFrame1_StatsFrame_PetHealthBarBG:Hide();
1397 Perl_Party_MemberFrame1_StatsFrame_PetHealthBar_CastClickOverlay:Hide();
1398 Perl_Party_MemberFrame1_StatsFrame:SetHeight(42);
1399 Perl_Party_MemberFrame1_StatsFrame_CastClickOverlay:SetHeight(42);
1400 Perl_Party_MemberFrame2_StatsFrame_PetHealthBar:Hide();
1401 Perl_Party_MemberFrame2_StatsFrame_PetHealthBarBG:Hide();
1402 Perl_Party_MemberFrame2_StatsFrame_PetHealthBar_CastClickOverlay:Hide();
1403 Perl_Party_MemberFrame2_StatsFrame:SetHeight(42);
1404 Perl_Party_MemberFrame2_StatsFrame_CastClickOverlay:SetHeight(42);
1405 Perl_Party_MemberFrame3_StatsFrame_PetHealthBar:Hide();
1406 Perl_Party_MemberFrame3_StatsFrame_PetHealthBarBG:Hide();
1407 Perl_Party_MemberFrame3_StatsFrame_PetHealthBar_CastClickOverlay:Hide();
1408 Perl_Party_MemberFrame3_StatsFrame:SetHeight(42);
1409 Perl_Party_MemberFrame3_StatsFrame_CastClickOverlay:SetHeight(42);
1410 Perl_Party_MemberFrame4_StatsFrame_PetHealthBar:Hide();
1411 Perl_Party_MemberFrame4_StatsFrame_PetHealthBarBG:Hide();
1412 Perl_Party_MemberFrame4_StatsFrame_PetHealthBar_CastClickOverlay:Hide();
1413 Perl_Party_MemberFrame4_StatsFrame:SetHeight(42);
1414 Perl_Party_MemberFrame4_StatsFrame_CastClickOverlay:SetHeight(42);
1415 --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Party Frame is now |cffffffffHiding Pets|cffffff00.");
1416 else
1417 local partypethealth, partypethealthmax, partypethealthpercent;
1418 for partynum=1,4 do
1419 local partyid = "party"..partynum;
1420 local frame = getglobal("Perl_Party_MemberFrame"..partynum);
1421 if (UnitName(partyid) ~= nil) then
1422 if (UnitIsConnected(partyid) and UnitExists("partypet"..partynum)) then
1423 partypethealth = UnitHealth("partypet"..partynum);
1424 partypethealthmax = UnitHealthMax("partypet"..partynum);
1425 partypethealthpercent = floor(partypethealth/partypethealthmax*100+0.5);
1426  
1427 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):Show();
1428 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBarBG"):Show();
1429 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_CastClickOverlay"):Show();
1430 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame"):SetHeight(54);
1431 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_CastClickOverlay"):SetHeight(54);
1432  
1433 if (partynum == 1 or partynum == 2 or partynum == 3) then
1434 local partynumspace = partynum + 1;
1435 local partypetspacing = partyspacing - 12;
1436 getglobal("Perl_Party_MemberFrame"..partynumspace):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..partynum, "TOPLEFT", 0, partypetspacing);
1437 end
1438  
1439 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):SetMinMaxValues(0, partypethealthmax);
1440 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar"):SetValue(partypethealth);
1441  
1442 if (compactmode == 0) then
1443 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText(partypethealth.."/"..partypethealthmax);
1444 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealthpercent.."%");
1445 else
1446 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarText"):SetText();
1447 getglobal("Perl_Party_MemberFrame"..partynum.."_StatsFrame_PetHealthBar_PetHealthBarTextPercent"):SetText(partypethealth.."/"..partypethealthmax);
1448 end
1449 end
1450 else
1451 -- should be hidden, and will correctly adjust later when needed
1452 end
1453 end
1454 --DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Party Frame is now |cffffffffShowing Pets|cffffff00.");
1455 end
1456 Perl_Party_Set_Space();
1457 Perl_Party_Update_Buffs();
1458 end
1459  
1460 function Perl_Party_Set_Progressive_Color(newvalue)
1461 colorhealth = newvalue;
1462 Perl_Party_UpdateVars();
1463 end
1464  
1465 function Perl_Party_Set_Lock(newvalue)
1466 locked = newvalue;
1467 Perl_Party_UpdateVars();
1468 end
1469  
1470 function Perl_Party_Set_VerticalAlign(newvalue)
1471 verticalalign = newvalue;
1472 Perl_Party_UpdateVars();
1473 Perl_Party_Set_Space();
1474 end
1475  
1476 function Perl_Party_Set_Compact_Percent(newvalue)
1477 compactpercent = newvalue;
1478 Perl_Party_UpdateVars();
1479 Perl_Party_Set_Compact();
1480 end
1481  
1482 function Perl_Party_Set_Portrait(newvalue)
1483 showportrait = newvalue;
1484 Perl_Party_UpdateVars();
1485 Perl_Party_Update_Portrait(1);
1486 Perl_Party_Update_Portrait(2);
1487 Perl_Party_Update_Portrait(3);
1488 Perl_Party_Update_Portrait(4);
1489 end
1490  
1491 function Perl_Party_Set_3D_Portrait(newvalue)
1492 threedportrait = newvalue;
1493 Perl_Party_UpdateVars();
1494 Perl_Party_Update_Portrait(1);
1495 Perl_Party_Update_Portrait(2);
1496 Perl_Party_Update_Portrait(3);
1497 Perl_Party_Update_Portrait(4);
1498 end
1499  
1500 function Perl_Party_Set_FKeys(newvalue)
1501 showfkeys = newvalue;
1502 Perl_Party_UpdateVars();
1503 Perl_Party_Force_Update();
1504 end
1505  
1506 function Perl_Party_Set_Class_Buffs(newvalue)
1507 if (newvalue ~= nil) then
1508 displaycastablebuffs = newvalue;
1509 end
1510 Perl_Party_UpdateVars();
1511 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set size
1512 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1513 end
1514  
1515 function Perl_Party_Set_Buff_Location(newvalue)
1516 if (newvalue ~= nil) then
1517 bufflocation = newvalue;
1518 end
1519 Perl_Party_UpdateVars();
1520 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set size
1521 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1522 end
1523  
1524 function Perl_Party_Set_Debuff_Location(newvalue)
1525 if (newvalue ~= nil) then
1526 debufflocation = newvalue;
1527 end
1528 Perl_Party_UpdateVars();
1529 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set size
1530 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1531 end
1532  
1533 function Perl_Party_Set_Buff_Size(newvalue)
1534 if (newvalue ~= nil) then
1535 buffsize = newvalue;
1536 end
1537 Perl_Party_UpdateVars();
1538 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set size
1539 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1540 end
1541  
1542 function Perl_Party_Set_Debuff_Size(newvalue)
1543 if (newvalue ~= nil) then
1544 debuffsize = newvalue;
1545 end
1546 Perl_Party_UpdateVars();
1547 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set size
1548 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1549 end
1550  
1551 function Perl_Party_Set_Scale(number)
1552 local unsavedscale;
1553 if (number ~= nil) then
1554 scale = (number / 100);
1555 end
1556 unsavedscale = 1 - UIParent:GetEffectiveScale() + scale; -- run it through the scaling formula introduced in 1.9
1557 Perl_Party_MemberFrame1:SetScale(unsavedscale);
1558 Perl_Party_MemberFrame2:SetScale(unsavedscale);
1559 Perl_Party_MemberFrame3:SetScale(unsavedscale);
1560 Perl_Party_MemberFrame4:SetScale(unsavedscale);
1561 Perl_Party_UpdateVars();
1562 end
1563  
1564 function Perl_Party_Set_Transparency(number)
1565 if (number ~= nil) then
1566 transparency = (number / 100);
1567 end
1568 Perl_Party_MemberFrame1:SetAlpha(transparency);
1569 Perl_Party_MemberFrame2:SetAlpha(transparency);
1570 Perl_Party_MemberFrame3:SetAlpha(transparency);
1571 Perl_Party_MemberFrame4:SetAlpha(transparency);
1572 Perl_Party_UpdateVars();
1573 end
1574  
1575  
1576 ------------------------------
1577 -- Saved Variable Functions --
1578 ------------------------------
1579 function Perl_Party_GetVars()
1580 locked = Perl_Party_Config[UnitName("player")]["Locked"];
1581 compactmode = Perl_Party_Config[UnitName("player")]["CompactMode"];
1582 partyhidden = Perl_Party_Config[UnitName("player")]["PartyHidden"];
1583 partyspacing = Perl_Party_Config[UnitName("player")]["PartySpacing"];
1584 scale = Perl_Party_Config[UnitName("player")]["Scale"];
1585 showpets = Perl_Party_Config[UnitName("player")]["ShowPets"];
1586 colorhealth = Perl_Party_Config[UnitName("player")]["ColorHealth"];
1587 healermode = Perl_Party_Config[UnitName("player")]["HealerMode"];
1588 transparency = Perl_Party_Config[UnitName("player")]["Transparency"];
1589 bufflocation = Perl_Party_Config[UnitName("player")]["BuffLocation"];
1590 debufflocation = Perl_Party_Config[UnitName("player")]["DebuffLocation"];
1591 verticalalign = Perl_Party_Config[UnitName("player")]["VerticalAlign"];
1592 compactpercent = Perl_Party_Config[UnitName("player")]["CompactPercent"];
1593 showportrait = Perl_Party_Config[UnitName("player")]["ShowPortrait"];
1594 showfkeys = Perl_Party_Config[UnitName("player")]["ShowFKeys"];
1595 displaycastablebuffs = Perl_Party_Config[UnitName("player")]["DisplayCastableBuffs"];
1596 threedportrait = Perl_Party_Config[UnitName("player")]["ThreeDPortrait"];
1597 buffsize = Perl_Party_Config[UnitName("player")]["BuffSize"];
1598 debuffsize = Perl_Party_Config[UnitName("player")]["DebuffSize"];
1599  
1600 if (locked == nil) then
1601 locked = 0;
1602 end
1603 if (compactmode == nil) then
1604 compactmode = 0;
1605 end
1606 if (partyhidden == nil) then
1607 partyhidden = 0;
1608 end
1609 if (partyspacing == nil) then
1610 partyspacing = -80;
1611 end
1612 if (scale == nil) then
1613 scale = 1;
1614 end
1615 if (showpets == nil) then
1616 showpets = 1;
1617 end
1618 if (colorhealth == nil) then
1619 colorhealth = 0;
1620 end
1621 if (healermode == nil) then
1622 healermode = 0;
1623 end
1624 if (transparency == nil) then
1625 transparency = 1;
1626 end
1627 if (bufflocation == nil) then
1628 bufflocation = 4;
1629 end
1630 if (debufflocation == nil) then
1631 debufflocation = 1;
1632 end
1633 if (verticalalign == nil) then
1634 verticalalign = 1;
1635 end
1636 if (compactpercent == nil) then
1637 compactpercent = 0;
1638 end
1639 if (showportrait == nil) then
1640 showportrait = 0;
1641 end
1642 if (showfkeys == nil) then
1643 showfkeys = 0;
1644 end
1645 if (displaycastablebuffs == nil) then
1646 displaycastablebuffs = 0;
1647 end
1648 if (threedportrait == nil) then
1649 threedportrait = 0;
1650 end
1651 if (buffsize == nil) then
1652 buffsize = 16;
1653 end
1654 if (debuffsize == nil) then
1655 debuffsize = 16;
1656 end
1657  
1658 local vars = {
1659 ["locked"] = locked,
1660 ["compactmode"] = compactmode,
1661 ["partyhidden"] = partyhidden,
1662 ["partyspacing"] = partyspacing,
1663 ["scale"] = scale,
1664 ["showpets"] = showpets,
1665 ["colorhealth"] = colorhealth,
1666 ["healermode"] = healermode,
1667 ["transparency"] = transparency,
1668 ["bufflocation"] = bufflocation,
1669 ["debufflocation"] = debufflocation,
1670 ["verticalalign"] = verticalalign,
1671 ["compactpercent"] = compactpercent,
1672 ["showportrait"] = showportrait,
1673 ["showfkeys"] = showfkeys,
1674 ["displaycastablebuffs"] = displaycastablebuffs,
1675 ["threedportrait"] = threedportrait,
1676 ["buffsize"] = buffsize,
1677 ["debuffsize"] = debuffsize,
1678 }
1679 return vars;
1680 end
1681  
1682 function Perl_Party_UpdateVars(vartable)
1683 if (vartable ~= nil) then
1684 -- Sanity checks in case you use a load from an old version
1685 if (vartable["Global Settings"] ~= nil) then
1686 if (vartable["Global Settings"]["Locked"] ~= nil) then
1687 locked = vartable["Global Settings"]["Locked"];
1688 else
1689 locked = nil;
1690 end
1691 if (vartable["Global Settings"]["CompactMode"] ~= nil) then
1692 compactmode = vartable["Global Settings"]["CompactMode"];
1693 else
1694 compactmode = nil;
1695 end
1696 if (vartable["Global Settings"]["PartyHidden"] ~= nil) then
1697 partyhidden = vartable["Global Settings"]["PartyHidden"];
1698 else
1699 partyhidden = nil;
1700 end
1701 if (vartable["Global Settings"]["PartySpacing"] ~= nil) then
1702 partyspacing = vartable["Global Settings"]["PartySpacing"];
1703 else
1704 partyspacing = nil;
1705 end
1706 if (vartable["Global Settings"]["Scale"] ~= nil) then
1707 scale = vartable["Global Settings"]["Scale"];
1708 else
1709 scale = nil;
1710 end
1711 if (vartable["Global Settings"]["ShowPets"] ~= nil) then
1712 showpets = vartable["Global Settings"]["ShowPets"];
1713 else
1714 showpets = nil;
1715 end
1716 if (vartable["Global Settings"]["ColorHealth"] ~= nil) then
1717 colorhealth = vartable["Global Settings"]["ColorHealth"];
1718 else
1719 colorhealth = nil;
1720 end
1721 if (vartable["Global Settings"]["HealerMode"] ~= nil) then
1722 healermode = vartable["Global Settings"]["HealerMode"];
1723 else
1724 healermode = nil;
1725 end
1726 if (vartable["Global Settings"]["Transparency"] ~= nil) then
1727 transparency = vartable["Global Settings"]["Transparency"];
1728 else
1729 transparency = nil;
1730 end
1731 if (vartable["Global Settings"]["BuffLocation"] ~= nil) then
1732 bufflocation = vartable["Global Settings"]["BuffLocation"];
1733 else
1734 bufflocation = nil;
1735 end
1736 if (vartable["Global Settings"]["DebuffLocation"] ~= nil) then
1737 debufflocation = vartable["Global Settings"]["DebuffLocation"];
1738 else
1739 debufflocation = nil;
1740 end
1741 if (vartable["Global Settings"]["VerticalAlign"] ~= nil) then
1742 verticalalign = vartable["Global Settings"]["VerticalAlign"];
1743 else
1744 verticalalign = nil;
1745 end
1746 if (vartable["Global Settings"]["CompactPercent"] ~= nil) then
1747 compactpercent = vartable["Global Settings"]["CompactPercent"];
1748 else
1749 compactpercent = nil;
1750 end
1751 if (vartable["Global Settings"]["ShowPortrait"] ~= nil) then
1752 showportrait = vartable["Global Settings"]["ShowPortrait"];
1753 else
1754 showportrait = nil;
1755 end
1756 if (vartable["Global Settings"]["ShowFKeys"] ~= nil) then
1757 showfkeys = vartable["Global Settings"]["ShowFKeys"];
1758 else
1759 showfkeys = nil;
1760 end
1761 if (vartable["Global Settings"]["DisplayCastableBuffs"] ~= nil) then
1762 displaycastablebuffs = vartable["Global Settings"]["DisplayCastableBuffs"];
1763 else
1764 displaycastablebuffs = nil;
1765 end
1766 if (vartable["Global Settings"]["ThreeDPortrait"] ~= nil) then
1767 threedportrait = vartable["Global Settings"]["ThreeDPortrait"];
1768 else
1769 threedportrait = nil;
1770 end
1771 if (vartable["Global Settings"]["BuffSize"] ~= nil) then
1772 buffsize = vartable["Global Settings"]["BuffSize"];
1773 else
1774 buffsize = nil;
1775 end
1776 if (vartable["Global Settings"]["DebuffSize"] ~= nil) then
1777 debuffsize = vartable["Global Settings"]["DebuffSize"];
1778 else
1779 debuffsize = nil;
1780 end
1781 end
1782  
1783 -- Set the new values if any new values were found, same defaults as above
1784 if (locked == nil) then
1785 locked = 0;
1786 end
1787 if (compactmode == nil) then
1788 compactmode = 0;
1789 end
1790 if (partyhidden == nil) then
1791 partyhidden = 0;
1792 end
1793 if (partyspacing == nil) then
1794 partyspacing = -80;
1795 end
1796 if (scale == nil) then
1797 scale = 1;
1798 end
1799 if (showpets == nil) then
1800 showpets = 1;
1801 end
1802 if (colorhealth == nil) then
1803 colorhealth = 0;
1804 end
1805 if (healermode == nil) then
1806 healermode = 0;
1807 end
1808 if (transparency == nil) then
1809 transparency = 1;
1810 end
1811 if (bufflocation == nil) then
1812 bufflocation = 4;
1813 end
1814 if (debufflocation == nil) then
1815 debufflocation = 1;
1816 end
1817 if (verticalalign == nil) then
1818 verticalalign = 1;
1819 end
1820 if (compactpercent == nil) then
1821 compactpercent = 0;
1822 end
1823 if (showportrait == nil) then
1824 showportrait = 0;
1825 end
1826 if (showfkeys == nil) then
1827 showfkeys = 0;
1828 end
1829 if (displaycastablebuffs == nil) then
1830 displaycastablebuffs = 0;
1831 end
1832 if (threedportrait == nil) then
1833 threedportrait = 0;
1834 end
1835 if (buffsize == nil) then
1836 buffsize = 16;
1837 end
1838 if (debuffsize == nil) then
1839 debuffsize = 16;
1840 end
1841  
1842 -- Call any code we need to activate them
1843 Perl_Party_Set_Space(); -- This probably isn't needed, but one extra call for this won't matter
1844 Perl_Party_Set_Hidden(partyhidden);
1845 Perl_Party_Set_Compact(compactmode);
1846 Perl_Party_Set_Healer(healermode);
1847 Perl_Party_Set_Pets(showpets);
1848 Perl_Party_Reset_Buffs(); -- Reset the buff icons and set sizes
1849 Perl_Party_Update_Buffs(); -- Repopulate the buff icons
1850 Perl_Party_Set_Scale();
1851 Perl_Party_Set_Transparency();
1852 end
1853  
1854 Perl_Party_Config[UnitName("player")] = {
1855 ["Locked"] = locked,
1856 ["CompactMode"] = compactmode,
1857 ["PartyHidden"] = partyhidden,
1858 ["PartySpacing"] = partyspacing,
1859 ["Scale"] = scale,
1860 ["ShowPets"] = showpets,
1861 ["ColorHealth"] = colorhealth,
1862 ["HealerMode"] = healermode,
1863 ["Transparency"] = transparency,
1864 ["BuffLocation"] = bufflocation,
1865 ["DebuffLocation"] = debufflocation,
1866 ["VerticalAlign"] = verticalalign,
1867 ["CompactPercent"] = compactpercent,
1868 ["ShowPortrait"] = showportrait,
1869 ["ShowFKeys"] = showfkeys,
1870 ["DisplayCastableBuffs"] = displaycastablebuffs,
1871 ["ThreeDPortrait"] = threedportrait,
1872 ["BuffSize"] = buffsize,
1873 ["DebuffSize"] = debuffsize,
1874 };
1875 end
1876  
1877  
1878 --------------------
1879 -- Buff Functions --
1880 --------------------
1881 function Perl_Party_Buff_UpdateAll(partymember)
1882 local id, partyid;
1883 if (partymember == nil) then
1884 id = this:GetID();
1885 partyid = "party"..id;
1886 else
1887 id = partymember;
1888 partyid = "party"..id;
1889 end
1890  
1891 if (UnitName(partyid)) then
1892 for buffnum=1,16 do
1893 local button = getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff"..buffnum);
1894 local icon = getglobal(button:GetName().."Icon");
1895 local debuff = getglobal(button:GetName().."DebuffBorder");
1896  
1897 if (UnitBuff(partyid, buffnum, displaycastablebuffs)) then
1898 icon:SetTexture(UnitBuff(partyid, buffnum, displaycastablebuffs));
1899 debuff:Hide();
1900 button:Show();
1901 else
1902 button:Hide();
1903 end
1904 end
1905  
1906 local debuffCount, debuffTexture, debuffApplications;
1907 for buffnum=1,16 do
1908 debuffTexture, debuffApplications = UnitDebuff(partyid, buffnum, displaycastablebuffs);
1909 local button = getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff"..buffnum);
1910 local icon = getglobal(button:GetName().."Icon");
1911 local debuff = getglobal(button:GetName().."DebuffBorder");
1912  
1913 if (UnitDebuff(partyid, buffnum, displaycastablebuffs)) then
1914 icon:SetTexture(UnitDebuff(partyid, buffnum, displaycastablebuffs));
1915 debuff:Show();
1916 button:Show();
1917 debuffCount = getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff"..(buffnum).."Count");
1918 if (debuffApplications > 1) then
1919 debuffCount:SetText(debuffApplications);
1920 debuffCount:Show();
1921 else
1922 debuffCount:Hide();
1923 end
1924 else
1925 button:Hide();
1926 end
1927 end
1928  
1929 Perl_Party_Buff_Position_Update(id, partyid);
1930 end
1931 end
1932  
1933 function Perl_Party_Update_Buffs()
1934 Perl_Party_Buff_UpdateAll(1);
1935 Perl_Party_Buff_UpdateAll(2);
1936 Perl_Party_Buff_UpdateAll(3);
1937 Perl_Party_Buff_UpdateAll(4);
1938 end
1939  
1940 function Perl_Party_Buff_Position_Update(id, partyid)
1941 if (bufflocation == 1) then
1942 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_NameFrame", "TOPRIGHT", 0, -3);
1943 elseif (bufflocation == 2) then
1944 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "TOPRIGHT", 0, -3);
1945 elseif (bufflocation == 3) then
1946 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "TOPRIGHT", 0, -23);
1947 elseif (bufflocation == 4) then
1948 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "BOTTOMLEFT", -27, 0);
1949 elseif (bufflocation == 5) then
1950 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "BOTTOMLEFT", -27, -20);
1951 end
1952  
1953 if (debufflocation == 1) then
1954 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_NameFrame", "TOPRIGHT", 0, -3);
1955 elseif (debufflocation == 2) then
1956 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "TOPRIGHT", 0, -3);
1957 elseif (debufflocation == 3) then
1958 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "TOPRIGHT", 0, -23);
1959 elseif (debufflocation == 4) then
1960 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "BOTTOMLEFT", -27, 0);
1961 elseif (debufflocation == 5) then
1962 getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff1"):SetPoint("TOPLEFT", "Perl_Party_MemberFrame"..id.."_StatsFrame", "BOTTOMLEFT", -27, -20);
1963 end
1964 end
1965  
1966 function Perl_Party_Reset_Buffs()
1967 local button, debuff, icon;
1968 for id=1,4 do
1969 for buffnum=1,16 do
1970 button = getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Buff"..buffnum);
1971 icon = getglobal(button:GetName().."Icon");
1972 debuff = getglobal(button:GetName().."DebuffBorder");
1973 button:SetHeight(buffsize);
1974 button:SetWidth(buffsize);
1975 icon:SetHeight(buffsize);
1976 icon:SetWidth(buffsize);
1977 debuff:SetHeight(buffsize);
1978 debuff:SetWidth(buffsize);
1979 button:Hide();
1980 end
1981 for buffnum=1,16 do
1982 button = getglobal("Perl_Party_MemberFrame"..id.."_BuffFrame_Debuff"..buffnum);
1983 icon = getglobal(button:GetName().."Icon");
1984 debuff = getglobal(button:GetName().."DebuffBorder");
1985 button:SetHeight(debuffsize);
1986 button:SetWidth(debuffsize);
1987 icon:SetHeight(debuffsize);
1988 icon:SetWidth(debuffsize);
1989 debuff:SetHeight(debuffsize);
1990 debuff:SetWidth(debuffsize);
1991 button:Hide();
1992 end
1993 end
1994 end
1995  
1996 function Perl_Party_SetBuffTooltip()
1997 local partyid = "party"..this:GetParent():GetParent():GetID();
1998 GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT");
1999 if (this:GetID() > 16) then
2000 GameTooltip:SetUnitDebuff(partyid, this:GetID()-16); -- 16 being the number of buffs before debuffs in the xml
2001 else
2002 GameTooltip:SetUnitBuff(partyid, this:GetID());
2003 end
2004 end
2005  
2006  
2007 --------------------
2008 -- Click Handlers --
2009 --------------------
2010 function Perl_PartyDropDown_OnLoad()
2011 UIDropDownMenu_Initialize(this, Perl_PartyDropDown_Initialize, "MENU");
2012 end
2013  
2014 function Perl_PartyDropDown_Initialize()
2015 local dropdown;
2016 local id = this:GetID();
2017  
2018 if (UIDROPDOWNMENU_OPEN_MENU) then
2019 dropdown = getglobal(UIDROPDOWNMENU_OPEN_MENU);
2020 else
2021 dropdown = this;
2022 end
2023 if (id == 0) then
2024 local name = this:GetName();
2025 id = string.sub(name, 23, 23);
2026 end
2027 UnitPopup_ShowMenu(dropdown, "PARTY", "party"..id);
2028 end
2029  
2030 function Perl_Party_MouseClick(button)
2031 local id = this:GetID();
2032 if (id == 0) then
2033 local name = this:GetName();
2034 id = string.sub(name, 23, 23);
2035 end
2036  
2037 if (CastPartyConfig and PCUF_CASTPARTYSUPPORT == 1) then
2038 if (not string.find(GetMouseFocus():GetName(), "Name")) then
2039 CastParty_OnClickByUnit(button, "party"..id);
2040 end
2041 elseif (Genesis_data and PCUF_CASTPARTYSUPPORT == 1) then
2042 if (not string.find(GetMouseFocus():GetName(), "Name")) then
2043 Genesis_MouseHeal("party"..id, button);
2044 end
2045 else
2046 if (SpellIsTargeting() and button == "RightButton") then
2047 SpellStopTargeting();
2048 return;
2049 end
2050  
2051 if (button == "LeftButton") then
2052 if (SpellIsTargeting()) then
2053 SpellTargetUnit("party"..id);
2054 elseif (CursorHasItem()) then
2055 DropItemOnUnit("party"..id);
2056 else
2057 TargetUnit("party"..id);
2058 end
2059 end
2060 end
2061 end
2062  
2063 function Perl_Party_MouseDown(button)
2064 if (button == "LeftButton" and locked == 0) then
2065 Perl_Party_Frame:StartMoving();
2066 end
2067 end
2068  
2069 function Perl_Party_MouseUp(button)
2070 local id = this:GetID();
2071 if (id == 0) then
2072 local name = this:GetName();
2073 id = string.sub(name, 23, 23);
2074 end
2075  
2076 if (button == "RightButton") then
2077 if ((CastPartyConfig or Genesis_data) and PCUF_CASTPARTYSUPPORT == 1) then
2078 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
2079 ToggleDropDownMenu(1, nil, getglobal("Perl_Party_MemberFrame"..id.."_DropDown"), "Perl_Party_MemberFrame"..id, 0, 0);
2080 end
2081 else
2082 if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then -- if alt, ctrl, or shift ARE NOT held, show the menu
2083 ToggleDropDownMenu(1, nil, getglobal("Perl_Party_MemberFrame"..id.."_DropDown"), "Perl_Party_MemberFrame"..id, 0, 0);
2084 end
2085 end
2086 end
2087  
2088 Perl_Party_Frame:StopMovingOrSizing();
2089 end
2090  
2091 function Perl_Party_Pet_MouseClick(button)
2092 local id = this:GetID();
2093 if (id == 0) then
2094 local name = this:GetName();
2095 id = string.sub(name, 23, 23);
2096 end
2097  
2098 if (CastPartyConfig and PCUF_CASTPARTYSUPPORT == 1) then
2099 if (not string.find(GetMouseFocus():GetName(), "Name")) then
2100 CastParty_OnClickByUnit(button, "partypet"..id);
2101 end
2102 elseif (Genesis_data and PCUF_CASTPARTYSUPPORT == 1) then
2103 if (not string.find(GetMouseFocus():GetName(), "Name")) then
2104 Genesis_MouseHeal("partypet"..id, button);
2105 end
2106 else
2107 if (SpellIsTargeting() and button == "RightButton") then
2108 SpellStopTargeting();
2109 return;
2110 end
2111  
2112 if (button == "LeftButton") then
2113 if (SpellIsTargeting()) then
2114 SpellTargetUnit("partypet"..id);
2115 elseif (CursorHasItem()) then
2116 DropItemOnUnit("partypet"..id);
2117 else
2118 TargetUnit("partypet"..id);
2119 end
2120 end
2121 end
2122 end
2123  
2124  
2125 -------------
2126 -- Tooltip --
2127 -------------
2128 function Perl_Party_Tip()
2129 local id = this:GetID();
2130 if (id == 0) then
2131 local name=this:GetName();
2132 id = string.sub(name, 23, 23);
2133 end
2134 UnitFrame_Initialize("party"..id)
2135 end
2136  
2137 function UnitFrame_Initialize(unit) -- Hopefully this doesn't break any mods
2138 this.unit = unit;
2139 end
2140  
2141  
2142 ----------------------
2143 -- myAddOns Support --
2144 ----------------------
2145 function Perl_Party_myAddOns_Support()
2146 -- Register the addon in myAddOns
2147 if (myAddOnsFrame_Register) then
2148 local Perl_Party_myAddOns_Details = {
2149 name = "Perl_Party",
2150 version = "Version 0.55",
2151 releaseDate = "April ??, 2006",
2152 author = "Perl; Maintained by Global",
2153 email = "global@g-ball.com",
2154 website = "http://www.curse-gaming.com/mod.php?addid=2257",
2155 category = MYADDONS_CATEGORY_OTHERS
2156 };
2157 Perl_Party_myAddOns_Help = {};
2158 Perl_Party_myAddOns_Help[1] = "/perl\n";
2159 myAddOnsFrame_Register(Perl_Party_myAddOns_Details, Perl_Party_myAddOns_Help);
2160 end
2161 end