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