vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local XPerl_Party_Events = {}
2 local PartyFrames = {}
3  
4 ----------------------
5 -- Loading Function --
6 ----------------------
7 function XPerl_Party_OnLoadEvents()
8 this.time = 0
9 this:RegisterEvent("PLAYER_ENTERING_WORLD")
10 this:RegisterEvent("PLAYER_LEAVING_WORLD")
11  
12 -- Set here to reduce amount of function calls made
13 this:SetScript("OnEvent", XPerl_Party_OnEvent)
14 this:SetScript("OnUpdate", XPerl_Party_OnUpdate)
15 end
16  
17 -- XPerl_Party_OnLoad
18 function XPerl_Party_OnLoad()
19  
20 this.feigning = 0
21 this.partyid = "party"..this:GetID()
22  
23 PartyFrames[this.partyid] = this
24  
25 XPerl_InitFadeFrame(this)
26  
27 XPerl_RegisterHighlight(getglobal(this:GetName().."_CastClickOverlay"), 3)
28 XPerl_RegisterHighlight(getglobal(this:GetName().."_TargetFrame"), 3)
29 XPerl_RegisterPerlFrames(this, {"NameFrame", "StatsFrame", "PortraitFrame", "LevelFrame", "TargetFrame"})
30  
31 this.FlashFrames = {getglobal(this:GetName().."_NameFrame"),
32 getglobal(this:GetName().."_LevelFrame"),
33 getglobal(this:GetName().."_StatsFrame"),
34 getglobal(this:GetName().."_PortraitFrame")}
35 end
36  
37 local PartyEvents = { "PARTY_MEMBERS_CHANGED", "PARTY_LEADER_CHANGED", "PARTY_LOOT_METHOD_CHANGED",
38 "UNIT_FACTION", "UNIT_DYNAMIC_FLAGS", "UNIT_FLAGS", "UNIT_AURA", "PARTY_MEMBER_ENABLE",
39 "PARTY_MEMBER_DISABLE", "UNIT_MODEL_CHANGED"}
40  
41 -- XPerl_Party_RegisterSome
42 local function XPerl_Party_RegisterSome()
43 for i,name in pairs(PartyEvents) do
44 XPerl_Party_EventFrame:RegisterEvent(name)
45 end
46 XPerl_RegisterBasics(XPerl_Party_EventFrame)
47 end
48  
49 -- XPerl_Party_UnregisterSome
50 local function XPerl_Party_UnregisterSome()
51 for i,name in pairs(PartyEvents) do
52 XPerl_Party_EventFrame:UnregisterEvent(name)
53 end
54 XPerl_UnregisterBasics(XPerl_Party_EventFrame)
55 end
56  
57 -- ShowHideValues
58 local function ShowHideValues(prefix)
59 if (XPerlConfig.ShowPartyValues == 1) then
60 getglobal(prefix.."_StatsFrame_HealthBarText"):Show()
61 getglobal(prefix.."_StatsFrame_ManaBarText"):Show()
62 else
63 getglobal(prefix.."_StatsFrame_HealthBarText"):Hide()
64 getglobal(prefix.."_StatsFrame_ManaBarText"):Hide()
65 end
66 end
67  
68 -- XPerl_Party_ShowPercentages
69 local function XPerl_Party_ShowPercentages(thisFrame)
70 local thisid = thisFrame:GetName()
71 if (XPerlConfig.ShowPartyPercent==1) then
72 getglobal(thisid.."_StatsFrame"):SetWidth(136)
73 end
74 ShowHideValues(thisid)
75 end
76  
77 -- XPerl_Party_HidePercentages
78 local function XPerl_Party_HidePercentages(thisFrame, argReason)
79 local thisid = thisFrame:GetName()
80 getglobal(thisid.."_StatsFrame"):SetWidth(106)
81  
82 if (argReason and type(argReason) == "string") then
83 getglobal(thisid.."_StatsFrame_HealthBarText"):SetText(argReason)
84 getglobal(thisid.."_StatsFrame_HealthBarText"):Show()
85 getglobal(thisid.."_StatsFrame_ManaBarText"):Hide()
86 else
87 ShowHideValues(thisid)
88 end
89  
90 getglobal(thisid.."_StatsFrame_HealthBarPercent"):Hide()
91 getglobal(thisid.."_StatsFrame_ManaBarPercent"):Hide()
92 end
93  
94 -- XPerl_Party_UpdateHealth
95 local function XPerl_Party_UpdateHealth(thisFrame)
96 local numID = thisFrame:GetID()
97 local Partyhealth = UnitHealth(thisFrame.partyid)
98 local Partyhealthmax = UnitHealthMax(thisFrame.partyid)
99 local frameID = thisFrame:GetName().."_StatsFrame_"
100 local healthBar = getglobal(frameID.."HealthBar")
101 local healthBarPercent = getglobal(frameID.."HealthBarPercent")
102 local hide = (XPerlConfig.ShowPartyPercent == 0)
103 local percVis = healthBarPercent:IsShown()
104  
105 if (thisFrame.feigning == 1 and Partyhealth > 1) then
106 thisFrame.feigning = 0
107 end
108 if (thisFrame.feigning == 1) then
109 healthBar:SetMinMaxValues(0, 1)
110 healthBar:SetValue(0)
111 XPerl_SetSmoothBarColor(healthBar, 1)
112 else
113 XPerl_SetHealthBar(healthBar, Partyhealth, Partyhealthmax)
114 end
115  
116 local frameID = thisFrame:GetName().."_StatsFrame_"
117 healthBarPercent:SetText(string.format("%d",(100*(Partyhealth / Partyhealthmax))+0.5).."%")
118 healthBarPercent:Show()
119  
120 local petFrame = getglobal("XPerl_partypet"..numID)
121 if (not UnitIsConnected(thisFrame.partyid)) then
122 hide = XPERL_LOC_OFFLINE
123 thisFrame:SetAlpha(XPerlConfig.Transparency/2)
124 if (petFrame) then
125 petFrame:SetAlpha(XPerlConfig.Transparency/2)
126 end
127 else
128 thisFrame:SetAlpha(XPerlConfig.Transparency)
129 if (petFrame) then
130 petFrame:SetAlpha(XPerlConfig.Transparency)
131 end
132  
133 if (thisFrame.feigning == 1) then
134 hide = XPERL_LOC_FEIGNDEATH
135  
136 elseif (UnitIsDead(thisFrame.partyid)) then
137 hide = XPERL_LOC_DEAD
138  
139 elseif (UnitIsGhost(thisFrame.partyid)) then
140 hide = XPERL_LOC_GHOST
141  
142 elseif ((Partyhealth==1) and (Partyhealthmax==1)) then
143 hide = XPERL_LOC_UPDATING
144 end
145 end
146  
147 if (hide) then
148 XPerl_Party_HidePercentages(thisFrame, hide)
149 else
150 XPerl_Party_ShowPercentages(thisFrame)
151 end
152  
153 if (percVis ~= getglobal(frameID.."HealthBarPercent"):IsShown()) then
154 XPerl_StatsFrameSetup(getglobal(thisFrame:GetName().."_StatsFrame"))
155 end
156 end
157  
158 --------------------
159 -- Buff Functions --
160 --------------------
161  
162 -- GetBuffButton(thisFrame, buffnum, debuff, createIfAbsent)
163 -- debuff must be 1 or 0, as it's used in size calc
164 local function GetBuffButton(thisFrame, buffnum, debuff, createIfAbsent)
165  
166 local buffType
167 if (debuff == 1) then
168 buffType = "DeBuff"
169 else
170 buffType = "Buff"
171 end
172 local name = thisFrame:GetName().."_BuffFrame_"..buffType..buffnum
173 local button = getglobal(name)
174  
175 if (not button and createIfAbsent) then
176 button = CreateFrame("Button", name, getglobal(thisFrame:GetName().."_BuffFrame"), "XPerl_"..buffType.."Template")
177 button:SetID(buffnum)
178  
179 local size = XPerlConfig.PartyBuffSize * (1 + (0.4 * debuff))
180 button:SetHeight(size)
181 button:SetWidth(size)
182  
183 if (debuff == 1) then
184 button:SetScript("OnEnter", XPerl_Party_SetDeBuffTooltip)
185 else
186 button:SetScript("OnEnter", XPerl_Party_SetBuffTooltip)
187 end
188 button:SetScript("OnLeave", XPerl_PlayerTipHide)
189  
190 button:ClearAllPoints()
191 if (buffnum == 1) then
192 if (debuff == 1) then
193 button:SetPoint("LEFT", thisFrame:GetName().."_StatsFrame", "RIGHT", 0, 0)
194 else
195 button:SetPoint("TOPLEFT", getglobal(thisFrame:GetName().."_BuffFrame"), "TOPLEFT", 0, 0)
196 end
197 else
198 local prevButton = getglobal(thisFrame:GetName().."_BuffFrame_"..buffType..(buffnum - 1))
199 button:SetPoint("TOPLEFT", prevButton, "TOPRIGHT", 1 + debuff, 0)
200 end
201 end
202  
203 return button
204 end
205  
206 -- XPerl_Party_SetDebuffLoc
207 local function XPerl_Party_SetDebuffLocation(thisFrame)
208 local debuff1 = getglobal("XPerl_party"..thisFrame:GetID().."_BuffFrame_DeBuff1")
209 if (debuff1) then
210 debuff1:ClearAllPoints()
211  
212 if (XPerlConfig.PartyDebuffsBelow == 0) then
213 local petFrame = getglobal("XPerl_partypet"..thisFrame:GetID())
214 if (petFrame and petFrame:IsVisible()) then
215 debuff1:SetPoint("LEFT", "XPerl_partypet"..thisFrame:GetID().."_StatsFrame", "RIGHT", 0, 0)
216 else
217 debuff1:SetPoint("LEFT", "XPerl_party"..thisFrame:GetID().."_StatsFrame", "RIGHT", 0, 0)
218 end
219 else
220 local buff1 = getglobal("XPerl_party"..thisFrame:GetID().."_BuffFrame_Buff1")
221 if (not buff1) then
222 debuff1:SetPoint("TOPLEFT", ("XPerl_party"..thisFrame:GetID().."_BuffFrame_BuffFrame"), "TOPLEFT", 0, -20)
223 else
224 debuff1:SetPoint("TOPLEFT", buff1, "BOTTOMLEFT", 0, -2)
225 end
226 end
227 end
228 end
229  
230 -- XPerl_Party_SetBuffLoc
231 function XPerl_Party_SetBuffLocation(thisFrame)
232 local buff1 = getglobal(thisFrame:GetName().."_BuffFrame_Buff1")
233 if (buff1) then
234 buff1:ClearAllPoints()
235 local buffFrame = getglobal(thisFrame:GetName().."_BuffFrame")
236  
237 buff1:SetPoint("TOPLEFT", buffFrame, "TOPLEFT", 0, 0)
238 end
239 end
240  
241 -- XPerl_IsFeignDeath(unit)
242 function XPerl_IsFeignDeath(unit)
243 for i = 1,20 do
244 local buff = UnitBuff(unit, i)
245  
246 if (buff) then
247 if (strfind(strlower(buff), "feigndeath")) then
248 return true
249 end
250 else
251 break
252 end
253 end
254 end
255  
256 -- XPerl_Party_Buff_UpdateAll
257 local function XPerl_Party_Buff_UpdateAll(thisFrame)
258 local partyid = thisFrame.partyid
259 local thisid = thisFrame:GetName()
260  
261 if (XPerlConfig.PartyBuffs == 0 and XPerlConfig.PartyDebuffs == 0) then
262 getglobal(thisid.."_BuffFrame"):Hide()
263 else
264 getglobal(thisid.."_BuffFrame"):Show()
265  
266 if (UnitExists(partyid)) then
267 local needUpdateHealth = false
268  
269 if (XPerlConfig.PartyBuffs == 1) then
270 for buffnum=1,16 do
271 local buff, count = XPerl_UnitBuff(partyid, buffnum, XPerlConfig.PartyCastableBuffs)
272  
273 if (buff) then
274 local button = GetBuffButton(thisFrame, buffnum, 0, true)
275  
276 local icon = getglobal(button:GetName().."Icon")
277 icon:SetTexture(buff)
278  
279 if (strfind(strlower(buff), "feigndeath")) then
280 if (thisFrame.feigning == 0) then
281 thisFrame.feigning = 1
282 needUpdateHealth = true
283 end
284 end
285 local buffCount = getglobal(button:GetName().."Count")
286 if (count > 1) then
287 buffCount:SetText(count)
288 buffCount:Show()
289 else
290 buffCount:Hide()
291 end
292 button:Show()
293 else
294 local button = getglobal(thisid.."_BuffFrame_Buff"..buffnum)
295 if (button) then
296 button:Hide()
297 end
298 end
299 end
300  
301 XPerl_Party_SetBuffLocation(thisFrame)
302 else
303 for buffnum=1,16 do
304 local button = getglobal(thisid.."_BuffFrame_Buff"..buffnum)
305 if (button) then
306 button:Hide()
307 end
308 end
309 end
310  
311 if (XPerlConfig.PartyDebuffs == 1) then
312 for buffnum=1,8 do
313 local buff, count, debuffType = XPerl_UnitDebuff(partyid, buffnum, XPerlConfig.PartyCurableDebuffs)
314  
315 if (buff) then
316 local button = GetBuffButton(thisFrame, buffnum, 1, buff)
317  
318 local icon = getglobal(button:GetName().."Icon")
319 icon:SetTexture(buff)
320  
321 local buffCount = getglobal(button:GetName().."Count")
322 if (count > 1) then
323 buffCount:SetText(count)
324 buffCount:Show()
325 else
326 buffCount:Hide()
327 end
328  
329 local borderColor = DebuffTypeColor[(debuffType or "none")]
330 local buffBorder = getglobal(button:GetName().."Border")
331 buffBorder:SetVertexColor(borderColor.r, borderColor.g, borderColor.b)
332  
333 button:Show()
334 else
335 local button = getglobal(thisid.."_BuffFrame_DeBuff"..buffnum)
336 if (button) then
337 button:Hide()
338 end
339 end
340 end
341  
342 XPerl_Party_SetDebuffLocation(thisFrame)
343 else
344 for buffnum=1,8 do
345 local button = getglobal(thisid.."_BuffFrame_DeBuff"..buffnum)
346 if (button) then
347 button:Hide()
348 end
349 end
350 end
351  
352 if (XPerlConfig.PartyBuffs == 0 or XPerlConfig.PartyCastableBuffs == 1) then
353 local _, class = UnitClass(thisFrame.partyid)
354 if (class == "HUNTER") then
355 if (XPerl_IsFeignDeath(thisFrame.partyid)) then
356 thisFrame.feigning = 1
357 needUpdateHealth = true
358 end
359 end
360 end
361  
362 if (needUpdateHealth) then
363 XPerl_Party_UpdateHealth(thisFrame)
364 end
365 end
366 end
367  
368 XPerl_CheckDebuffs(partyid, {getglobal(thisFrame:GetName().."_NameFrame"),getglobal(thisFrame:GetName().."_LevelFrame"),getglobal(thisFrame:GetName().."_PortraitFrame"),getglobal(thisFrame:GetName().."_StatsFrame")})
369 end
370  
371 -- XPerl_Party_SetBuffTooltip
372 function XPerl_Party_SetBuffTooltip()
373 local partyid = "party"..this:GetParent():GetParent():GetID()
374 GameTooltip:SetOwner(this,"ANCHOR_BOTTOMRIGHT",30,0)
375 --GameTooltip:SetUnitBuff(partyid, this:GetID(), XPerlConfig.PartyCastableBuffs)
376 XPerl_TooltipSetUnitBuff(GameTooltip, partyid, this:GetID(), XPerlConfig.PartyCastableBuffs)
377 XPerl_ToolTip_AddBuffDuration(partyid)
378 end
379  
380 -- XPerl_Party_SetDeBuffTooltip
381 function XPerl_Party_SetDeBuffTooltip()
382 local partyid = "party"..this:GetParent():GetParent():GetID()
383 GameTooltip:SetOwner(this,"ANCHOR_BOTTOMRIGHT",30,0)
384 --GameTooltip:SetUnitDebuff(partyid, this:GetID(), XPerlConfig.PartyCurableDebuffs)
385 XPerl_TooltipSetUnitDebuff(GameTooltip, partyid, this:GetID(), XPerlConfig.PartyCurableDebuffs)
386 end
387  
388 -------------------------
389 -- The Update Function --
390 -------------------------
391 local function XPerl_Party_CombatFlash(thisFrame, elapsed, argNew, argGreen)
392 if (XPerl_CombatFlashSet (elapsed, thisFrame, argNew, argGreen)) then
393 XPerl_CombatFlashSetFrames(thisFrame)
394 end
395 end
396  
397 -- XPerl_Party_UpdatePortrait
398 function XPerl_Party_UpdatePortrait(thisFrame)
399 if (XPerlConfig.ShowPartyPortrait == 1) then
400 local framePortrait = getglobal(thisFrame:GetName().."_PortraitFrame_Portrait")
401 local framePortrait3D = getglobal(thisFrame:GetName().."_PortraitFrame_Portrait3D")
402  
403 if (XPerlConfig.ShowPartyPortrait3D == 1 and UnitIsVisible(thisFrame.partyid)) then
404 framePortrait:Hide()
405 framePortrait3D:Show()
406 XPerlSetPortrait3D(framePortrait3D, thisFrame.partyid)
407 else
408 framePortrait3D.last3DTime = nil
409 framePortrait:Show()
410 framePortrait3D:Hide()
411 SetPortraitTexture(framePortrait, thisFrame.partyid)
412 end
413 end
414 end
415  
416 -- XPerl_Party_UpdateName
417 local function XPerl_Party_UpdateName(thisFrame)
418 local thisid = thisFrame:GetName()
419 local Partyname = UnitName(thisFrame.partyid)
420 if (Partyname) then
421 local nameFrame = getglobal(thisid.."_NameFrame")
422 local textFrame = getglobal(thisid.."_NameFrameText")
423  
424 textFrame:SetFontObject(GameFontNormal)
425 textFrame:SetText(Partyname)
426  
427 if (textFrame:GetStringWidth() > nameFrame:GetWidth() - 4) then
428 textFrame:SetFontObject(GameFontNormalSmall)
429 end
430  
431 XPerl_ColourFriendlyUnit(textFrame, thisFrame.partyid)
432 end
433 end
434  
435 -- XPerl_Party_UpdateLeader
436 local function XPerl_Party_UpdateLeader(thisFrame)
437 --partyid = ("party"..this:GetID())
438 local thisid = thisFrame:GetName()
439 local id = thisFrame:GetID()
440 local icon = getglobal(thisid.."_NameFrame_LeaderIcon")
441 if (GetPartyLeaderIndex() == id ) then
442 icon:Show()
443 else
444 icon:Hide()
445 end
446 icon = getglobal(thisid.."_NameFrame_MasterIcon")
447 local lootMethod
448 local lootMaster
449 lootMethod, lootMaster = GetLootMethod()
450 if ( id == lootMaster ) then
451 icon:Show()
452 else
453 icon:Hide()
454 end
455 end
456  
457 -- XPerl_Party_Update_Control
458 local function XPerl_Party_Update_Control(thisFrame)
459 if (UnitIsVisible(thisFrame.partyid) and UnitIsCharmed(thisFrame.partyid)) then
460 --XPerl_Target_Warning:SetTexture("Interface\Minimap\Ping\ping6")
461 --XPerl_Target_Warning:SetBlendMode("ADD")
462 getglobal(thisFrame:GetName().."_NameFrame_Warning"):Show()
463 else
464 getglobal(thisFrame:GetName().."_NameFrame_Warning"):Hide()
465 end
466 end
467  
468 -- XPerl_Party_UpdatePVP
469 local function XPerl_Party_UpdatePVP(thisFrame)
470 local f = getglobal(thisFrame:GetName().."_NameFrame_PVPStatus")
471 if (XPerlConfig.ShowPartyPVP == 1 and UnitIsPVP(thisFrame.partyid)) then
472 f:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..(UnitFactionGroup(thisFrame.partyid) or "FFA"))
473 f:Show()
474 else
475 f:Hide()
476 end
477 end
478  
479 -- XPerl_Party_UpdateCombat
480 function XPerl_Party_UpdateCombat(thisFrame)
481 XPerl_Party_UpdateCombat1(thisFrame.partyid, thisFrame:GetName())
482 XPerl_Party_Update_Control(thisFrame)
483 end
484  
485 -- XPerl_Party_UpdateCombat1
486 function XPerl_Party_UpdateCombat1(argID,argName)
487 local frame = getglobal(argName.."_NameFrame_ActivityStatus")
488 if (UnitAffectingCombat(argID)) then
489 frame:Show()
490 else
491 frame:Hide()
492 end
493 end
494  
495 -- XPerl_Party_UpdateLevel
496 local function XPerl_Party_UpdateLevel(thisFrame)
497 local Partylevel = UnitLevel(thisFrame.partyid)
498 local color = GetDifficultyColor(Partylevel)
499 getglobal(thisFrame:GetName().."_LevelFrame_LevelBarText"):SetTextColor(color.r,color.g,color.b)
500 getglobal(thisFrame:GetName().."_LevelFrame_LevelBarText"):SetText(Partylevel)
501 end
502  
503 -- XPerl_Party_UpdateClass
504 local function XPerl_Party_UpdateClass(thisFrame)
505 if (UnitIsPlayer(thisFrame.partyid)) then
506 local _, PlayerClass = UnitClass(thisFrame.partyid)
507 local r, l, t, b = XPerl_ClassPos(PlayerClass)
508 getglobal(thisFrame:GetName().."_LevelFrame_ClassTexture"):SetTexCoord(r, l, t, b)
509 end
510  
511 if (XPerlConfig.ShowPartyClassIcon==1) then
512 getglobal(thisFrame:GetName().."_LevelFrame_ClassTexture"):Show()
513 else
514 getglobal(thisFrame:GetName().."_LevelFrame_ClassTexture"):Hide()
515 end
516 end
517  
518 -- XPerl_Party_UpdateManaType
519 local function XPerl_Party_UpdateManaType(thisFrame)
520 local frameName = thisFrame:GetName().."_StatsFrame_ManaBar"
521 XPerl_SetManaBarType(thisFrame.partyid, getglobal(frameName), getglobal(frameName.."BG"))
522 end
523  
524 -- XPerl_Party_UpdateMana
525 local function XPerl_Party_UpdateMana(thisFrame)
526 --partyid = ("party"..this:GetID())
527 local thisid = thisFrame:GetName()
528 local Partymana = UnitMana(thisFrame.partyid)
529 local Partymanamax = UnitManaMax(thisFrame.partyid)
530 local frameManaBar = getglobal(thisid.."_StatsFrame_ManaBar")
531 local frameManaBarText = getglobal(thisid.."_StatsFrame_ManaBarText")
532 local frameManaBarPercent = getglobal(thisid.."_StatsFrame_ManaBarPercent")
533 local frameHealthBarPercent = getglobal(thisid.."_StatsFrame_HealthBarPercent")
534  
535 if (Partymanamax == 1 and Partymana > Partymanamax) then
536 Partymanamax = Partymana
537 end
538  
539 frameManaBar:SetMinMaxValues(0, Partymanamax)
540 frameManaBar:SetValue(Partymana)
541 pmanaPct = (Partymana * 100.0) / Partymanamax
542 pmanaPct = string.format("%3.0f", pmanaPct)
543 if (frameHealthBarPercent:IsVisible()) then
544 frameManaBarPercent:Show()
545 end
546 if (UnitPowerType(thisFrame.partyid)>=1) then
547 frameManaBarPercent:SetText(Partymana)
548 else
549 frameManaBarPercent:SetText(string.format("%d",(100*(Partymana / Partymanamax))+0.5).."%")
550 end
551  
552 if (XPerlConfig.ShowPartyValues == 1) then
553 frameManaBarText:Show()
554 else
555 frameManaBarText:Hide()
556 end
557  
558 frameManaBarText:SetText(Partymana.."/"..Partymanamax)
559 if (XPerlConfig.ShowPartyPercent==0) then
560 frameManaBarPercent:Hide()
561 frameHealthBarPercent:Hide()
562 getglobal(thisid.."_StatsFrame"):SetWidth(106)
563 end
564 local petFrame = getglobal("XPerl_partypet"..thisFrame:GetID())
565 if (UnitIsConnected(thisFrame.partyid)) then
566 thisFrame:SetAlpha(XPerlConfig.Transparency)
567 if (petFrame) then
568 petFrame:SetAlpha(XPerlConfig.Transparency)
569 end
570 else
571 thisFrame:SetAlpha(XPerlConfig.Transparency/2)
572 if (petFrame) then
573 petFrame:SetAlpha(XPerlConfig.Transparency/2)
574 end
575 getglobal(thisid.."_StatsFrame_HealthBarText"):SetText(XPERL_LOC_OFFLINE)
576 end
577 end
578  
579 -- XPerl_Party_UpdateRange
580 local function XPerl_Party_UpdateRange(thisFrame)
581 local f = getglobal(thisFrame:GetName().."_NameFrame_RangeStatus")
582  
583 if (XPerlConfig.ShowParty30YardSymbol == 0 or CheckInteractDistance(thisFrame.partyid, 4) or not UnitIsConnected(thisFrame.partyid)) then
584 f:Hide()
585 else
586 f:Show()
587 f:SetAlpha(1)
588 end
589 end
590  
591 -- XPerl_Party_OnUpdate
592 function XPerl_Party_OnUpdate()
593 local update
594 this.time = arg1 + this.time
595 if this.time >= 0.2 then
596 update = true
597 this.time = 0
598 end
599 local any
600  
601 for i,frame in pairs(PartyFrames) do
602 if (frame:IsShown()) then
603 if (frame.PlayerFlash) then
604 XPerl_Party_CombatFlash(frame, arg1, false)
605 end
606  
607 if (frame.Fading == 0) then
608 if (update) then
609 XPerl_Party_UpdateRange(frame)
610 XPerl_Party_UpdateTarget(frame)
611 end
612 else
613 XPerl_ProcessFade(frame)
614 end
615 any = true
616 end
617 end
618  
619 if (not any) then
620 XPerl_Party_EventFrame:Hide()
621 end
622 end
623  
624 -- XPerl_Party_StartFade
625 local function XPerl_Party_StartFade(thisFrame)
626 local framePet = getglobal("XPerl_partypet"..thisFrame:GetID())
627 if (framePet and framePet:IsVisible()) then
628 XPerl_StartFade(framePet)
629 end
630 XPerl_StartFade(thisFrame)
631  
632 if (UnitExists(thisFrame.partyid) and not UnitIsConnected(thisFrame.partyid)) then
633 thisFrame.FadeTime = 0.5
634 if (framePet and framePet:IsVisible()) then
635 framePet.FadeTime = 0.5
636 end
637 end
638 end
639  
640 -- XPerl_Party_UpdateDisplayAll
641 function XPerl_Party_UpdateDisplayAll()
642 local any
643 for i,frame in pairs(PartyFrames) do
644 XPerl_Party_UpdateDisplay(frame)
645 if (frame:IsShown()) then
646 any = true
647 end
648 end
649  
650 if (any) then
651 XPerl_Party_EventFrame:Show()
652 else
653 XPerl_Party_EventFrame:Hide()
654 end
655 end
656  
657 -- XPerl_Party_UpdateDisplay
658 function XPerl_Party_UpdateDisplay(thisFrame)
659 if (thisFrame and thisFrame.partyid) then
660 if (UnitExists(thisFrame.partyid)) then
661 XPerl_CancelFade(thisFrame)
662  
663 XPerl_Party_UpdateName(thisFrame)
664 XPerl_Party_UpdateLeader(thisFrame)
665 XPerl_Party_UpdateClass(thisFrame)
666 XPerl_Party_UpdateManaType(thisFrame)
667 XPerl_Party_UpdateHealth(thisFrame)
668 XPerl_Party_UpdateMana(thisFrame)
669 XPerl_Party_UpdateLevel(thisFrame)
670 XPerl_Party_Update_Control(thisFrame)
671 XPerl_Party_UpdateCombat(thisFrame)
672 XPerl_Party_UpdatePVP(thisFrame)
673 XPerl_Party_UpdatePortrait(thisFrame)
674 XPerl_Party_Buff_UpdateAll(thisFrame)
675  
676 if (XPerlConfig.ShowPartyRaid == 1 or not UnitInRaid("player")) then
677 thisFrame:Show()
678 else
679 XPerl_Party_StartFade(thisFrame)
680 end
681  
682 else
683 XPerl_Party_StartFade(thisFrame)
684 end
685 end
686 end
687  
688 --------------------
689 -- Click Handlers --
690 --------------------
691 -- Non local by request (GenesisClicks/Elsewhere)
692 Perl_Party_FindID = XPerl_Frame_FindID
693  
694 function XPerl_Party_OnClick(button,argTarget)
695  
696 local unit = this:GetParent().partyid
697  
698 if (argTarget == 1) then
699 unit = unit.."target"
700 end
701  
702 if (XPerl_OnClick_Handler(button, unit)) then
703 return
704 end
705  
706 if (button == "RightButton") then
707 if (argTarget == 0) then
708 local id = this:GetParent():GetID()
709  
710 HideDropDownMenu(1)
711 ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame"..id.."DropDown"), this:GetParent():GetName().."_StatsFrame", 0, 0)
712 end
713 end
714 end
715  
716 -- XPerl_Party_PlayerTip
717 function XPerl_Party_PlayerTip(argTarget)
718 local unitid = this:GetParent().partyid
719 if (argTarget) then
720 unitid = unitid.."target"
721 end
722  
723 XPerl_PlayerTip(unitid)
724 end
725  
726 -- XPerl_Party_UpdateTarget
727 function XPerl_Party_UpdateTarget(thisFrame)
728 local frame = getglobal("XPerl_"..thisFrame.partyid.."_TargetFrame")
729 local petFrame = getglobal("XPerl_partypet"..thisFrame:GetID())
730  
731 if (frame == nil) then
732 return
733 end
734 if (frame.Fading == 1) then
735 return
736 end
737  
738 if (XPerlConfig.ShowPartyTarget == 1) then
739 local frameText = getglobal("XPerl_"..thisFrame.partyid.."_TargetFrame_Target")
740 if (UnitIsConnected(thisFrame.partyid) and UnitExists(thisFrame.partyid) and UnitIsVisible(thisFrame.partyid)) then
741 local unit = thisFrame.partyid.."target"
742 local targetname = UnitName(unit)
743  
744 if (targetname and targetname ~= UNKNOWNOBJECT) then
745 -- if (UnitExists (unit)) then - Changed as a test, as u can often pick up unit name, and unit class, but not health etc.
746 --local targetname = UnitName(unit)
747 frameText:SetText(targetname)
748 local width = frameText:GetStringWidth()
749  
750 if (width < 68) then
751 frame:SetWidth(68)
752 elseif (width > 112) then
753 frame:SetWidth(120)
754  
755 local remCount = 1
756 while ((frameText:GetStringWidth() >= 112) and (string.len(targetname) > remCount)) do
757 targetname = string.sub(targetname, 1, string.len(targetname) - remCount)..".."
758 remCount = 3
759 frameText:SetText(targetname)
760 end
761 else
762 frame:SetWidth(width + 8)
763 end
764  
765 XPerl_SetUnitNameColor (unit, frameText)
766 frame:Show()
767  
768 local frameAct = getglobal("XPerl_"..thisFrame.partyid.."_TargetFrame_TargetActivityStatus")
769 if (UnitAffectingCombat(unit)) then
770 frameAct:SetTexCoord(0.5, 1.0, 0.0, 0.5)
771 frameAct:Show()
772 else
773 frameAct:Hide()
774 end
775  
776 local framePVP = getglobal("XPerl_"..thisFrame.partyid.."_TargetFrame_TargetPVPStatus")
777 if (XPerlConfig.ShowPartyPVP == 1 and UnitIsPVP(unit)) then
778 framePVP:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..(UnitFactionGroup(unit) or "FFA"))
779 framePVP:Show()
780 else
781 framePVP:Hide()
782 end
783 else
784 frame:Hide()
785 end
786 else
787 frame:Hide()
788 end
789 else
790 frame:Hide()
791 end
792  
793 if (petFrame) then
794 petFrame:ClearAllPoints()
795 if (frame:IsShown() and XPerlConfig.ShowPartyPetName == 1) then
796 petFrame:SetPoint("TOPLEFT", frame, "TOPRIGHT", -2, 2)
797 else
798 if (XPerlConfig.ShowPartyPetName == 1) then
799 petFrame:SetPoint("TOPLEFT", frame:GetParent():GetName().."_StatsFrame", "TOPRIGHT", -2, 21)
800 else
801 petFrame:SetPoint("TOPLEFT", frame:GetParent():GetName().."_StatsFrame", "TOPRIGHT", -2, 0)
802 end
803 end
804 end
805 end
806  
807 -------------------
808 -- Event Handler --
809 -------------------
810 function XPerl_Party_OnEvent()
811 local func = XPerl_Party_Events[event]
812 if (func) then
813 func()
814 else
815 XPerl_ShowMessage("EXTRA EVENT")
816 --XPerl_Party_UpdateDisplay()
817 end
818 end
819  
820 -- PLAYER_ENTERING_WORLD
821 function XPerl_Party_Events:PLAYER_ENTERING_WORLD()
822 XPerl_Party_RegisterSome()
823 XPerl_Party_UpdateDisplayAll()
824 end
825 XPerl_Party_Events.PARTY_MEMBERS_CHANGED = XPerl_Party_Events.PLAYER_ENTERING_WORLD
826  
827 -- PLAYER_LEAVING_WORLD()
828 function XPerl_Party_Events:PLAYER_LEAVING_WORLD()
829 XPerl_Party_UnregisterSome()
830 end
831  
832 -- PARTY_LEADER_CHANGED
833 function XPerl_Party_Events:PARTY_LEADER_CHANGED()
834 for i,frame in pairs(PartyFrames) do
835 XPerl_Party_UpdateLeader(frame)
836 end
837 end
838  
839 XPerl_Party_Events.PARTY_LOOT_METHOD_CHANGED = XPerl_Party_Events.PARTY_LEADER_CHANGED
840  
841 -- UNIT_COMBAT
842 function XPerl_Party_Events:UNIT_COMBAT()
843 local f = PartyFrames[arg1]
844 if (f) then
845 XPerl_Party_UpdateCombat(f)
846  
847 if (arg2 == "HEAL") then
848 XPerl_Party_CombatFlash(f, 0, true, true)
849 elseif (arg4 and arg4 > 0) then
850 XPerl_Party_CombatFlash(f, 0, true)
851 end
852 end
853 end
854  
855 -- UNIT_HEALTH, UNIT_MAXHEALTH
856 function XPerl_Party_Events:UNIT_HEALTH()
857 local f = PartyFrames[arg1]
858 if (f) then
859 XPerl_Party_UpdateHealth(f)
860 end
861 end
862  
863 -- UNIT_MAXHEALTH
864 function XPerl_Party_Events:UNIT_MAXHEALTH()
865 local f = PartyFrames[arg1]
866 if (f) then
867 XPerl_Party_UpdateHealth(f)
868 XPerl_Party_UpdateLevel(f) -- Level not available until we've received maxhealth
869 XPerl_Party_UpdateClass(f)
870 end
871 end
872  
873 XPerl_Party_Events.PARTY_MEMBER_ENABLE = XPerl_Party_Events.UNIT_HEALTH
874 XPerl_Party_Events.PARTY_MEMBER_DISABLE = XPerl_Party_Events.UNIT_HEALTH
875  
876 -- UNIT_MODEL_CHANGED
877 function XPerl_Party_Events:UNIT_MODEL_CHANGED()
878 local f = PartyFrames[arg1]
879 if (f) then
880 XPerl_Party_UpdatePortrait(f)
881 end
882 end
883 --XPerl_Party_Events.UNIT_PORTRAIT_UPDATE = XPerl_Party_Events.UNIT_MODEL_CHANGED
884  
885 -- UNIT_MANA
886 function XPerl_Party_Events:UNIT_MANA()
887 local f = PartyFrames[arg1]
888 if (f) then
889 XPerl_Party_UpdateMana(f)
890 end
891 end
892  
893 XPerl_Party_Events.UNIT_MAXMANA = XPerl_Party_Events.UNIT_MANA
894 XPerl_Party_Events.UNIT_RAGE = XPerl_Party_Events.UNIT_MANA
895 XPerl_Party_Events.UNIT_MAXRAGE = XPerl_Party_Events.UNIT_MANA
896 XPerl_Party_Events.UNIT_ENERGY = XPerl_Party_Events.UNIT_MANA
897 XPerl_Party_Events.UNIT_MAXENERGY = XPerl_Party_Events.UNIT_MANA
898 XPerl_Party_Events.UNIT_FOCUS = XPerl_Party_Events.UNIT_MANA
899 XPerl_Party_Events.UNIT_MAXFOCUS = XPerl_Party_Events.UNIT_MANA
900  
901 -- UNIT_DISPLAYPOWER
902 function XPerl_Party_Events:UNIT_DISPLAYPOWER()
903 local f = PartyFrames[arg1]
904 if (f) then
905 XPerl_Party_UpdateManaType(f)
906 XPerl_Party_UpdateMana(f)
907 end
908 end
909  
910 -- UNIT_NAME_UPDATE
911 function XPerl_Party_Events:UNIT_NAME_UPDATE()
912 if (PartyFrames[arg1]) then
913 XPerl_Party_UpdateName(PartyFrames[arg1])
914 end
915 end
916  
917 -- UNIT_LEVEL
918 function XPerl_Party_Events:UNIT_LEVEL()
919 if (PartyFrames[arg1]) then
920 XPerl_Party_UpdateLevel(PartyFrames[arg1])
921 end
922 end
923  
924 -- UNIT_AURA
925 function XPerl_Party_Events:UNIT_AURA()
926 local f = PartyFrames[arg1]
927 if (f) then
928 XPerl_Party_Buff_UpdateAll(f)
929 end
930 end
931  
932 -- UNIT_FACTION
933 function XPerl_Party_Events:UNIT_FACTION()
934 local f = PartyFrames[arg1]
935 if (f) then
936 XPerl_Party_UpdateName(f)
937 XPerl_Party_UpdateCombat(f)
938 XPerl_Party_Update_Control(f)
939 XPerl_Party_UpdatePVP(f)
940 end
941 end
942  
943 XPerl_Party_Events.UNIT_FLAGS = XPerl_Party_Events.UNIT_FACTION
944 XPerl_Party_Events.UNIT_DYNAMIC_FLAGS = XPerl_Party_Events.UNIT_FACTION
945  
946 ---- Moving stuff ----
947 -- XPerl_Party_GetGap
948 function XPerl_Party_GetGap()
949 return math.floor(math.floor((XPerl_party1:GetBottom() - XPerl_party2:GetTop() + 0.01) * 100) / 100)
950 end
951  
952 -- XPerl_Party_SetGap
953 function XPerl_Party_SetGap(newGap)
954 if (type(newGap) ~= "number") then
955 return
956 end
957  
958 local top = XPerl_party1:GetTop()
959 local height = XPerl_party1:GetHeight()
960  
961 if (type(newGap) == "number") then
962 for i = 1,4 do
963 local frame = getglobal("XPerl_party"..i)
964 local left = frame:GetLeft()
965  
966 frame:ClearAllPoints()
967 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", left, top)
968  
969 top = top - (newGap + height)
970  
971 frame:SetUserPlaced(true)
972 end
973 end
974 end
975  
976 -- XPerl_Party_AlignLeft
977 function XPerl_Party_AlignLeft()
978 local left = XPerl_party1:GetLeft()
979  
980 for i = 1,4 do
981 local frame = getglobal("XPerl_party"..i)
982  
983 local top = frame:GetTop()
984  
985 frame:ClearAllPoints()
986 frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", left, top)
987  
988 frame:SetUserPlaced(true)
989 end
990 end
991  
992 -- XPerl_Party_Set_Bits
993 function XPerl_Party_Set_Bits()
994 for num=1,4 do
995 local levelFrame = getglobal("XPerl_party"..num.."_LevelFrame")
996 local nameFrame = getglobal("XPerl_party"..num.."_NameFrame")
997 local statsFrame = getglobal("XPerl_party"..num.."_StatsFrame")
998 local portraitFrame = getglobal("XPerl_party"..num.."_PortraitFrame")
999 local clickFrame = getglobal("XPerl_party"..num.."_CastClickOverlay")
1000 local classTexture = getglobal("XPerl_party"..num.."_LevelFrame_ClassTexture")
1001 local levelText = getglobal("XPerl_party"..num.."_LevelFrame_LevelBarText")
1002  
1003 portraitFrame:ClearAllPoints()
1004 nameFrame:ClearAllPoints()
1005 levelFrame:ClearAllPoints()
1006 statsFrame:ClearAllPoints()
1007 classTexture:ClearAllPoints()
1008 levelText:ClearAllPoints()
1009 clickFrame:ClearAllPoints()
1010  
1011 if (XPerlConfig.ShowPartyPortrait==0) then
1012 portraitFrame:Hide()
1013  
1014 levelFrame:SetWidth(30)
1015 levelFrame:SetHeight(41)
1016  
1017 nameFrame:SetPoint("TOPLEFT", getglobal("XPerl_party"..num), "TOPLEFT", 0, 0)
1018 levelFrame:SetPoint("TOPLEFT", nameFrame, "BOTTOMLEFT", 0, 3)
1019 statsFrame:SetPoint("TOPLEFT", levelFrame, "TOPRIGHT", -3, 0)
1020  
1021 levelText:SetPoint("BOTTOM", levelFrame, "BOTTOM", 0, 4)
1022 classTexture:SetPoint("TOPLEFT", levelFrame, "TOPLEFT", 5, -5)
1023  
1024 getglobal("XPerl_party"..num.."_BuffFrame"):SetPoint("TOPLEFT", statsFrame, "BOTTOMLEFT", 5, 0)
1025  
1026 clickFrame:SetPoint("TOPLEFT", nameFrame, "TOPLEFT", 0, 0)
1027 clickFrame:SetPoint("BOTTOMRIGHT", statsFrame, "BOTTOMRIGHT", 0, 0)
1028 else
1029 portraitFrame:Show()
1030  
1031 levelFrame:SetWidth(27)
1032 levelFrame:SetHeight(22)
1033  
1034 levelFrame:SetPoint("TOPLEFT", getglobal("XPerl_party"..num), "TOPLEFT", 0, 0)
1035 portraitFrame:SetPoint("TOPLEFT", levelFrame, "TOPRIGHT", -2, 0)
1036 nameFrame:SetPoint("TOPLEFT", portraitFrame, "TOPRIGHT", -3, 0)
1037 statsFrame:SetPoint("TOPLEFT", nameFrame, "BOTTOMLEFT", 0, 3)
1038  
1039 levelText:SetPoint("CENTER", 0, 0)
1040 classTexture:SetPoint("BOTTOMRIGHT", portraitFrame, "BOTTOMLEFT", 0, 3)
1041  
1042 getglobal("XPerl_party"..num.."_BuffFrame"):SetPoint("TOPLEFT", portraitFrame, "BOTTOMLEFT", 5, 0)
1043  
1044 clickFrame:SetPoint("TOPLEFT", levelFrame, "TOPLEFT", 0, 0)
1045 clickFrame:SetPoint("BOTTOMRIGHT", statsFrame, "BOTTOMRIGHT", 0, 0)
1046 end
1047  
1048 if (XPerlConfig.ShowPartyLevel==0) then
1049 getglobal("XPerl_party"..num.."_LevelFrame_LevelBarText"):Hide()
1050 if (XPerlConfig.ShowPartyLevel==1) then
1051 levelFrame:SetHeight(levelFrame:GetHeight()-10)
1052 end
1053 else
1054 getglobal("XPerl_party"..num.."_LevelFrame_LevelBarText"):Show()
1055 levelFrame:Show()
1056  
1057 if (XPerlConfig.ShowPartyLevel==0) then
1058 levelFrame:SetHeight(levelFrame:GetHeight()+10)
1059 end
1060  
1061 if (XPerlConfig.ShowPartyPortrait == 1) then
1062 levelFrame:SetWidth(27)
1063 else
1064 levelFrame:SetWidth(30)
1065 end
1066 end
1067  
1068 if (XPerlConfig.ShowPartyClassIcon==0) then
1069 classTexture:Hide()
1070  
1071 if (XPerlConfig.ShowPartyLevel == 0) then
1072 levelFrame:SetWidth(1)
1073 levelFrame:Hide()
1074 end
1075 else
1076 classTexture:Show()
1077 levelFrame:Show()
1078  
1079 if (XPerlConfig.ShowPartyPortrait == 1) then
1080 levelFrame:SetWidth(27)
1081 else
1082 levelFrame:SetWidth(30)
1083 end
1084 end
1085  
1086 local frameHealth = getglobal("XPerl_party"..num.."_StatsFrame_HealthBarPercent")
1087 local frameMana = getglobal("XPerl_party"..num.."_StatsFrame_ManaBarPercent")
1088 local width = (30 * XPerlConfig.ShowPartyPercent) + 106; -- 136 enabled, 106 disabled
1089  
1090 statsFrame:SetWidth(width)
1091 if (XPerlConfig.ShowPartyPercent == 0) then
1092 frameHealth:Hide()
1093 frameMana:Hide()
1094 else
1095 frameHealth:Show()
1096 frameMana:Show()
1097 end
1098  
1099 local height = (XPerlConfig.ShowPartyNames * 22) + 2; -- 24 when enabled, 2 when disabled
1100 local targetFrame = getglobal("XPerl_party"..num.."_TargetFrame")
1101  
1102 targetFrame:ClearAllPoints()
1103 nameFrame:SetHeight(height)
1104  
1105 if (XPerlConfig.ShowPartyNames==0) then
1106 nameFrame:Hide()
1107 targetFrame:SetPoint("TOPLEFT", statsFrame, "BOTTOMLEFT", 0, 2)
1108 else
1109 nameFrame:Show()
1110 targetFrame:SetPoint("BOTTOMLEFT", nameFrame, "BOTTOMRIGHT", -2, 2)
1111 end
1112  
1113 XPerlConfig.PartyBuffSize = tonumber(XPerlConfig.PartyBuffSize) or 20
1114 XPerl_SetBuffSize("XPerl_party"..num.."_", XPerlConfig.PartyBuffSize, XPerlConfig.PartyBuffSize * 1.4)
1115 end
1116 end
1117  
1118 -- XPerl_ScaleParty
1119 function XPerl_ScaleParty(num)
1120 XPerl_party4:SetScale(num)
1121 XPerl_party3:SetScale(num)
1122 XPerl_party2:SetScale(num)
1123 XPerl_party1:SetScale(num)
1124 end