vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- // OnFoo Functions // -- |
2 | function CT_PartyFrameSlider_OnLoad() |
||
3 | getglobal(this:GetName().."Text"):SetText(CT_UFO_PARTYTEXTSIZE); |
||
4 | getglobal(this:GetName().."High"):SetText(CT_UFO_PARTYTEXTSIZE_LARGE); |
||
5 | getglobal(this:GetName().."Low"):SetText(CT_UFO_PARTYTEXTSIZE_SMALL); |
||
6 | this:SetMinMaxValues(1, 5); |
||
7 | this:SetValueStep(1); |
||
8 | this.tooltipText = "Allows you to change the text size of the party health & mana texts."; |
||
9 | end |
||
10 | |||
11 | function CT_PartyFrame_ShallDisplay(offset) |
||
12 | return CT_UnitFramesOptions.styles[2][offset][1]; |
||
13 | end |
||
14 | |||
15 | function CT_PartyFrame_GetHealth(unit, id) |
||
16 | if ( id == 1 ) then |
||
17 | return ""; |
||
18 | end |
||
19 | if ( not UnitExists(unit) or not UnitExists("player") ) then |
||
20 | return ""; |
||
21 | end |
||
22 | if ( (UnitHealth(unit) <= 0) and UnitIsConnected(unit) ) then |
||
23 | return ""; |
||
24 | end |
||
25 | if ( UnitHealthMax(unit) == 100 ) then |
||
26 | id = 2; |
||
27 | end |
||
28 | if ( id == 2 ) then |
||
29 | return floor(( UnitHealth(unit) or 1 ) / ( UnitHealthMax(unit) or 1)*100) .. "%"; |
||
30 | elseif ( id == 3 ) then |
||
31 | local deficit = ( UnitHealth(unit) or 1 ) - ( UnitHealthMax(unit) or 1 ); |
||
32 | if ( deficit == 0 ) then |
||
33 | deficit = ""; |
||
34 | end |
||
35 | return deficit; |
||
36 | elseif ( id == 4 ) then |
||
37 | return ( UnitHealth(unit) or "?" ) .. "/" .. ( UnitHealthMax(unit) or "?" ); |
||
38 | end |
||
39 | end |
||
40 | |||
41 | function CT_PartyFrame_GetMana(unit, id) |
||
42 | if ( id == 1 ) then |
||
43 | return ""; |
||
44 | end |
||
45 | if ( not UnitExists(unit) or not UnitExists("player") ) then |
||
46 | return ""; |
||
47 | end |
||
48 | if ( UnitPowerType(unit) > 0 or UnitManaMax(unit) == 0 or ( UnitIsDead(unit) and UnitIsConnected(unit) ) ) then |
||
49 | return ""; |
||
50 | end |
||
51 | if ( id == 2 ) then |
||
52 | return floor(( UnitMana(unit) or 1 ) / ( UnitManaMax(unit) or 1)*100) .. "%"; |
||
53 | elseif ( id == 3 ) then |
||
54 | local deficit = ( UnitMana(unit) or 1 ) - ( UnitManaMax(unit) or 1 ); |
||
55 | if ( deficit == 0 ) then |
||
56 | deficit = ""; |
||
57 | end |
||
58 | return deficit; |
||
59 | elseif ( id == 4 ) then |
||
60 | return ( UnitMana(unit) or "?" ) .. "/" .. ( UnitManaMax(unit) or "?" ); |
||
61 | end |
||
62 | end |
||
63 | |||
64 | -- // Update Party Member's Health // -- |
||
65 | function CT_PartyFrame_UpdateMember(unit, health) |
||
66 | if ( not UnitExists(unit) ) then |
||
67 | return; |
||
68 | end |
||
69 | local i = strsub(unit, 6, 6); |
||
70 | getglobal("CT_PartyFrame" .. i .. "HealthBar"):SetTextHeight( ( CT_UnitFramesOptions.partyTextSize or 3 ) + 7); |
||
71 | local color = CT_UnitFramesOptions.styles[2]; |
||
72 | getglobal("CT_PartyFrame" .. i .. "HealthBar"):SetTextColor(color[1][2], color[1][3], color[1][4], color[1][5]); |
||
73 | getglobal("CT_PartyFrame" .. i .. "HealthRight"):SetTextHeight( ( CT_UnitFramesOptions.partyTextSize or 3 ) + 7); |
||
74 | getglobal("CT_PartyFrame" .. i .. "HealthRight"):SetTextColor(color[2][2], color[2][3], color[2][4], color[2][5]); |
||
75 | getglobal("CT_PartyFrame" .. i .. "ManaBar"):SetTextHeight( ( CT_UnitFramesOptions.partyTextSize or 3 ) + 7); |
||
76 | getglobal("CT_PartyFrame" .. i .. "ManaBar"):SetTextColor(color[3][2], color[3][3], color[3][4], color[3][5]); |
||
77 | getglobal("CT_PartyFrame" .. i .. "ManaRight"):SetTextHeight( ( CT_UnitFramesOptions.partyTextSize or 3 ) + 7); |
||
78 | getglobal("CT_PartyFrame" .. i .. "ManaRight"):SetTextColor(color[4][2], color[4][3], color[4][4], color[4][5]); |
||
79 | if ( health ) then |
||
80 | local hp = getglobal("PartyMemberFrame" .. i).unitHPPercent; |
||
81 | if ( hp ) then |
||
82 | if ( hp > 0 ) then |
||
83 | if ( hp > 0.5 ) then |
||
84 | r = (1.0 - hp) * 2; |
||
85 | g = 1.0; |
||
86 | else |
||
87 | r = 1.0; |
||
88 | g = hp * 2; |
||
89 | end |
||
90 | else |
||
91 | r = 0; g = 1; |
||
92 | end |
||
93 | else |
||
94 | r = 0; g = 1; |
||
95 | end |
||
96 | getglobal("PartyMemberFrame" .. i .. "HealthBar"):SetStatusBarColor(r, g, 0); |
||
97 | local typeOnHealth, typeRightHealth = CT_PartyFrame_ShallDisplay(1), CT_PartyFrame_ShallDisplay(2); |
||
98 | getglobal("CT_PartyFrame" .. i .. "HealthBar"):SetText(CT_PartyFrame_GetHealth(unit, typeOnHealth)); |
||
99 | getglobal("CT_PartyFrame" .. i .. "HealthRight"):SetText(CT_PartyFrame_GetHealth(unit, typeRightHealth)); |
||
100 | else |
||
101 | local typeOnMana, typeRightMana = CT_PartyFrame_ShallDisplay(3), CT_PartyFrame_ShallDisplay(4); |
||
102 | getglobal("CT_PartyFrame" .. i .. "ManaBar"):SetText(CT_PartyFrame_GetMana(unit, typeOnMana)); |
||
103 | getglobal("CT_PartyFrame" .. i .. "ManaRight"):SetText(CT_PartyFrame_GetMana(unit, typeRightMana)); |
||
104 | end |
||
105 | end |
||
106 | |||
107 | function CT_PartyFrame_Update(unit, event) |
||
108 | if ( event == "PARTY_MEMBERS_CHANGED" or event == "VARIABLES_LOADED" ) then |
||
109 | for i = 1, GetNumPartyMembers(), 1 do |
||
110 | CT_PartyFrame_UpdateMember("party" .. i, 1); |
||
111 | CT_PartyFrame_UpdateMember("party" .. i, nil); |
||
112 | end |
||
113 | elseif ( string.find(unit, "^party%d$") ) then |
||
114 | if ( event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" or event == "UNIT_DISPLAYPOWER" ) then |
||
115 | CT_PartyFrame_UpdateMember(unit, 1); |
||
116 | else |
||
117 | CT_PartyFrame_UpdateMember(unit, nil); |
||
118 | end |
||
119 | end |
||
120 | end |