vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function DUF_HealthBar_Update()
2 if ((not this.health) or (not this.healthmax) or this.healthmax == 0) then return; end
3 local value = this.health / this.healthmax * 100;
4 local value2 = 0;
5 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].fade and this.lasthealth < this.healthmax) then
6 value2 = this.lasthealth / this.healthmax * 100;
7 end
8 if (this.lasthealth > this.health and value2 > 0) then
9 this.lasthealthalpha = 1;
10 end
11  
12 local width = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].width
13 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].resizemax and this.lasthealthmax ~= this.healthmax) then
14 this.lasthealthmax = this.healthmax;
15 local percent = this.healthmax / UnitHealthMax("player");
16 width = width * percent;
17 local padding = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].bgpadding * 2;
18 getglobal(this:GetName().."_HealthBar").dynamicsize = percent;
19 getglobal(this:GetName().."_HealthBar_Background"):SetWidth(width + padding);
20 end
21 this.lasthealth = this.health;
22 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[1].fill) then
23 DUF_StatusBar_SetValue(getglobal(this:GetName().."_HealthBar_Bar"), 100 - value, 1, width);
24 DUF_StatusBar_SetValue(getglobal(this:GetName().."_HealthBar_Bar2"), 0, 1, width);
25 else
26 DUF_StatusBar_SetValue(getglobal(this:GetName().."_HealthBar_Bar"), value, 1, width);
27 DUF_StatusBar_SetValue(getglobal(this:GetName().."_HealthBar_Bar2"), value2, 1, width);
28 end
29 end
30  
31 function DUF_HonorBar_Update()
32 if (DUF_Settings[DUF_INDEX].player.StatusBar[6].trackRep) then
33 DUF_ReputationBar_Update(2)
34 return
35 end
36 DUF_StatusBar_SetValue(DUF_PlayerFrame_HonorBar_Bar, GetPVPRankProgress() * 100, 1, DUF_Settings[DUF_INDEX].player.StatusBar[6].width);
37 DUF_StatusBar_SetValue(DUF_PlayerFrame_HonorBar_Bar2, GetPVPRankProgress() * 100, 1, DUF_Settings[DUF_INDEX].player.StatusBar[6].width);
38 end
39  
40 function DUF_ManaBar_Update()
41 if ((not this.mana) or (not this.manamax) or this.manamax == 0) then
42 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].hideifnomana and (not DUF_OPTIONS_VISIBLE)) then
43 getglobal(this:GetName().."_ManaBar"):Hide();
44 return;
45 else
46 if ((not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].hide) and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].mouseover)) then
47 getglobal(this:GetName().."_ManaBar"):Show();
48 else
49 return;
50 end
51 if (DUF_OPTIONS_VISIBLE) then
52 this.mana = 100;
53 this.manamax = 100;
54 this.lastmana = 100;
55 else
56 this.mana = 0;
57 this.manamax = 0;
58 this.lastmana = 0;
59 end
60 end
61 elseif ((not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].hide) and (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].mouseover)) then
62 getglobal(this:GetName().."_ManaBar"):Show();
63 end
64 if (not this.mana) then this.mana = 0 end
65 local value = this.mana / this.manamax * 100;
66 local value2 = 0;
67 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].fade and this.lastmana < this.manamax) then
68 value2 = this.lastmana / this.manamax * 100;
69 end
70 if (this.manamax == 0) then
71 value = 0;
72 value2 = 0;
73 end
74 if (this.lastmana > this.mana and value2 > 0) then
75 this.lastmanaalpha = 1;
76 end
77 this.lastmana = this.mana;
78  
79 local width = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].width;
80 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].resizemax and this.lastmanamax ~= this.manamax) then
81 this.lastmanamax = this.manamax;
82 local percent = this.manamax / UnitManaMax("player");
83 width = width * percent;
84 local padding = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].bgpadding * 2;
85 getglobal(this:GetName().."_ManaBar").dynamicsize = percent;
86 getglobal(this:GetName().."_ManaBar_Background"):SetWidth(width + padding);
87 end
88 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].fill) then
89 DUF_StatusBar_SetValue(getglobal(this:GetName().."_ManaBar_Bar"), 100 - value, 1, width);
90 DUF_StatusBar_SetValue(getglobal(this:GetName().."_ManaBar_Bar2"), 0, 1, width);
91 else
92 DUF_StatusBar_SetValue(getglobal(this:GetName().."_ManaBar_Bar"), value, 1, width);
93 DUF_StatusBar_SetValue(getglobal(this:GetName().."_ManaBar_Bar2"), value2, 1, width);
94 end
95 end
96  
97 function DUF_ManaBar_UpdateType()
98 local color;
99 if (this.manatype == 0) then
100 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].manacolor;
101 elseif (this.manatype == 1) then
102 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].ragecolor;
103 elseif (this.manatype == 2) then
104 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].focuscolor;
105 elseif (this.manatype == 3) then
106 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[2].energycolor;
107 end
108 if (color) then
109 getglobal(this:GetName().."_ManaBar").manacolor = color;
110 getglobal(this:GetName().."_ManaBar_Bar"):SetVertexColor(color.r, color.g, color.b);
111 end
112 end
113  
114 function DUF_PetXPBar_Update()
115 local current, needed = GetPetExperience();
116 local percent = current / needed * 100;
117 if (needed == 0) then
118 percent = 0;
119 end
120 DUF_StatusBar_SetValue(DUF_PetFrame_XPBar_Bar, percent, 1, DUF_Settings[DUF_INDEX].pet.StatusBar[3].width);
121 DUF_StatusBar_SetValue(DUF_PetFrame_XPBar_Bar2, percent, 1, DUF_Settings[DUF_INDEX].pet.StatusBar[3].width);
122 end
123  
124 function DUF_TargetHealthBar_Update()
125 if ((not this.healthtarget) or (not this.healthmaxtarget) or this.healthmaxtarget == 0) then
126 if (DUF_OPTIONS_VISIBLE) then
127 if (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[4].hide) then
128 getglobal(this:GetName().."_TargetHealthBar"):Show();
129 else
130 return;
131 end
132 this.healthtarget = 100;
133 this.healthmaxtarget = 100;
134 else
135 getglobal(this:GetName().."_TargetHealthBar"):Hide();
136 return;
137 end
138 end
139 if (not this.unit) then return; end
140 if ( (not DL_UnitName(this.unit.."target")) and (not DUF_OPTIONS_VISIBLE) ) then
141 getglobal(this:GetName().."_TargetHealthBar"):Hide();
142 return;
143 elseif (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[4].hide) then
144 getglobal(this:GetName().."_TargetHealthBar"):Show();
145 end
146 local value = this.healthtarget / this.healthmaxtarget * 100;
147 if (this.healthmaxtarget == 0) then
148 value = 100;
149 end
150 local width = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[4].width;
151 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[4].fill) then
152 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetHealthBar_Bar"), 100 - value, 1, width);
153 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetHealthBar_Bar2"), 0, 1, width);
154 else
155 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetHealthBar_Bar"), value, 1, width);
156 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetHealthBar_Bar2"), 0, 1, width);
157 end
158 end
159  
160 function DUF_TargetManaBar_Update()
161 if ((not this.manatarget) or (not this.manamaxtarget) or this.manamaxtarget == 0) then
162 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].hideifnomana and (not DUF_OPTIONS_VISIBLE)) then
163 getglobal(this:GetName().."_TargetManaBar"):Hide();
164 return;
165 elseif (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].hide) then
166 getglobal(this:GetName().."_TargetManaBar"):Show();
167 this.manatarget = 0;
168 this.manamaxtarget = 0;
169 else
170 return;
171 end
172 end
173 if (not this.unit) then return; end
174 if ((not DL_UnitName(this.unit.."target")) and (not DUF_OPTIONS_VISIBLE)) then
175 getglobal(this:GetName().."_TargetManaBar"):Hide();
176 return;
177 elseif (not DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].hide) then
178 getglobal(this:GetName().."_TargetManaBar"):Show();
179 end
180 local value = this.manatarget / this.manamaxtarget * 100;
181 if (this.manamaxtarget == 0) then
182 value = 100;
183 end
184 if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].fill) then
185 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetManaBar_Bar"), 100 - value, 1, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].width);
186 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetManaBar_Bar2"), 0, 1, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].width);
187 else
188 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetManaBar_Bar"), value, 1, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].width);
189 DUF_StatusBar_SetValue(getglobal(this:GetName().."_TargetManaBar_Bar2"), 0, 1, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].width);
190 end
191 end
192  
193 function DUF_TargetManaBar_UpdateType()
194 local color;
195 if (this.manatypetarget == 0) then
196 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].manacolor;
197 elseif (this.manatypetarget == 1) then
198 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].ragecolor;
199 elseif (this.manatypetarget == 2) then
200 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].focuscolor;
201 elseif (this.manatypetarget == 3) then
202 color = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[this.unit].index].StatusBar[5].energycolor;
203 end
204 if (color) then
205 getglobal(this:GetName().."_TargetManaBar").manacolor = color;
206 getglobal(this:GetName().."_TargetManaBar_Bar"):SetVertexColor(color.r, color.g, color.b);
207 end
208 end
209  
210 function DUF_XPBar_Update()
211 if (DUF_Settings[DUF_INDEX].player.StatusBar[3].trackRep) then
212 DUF_ReputationBar_Update(1)
213 return
214 end
215 local percent = UnitXP("player") / UnitXPMax("player") * 100;
216 if (UnitXPMax("player") == 0) then
217 percent = 0;
218 end
219 local bonusxp = GetXPExhaustion();
220 local bonusxp2 = 0;
221 if (bonusxp) then
222 bonusxp2 = bonusxp;
223 bonusxp = math.floor(bonusxp / 2);
224 else
225 bonusxp = 0;
226 end
227 local bonuspercent = (UnitXP("player") + bonusxp2)/ UnitXPMax("player") * 100;
228 if (UnitXPMax("player") == 0) then
229 bonuspercent = 0;
230 end
231 if (bonuspercent > 100) then
232 bonuspercent = 100;
233 end
234 DUF_StatusBar_SetValue(DUF_PlayerFrame_XPBar_Bar, percent, 1, DUF_Settings[DUF_INDEX].player.StatusBar[3].width);
235 DUF_StatusBar_SetValue(DUF_PlayerFrame_XPBar_Bar2, bonuspercent, 1, DUF_Settings[DUF_INDEX].player.StatusBar[3].width);
236 end
237  
238 function DUF_ReputationBar_Update(bar)
239 local _, _, min, max, value = GetWatchedFactionInfo();
240 local percent = (value - min) / (max - min) * 100;
241 if (max - min == 0) then
242 percent = 0
243 end
244 local frame, frame2, sbi
245 if (bar == 1) then
246 frame = DUF_PlayerFrame_XPBar_Bar
247 frame2 = DUF_PlayerFrame_XPBar_Bar2
248 sbi = 3
249 else
250 frame = DUF_PlayerFrame_HonorBar_Bar
251 frame2 = DUF_PlayerFrame_HonorBar_Bar2
252 sbi = 6
253 end
254 DUF_StatusBar_SetValue(frame, percent, 1, DUF_Settings[DUF_INDEX].player.StatusBar[sbi].width);
255 DUF_StatusBar_SetValue(frame2, percent, 1, DUF_Settings[DUF_INDEX].player.StatusBar[sbi].width);
256 end
257  
258 function DUF_StatusBar_SetValue(bar, value)
259 if (value == 0) then value = .01; end
260 value = value / 100;
261 if (value > 1) then value = 1; end
262  
263 if (bar.direction < 3) then
264 bar:SetWidth(bar.length * value);
265 else
266 bar:SetHeight(bar.length * value);
267 end
268  
269 if (bar.direction == 1) then
270 bar:SetTexCoord(0, value, 0, 1);
271 elseif (bar.direction == 2) then
272 bar:SetTexCoord(value, 0, 0, 1);
273 elseif (bar.direction == 3) then
274 bar:SetTexCoord(0, 1, value, 0);
275 elseif (bar.direction == 4) then
276 bar:SetTexCoord(0, 1, 0, value);
277 end
278 end