vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --------------- |
2 | -- Variables -- |
||
3 | --------------- |
||
4 | Perl_CombatDisplay_Config = {}; |
||
5 | |||
6 | -- Default Saved Variables (also set in Perl_CombatDisplay_GetVars) |
||
7 | local state = 3; -- hidden unless in combat by default |
||
8 | local manapersist = 0; -- mana persist is off by default |
||
9 | local healthpersist = 0; -- health persist is off by default |
||
10 | local locked = 0; -- unlocked by default |
||
11 | local scale = 1; -- default scale |
||
12 | local transparency = 1; -- transparency for the frame |
||
13 | local showtarget = 0; -- target frame is disabled by default |
||
14 | local mobhealthsupport = 1; -- mobhealth is enabled by default |
||
15 | local showdruidbar = 1; -- Druid Bar support is enabled by default |
||
16 | local showpetbars = 0; -- Pet info is hidden by default |
||
17 | |||
18 | -- Default Local Variables |
||
19 | local IsAggroed = 0; |
||
20 | local InCombat = 0; |
||
21 | local Initialized = nil; |
||
22 | local healthfull = 0; |
||
23 | local manafull = 0; |
||
24 | |||
25 | |||
26 | ---------------------- |
||
27 | -- Loading Function -- |
||
28 | ---------------------- |
||
29 | function Perl_CombatDisplay_OnLoad() |
||
30 | -- Events |
||
31 | this:RegisterEvent("ADDON_LOADED"); |
||
32 | this:RegisterEvent("PLAYER_ENTER_COMBAT"); |
||
33 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
34 | this:RegisterEvent("PLAYER_LEAVE_COMBAT"); |
||
35 | this:RegisterEvent("PLAYER_REGEN_DISABLED"); |
||
36 | this:RegisterEvent("PLAYER_REGEN_ENABLED"); |
||
37 | this:RegisterEvent("PLAYER_TARGET_CHANGED"); |
||
38 | this:RegisterEvent("UNIT_DISPLAYPOWER"); |
||
39 | this:RegisterEvent("UNIT_ENERGY"); |
||
40 | this:RegisterEvent("UNIT_FOCUS"); |
||
41 | this:RegisterEvent("UNIT_HEALTH"); |
||
42 | this:RegisterEvent("UNIT_MANA"); |
||
43 | this:RegisterEvent("UNIT_MAXENERGY"); |
||
44 | this:RegisterEvent("UNIT_MAXFOCUS"); |
||
45 | this:RegisterEvent("UNIT_MAXHEALTH"); |
||
46 | this:RegisterEvent("UNIT_MAXMANA"); |
||
47 | this:RegisterEvent("UNIT_MAXRAGE"); |
||
48 | this:RegisterEvent("UNIT_PET"); |
||
49 | this:RegisterEvent("UNIT_RAGE"); |
||
50 | this:RegisterEvent("VARIABLES_LOADED"); |
||
51 | |||
52 | -- Button Click Overlays (in order of occurrence in XML) |
||
53 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetFrameLevel(Perl_CombatDisplay_ManaFrame:GetFrameLevel() + 2); |
||
54 | |||
55 | if (DEFAULT_CHAT_FRAME) then |
||
56 | DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Perl Classic: CombatDisplay loaded successfully."); |
||
57 | end |
||
58 | end |
||
59 | |||
60 | function Perl_CombatDisplay_Target_OnLoad() |
||
61 | -- Button Click Overlays (in order of occurrence in XML) |
||
62 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetFrameLevel(Perl_CombatDisplay_Target_ManaFrame:GetFrameLevel() + 2); |
||
63 | end |
||
64 | |||
65 | |||
66 | ------------------- |
||
67 | -- Event Handler -- |
||
68 | ------------------- |
||
69 | function Perl_CombatDisplay_OnEvent(event) |
||
70 | if (event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH") then |
||
71 | if (arg1 == "player") then |
||
72 | if (UnitHealth("player") == UnitHealthMax("player")) then |
||
73 | healthfull = 1; |
||
74 | if (healthpersist == 1) then |
||
75 | Perl_CombatDisplay_UpdateDisplay(); |
||
76 | end |
||
77 | else |
||
78 | healthfull = 0; |
||
79 | end |
||
80 | Perl_CombatDisplay_Update_Health(); |
||
81 | end |
||
82 | if (arg1 == "pet") then |
||
83 | if (showpetbars == 1) then |
||
84 | Perl_CombatDisplay_Update_PetHealth(); |
||
85 | end |
||
86 | end |
||
87 | if (arg1 == "target") then |
||
88 | Perl_CombatDisplay_Target_Update_Health(); |
||
89 | end |
||
90 | return; |
||
91 | elseif (event == "UNIT_ENERGY" or event == "UNIT_MAXENERGY") then |
||
92 | if (arg1 == "player") then |
||
93 | if (UnitMana("player") == UnitManaMax("player")) then |
||
94 | manafull = 1; |
||
95 | if (manapersist == 1) then |
||
96 | Perl_CombatDisplay_UpdateDisplay(); |
||
97 | end |
||
98 | else |
||
99 | manafull = 0; |
||
100 | end |
||
101 | Perl_CombatDisplay_Update_Mana(); |
||
102 | end |
||
103 | if (arg1 == "target") then |
||
104 | Perl_CombatDisplay_Target_Update_Mana(); |
||
105 | end |
||
106 | return; |
||
107 | elseif (event == "UNIT_MANA" or event == "UNIT_MAXMANA") then |
||
108 | if (arg1 == "player") then |
||
109 | if (UnitMana("player") == UnitManaMax("player")) then |
||
110 | manafull = 1; |
||
111 | if (manapersist == 1) then |
||
112 | Perl_CombatDisplay_UpdateDisplay(); |
||
113 | end |
||
114 | else |
||
115 | manafull = 0; |
||
116 | end |
||
117 | Perl_CombatDisplay_Update_Mana(); |
||
118 | end |
||
119 | if (arg1 == "pet") then |
||
120 | if (showpetbars == 1) then |
||
121 | Perl_CombatDisplay_Update_PetMana(); |
||
122 | end |
||
123 | end |
||
124 | if (arg1 == "target") then |
||
125 | Perl_CombatDisplay_Target_Update_Mana(); |
||
126 | end |
||
127 | return; |
||
128 | elseif (event == "UNIT_RAGE" or event == "UNIT_MAXRAGE") then |
||
129 | if (arg1 == "player") then |
||
130 | if (UnitMana("player") == 0) then |
||
131 | manafull = 1; |
||
132 | if (manapersist == 1) then |
||
133 | Perl_CombatDisplay_UpdateDisplay(); |
||
134 | end |
||
135 | else |
||
136 | manafull = 0; |
||
137 | end |
||
138 | Perl_CombatDisplay_Update_Mana(); |
||
139 | end |
||
140 | if (arg1 == "target") then |
||
141 | Perl_CombatDisplay_Target_Update_Mana(); |
||
142 | end |
||
143 | return; |
||
144 | elseif (event == "UNIT_FOCUS" or event == "UNIT_MAXFOCUS") then |
||
145 | if (arg1 == "pet") then |
||
146 | if (showpetbars == 1) then |
||
147 | Perl_CombatDisplay_Update_PetMana(); |
||
148 | end |
||
149 | end |
||
150 | elseif (event == "PLAYER_TARGET_CHANGED") then |
||
151 | Perl_CombatDisplay_UpdateDisplay(); |
||
152 | return; |
||
153 | elseif (event == "PLAYER_COMBO_POINTS") then |
||
154 | Perl_CombatDisplay_Update_Combo_Points(); |
||
155 | return; |
||
156 | elseif (event == "PLAYER_REGEN_ENABLED") then -- Player no longer in combat (something has agro on you) |
||
157 | IsAggroed = 0; |
||
158 | if (state == 3) then |
||
159 | Perl_CombatDisplay_UpdateDisplay(); |
||
160 | end |
||
161 | return; |
||
162 | elseif (event == "PLAYER_REGEN_DISABLED") then -- Player in combat (something has agro on you) |
||
163 | IsAggroed = 1; |
||
164 | if (state == 3) then |
||
165 | Perl_CombatDisplay_UpdateDisplay(); |
||
166 | end |
||
167 | return; |
||
168 | elseif (event == "PLAYER_ENTER_COMBAT") then -- Player attacking (auto attack) |
||
169 | InCombat = 1; |
||
170 | if (state == 2) then |
||
171 | Perl_CombatDisplay_UpdateDisplay(); |
||
172 | end |
||
173 | return; |
||
174 | elseif (event == "PLAYER_LEAVE_COMBAT") then -- Player not attacking (auto attack) |
||
175 | InCombat = 0; |
||
176 | if (state == 2) then |
||
177 | Perl_CombatDisplay_UpdateDisplay(); |
||
178 | end |
||
179 | return; |
||
180 | elseif (event == "UNIT_DISPLAYPOWER") then |
||
181 | if (arg1 == "player") then |
||
182 | Perl_CombatDisplay_UpdateBars(); |
||
183 | Perl_CombatDisplay_Update_Mana(); |
||
184 | if (InCombat == 0 and IsAggroed == 0) then |
||
185 | if (state == 1) then |
||
186 | Perl_CombatDisplay_Frame:Show(); |
||
187 | else |
||
188 | Perl_CombatDisplay_Frame:Hide(); |
||
189 | end |
||
190 | end |
||
191 | end |
||
192 | if (arg1 == "pet") then |
||
193 | if (showpetbars == 1) then |
||
194 | Perl_CombatDisplay_Update_PetManaBarColor(); -- What type of energy are we using now? |
||
195 | Perl_CombatDisplay_Update_PetMana(); -- Update the energy info immediately |
||
196 | end |
||
197 | end |
||
198 | return; |
||
199 | elseif (event == "UNIT_PET") then |
||
200 | Perl_CombatDisplay_CheckForPets(); |
||
201 | return; |
||
202 | elseif ((event == "VARIABLES_LOADED") or (event=="PLAYER_ENTERING_WORLD")) then |
||
203 | local powertype = UnitPowerType("player"); |
||
204 | InCombat = 0; |
||
205 | IsAggroed = 0; |
||
206 | |||
207 | if (UnitHealth("player") == UnitHealthMax("player")) then |
||
208 | healthfull = 1; |
||
209 | else |
||
210 | healthfull = 0; |
||
211 | end |
||
212 | if (powertype == 0 or powertype == 3) then |
||
213 | if (UnitMana("player") == UnitManaMax("player")) then |
||
214 | manafull = 1; |
||
215 | else |
||
216 | manafull = 0; |
||
217 | end |
||
218 | elseif (powertype == 1) then |
||
219 | if (UnitMana("player") == 0) then |
||
220 | manafull = 1; |
||
221 | else |
||
222 | manafull = 0; |
||
223 | end |
||
224 | end |
||
225 | |||
226 | -- Check if we loaded the mod already. |
||
227 | if (Initialized) then |
||
228 | Perl_CombatDisplay_UpdateBars(); -- what class are we? display the right color bars |
||
229 | Perl_CombatDisplay_Update_Health(); -- make sure we dont display 0/0 on load |
||
230 | Perl_CombatDisplay_Update_Mana(); -- make sure we dont display 0/0 on load |
||
231 | Perl_CombatDisplay_UpdateDisplay(); -- what mode are we in? |
||
232 | Perl_CombatDisplay_Set_Scale(); -- set the correct scale |
||
233 | Perl_CombatDisplay_Set_Transparency(); -- set the transparency |
||
234 | Perl_CombatDisplay_CheckForPets(); -- do we have a pet out? |
||
235 | else |
||
236 | Perl_CombatDisplay_Initialize(); |
||
237 | end |
||
238 | return; |
||
239 | elseif (event == "ADDON_LOADED") then |
||
240 | if (arg1 == "Perl_CombatDisplay") then |
||
241 | Perl_CombatDisplay_myAddOns_Support(); |
||
242 | end |
||
243 | return; |
||
244 | else |
||
245 | return; |
||
246 | end |
||
247 | end |
||
248 | |||
249 | |||
250 | ------------------------------- |
||
251 | -- Loading Settings Function -- |
||
252 | ------------------------------- |
||
253 | function Perl_CombatDisplay_Initialize() |
||
254 | -- Check if a previous exists, if not, enable by default. |
||
255 | if (type(Perl_CombatDisplay_Config[UnitName("player")]) == "table") then |
||
256 | Perl_CombatDisplay_GetVars(); |
||
257 | else |
||
258 | Perl_CombatDisplay_UpdateVars(); |
||
259 | end |
||
260 | |||
261 | -- Major config options. |
||
262 | Perl_CombatDisplay_Initialize_Frame_Color(); |
||
263 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
264 | |||
265 | Perl_CombatDisplay_UpdateBars(); -- Display the bars appropriate to your class |
||
266 | Perl_CombatDisplay_UpdateDisplay(); -- Show or hide the window based on whats happening |
||
267 | Perl_CombatDisplay_CheckForPets(); -- do we have a pet out? |
||
268 | |||
269 | Initialized = 1; |
||
270 | end |
||
271 | |||
272 | function Perl_CombatDisplay_Initialize_Frame_Color() |
||
273 | Perl_CombatDisplay_ManaFrame:SetBackdropColor(0, 0, 0, 1); |
||
274 | Perl_CombatDisplay_ManaFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
275 | Perl_CombatDisplay_HealthBarText:SetTextColor(1, 1, 1, 1); |
||
276 | Perl_CombatDisplay_ManaBarText:SetTextColor(1, 1, 1, 1); |
||
277 | Perl_CombatDisplay_CPBarText:SetTextColor(1, 1, 1, 1); |
||
278 | Perl_CombatDisplay_PetHealthBarText:SetTextColor(1, 1, 1, 1); |
||
279 | Perl_CombatDisplay_PetManaBarText:SetTextColor(1, 1, 1, 1); |
||
280 | |||
281 | Perl_CombatDisplay_Target_ManaFrame:SetBackdropColor(0, 0, 0, 1); |
||
282 | Perl_CombatDisplay_Target_ManaFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1); |
||
283 | Perl_CombatDisplay_Target_HealthBarText:SetTextColor(1, 1, 1, 1); |
||
284 | Perl_CombatDisplay_Target_ManaBarText:SetTextColor(1, 1, 1, 1); |
||
285 | end |
||
286 | |||
287 | |||
288 | ---------------------- |
||
289 | -- Update Functions -- |
||
290 | ---------------------- |
||
291 | function Perl_CombatDisplay_UpdateDisplay() |
||
292 | if (state == 0) then |
||
293 | Perl_CombatDisplay_Frame:Hide(); |
||
294 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
295 | Perl_CombatDisplay_Frame:StopMovingOrSizing(); |
||
296 | Perl_CombatDisplay_Target_Frame:StopMovingOrSizing(); |
||
297 | elseif (state == 1) then |
||
298 | Perl_CombatDisplay_Frame:Show(); |
||
299 | Perl_CombatDisplay_Target_Show(); |
||
300 | elseif (state == 2) then |
||
301 | if (InCombat == 1) then |
||
302 | Perl_CombatDisplay_Frame:Show(); |
||
303 | Perl_CombatDisplay_Target_Show(); |
||
304 | elseif (manapersist == 1 and manafull == 0) then |
||
305 | Perl_CombatDisplay_Frame:Show(); |
||
306 | Perl_CombatDisplay_Target_Show(); |
||
307 | elseif (healthpersist == 1 and healthfull == 0) then |
||
308 | Perl_CombatDisplay_Frame:Show(); |
||
309 | Perl_CombatDisplay_Target_Show(); |
||
310 | else |
||
311 | Perl_CombatDisplay_Frame:Hide(); |
||
312 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
313 | Perl_CombatDisplay_Frame:StopMovingOrSizing(); |
||
314 | Perl_CombatDisplay_Target_Frame:StopMovingOrSizing(); |
||
315 | end |
||
316 | elseif (state == 3) then |
||
317 | if (IsAggroed == 1) then |
||
318 | Perl_CombatDisplay_Frame:Show(); |
||
319 | Perl_CombatDisplay_Target_Show(); |
||
320 | elseif (manapersist == 1 and manafull == 0) then |
||
321 | Perl_CombatDisplay_Frame:Show(); |
||
322 | Perl_CombatDisplay_Target_Show(); |
||
323 | elseif (healthpersist == 1 and healthfull == 0) then |
||
324 | Perl_CombatDisplay_Frame:Show(); |
||
325 | Perl_CombatDisplay_Target_Show(); |
||
326 | else |
||
327 | Perl_CombatDisplay_Frame:Hide(); |
||
328 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
329 | Perl_CombatDisplay_Frame:StopMovingOrSizing(); |
||
330 | Perl_CombatDisplay_Target_Frame:StopMovingOrSizing(); |
||
331 | end |
||
332 | end |
||
333 | end |
||
334 | |||
335 | function Perl_CombatDisplay_Update_Health() |
||
336 | local playerhealth = UnitHealth("player"); |
||
337 | local playerhealthmax = UnitHealthMax("player"); |
||
338 | |||
339 | if (UnitIsDead("player") or UnitIsGhost("player")) then -- This prevents negative health |
||
340 | playerhealth = 0; |
||
341 | end |
||
342 | |||
343 | if (PCUF_COLORHEALTH == 1) then |
||
344 | local playerhealthpercent = floor(playerhealth/playerhealthmax*100+0.5); |
||
345 | if ((playerhealthpercent <= 100) and (playerhealthpercent > 75)) then |
||
346 | Perl_CombatDisplay_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
347 | Perl_CombatDisplay_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
348 | elseif ((playerhealthpercent <= 75) and (playerhealthpercent > 50)) then |
||
349 | Perl_CombatDisplay_HealthBar:SetStatusBarColor(1, 1, 0); |
||
350 | Perl_CombatDisplay_HealthBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
351 | elseif ((playerhealthpercent <= 50) and (playerhealthpercent > 25)) then |
||
352 | Perl_CombatDisplay_HealthBar:SetStatusBarColor(1, 0.5, 0); |
||
353 | Perl_CombatDisplay_HealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
354 | else |
||
355 | Perl_CombatDisplay_HealthBar:SetStatusBarColor(1, 0, 0); |
||
356 | Perl_CombatDisplay_HealthBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
357 | end |
||
358 | else |
||
359 | Perl_CombatDisplay_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
360 | Perl_CombatDisplay_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
361 | end |
||
362 | |||
363 | Perl_CombatDisplay_HealthBar:SetMinMaxValues(0, playerhealthmax); |
||
364 | Perl_CombatDisplay_HealthBar:SetValue(playerhealth); |
||
365 | Perl_CombatDisplay_HealthBarText:SetText(playerhealth.."/"..playerhealthmax); |
||
366 | end |
||
367 | |||
368 | function Perl_CombatDisplay_Update_Mana() |
||
369 | local playermana = UnitMana("player"); |
||
370 | local playermanamax = UnitManaMax("player"); |
||
371 | local playerpower = UnitPowerType("player"); |
||
372 | |||
373 | if (UnitIsDead("player") or UnitIsGhost("player")) then -- This prevents negative mana |
||
374 | playermana = 0; |
||
375 | end |
||
376 | |||
377 | Perl_CombatDisplay_ManaBar:SetMinMaxValues(0, playermanamax); |
||
378 | Perl_CombatDisplay_ManaBar:SetValue(playermana); |
||
379 | |||
380 | if (playerpower == 1) then |
||
381 | Perl_CombatDisplay_ManaBarText:SetText(playermana); |
||
382 | else |
||
383 | Perl_CombatDisplay_ManaBarText:SetText(playermana.."/"..playermanamax); |
||
384 | end |
||
385 | |||
386 | if (showdruidbar == 1) then |
||
387 | if (DruidBarKey and (UnitClass("player") == PERL_LOCALIZED_DRUID)) then |
||
388 | if (playerpower > 0) then |
||
389 | -- Show the bars and set the text and reposition the original mana bar below the druid bar |
||
390 | local playerdruidbarmana = floor(DruidBarKey.keepthemana); |
||
391 | local playerdruidbarmanamax = DruidBarKey.maxmana; |
||
392 | local playerdruidbarmanapercent = floor(playerdruidbarmana/playerdruidbarmanamax*100+0.5); |
||
393 | |||
394 | if (playerdruidbarmanapercent == 100) then -- This is to ensure the value isn't 1 or 2 mana under max when 100% |
||
395 | playerdruidbarmana = playerdruidbarmanamax; |
||
396 | end |
||
397 | |||
398 | Perl_CombatDisplay_DruidBar:SetMinMaxValues(0, playerdruidbarmanamax); |
||
399 | Perl_CombatDisplay_DruidBar:SetValue(playerdruidbarmana); |
||
400 | |||
401 | -- Show the bar and adjust the stats frame |
||
402 | Perl_CombatDisplay_DruidBar:Show(); |
||
403 | Perl_CombatDisplay_DruidBarBG:Show(); |
||
404 | Perl_CombatDisplay_ManaBar:SetPoint("TOP", "Perl_CombatDisplay_DruidBar", "BOTTOM", 0, -2); |
||
405 | if (playerpower == 3) then |
||
406 | Perl_CombatDisplay_ManaFrame:SetHeight(66); -- Energy and Combo Points |
||
407 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(66); |
||
408 | else |
||
409 | Perl_CombatDisplay_ManaFrame:SetHeight(54); -- Rage |
||
410 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(54); |
||
411 | end |
||
412 | |||
413 | -- Display the needed text |
||
414 | Perl_CombatDisplay_DruidBarText:SetText(playerdruidbarmana.."/"..playerdruidbarmanamax); |
||
415 | else |
||
416 | -- Hide it all (bars and text) |
||
417 | Perl_CombatDisplay_DruidBarText:SetText(); |
||
418 | Perl_CombatDisplay_DruidBar:Hide(); |
||
419 | Perl_CombatDisplay_DruidBarBG:Hide(); |
||
420 | Perl_CombatDisplay_ManaBar:SetPoint("TOP", "Perl_CombatDisplay_HealthBar", "BOTTOM", 0, -2); |
||
421 | if (playerpower == 3) then |
||
422 | Perl_CombatDisplay_ManaFrame:SetHeight(54); -- Energy and Combo Points |
||
423 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(54); |
||
424 | else |
||
425 | Perl_CombatDisplay_ManaFrame:SetHeight(42); -- Using mana or rage, use default height |
||
426 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(42); |
||
427 | end |
||
428 | end |
||
429 | else |
||
430 | -- Hide it all (bars and text) |
||
431 | Perl_CombatDisplay_DruidBarText:SetText(); |
||
432 | Perl_CombatDisplay_DruidBar:Hide(); |
||
433 | Perl_CombatDisplay_DruidBarBG:Hide(); |
||
434 | Perl_CombatDisplay_ManaBar:SetPoint("TOP", "Perl_CombatDisplay_HealthBar", "BOTTOM", 0, -2); |
||
435 | if (playerpower == 3) then |
||
436 | Perl_CombatDisplay_ManaFrame:SetHeight(54); -- Energy and Combo Points |
||
437 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(54); |
||
438 | else |
||
439 | Perl_CombatDisplay_ManaFrame:SetHeight(42); -- Using mana or rage, use default height |
||
440 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(42); |
||
441 | end |
||
442 | end |
||
443 | else |
||
444 | -- Hide it all (bars and text) |
||
445 | Perl_CombatDisplay_DruidBarText:SetText(); |
||
446 | Perl_CombatDisplay_DruidBar:Hide(); |
||
447 | Perl_CombatDisplay_DruidBarBG:Hide(); |
||
448 | Perl_CombatDisplay_ManaBar:SetPoint("TOP", "Perl_CombatDisplay_HealthBar", "BOTTOM", 0, -2); |
||
449 | if (playerpower == 3) then |
||
450 | Perl_CombatDisplay_ManaFrame:SetHeight(54); -- Energy and Combo Points |
||
451 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(54); |
||
452 | else |
||
453 | Perl_CombatDisplay_ManaFrame:SetHeight(42); -- Using mana or rage, use default height |
||
454 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(42); |
||
455 | end |
||
456 | end |
||
457 | |||
458 | if (showpetbars == 1) then -- running this check here since all the previous if's will undo it if i don't |
||
459 | if (UnitExists("pet")) then |
||
460 | Perl_CombatDisplay_ManaFrame:SetHeight(66); -- health and mana/focus bar |
||
461 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(66); |
||
462 | end |
||
463 | end |
||
464 | end |
||
465 | |||
466 | function Perl_CombatDisplay_Update_Combo_Points() |
||
467 | Perl_CombatDisplay_CPBarText:SetText(GetComboPoints()..'/5'); |
||
468 | Perl_CombatDisplay_CPBar:SetValue(GetComboPoints()); |
||
469 | end |
||
470 | |||
471 | function Perl_CombatDisplay_UpdateBars() |
||
472 | local playerpower = UnitPowerType("player"); |
||
473 | |||
474 | -- Set power type specific events and colors. |
||
475 | if (playerpower == 0) then -- mana |
||
476 | Perl_CombatDisplay_ManaBar:SetStatusBarColor(0, 0, 1, 1); |
||
477 | Perl_CombatDisplay_ManaBarBG:SetStatusBarColor(0, 0, 1, 0.25); |
||
478 | -- Hide CP Bar |
||
479 | Perl_CombatDisplay_CPBar:Hide(); |
||
480 | Perl_CombatDisplay_CPBarBG:Hide(); |
||
481 | Perl_CombatDisplay_CPBarText:Hide(); |
||
482 | Perl_CombatDisplay_ManaFrame:SetHeight(42); |
||
483 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(42); |
||
484 | return; |
||
485 | elseif (playerpower == 1) then -- rage |
||
486 | Perl_CombatDisplay_ManaBar:SetStatusBarColor(1, 0, 0, 1); |
||
487 | Perl_CombatDisplay_ManaBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
488 | -- Hide CP Bar |
||
489 | Perl_CombatDisplay_CPBar:Hide(); |
||
490 | Perl_CombatDisplay_CPBarBG:Hide(); |
||
491 | Perl_CombatDisplay_CPBarText:Hide(); |
||
492 | Perl_CombatDisplay_ManaFrame:SetHeight(42); |
||
493 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(42); |
||
494 | return; |
||
495 | elseif (playerpower == 3) then -- energy |
||
496 | this:RegisterEvent("PLAYER_COMBO_POINTS"); |
||
497 | Perl_CombatDisplay_ManaBar:SetStatusBarColor(1, 1, 0, 1); |
||
498 | Perl_CombatDisplay_ManaBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
499 | -- Setup CP Bar |
||
500 | Perl_CombatDisplay_CPBar:Show(); |
||
501 | Perl_CombatDisplay_CPBarBG:Show(); |
||
502 | Perl_CombatDisplay_CPBarText:Show(); |
||
503 | Perl_CombatDisplay_CPBarText:SetText('0/5'); |
||
504 | Perl_CombatDisplay_ManaFrame:SetHeight(54); |
||
505 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(54); |
||
506 | Perl_CombatDisplay_CPBar:SetMinMaxValues(0,5); |
||
507 | Perl_CombatDisplay_CPBar:SetValue(GetComboPoints()); |
||
508 | return; |
||
509 | end |
||
510 | end |
||
511 | |||
512 | function Perl_CombatDisplay_CheckForPets() |
||
513 | if (showpetbars == 1 and UnitExists("pet")) then |
||
514 | Perl_CombatDisplay_PetHealthBar:Show(); |
||
515 | Perl_CombatDisplay_PetHealthBarBG:Show(); |
||
516 | Perl_CombatDisplay_PetManaBar:Show(); |
||
517 | Perl_CombatDisplay_PetManaBarBG:Show(); |
||
518 | Perl_CombatDisplay_ManaFrame:SetHeight(66); -- health and mana/focus bar |
||
519 | Perl_CombatDisplay_ManaFrame_CastClickOverlay:SetHeight(66); |
||
520 | Perl_CombatDisplay_Update_PetManaBarColor(); |
||
521 | Perl_CombatDisplay_Update_PetHealth(); |
||
522 | Perl_CombatDisplay_Update_PetMana(); |
||
523 | else |
||
524 | Perl_CombatDisplay_PetHealthBar:Hide(); |
||
525 | Perl_CombatDisplay_PetHealthBarBG:Hide(); |
||
526 | Perl_CombatDisplay_PetManaBar:Hide(); |
||
527 | Perl_CombatDisplay_PetManaBarBG:Hide(); |
||
528 | Perl_CombatDisplay_UpdateBars(); |
||
529 | end |
||
530 | end |
||
531 | |||
532 | function Perl_CombatDisplay_Update_PetManaBarColor() |
||
533 | local petpower = UnitPowerType("pet"); |
||
534 | -- Set mana bar color |
||
535 | if (petpower == 0) then -- mana |
||
536 | Perl_CombatDisplay_PetManaBar:SetStatusBarColor(0, 0, 1, 1); |
||
537 | Perl_CombatDisplay_PetManaBarBG:SetStatusBarColor(0, 0, 1, 0.25); |
||
538 | elseif (petpower == 2) then -- focus |
||
539 | Perl_CombatDisplay_PetManaBar:SetStatusBarColor(1, 0.5, 0, 1); |
||
540 | Perl_CombatDisplay_PetManaBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
541 | end |
||
542 | end |
||
543 | |||
544 | function Perl_CombatDisplay_Update_PetHealth() |
||
545 | local pethealth = UnitHealth("pet"); |
||
546 | local pethealthmax = UnitHealthMax("pet"); |
||
547 | |||
548 | if (UnitIsDead("pet") or UnitIsGhost("pet")) then -- This prevents negative health |
||
549 | pethealth = 0; |
||
550 | end |
||
551 | |||
552 | if (PCUF_COLORHEALTH == 1) then |
||
553 | local pethealthpercent = floor(pethealth/pethealthmax*100+0.5); |
||
554 | if ((pethealthpercent <= 100) and (pethealthpercent > 75)) then |
||
555 | Perl_CombatDisplay_PetHealthBar:SetStatusBarColor(0, 0.8, 0); |
||
556 | Perl_CombatDisplay_PetHealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
557 | elseif ((pethealthpercent <= 75) and (pethealthpercent > 50)) then |
||
558 | Perl_CombatDisplay_PetHealthBar:SetStatusBarColor(1, 1, 0); |
||
559 | Perl_CombatDisplay_PetHealthBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
560 | elseif ((pethealthpercent <= 50) and (pethealthpercent > 25)) then |
||
561 | Perl_CombatDisplay_PetHealthBar:SetStatusBarColor(1, 0.5, 0); |
||
562 | Perl_CombatDisplay_PetHealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
563 | else |
||
564 | Perl_CombatDisplay_PetHealthBar:SetStatusBarColor(1, 0, 0); |
||
565 | Perl_CombatDisplay_PetHealthBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
566 | end |
||
567 | else |
||
568 | Perl_CombatDisplay_PetHealthBar:SetStatusBarColor(0, 0.8, 0); |
||
569 | Perl_CombatDisplay_PetHealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
570 | end |
||
571 | |||
572 | Perl_CombatDisplay_PetHealthBar:SetMinMaxValues(0, pethealthmax); |
||
573 | Perl_CombatDisplay_PetHealthBar:SetValue(pethealth); |
||
574 | Perl_CombatDisplay_PetHealthBarText:SetText(pethealth.."/"..pethealthmax); |
||
575 | end |
||
576 | |||
577 | function Perl_CombatDisplay_Update_PetMana() |
||
578 | local petmana = UnitMana("pet"); |
||
579 | local petmanamax = UnitManaMax("pet"); |
||
580 | local petpower = UnitPowerType("pet"); |
||
581 | |||
582 | if (UnitIsDead("pet") or UnitIsGhost("pet")) then -- This prevents negative mana |
||
583 | petmana = 0; |
||
584 | end |
||
585 | |||
586 | Perl_CombatDisplay_PetManaBar:SetMinMaxValues(0, petmanamax); |
||
587 | Perl_CombatDisplay_PetManaBar:SetValue(petmana); |
||
588 | |||
589 | if (petpower == 2) then |
||
590 | Perl_CombatDisplay_PetManaBarText:SetText(petmana); |
||
591 | else |
||
592 | Perl_CombatDisplay_PetManaBarText:SetText(petmana.."/"..petmanamax); |
||
593 | end |
||
594 | end |
||
595 | |||
596 | |||
597 | ------------------------------- |
||
598 | -- Update Functions (Target) -- |
||
599 | ------------------------------- |
||
600 | function Perl_CombatDisplay_Target_UpdateAll() |
||
601 | if (UnitExists("target")) then |
||
602 | Perl_CombatDisplay_Target_Update_Health(); |
||
603 | Perl_CombatDisplay_Target_Update_Mana(); |
||
604 | Perl_CombatDisplay_Target_UpdateBars(); |
||
605 | end |
||
606 | end |
||
607 | |||
608 | function Perl_CombatDisplay_Target_Update_Health() |
||
609 | local targethealth = UnitHealth("target"); |
||
610 | local targethealthmax = UnitHealthMax("target"); |
||
611 | |||
612 | if (UnitIsDead("target") or UnitIsGhost("target")) then -- This prevents negative health |
||
613 | targethealth = 0; |
||
614 | end |
||
615 | |||
616 | if (PCUF_COLORHEALTH == 1) then |
||
617 | local targethealthpercent = floor(targethealth/targethealthmax*100+0.5); |
||
618 | if ((targethealthpercent <= 100) and (targethealthpercent > 75)) then |
||
619 | Perl_CombatDisplay_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
620 | Perl_CombatDisplay_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
621 | elseif ((targethealthpercent <= 75) and (targethealthpercent > 50)) then |
||
622 | Perl_CombatDisplay_Target_HealthBar:SetStatusBarColor(1, 1, 0); |
||
623 | Perl_CombatDisplay_Target_HealthBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
624 | elseif ((targethealthpercent <= 50) and (targethealthpercent > 25)) then |
||
625 | Perl_CombatDisplay_Target_HealthBar:SetStatusBarColor(1, 0.5, 0); |
||
626 | Perl_CombatDisplay_Target_HealthBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
627 | else |
||
628 | Perl_CombatDisplay_Target_HealthBar:SetStatusBarColor(1, 0, 0); |
||
629 | Perl_CombatDisplay_Target_HealthBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
630 | end |
||
631 | else |
||
632 | Perl_CombatDisplay_Target_HealthBar:SetStatusBarColor(0, 0.8, 0); |
||
633 | Perl_CombatDisplay_Target_HealthBarBG:SetStatusBarColor(0, 0.8, 0, 0.25); |
||
634 | end |
||
635 | |||
636 | Perl_CombatDisplay_Target_HealthBar:SetMinMaxValues(0, targethealthmax); |
||
637 | Perl_CombatDisplay_Target_HealthBar:SetValue(targethealth); |
||
638 | |||
639 | if (targethealthmax == 100) then |
||
640 | -- Begin Mobhealth support |
||
641 | if (mobhealthsupport == 1) then |
||
642 | if (MobHealthFrame) then |
||
643 | local index; |
||
644 | if UnitIsPlayer("target") then |
||
645 | index = UnitName("target"); |
||
646 | else |
||
647 | index = UnitName("target")..":"..UnitLevel("target"); |
||
648 | end |
||
649 | |||
650 | if ((MobHealthDB and MobHealthDB[index]) or (MobHealthPlayerDB and MobHealthPlayerDB[index])) then |
||
651 | local s, e; |
||
652 | local pts; |
||
653 | local pct; |
||
654 | |||
655 | if MobHealthDB[index] then |
||
656 | if (type(MobHealthDB[index]) ~= "string") then |
||
657 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."%"); |
||
658 | end |
||
659 | s, e, pts, pct = string.find(MobHealthDB[index], "^(%d+)/(%d+)$"); |
||
660 | else |
||
661 | if (type(MobHealthPlayerDB[index]) ~= "string") then |
||
662 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."%"); |
||
663 | end |
||
664 | s, e, pts, pct = string.find(MobHealthPlayerDB[index], "^(%d+)/(%d+)$"); |
||
665 | end |
||
666 | |||
667 | if (pts and pct) then |
||
668 | pts = pts + 0; |
||
669 | pct = pct + 0; |
||
670 | if (pct ~= 0) then |
||
671 | pointsPerPct = pts / pct; |
||
672 | else |
||
673 | pointsPerPct = 0; |
||
674 | end |
||
675 | end |
||
676 | |||
677 | local currentPct = UnitHealth("target"); |
||
678 | if (pointsPerPct > 0) then |
||
679 | Perl_CombatDisplay_Target_HealthBarText:SetText(string.format("%d", (currentPct * pointsPerPct) + 0.5).."/"..string.format("%d", (100 * pointsPerPct) + 0.5).." | "..targethealth.."%"); -- Stored unit info from the DB |
||
680 | end |
||
681 | else |
||
682 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."%"); -- Unit not in MobHealth DB |
||
683 | end |
||
684 | -- End MobHealth Support |
||
685 | else |
||
686 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."%"); -- MobHealth isn't installed |
||
687 | end |
||
688 | else -- mobhealthsupport == 0 |
||
689 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."%"); -- MobHealth support is disabled |
||
690 | end |
||
691 | else |
||
692 | Perl_CombatDisplay_Target_HealthBarText:SetText(targethealth.."/"..targethealthmax); -- Self/Party/Raid member |
||
693 | end |
||
694 | end |
||
695 | |||
696 | function Perl_CombatDisplay_Target_Update_Mana() |
||
697 | local targetmana = UnitMana("target"); |
||
698 | local targetmanamax = UnitManaMax("target"); |
||
699 | local targetpowertype = UnitPowerType("target"); |
||
700 | |||
701 | if (UnitIsDead("target") or UnitIsGhost("target")) then -- This prevents negative mana |
||
702 | targetmana = 0; |
||
703 | end |
||
704 | |||
705 | Perl_CombatDisplay_Target_ManaBar:SetMinMaxValues(0, targetmanamax); |
||
706 | Perl_CombatDisplay_Target_ManaBar:SetValue(targetmana); |
||
707 | |||
708 | if (targetpowertype == 1 or targetpowertype == 2) then |
||
709 | Perl_CombatDisplay_Target_ManaBarText:SetText(targetmana); |
||
710 | else |
||
711 | Perl_CombatDisplay_Target_ManaBarText:SetText(targetmana.."/"..targetmanamax); |
||
712 | end |
||
713 | end |
||
714 | |||
715 | function Perl_CombatDisplay_Target_UpdateBars() |
||
716 | local targetmanamax = UnitManaMax("target"); |
||
717 | local targetpowertype = UnitPowerType("target"); |
||
718 | |||
719 | -- Set power type specific events and colors. |
||
720 | if (targetmanamax == 0) then |
||
721 | Perl_CombatDisplay_Target_ManaBar:Hide(); |
||
722 | Perl_CombatDisplay_Target_ManaBarBG:Hide(); |
||
723 | Perl_CombatDisplay_Target_ManaFrame:SetHeight(30); |
||
724 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetHeight(30); |
||
725 | elseif (targetpowertype == 0) then -- mana |
||
726 | Perl_CombatDisplay_Target_ManaBar:SetStatusBarColor(0, 0, 1, 1); |
||
727 | Perl_CombatDisplay_Target_ManaBarBG:SetStatusBarColor(0, 0, 1, 0.25); |
||
728 | Perl_CombatDisplay_Target_ManaBar:Show(); |
||
729 | Perl_CombatDisplay_Target_ManaBarBG:Show(); |
||
730 | Perl_CombatDisplay_Target_ManaFrame:SetHeight(42); |
||
731 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetHeight(42); |
||
732 | return; |
||
733 | elseif (targetpowertype == 1) then -- rage |
||
734 | Perl_CombatDisplay_Target_ManaBar:SetStatusBarColor(1, 0, 0, 1); |
||
735 | Perl_CombatDisplay_Target_ManaBarBG:SetStatusBarColor(1, 0, 0, 0.25); |
||
736 | Perl_CombatDisplay_Target_ManaBar:Show(); |
||
737 | Perl_CombatDisplay_Target_ManaBarBG:Show(); |
||
738 | Perl_CombatDisplay_Target_ManaFrame:SetHeight(42); |
||
739 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetHeight(42); |
||
740 | return; |
||
741 | elseif (targetpowertype == 2) then -- focus |
||
742 | Perl_CombatDisplay_Target_ManaBar:SetStatusBarColor(1, 0.5, 0, 1); |
||
743 | Perl_CombatDisplay_Target_ManaBarBG:SetStatusBarColor(1, 0.5, 0, 0.25); |
||
744 | Perl_CombatDisplay_Target_ManaBar:Show(); |
||
745 | Perl_CombatDisplay_Target_ManaBarBG:Show(); |
||
746 | Perl_CombatDisplay_Target_ManaFrame:SetHeight(42); |
||
747 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetHeight(42); |
||
748 | return; |
||
749 | elseif (targetpowertype == 3) then -- energy |
||
750 | Perl_CombatDisplay_Target_ManaBar:SetStatusBarColor(1, 1, 0, 1); |
||
751 | Perl_CombatDisplay_Target_ManaBarBG:SetStatusBarColor(1, 1, 0, 0.25); |
||
752 | Perl_CombatDisplay_Target_ManaBar:Show(); |
||
753 | Perl_CombatDisplay_Target_ManaBarBG:Show(); |
||
754 | Perl_CombatDisplay_Target_ManaFrame:SetHeight(42); |
||
755 | Perl_CombatDisplay_Target_ManaFrame_CastClickOverlay:SetHeight(42); |
||
756 | return; |
||
757 | end |
||
758 | end |
||
759 | |||
760 | function Perl_CombatDisplay_Target_Show() |
||
761 | if (showtarget == 1) then |
||
762 | if (UnitExists("target")) then |
||
763 | Perl_CombatDisplay_Target_Frame:Show(); |
||
764 | Perl_CombatDisplay_Target_UpdateAll(); |
||
765 | else |
||
766 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
767 | end |
||
768 | end |
||
769 | end |
||
770 | |||
771 | |||
772 | -------------------------- |
||
773 | -- GUI Config Functions -- |
||
774 | -------------------------- |
||
775 | function Perl_CombatDisplay_Set_State(newvalue) |
||
776 | state = newvalue; |
||
777 | Perl_CombatDisplay_UpdateVars(); |
||
778 | Perl_CombatDisplay_UpdateDisplay(); |
||
779 | end |
||
780 | |||
781 | function Perl_CombatDisplay_Set_Health_Persistance(newvalue) |
||
782 | healthpersist = newvalue; |
||
783 | Perl_CombatDisplay_UpdateVars(); |
||
784 | Perl_CombatDisplay_UpdateDisplay(); |
||
785 | end |
||
786 | |||
787 | function Perl_CombatDisplay_Set_Mana_Persistance(newvalue) |
||
788 | manapersist = newvalue; |
||
789 | Perl_CombatDisplay_UpdateVars(); |
||
790 | Perl_CombatDisplay_UpdateDisplay(); |
||
791 | end |
||
792 | |||
793 | function Perl_CombatDisplay_Set_Lock(newvalue) |
||
794 | locked = newvalue; |
||
795 | Perl_CombatDisplay_UpdateVars(); |
||
796 | end |
||
797 | |||
798 | function Perl_CombatDisplay_Set_Target(newvalue) |
||
799 | showtarget = newvalue; |
||
800 | Perl_CombatDisplay_UpdateVars(); |
||
801 | if (showtarget == 0) then |
||
802 | Perl_CombatDisplay_Target_Frame:Hide(); |
||
803 | end |
||
804 | Perl_CombatDisplay_UpdateDisplay(); |
||
805 | end |
||
806 | |||
807 | function Perl_CombatDisplay_Set_MobHealth(newvalue) |
||
808 | mobhealthsupport = newvalue; |
||
809 | Perl_CombatDisplay_UpdateVars(); |
||
810 | Perl_CombatDisplay_Target_Update_Health(); |
||
811 | end |
||
812 | |||
813 | function Perl_CombatDisplay_Set_DruidBar(newvalue) |
||
814 | showdruidbar = newvalue; |
||
815 | Perl_CombatDisplay_UpdateVars(); |
||
816 | Perl_CombatDisplay_Update_Mana(); |
||
817 | end |
||
818 | |||
819 | function Perl_CombatDisplay_Set_PetBars(newvalue) |
||
820 | showpetbars = newvalue; |
||
821 | Perl_CombatDisplay_UpdateVars(); |
||
822 | Perl_CombatDisplay_CheckForPets(); |
||
823 | end |
||
824 | |||
825 | function Perl_CombatDisplay_Set_Scale(number) |
||
826 | local unsavedscale; |
||
827 | if (number ~= nil) then |
||
828 | scale = (number / 100); -- convert the user input to a wow acceptable value |
||
829 | end |
||
830 | unsavedscale = 1 - UIParent:GetEffectiveScale() + scale; -- run it through the scaling formula introduced in 1.9 |
||
831 | Perl_CombatDisplay_Frame:SetScale(unsavedscale); |
||
832 | Perl_CombatDisplay_Target_Frame:SetScale(unsavedscale); |
||
833 | Perl_CombatDisplay_UpdateVars(); |
||
834 | end |
||
835 | |||
836 | function Perl_CombatDisplay_Set_Transparency(number) |
||
837 | if (number ~= nil) then |
||
838 | transparency = (number / 100); -- convert the user input to a wow acceptable value |
||
839 | end |
||
840 | Perl_CombatDisplay_Frame:SetAlpha(transparency); |
||
841 | Perl_CombatDisplay_Target_Frame:SetAlpha(transparency); |
||
842 | Perl_CombatDisplay_UpdateVars(); |
||
843 | end |
||
844 | |||
845 | |||
846 | ------------------------------ |
||
847 | -- Saved Variable Functions -- |
||
848 | ------------------------------ |
||
849 | function Perl_CombatDisplay_GetVars() |
||
850 | state = Perl_CombatDisplay_Config[UnitName("player")]["State"]; |
||
851 | locked = Perl_CombatDisplay_Config[UnitName("player")]["Locked"]; |
||
852 | healthpersist = Perl_CombatDisplay_Config[UnitName("player")]["HealthPersist"]; |
||
853 | manapersist = Perl_CombatDisplay_Config[UnitName("player")]["ManaPersist"]; |
||
854 | scale = Perl_CombatDisplay_Config[UnitName("player")]["Scale"]; |
||
855 | transparency = Perl_CombatDisplay_Config[UnitName("player")]["Transparency"]; |
||
856 | showtarget = Perl_CombatDisplay_Config[UnitName("player")]["ShowTarget"]; |
||
857 | mobhealthsupport = Perl_CombatDisplay_Config[UnitName("player")]["MobHealthSupport"]; |
||
858 | showdruidbar = Perl_CombatDisplay_Config[UnitName("player")]["ShowDruidBar"]; |
||
859 | showpetbars = Perl_CombatDisplay_Config[UnitName("player")]["ShowPetBars"]; |
||
860 | |||
861 | if (state == nil) then |
||
862 | state = 3; |
||
863 | end |
||
864 | if (locked == nil) then |
||
865 | locked = 0; |
||
866 | end |
||
867 | if (healthpersist == nil) then |
||
868 | healthpersist = 0; |
||
869 | end |
||
870 | if (manapersist == nil) then |
||
871 | manapersist = 0; |
||
872 | end |
||
873 | if (scale == nil) then |
||
874 | scale = 1; |
||
875 | end |
||
876 | if (transparency == nil) then |
||
877 | transparency = 1; |
||
878 | end |
||
879 | if (showtarget == nil) then |
||
880 | showtarget = 0; |
||
881 | end |
||
882 | if (mobhealthsupport == nil) then |
||
883 | mobhealthsupport = 1; |
||
884 | end |
||
885 | if (showdruidbar == nil) then |
||
886 | showdruidbar = 1; |
||
887 | end |
||
888 | if (showpetbars == nil) then |
||
889 | showpetbars = 0; |
||
890 | end |
||
891 | |||
892 | local vars = { |
||
893 | ["state"] = state, |
||
894 | ["manapersist"] = manapersist, |
||
895 | ["healthpersist"] = healthpersist, |
||
896 | ["locked"] = locked, |
||
897 | ["scale"] = scale, |
||
898 | ["transparency"] = transparency, |
||
899 | ["showtarget"] = showtarget, |
||
900 | ["mobhealthsupport"] = mobhealthsupport, |
||
901 | ["showdruidbar"] = showdruidbar, |
||
902 | ["showpetbars"] = showpetbars, |
||
903 | } |
||
904 | return vars; |
||
905 | end |
||
906 | |||
907 | function Perl_CombatDisplay_UpdateVars(vartable) |
||
908 | if (vartable ~= nil) then |
||
909 | -- Sanity checks in case you use a load from an old version |
||
910 | if (vartable["Global Settings"] ~= nil) then |
||
911 | if (vartable["Global Settings"]["State"] ~= nil) then |
||
912 | state = vartable["Global Settings"]["State"]; |
||
913 | else |
||
914 | state = nil; |
||
915 | end |
||
916 | if (vartable["Global Settings"]["Locked"] ~= nil) then |
||
917 | locked = vartable["Global Settings"]["Locked"]; |
||
918 | else |
||
919 | locked = nil; |
||
920 | end |
||
921 | if (vartable["Global Settings"]["HealthPersist"] ~= nil) then |
||
922 | healthpersist = vartable["Global Settings"]["HealthPersist"]; |
||
923 | else |
||
924 | healthpersist = nil; |
||
925 | end |
||
926 | if (vartable["Global Settings"]["ManaPersist"] ~= nil) then |
||
927 | manapersist = vartable["Global Settings"]["ManaPersist"]; |
||
928 | else |
||
929 | manapersist = nil; |
||
930 | end |
||
931 | if (vartable["Global Settings"]["Scale"] ~= nil) then |
||
932 | scale = vartable["Global Settings"]["Scale"]; |
||
933 | else |
||
934 | scale = nil; |
||
935 | end |
||
936 | if (vartable["Global Settings"]["Transparency"] ~= nil) then |
||
937 | transparency = vartable["Global Settings"]["Transparency"]; |
||
938 | else |
||
939 | transparency = nil; |
||
940 | end |
||
941 | if (vartable["Global Settings"]["ShowTarget"] ~= nil) then |
||
942 | showtarget = vartable["Global Settings"]["ShowTarget"]; |
||
943 | else |
||
944 | showtarget = nil; |
||
945 | end |
||
946 | if (vartable["Global Settings"]["MobHealthSupport"] ~= nil) then |
||
947 | mobhealthsupport = vartable["Global Settings"]["MobHealthSupport"]; |
||
948 | else |
||
949 | mobhealthsupport = nil; |
||
950 | end |
||
951 | if (vartable["Global Settings"]["ShowDruidBar"] ~= nil) then |
||
952 | showdruidbar = vartable["Global Settings"]["ShowDruidBar"]; |
||
953 | else |
||
954 | showdruidbar = nil; |
||
955 | end |
||
956 | if (vartable["Global Settings"]["ShowPetBars"] ~= nil) then |
||
957 | showpetbars = vartable["Global Settings"]["ShowPetBars"]; |
||
958 | else |
||
959 | showpetbars = nil; |
||
960 | end |
||
961 | end |
||
962 | |||
963 | -- Set the new values if any new values were found, same defaults as above |
||
964 | if (state == nil) then |
||
965 | state = 3; |
||
966 | end |
||
967 | if (locked == nil) then |
||
968 | locked = 0; |
||
969 | end |
||
970 | if (healthpersist == nil) then |
||
971 | healthpersist = 0; |
||
972 | end |
||
973 | if (manapersist == nil) then |
||
974 | manapersist = 0; |
||
975 | end |
||
976 | if (scale == nil) then |
||
977 | scale = 1; |
||
978 | end |
||
979 | if (transparency == nil) then |
||
980 | transparency = 1; |
||
981 | end |
||
982 | if (showtarget == nil) then |
||
983 | showtarget = 0; |
||
984 | end |
||
985 | if (mobhealthsupport == nil) then |
||
986 | mobhealthsupport = 1; |
||
987 | end |
||
988 | if (showdruidbar == nil) then |
||
989 | showdruidbar = 1; |
||
990 | end |
||
991 | if (showpetbars == nil) then |
||
992 | showpetbars = 0; |
||
993 | end |
||
994 | |||
995 | -- Call any code we need to activate them |
||
996 | Perl_CombatDisplay_Set_Target(showtarget) |
||
997 | Perl_CombatDisplay_Target_Update_Health(); |
||
998 | Perl_CombatDisplay_Set_Scale() |
||
999 | Perl_CombatDisplay_Set_Transparency() |
||
1000 | Perl_CombatDisplay_UpdateDisplay(); |
||
1001 | end |
||
1002 | |||
1003 | Perl_CombatDisplay_Config[UnitName("player")] = { |
||
1004 | ["State"] = state, |
||
1005 | ["Locked"] = locked, |
||
1006 | ["HealthPersist"] = healthpersist, |
||
1007 | ["ManaPersist"] = manapersist, |
||
1008 | ["Scale"] = scale, |
||
1009 | ["Transparency"] = transparency, |
||
1010 | ["ShowTarget"] = showtarget, |
||
1011 | ["MobHealthSupport"] = mobhealthsupport, |
||
1012 | ["ShowDruidBar"] = showdruidbar, |
||
1013 | ["ShowPetBars"] = showpetbars, |
||
1014 | }; |
||
1015 | end |
||
1016 | |||
1017 | |||
1018 | ------------------- |
||
1019 | -- Click Handler -- |
||
1020 | ------------------- |
||
1021 | function Perl_CombatDisplayDropDown_OnLoad() |
||
1022 | UIDropDownMenu_Initialize(this, Perl_CombatDisplayDropDown_Initialize, "MENU"); |
||
1023 | end |
||
1024 | |||
1025 | function Perl_CombatDisplayDropDown_Initialize() |
||
1026 | UnitPopup_ShowMenu(Perl_CombatDisplay_DropDown, "SELF", "player"); |
||
1027 | end |
||
1028 | |||
1029 | function Perl_CombatDisplay_MouseClick(button) |
||
1030 | if (CastPartyConfig and PCUF_CASTPARTYSUPPORT == 1) then |
||
1031 | CastParty_OnClickByUnit(button, "player"); |
||
1032 | elseif (Genesis_data and PCUF_CASTPARTYSUPPORT == 1) then |
||
1033 | Genesis_MouseHeal("player", button); |
||
1034 | else |
||
1035 | if (SpellIsTargeting() and button == "RightButton") then |
||
1036 | SpellStopTargeting(); |
||
1037 | return; |
||
1038 | end |
||
1039 | |||
1040 | if (button == "LeftButton") then |
||
1041 | if (SpellIsTargeting()) then |
||
1042 | SpellTargetUnit("player"); |
||
1043 | elseif (CursorHasItem()) then |
||
1044 | DropItemOnUnit("player"); |
||
1045 | else |
||
1046 | TargetUnit("player"); |
||
1047 | end |
||
1048 | end |
||
1049 | end |
||
1050 | end |
||
1051 | |||
1052 | function Perl_CombatDisplay_MouseDown(button) |
||
1053 | if (button == "LeftButton" and locked == 0) then |
||
1054 | Perl_CombatDisplay_Frame:StartMoving(); |
||
1055 | end |
||
1056 | end |
||
1057 | |||
1058 | function Perl_CombatDisplay_MouseUp(button) |
||
1059 | if (button == "RightButton") then |
||
1060 | if ((CastPartyConfig or Genesis_MouseHeal) and PCUF_CASTPARTYSUPPORT == 1) then -- cant open the menu from combatdisplay if castparty or genesis is installed |
||
1061 | -- Do nothing |
||
1062 | else |
||
1063 | if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then |
||
1064 | ToggleDropDownMenu(1, nil, Perl_CombatDisplay_DropDown, "Perl_CombatDisplay_Frame", 40, 0); |
||
1065 | end |
||
1066 | end |
||
1067 | end |
||
1068 | |||
1069 | Perl_CombatDisplay_Frame:StopMovingOrSizing(); |
||
1070 | end |
||
1071 | |||
1072 | |||
1073 | function Perl_CombatDisplayTargetDropDown_OnLoad() |
||
1074 | UIDropDownMenu_Initialize(this, Perl_CombatDisplayTargetDropDown_Initialize, "MENU"); |
||
1075 | end |
||
1076 | |||
1077 | function Perl_CombatDisplayTargetDropDown_Initialize() |
||
1078 | local menu = nil; |
||
1079 | if (UnitIsEnemy("target", "player")) then |
||
1080 | return; |
||
1081 | end |
||
1082 | if (UnitIsUnit("target", "player")) then |
||
1083 | menu = "SELF"; |
||
1084 | elseif (UnitIsUnit("target", "pet")) then |
||
1085 | menu = "PET"; |
||
1086 | elseif (UnitIsPlayer("target")) then |
||
1087 | if (UnitInParty("target")) then |
||
1088 | menu = "PARTY"; |
||
1089 | else |
||
1090 | menu = "PLAYER"; |
||
1091 | end |
||
1092 | end |
||
1093 | if (menu) then |
||
1094 | UnitPopup_ShowMenu(Perl_CombatDisplay_Target_DropDown, menu, "target"); |
||
1095 | end |
||
1096 | end |
||
1097 | |||
1098 | function Perl_CombatDisplay_Target_MouseClick(button) |
||
1099 | if (CastPartyConfig and PCUF_CASTPARTYSUPPORT == 1) then |
||
1100 | CastParty_OnClickByUnit(button, "target"); |
||
1101 | elseif (Genesis_data and PCUF_CASTPARTYSUPPORT == 1) then |
||
1102 | Genesis_MouseHeal("target", button); |
||
1103 | else |
||
1104 | if (SpellIsTargeting() and button == "RightButton") then |
||
1105 | SpellStopTargeting(); |
||
1106 | return; |
||
1107 | end |
||
1108 | |||
1109 | if (button == "LeftButton") then |
||
1110 | if (SpellIsTargeting()) then |
||
1111 | SpellTargetUnit("player"); |
||
1112 | elseif (CursorHasItem()) then |
||
1113 | DropItemOnUnit("player"); |
||
1114 | else |
||
1115 | TargetUnit("player"); |
||
1116 | end |
||
1117 | end |
||
1118 | end |
||
1119 | end |
||
1120 | |||
1121 | function Perl_CombatDisplay_Target_MouseDown(button) |
||
1122 | if (button == "LeftButton" and locked == 0) then |
||
1123 | Perl_CombatDisplay_Target_Frame:StartMoving(); |
||
1124 | end |
||
1125 | end |
||
1126 | |||
1127 | function Perl_CombatDisplay_Target_MouseUp(button) |
||
1128 | if (button == "RightButton") then |
||
1129 | if ((CastPartyConfig or Genesis_data) and PCUF_CASTPARTYSUPPORT == 1) then -- cant open the menu from combatdisplay if castparty or genesis is installed |
||
1130 | -- Do nothing |
||
1131 | else |
||
1132 | if (not (IsAltKeyDown() or IsControlKeyDown() or IsShiftKeyDown())) then -- if alt, ctrl, or shift ARE NOT held, show the menu |
||
1133 | ToggleDropDownMenu(1, nil, Perl_CombatDisplay_Target_DropDown, "Perl_CombatDisplay_Target_Frame", 40, 0); |
||
1134 | end |
||
1135 | end |
||
1136 | end |
||
1137 | |||
1138 | Perl_CombatDisplay_Target_Frame:StopMovingOrSizing(); |
||
1139 | end |
||
1140 | |||
1141 | |||
1142 | ---------------------- |
||
1143 | -- myAddOns Support -- |
||
1144 | ---------------------- |
||
1145 | function Perl_CombatDisplay_myAddOns_Support() |
||
1146 | -- Register the addon in myAddOns |
||
1147 | if(myAddOnsFrame_Register) then |
||
1148 | local Perl_CombatDisplay_myAddOns_Details = { |
||
1149 | name = "Perl_CombatDisplay", |
||
1150 | version = "Version 0.58", |
||
1151 | releaseDate = "April 15, 2006", |
||
1152 | author = "Perl; Maintained by Global", |
||
1153 | email = "global@g-ball.com", |
||
1154 | website = "http://www.curse-gaming.com/mod.php?addid=2257", |
||
1155 | category = MYADDONS_CATEGORY_OTHERS |
||
1156 | }; |
||
1157 | Perl_CombatDisplay_myAddOns_Help = {}; |
||
1158 | Perl_CombatDisplay_myAddOns_Help[1] = "/perl"; |
||
1159 | myAddOnsFrame_Register(Perl_CombatDisplay_myAddOns_Details, Perl_CombatDisplay_myAddOns_Help); |
||
1160 | end |
||
1161 | end |