vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Nurfed_PlayerFrame.lua |
||
3 | GypsyVersion++2004.11.13++ |
||
4 | |||
5 | Moves the player frame to the bottom |
||
6 | left corner of the screen. |
||
7 | Adds health, mana, and experience |
||
8 | text, as well as hit point percentage |
||
9 | and rested experience bonus to the right |
||
10 | and below the default player frame. |
||
11 | Adds graphical framework to accomodate |
||
12 | the textual displays. |
||
13 | Moves the right click player window |
||
14 | to be viewable with the new player frame |
||
15 | placement. |
||
16 | ]] |
||
17 | |||
18 | -- ** DEFAULT SETTINGS ** -- |
||
19 | |||
20 | -- Color player health by default |
||
21 | Nurfed_DefaultColorPlayerHealth = 1; |
||
22 | -- Color player mana by default |
||
23 | Nurfed_DefaultColorPlayerMana = 1; |
||
24 | -- Color player name on attack by default |
||
25 | Nurfed_DefaultColorPlayerName = 1; |
||
26 | -- Color player health bar by default |
||
27 | Nurfed_DefaultColorPlayerHealthBar = 1; |
||
28 | |||
29 | -- ** PLAYER FRAME FUNCTIONS ** -- |
||
30 | |||
31 | function Nurfed_PlayerFrameOnLoad () |
||
32 | -- Health and mana registrations |
||
33 | this:RegisterEvent("UNIT_HEALTH"); |
||
34 | this:RegisterEvent("UNIT_MANA"); |
||
35 | this:RegisterEvent("UNIT_RAGE"); |
||
36 | this:RegisterEvent("UNIT_FOCUS"); |
||
37 | this:RegisterEvent("UNIT_ENERGY"); |
||
38 | -- If a druid shapeshifts, the bar changes from rage/mana/energy/etc |
||
39 | this:RegisterEvent("UPDATE_SHAPESHIFT_FORMS"); |
||
40 | -- Experience registrations |
||
41 | this:RegisterEvent("PLAYER_XP_UPDATE"); |
||
42 | this:RegisterEvent("UPDATE_EXHAUSTION"); |
||
43 | this:RegisterEvent("PLAYER_LEVEL_UP"); |
||
44 | -- Register for variable loading to run our configuration registrations |
||
45 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
46 | this:RegisterEvent("VARIABLES_LOADED"); |
||
47 | -- Combat events for coloring the player name |
||
48 | this:RegisterEvent("PLAYER_ENTER_COMBAT"); |
||
49 | this:RegisterEvent("PLAYER_LEAVE_COMBAT"); |
||
50 | end |
||
51 | |||
52 | function Nurfed_PlayerFrameOnEvent (event) |
||
53 | if ( event == "PLAYER_ENTERING_WORLD" ) then |
||
54 | -- We need to do an initial display of all our values when the player first logs in. |
||
55 | Nurfed_ShowPlayerHealth(); |
||
56 | Nurfed_ShowPlayerHealthPercent(); |
||
57 | Nurfed_ShowPlayerMana(); |
||
58 | Nurfed_ShowPlayerExp(); |
||
59 | return; |
||
60 | end |
||
61 | -- Added unit exp handles to update the player displayed experience numbers. |
||
62 | if(event == "PLAYER_XP_UPDATE" or event == "UPDATE_EXHAUSTION" or event == "PLAYER_LEVEL_UP") then |
||
63 | Nurfed_ShowPlayerExp(); |
||
64 | return; |
||
65 | end |
||
66 | -- Added unit_health and unit_mana (ish) event handlers. Anytime either of these values change, we need to update. |
||
67 | if( event == "UNIT_HEALTH" ) then |
||
68 | Nurfed_ShowPlayerHealth(); |
||
69 | Nurfed_ShowPlayerHealthPercent(); |
||
70 | return; |
||
71 | end |
||
72 | -- Also keep in mind, "mana" is really mana, energy, focus, or rage, so we need to watch all of those. |
||
73 | if( event == "UNIT_MANA" or event == "UNIT_RAGE" or event == "UNIT_FOCUS" or event == "UNIT_ENERGY" or event == "UPDATE_SHAPESHIFT_FORMS") then |
||
74 | Nurfed_ShowPlayerMana(); |
||
75 | return; |
||
76 | end |
||
77 | -- Color the player name text red when entering combat |
||
78 | if (event == "PLAYER_ENTER_COMBAT") then |
||
79 | Nurfed_UpdateAttackState(); |
||
80 | return; |
||
81 | end |
||
82 | -- Reset player name text |
||
83 | if (event == "PLAYER_LEAVE_COMBAT") then |
||
84 | Nurfed_UpdateAttackState(); |
||
85 | return; |
||
86 | end |
||
87 | -- When variables load, run our options setup |
||
88 | if (event == "VARIABLES_LOADED") then |
||
89 | -- Check to see if the player frame is a standalone addon or if the GypsyMod shell is available |
||
90 | if (Nurfed_SHELL == 1) then |
||
91 | -- Set defaults if there is no saved value |
||
92 | if (Nurfed_RetrieveSaved("ColorPlayerHealth") == nil) then |
||
93 | Nurfed_ColorPlayerHealth = Nurfed_DefaultColorPlayerHealth; |
||
94 | else |
||
95 | Nurfed_ColorPlayerHealth = Nurfed_RetrieveSaved("ColorPlayerHealth"); |
||
96 | end |
||
97 | if (Nurfed_RetrieveSaved("ColorPlayerMana") == nil) then |
||
98 | Nurfed_ColorPlayerMana = Nurfed_DefaultColorPlayerMana; |
||
99 | else |
||
100 | Nurfed_ColorPlayerMana = Nurfed_RetrieveSaved("ColorPlayerMana"); |
||
101 | end |
||
102 | if (Nurfed_RetrieveSaved("ColorPlayerName") == nil) then |
||
103 | Nurfed_ColorPlayerName = Nurfed_DefaultColorPlayerName; |
||
104 | else |
||
105 | Nurfed_ColorPlayerName = Nurfed_RetrieveSaved("ColorPlayerName"); |
||
106 | end |
||
107 | if (Nurfed_RetrieveSaved("ColorPlayerHealthBar") == nil) then |
||
108 | Nurfed_ColorPlayerHealthBar = Nurfed_DefaultColorPlayerHealthBar; |
||
109 | else |
||
110 | Nurfed_ColorPlayerHealthBar = Nurfed_RetrieveSaved("ColorPlayerHealthBar"); |
||
111 | end |
||
112 | --Register with GypsyMod saving |
||
113 | Nurfed_RegisterOption(210, "header", nil, nil, nil, Nurfed_TEXT_UNITBARS_PLAYERHEADERLABEL, Nurfed_TEXT_UNITBARS_PLAYERHEADERTOOLTIP); |
||
114 | Nurfed_RegisterOption(211, "check", Nurfed_ColorPlayerHealth, "ColorPlayerHealth", Nurfed_ShowPlayerHealthPercent, Nurfed_TEXT_UNITBARS_COLORPLAYERTEXTLABEL, Nurfed_TEXT_UNITBARS_COLORPLAYERTEXTTOOLTIP); |
||
115 | Nurfed_RegisterOption(212, "check", Nurfed_ColorPlayerMana, "ColorPlayerMana", Nurfed_ShowPlayerMana, Nurfed_TEXT_UNITBARS_COLORPLAYERMANATEXTLABEL, Nurfed_TEXT_UNITBARS_COLORPLAYERMANATEXTTOOLTIP); |
||
116 | Nurfed_RegisterOption(213, "check", Nurfed_ColorPlayerName, "ColorPlayerName", nil, Nurfed_TEXT_UNITBARS_COLORNAMELABEL, Nurfed_TEXT_UNITBARS_COLORNAMETOOLTIP); |
||
117 | Nurfed_RegisterOption(214, "check", Nurfed_ColorPlayerHealthBar, "ColorPlayerHealthBar", Nurfed_ShowPlayerHealthPercent, Nurfed_TEXT_UNITBARS_COLORPLAYERBARLABEL, Nurfed_TEXT_UNITBARS_COLORPLAYERBARTOOLTIP); |
||
118 | else |
||
119 | -- If our toggles aren't saved, default to on |
||
120 | if (Nurfed_ColorPlayerHealth == nil) then |
||
121 | Nurfed_ColorPlayerHealth = Nurfed_DefaultColorPlayerHealth; |
||
122 | end |
||
123 | if (Nurfed_ColorPlayerMana == nil) then |
||
124 | Nurfed_ColorPlayerMana = Nurfed_DefaultColorPlayerMana; |
||
125 | end |
||
126 | if (Nurfed_ColorPlayerName == nil) then |
||
127 | Nurfed_ColorPlayerName = Nurfed_DefaultColorPlayerName; |
||
128 | end |
||
129 | if (Nurfed_ColorPlayerHealthBar == nil) then |
||
130 | Nurfed_ColorPlayerHealthBar = Nurfed_DefaultColorPlayerHealthBar; |
||
131 | end |
||
132 | -- Save manually for standalone options |
||
133 | --RegisterForSave("Nurfed_ColorPlayerHealth"); |
||
134 | --RegisterForSave("Nurfed_ColorPlayerMana"); |
||
135 | --RegisterForSave("Nurfed_ColorPlayerName"); |
||
136 | --RegisterForSave("Nurfed_ColorPlayerHealthBar"); |
||
137 | -- Register slash commands |
||
138 | SlashCmdList["Nurfed_COLORPLAYERHEALTH"] = Nurfed_ColorPlayerHealthSlashHandler; |
||
139 | SLASH_Nurfed_COLORPLAYERHEALTH1 = "/unitbarcolorplayerhealth"; |
||
140 | SLASH_Nurfed_COLORPLAYERHEALTH2 = "/ubcolorplayerhealth"; |
||
141 | SlashCmdList["Nurfed_COLORPLAYERMANA"] = Nurfed_ColorPlayerManaSlashHandlers; |
||
142 | SLASH_Nurfed_COLORPLAYERMANA1 = "/unitbarcolorplayermana"; |
||
143 | SLASH_Nurfed_COLORPLAYERMANA2 = "/ubcolorplayermana"; |
||
144 | SlashCmdList["Nurfed_COLORPLAYERNAME"] = Nurfed_ColorPlayerNameSlashHandlers; |
||
145 | SLASH_Nurfed_COLORPLAYERNAME1 = "/unitbarcolorplayername"; |
||
146 | SLASH_Nurfed_COLORPLAYERNAME2 = "/ubcolorplayername"; |
||
147 | SlashCmdList["Nurfed_COLORPLAYERHEALTHBAR"] = Nurfed_ColorPlayerHealthBarSlashHandlers; |
||
148 | SLASH_Nurfed_COLORPLAYERHEALTHBAR1 = "/unitbarcolorplayerhealthbar"; |
||
149 | SLASH_Nurfed_COLORPLAYERHEALTHBAR2 = "/ubcolorplayerhealthbar"; |
||
150 | end |
||
151 | return; |
||
152 | end |
||
153 | end |
||
154 | |||
155 | -- Update player name depending on attack state |
||
156 | function Nurfed_UpdateAttackState () |
||
157 | if (Nurfed_RetrieveOption ~= nil) then |
||
158 | if (Nurfed_RetrieveOption(213) ~= nil) then |
||
159 | Nurfed_ColorPlayerName = Nurfed_RetrieveOption(213)[Nurfed_VALUE]; |
||
160 | end |
||
161 | end |
||
162 | if (Nurfed_ColorPlayerName == 1) then |
||
163 | local playerFrame = getglobal("PlayerFrame"); |
||
164 | if (playerFrame.inCombat and playerFrame.OnHateList or playerFrame.inCombat) then |
||
165 | PlayerName:SetTextColor(1, 0, 0); |
||
166 | else |
||
167 | PlayerName:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
168 | end |
||
169 | end |
||
170 | end |
||
171 | |||
172 | -- ** EXPERIENCE BAR FUNCTIONS ** -- |
||
173 | |||
174 | function Nurfed_PlayerFrameExpBarOnLoad () |
||
175 | -- Experience bar registrations |
||
176 | this:RegisterEvent("PLAYER_XP_UPDATE"); |
||
177 | this:RegisterEvent("PLAYER_LEVEL_UP"); |
||
178 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
179 | -- Can not be any higher, should not be lower |
||
180 | this:SetFrameLevel(0); |
||
181 | end |
||
182 | |||
183 | function Nurfed_PlayerFrameExpBarOnEvent (event) |
||
184 | -- Setup our experience bar when the player logs in, when experience changes, or when the player levels up |
||
185 | if (event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" or event == "PLAYER_ENTERING_WORLD") then |
||
186 | local currXP = UnitXP("player"); |
||
187 | local nextXP = UnitXPMax("player"); |
||
188 | this:SetMinMaxValues(min(0, currXP), nextXP); |
||
189 | this:SetValue(currXP); |
||
190 | return; |
||
191 | end |
||
192 | end |
||
193 | |||
194 | -- ** CLICK CATCH FUNCTIONS ** -- |
||
195 | |||
196 | -- Function to register for clicks for the click catcher when it loads |
||
197 | function Nurfed_PlayerFrameClickCatchOnLoad () |
||
198 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp"); |
||
199 | end |
||
200 | |||
201 | -- Function pulled from PlayerFrame.lua to handle clicks in our AddOn |
||
202 | function Nurfed_PlayerFrameClickCatch(button) |
||
203 | if ( SpellIsTargeting() and button == "RightButton" ) then |
||
204 | SpellStopTargeting(); |
||
205 | return; |
||
206 | end |
||
207 | if ( button == "LeftButton" ) then |
||
208 | if ( SpellIsTargeting() ) then |
||
209 | SpellTargetUnit("player"); |
||
210 | elseif ( CursorHasItem() ) then |
||
211 | AutoEquipCursorItem(); |
||
212 | else |
||
213 | TargetUnit("player"); |
||
214 | end |
||
215 | else |
||
216 | -- Right click menu needs to be moved |
||
217 | ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "PlayerFrame", 106, 27); |
||
218 | -- UnitPopup_ShowMenu(Nurfed_PlayerFrame, "SELF", "player"); |
||
219 | -- UnitPopup:ClearAllPoints(); |
||
220 | DropDownList1:ClearAllPoints(); |
||
221 | -- Check for inverted frame status and position the menu accordingly |
||
222 | if (Nurfed_InvertUnitFrames == 1) then |
||
223 | DropDownList1:SetPoint("BOTTOMLEFT", "PlayerFrame", "TOPLEFT", 20, -10); |
||
224 | else |
||
225 | DropDownList1:SetPoint("TOPLEFT", "PlayerFrame", "BOTTOMLEFT", 20, 10); |
||
226 | end |
||
227 | end |
||
228 | end |
||
229 | |||
230 | -- ** TEXT DISPLAY FUNCTIONS ** -- |
||
231 | |||
232 | function Nurfed_ShowPlayerHealth() |
||
233 | -- This gets the whole status text "Health xxxx / yyyy" - we need to parse it to remove the "Health" part |
||
234 | --[[ local text = PlayerFrameHealthBarText:GetText(); |
||
235 | if( text == nil ) then |
||
236 | Nurfed_PlayerHealthText:SetText("Failure #1"); |
||
237 | else |
||
238 | -- It always says "Health " first, so just remove the first 7 characters off the string |
||
239 | local health = strsub(text, 7); |
||
240 | if(health == nil) then |
||
241 | Nurfed_PlayerHealthText:SetText("Failure #2"); |
||
242 | else |
||
243 | Nurfed_PlayerHealthText:SetText(health); |
||
244 | end |
||
245 | end]] |
||
246 | if (UnitHealth("player") and UnitHealthMax("player")) then |
||
247 | Nurfed_PlayerHealthText:SetText(UnitHealth("player").." / "..UnitHealthMax("player")); |
||
248 | end |
||
249 | end |
||
250 | |||
251 | function Nurfed_ShowPlayerHealthPercent() |
||
252 | -- This gets the whole status text "Health xxxx / yyyy" - we need to parse it to remove the "Health" part |
||
253 | --[[ local text = PlayerFrameHealthBarText:GetText(); |
||
254 | if( text == nil ) then |
||
255 | Nurfed_PlayerHealthPercent:SetText("Failure #1"); |
||
256 | else |
||
257 | -- It always says "Health " first, so just remove the first 7 characters off the string |
||
258 | local health = strsub(text, 7); |
||
259 | -- We now have "617 / 1234". We need to parse that to 2 variables: cur = "617" and total = "1234" |
||
260 | local find = strfind(health, "/"); |
||
261 | if( find == nil ) then |
||
262 | Nurfed_PlayerHealthPercent:SetText(health); |
||
263 | else |
||
264 | local cur = strsub(health, 0, strlen(health)-find); |
||
265 | if( cur == nil) then |
||
266 | Nurfed_PlayerHealthPercent:SetText("Failure #2b"); |
||
267 | else |
||
268 | local total = strsub(health, strlen(cur)+2); |
||
269 | if(strfind(total, "/") ~= nil) then |
||
270 | total = strsub(total, 2); |
||
271 | end |
||
272 | |||
273 | if ( total == nil ) then |
||
274 | Nurfed_PlayerHealthPercent:SetText("Failure #2c"); |
||
275 | else |
||
276 | if( tonumber(cur) == 0 or tonumber(cur) == nil ) then |
||
277 | -- This can happen if you are dead |
||
278 | Nurfed_PlayerHealthPercent:SetText("0%"); |
||
279 | return; |
||
280 | end |
||
281 | if(tonumber(total) == 0 or tonumber(total) == nil) then |
||
282 | -- This REALLY should be impossible |
||
283 | Nurfed_PlayerHealthPercent:SetText("Failure #2d"); |
||
284 | return; |
||
285 | end |
||
286 | local percent = (tonumber(cur) / tonumber(total)) * 100; |
||
287 | Nurfed_PlayerHealthPercent:SetText(ceil(percent) .. "%"); |
||
288 | |||
289 | if (Nurfed_RetrieveOption ~= nil) then |
||
290 | if (Nurfed_RetrieveOption(211) ~= nil) then |
||
291 | Nurfed_ColorPlayerHealth = Nurfed_RetrieveOption(211)[Nurfed_VALUE]; |
||
292 | end |
||
293 | if (Nurfed_RetrieveOption(214) ~= nil) then |
||
294 | Nurfed_ColorPlayerHealthBar = Nurfed_RetrieveOption(214)[Nurfed_VALUE]; |
||
295 | end |
||
296 | end |
||
297 | if (Nurfed_ColorPlayerHealth == 1) then |
||
298 | if ((percent <= 100) and (percent > 75)) then |
||
299 | Nurfed_PlayerHealthPercent:SetTextColor(0, 1, 0); |
||
300 | Nurfed_PlayerHealthText:SetTextColor(0, 1, 0); |
||
301 | elseif ((percent <= 75) and (percent > 50)) then |
||
302 | Nurfed_PlayerHealthPercent:SetTextColor(1, 1, 0); |
||
303 | Nurfed_PlayerHealthText:SetTextColor(1, 1, 0); |
||
304 | elseif ((percent <= 50) and (percent > 25)) then |
||
305 | Nurfed_PlayerHealthPercent:SetTextColor(1, 0.5, 0); |
||
306 | Nurfed_PlayerHealthText:SetTextColor(1, 0.5, 0); |
||
307 | else |
||
308 | Nurfed_PlayerHealthPercent:SetTextColor(1, 0, 0); |
||
309 | Nurfed_PlayerHealthText:SetTextColor(1, 0, 0); |
||
310 | end |
||
311 | else |
||
312 | Nurfed_PlayerHealthPercent:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
313 | Nurfed_PlayerHealthText:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
314 | end |
||
315 | if (Nurfed_ColorPlayerHealthBar == 1) then |
||
316 | if ((percent <= 100) and (percent > 75)) then |
||
317 | PlayerFrameHealthBar:SetStatusBarColor(0, 1, 0); |
||
318 | elseif ((percent <= 75) and (percent > 50)) then |
||
319 | PlayerFrameHealthBar:SetStatusBarColor(1, 1, 0); |
||
320 | elseif ((percent <= 50) and (percent > 25)) then |
||
321 | PlayerFrameHealthBar:SetStatusBarColor(1, 0.5, 0); |
||
322 | else |
||
323 | PlayerFrameHealthBar:SetStatusBarColor(1, 0, 0); |
||
324 | end |
||
325 | else |
||
326 | PlayerFrameHealthBar:SetStatusBarColor(0, 1, 0); |
||
327 | end |
||
328 | end |
||
329 | end |
||
330 | end |
||
331 | end]] |
||
332 | if (UnitHealth("player") and UnitHealthMax("player")) then |
||
333 | local health = UnitHealth("player"); |
||
334 | local max = UnitHealthMax("player"); |
||
335 | local percent = (health/max) * 100; |
||
336 | |||
337 | Nurfed_PlayerHealthPercent:SetText(ceil(percent).."%"); |
||
338 | |||
339 | if (Nurfed_RetrieveOption ~= nil) then |
||
340 | if (Nurfed_RetrieveOption(211) ~= nil) then |
||
341 | Nurfed_ColorPlayerHealth = Nurfed_RetrieveOption(211)[Nurfed_VALUE]; |
||
342 | end |
||
343 | if (Nurfed_RetrieveOption(214) ~= nil) then |
||
344 | Nurfed_ColorPlayerHealthBar = Nurfed_RetrieveOption(214)[Nurfed_VALUE]; |
||
345 | end |
||
346 | end |
||
347 | if (Nurfed_ColorPlayerHealth == 1) then |
||
348 | if ((percent <= 100) and (percent > 75)) then |
||
349 | Nurfed_PlayerHealthPercent:SetTextColor(0, 1, 0); |
||
350 | Nurfed_PlayerHealthText:SetTextColor(0, 1, 0); |
||
351 | elseif ((percent <= 75) and (percent > 50)) then |
||
352 | Nurfed_PlayerHealthPercent:SetTextColor(1, 1, 0); |
||
353 | Nurfed_PlayerHealthText:SetTextColor(1, 1, 0); |
||
354 | elseif ((percent <= 50) and (percent > 25)) then |
||
355 | Nurfed_PlayerHealthPercent:SetTextColor(1, 0.5, 0); |
||
356 | Nurfed_PlayerHealthText:SetTextColor(1, 0.5, 0); |
||
357 | else |
||
358 | Nurfed_PlayerHealthPercent:SetTextColor(1, 0, 0); |
||
359 | Nurfed_PlayerHealthText:SetTextColor(1, 0, 0); |
||
360 | end |
||
361 | else |
||
362 | Nurfed_PlayerHealthPercent:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
363 | Nurfed_PlayerHealthText:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
364 | end |
||
365 | if (Nurfed_ColorPlayerHealthBar == 1) then |
||
366 | if ((percent <= 100) and (percent > 75)) then |
||
367 | PlayerFrameHealthBar:SetStatusBarColor(0, 1, 0); |
||
368 | elseif ((percent <= 75) and (percent > 50)) then |
||
369 | PlayerFrameHealthBar:SetStatusBarColor(1, 1, 0); |
||
370 | elseif ((percent <= 50) and (percent > 25)) then |
||
371 | PlayerFrameHealthBar:SetStatusBarColor(1, 0.5, 0); |
||
372 | else |
||
373 | PlayerFrameHealthBar:SetStatusBarColor(1, 0, 0); |
||
374 | end |
||
375 | else |
||
376 | PlayerFrameHealthBar:SetStatusBarColor(0, 1, 0); |
||
377 | end |
||
378 | end |
||
379 | end |
||
380 | |||
381 | function Nurfed_ShowPlayerMana() |
||
382 | -- This gets the whole status text "Mana xxxx / yyyy" - we need to parse it to remove the "Mana " part |
||
383 | --[[ local text = PlayerFrameManaBarText:GetText(); |
||
384 | if( text == nil ) then |
||
385 | Nurfed_PlayerManaText:SetText("Failure #1"); |
||
386 | else |
||
387 | -- Determine mana type and set a globally accessible variable |
||
388 | if (strfind(text, "Rage")) then |
||
389 | Nurfed_PlayerManaType = "Rage"; |
||
390 | elseif (strfind(text, "Energy")) then |
||
391 | Nurfed_PlayerManaType = "Energy"; |
||
392 | else |
||
393 | Nurfed_PlayerManaType = "Mana"; |
||
394 | end |
||
395 | -- Initialize local mana text variable |
||
396 | local mana = nil; |
||
397 | -- Remove the first 5 or 7 characters, depending on mana type |
||
398 | if (Nurfed_PlayerManaType == "Energy") then |
||
399 | mana = strsub(text, 7); |
||
400 | else |
||
401 | mana = strsub(text, 5); |
||
402 | end |
||
403 | -- Make sure mana contains text, then color our text accordingly |
||
404 | if(mana == nil) then |
||
405 | Nurfed_PlayerManaText:SetText("Failure #2"); |
||
406 | else |
||
407 | Nurfed_PlayerManaText:SetText(mana); |
||
408 | |||
409 | if (Nurfed_RetrieveOption ~= nil) then |
||
410 | if (Nurfed_RetrieveOption(212) ~= nil) then |
||
411 | Nurfed_ColorPlayerMana = Nurfed_RetrieveOption(212)[Nurfed_VALUE]; |
||
412 | end |
||
413 | end |
||
414 | if (Nurfed_ColorPlayerMana == 1) then |
||
415 | if (Nurfed_PlayerManaType == "Rage") then |
||
416 | Nurfed_PlayerManaText:SetTextColor(1, 0.50, 0.50); |
||
417 | elseif (Nurfed_PlayerManaType == "Energy") then |
||
418 | Nurfed_PlayerManaText:SetTextColor(1, 1, 0); |
||
419 | else |
||
420 | Nurfed_PlayerManaText:SetTextColor(0.75, 0.75, 1); |
||
421 | end |
||
422 | else |
||
423 | Nurfed_PlayerManaText:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
424 | end |
||
425 | end |
||
426 | end]] |
||
427 | if (UnitMana("player") and UnitManaMax("player") and UnitPowerType("player")) then |
||
428 | Nurfed_PlayerManaText:SetText(UnitMana("player").." / "..UnitManaMax("player")); |
||
429 | local type = UnitPowerType("player"); |
||
430 | if (Nurfed_RetrieveOption ~= nil) then |
||
431 | if (Nurfed_RetrieveOption(212) ~= nil) then |
||
432 | Nurfed_ColorPlayerMana = Nurfed_RetrieveOption(212)[Nurfed_VALUE]; |
||
433 | end |
||
434 | end |
||
435 | if (Nurfed_ColorPlayerMana == 1) then |
||
436 | if (type == 0) then |
||
437 | Nurfed_PlayerManaText:SetTextColor(0.75, 0.75, 1); |
||
438 | elseif (type == 1) then |
||
439 | Nurfed_PlayerManaText:SetTextColor(1, 0.50, 0.50); |
||
440 | elseif (type == 3) then |
||
441 | Nurfed_PlayerManaText:SetTextColor(1, 1, 0); |
||
442 | end |
||
443 | else |
||
444 | Nurfed_PlayerManaText:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); |
||
445 | end |
||
446 | end |
||
447 | end |
||
448 | |||
449 | function Nurfed_ShowPlayerExp() |
||
450 | local currXP = UnitXP("player"); |
||
451 | local nextXP = UnitXPMax("player"); |
||
452 | local restXP = GetXPExhaustion(); |
||
453 | |||
454 | if(restXP == nil) then |
||
455 | local str = format("%s / %s", currXP, nextXP); |
||
456 | Nurfed_ExpAmount:SetText(str); |
||
457 | else |
||
458 | -- Divide the rested # in half because |
||
459 | -- (a) that's the exp you really end up getting |
||
460 | -- (b) it isn't such an absurdly huge number taking up a lot of space on the UI. |
||
461 | |||
462 | local str = format("%s / %s (+%s)", currXP, nextXP, (tonumber(restXP) / 2)); |
||
463 | Nurfed_ExpAmount:SetText(str); |
||
464 | end |
||
465 | end |
||
466 | |||
467 | -- ** SLASH HANDLER FUNCTIONS ** -- |
||
468 | |||
469 | function Nurfed_ColorPlayerHealthSlashHandler (msg) |
||
470 | msg = string.lower(msg); |
||
471 | if (msg == "yes" or msg == "1" or msg == "true") then |
||
472 | Nurfed_ColorPlayerHealth = 1; |
||
473 | DEFAULT_CHAT_FRAME:AddMessage("Setting player health display text to color according to health percentage.", 1, 1, 1); |
||
474 | elseif (msg == "no" or msg == "0" or msg == "false") then |
||
475 | Nurfed_ColorPlayerHealth = 0; |
||
476 | DEFAULT_CHAT_FRAME:AddMessage("Setting player health display text color to default.", 1, 1, 1); |
||
477 | elseif (msg == "default" or msg == "reset" or msg == "revert") then |
||
478 | Nurfed_ColorPlayerHealth = Nurfed_DefaultColorPlayerHealth; |
||
479 | DEFAULT_CHAT_FRAME:AddMessage("Reverting player health color state to default.", 1, 1, 1); |
||
480 | elseif (msg == "help") then |
||
481 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayerhealth /ubcolorplayerhealth", 1, 0.89, 0.01); |
||
482 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
483 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player health.", 1, 1, 1); |
||
484 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player health.", 1, 1, 1); |
||
485 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
486 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
487 | elseif (msg == "") then |
||
488 | if (Nurfed_ColorPlayerHealth == 1) then |
||
489 | Nurfed_ColorPlayerHealth = 0; |
||
490 | DEFAULT_CHAT_FRAME:AddMessage("Setting player health display text color to default.", 1, 1, 1); |
||
491 | else |
||
492 | Nurfed_ColorPlayerHealth = 1; |
||
493 | DEFAULT_CHAT_FRAME:AddMessage("Setting player health display text to color according to health percentage.", 1, 1, 1); |
||
494 | end |
||
495 | else |
||
496 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayerhealth /ubcolorplayerhealth", 1, 0.89, 0.01); |
||
497 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
498 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player health.", 1, 1, 1); |
||
499 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player health.", 1, 1, 1); |
||
500 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
501 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
502 | end |
||
503 | end |
||
504 | |||
505 | function Nurfed_ColorPlayerManaSlashHanlder (msg) |
||
506 | msg = string.lower(msg); |
||
507 | if (msg == "yes" or msg == "1" or msg == "true") then |
||
508 | Nurfed_ColorPlayerMana = 1; |
||
509 | DEFAULT_CHAT_FRAME:AddMessage("Setting player mana display text to color according to mana type.", 1, 1, 1); |
||
510 | elseif (msg == "no" or msg == "0" or msg == "false") then |
||
511 | Nurfed_ColorPlayerMana = 0; |
||
512 | DEFAULT_CHAT_FRAME:AddMessage("Setting player mana display text color to default.", 1, 1, 1); |
||
513 | elseif (msg == "default" or msg == "reset" or msg == "revert") then |
||
514 | Nurfed_ColorPlayerMana = Nurfed_DefaultColorPlayerMana; |
||
515 | DEFAULT_CHAT_FRAME:AddMessage("Reverting player mana text display state to default.", 1, 1, 1); |
||
516 | elseif (msg == "help") then |
||
517 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayermana /ubcolorplayermana", 1, 0.89, 0.01); |
||
518 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
519 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player mana.", 1, 1, 1); |
||
520 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player mana.", 1, 1, 1); |
||
521 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
522 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
523 | elseif (msg == "") then |
||
524 | if (Nurfed_ColorPlayerMana == 1) then |
||
525 | Nurfed_ColorPlayerMana = 0; |
||
526 | DEFAULT_CHAT_FRAME:AddMessage("Setting player mana display text color to default.", 1, 1, 1); |
||
527 | else |
||
528 | Nurfed_ColorPlayerMana = 1; |
||
529 | DEFAULT_CHAT_FRAME:AddMessage("Setting player mana display text to color according to mana type.", 1, 1, 1); |
||
530 | end |
||
531 | else |
||
532 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayermana /ubcolorplayermana", 1, 0.89, 0.01); |
||
533 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
534 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player mana.", 1, 1, 1); |
||
535 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player mana.", 1, 1, 1); |
||
536 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
537 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
538 | end |
||
539 | end |
||
540 | |||
541 | function Nurfed_ColorPlayerNameSlashHanlder (msg) |
||
542 | msg = string.lower(msg); |
||
543 | if (msg == "yes" or msg == "1" or msg == "true") then |
||
544 | Nurfed_ColorPlayerName = 1; |
||
545 | DEFAULT_CHAT_FRAME:AddMessage("Setting player name text to color red when attack is on.", 1, 1, 1); |
||
546 | elseif (msg == "no" or msg == "0" or msg == "false") then |
||
547 | Nurfed_ColorPlayerName = 0; |
||
548 | DEFAULT_CHAT_FRAME:AddMessage("Setting player name text to stay default.", 1, 1, 1); |
||
549 | elseif (msg == "default" or msg == "reset" or msg == "revert") then |
||
550 | Nurfed_ColorPlayerName = Nurfed_DefaultColorPlayerName; |
||
551 | DEFAULT_CHAT_FRAME:AddMessage("Reverting player name text display state to default.", 1, 1, 1); |
||
552 | elseif (msg == "help") then |
||
553 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayername /ubcolorplayername", 1, 0.89, 0.01); |
||
554 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
555 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player name on attack.", 1, 1, 1); |
||
556 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player name on attack.", 1, 1, 1); |
||
557 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
558 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
559 | elseif (msg == "") then |
||
560 | if (Nurfed_ColorPlayerName == 1) then |
||
561 | Nurfed_ColorPlayerName = 0; |
||
562 | DEFAULT_CHAT_FRAME:AddMessage("Setting player name text to stay default.", 1, 1, 1); |
||
563 | else |
||
564 | Nurfed_ColorPlayerName = 1; |
||
565 | DEFAULT_CHAT_FRAME:AddMessage("Setting player name text to color red when attack is on.", 1, 1, 1); |
||
566 | end |
||
567 | else |
||
568 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayername /ubcolorplayername", 1, 0.89, 0.01); |
||
569 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
570 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player name on attack.", 1, 1, 1); |
||
571 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player name on attack.", 1, 1, 1); |
||
572 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
573 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
574 | end |
||
575 | end |
||
576 | |||
577 | function Nurfed_ColorPlayerHealthBarSlashHanlder (msg) |
||
578 | msg = string.lower(msg); |
||
579 | if (msg == "yes" or msg == "1" or msg == "true") then |
||
580 | Nurfed_ColorPlayerHealthBar = 1; |
||
581 | DEFAULT_CHAT_FRAME:AddMessage("Coloring player health bar progressively.", 1, 1, 1); |
||
582 | elseif (msg == "no" or msg == "0" or msg == "false") then |
||
583 | Nurfed_ColorPlayerHealthBar = 0; |
||
584 | DEFAULT_CHAT_FRAME:AddMessage("Coloring player health bar normally.", 1, 1, 1); |
||
585 | elseif (msg == "default" or msg == "reset" or msg == "revert") then |
||
586 | Nurfed_ColorPlayerHealthBar = Nurfed_DefaultColorPlayerHealthBar; |
||
587 | DEFAULT_CHAT_FRAME:AddMessage("Reverting player health bar option state to default.", 1, 1, 1); |
||
588 | elseif (msg == "help") then |
||
589 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayerhealthbar /ubcolorplayerhealthbar", 1, 0.89, 0.01); |
||
590 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
591 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player health bar progressively.", 1, 1, 1); |
||
592 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player health bar progressively.", 1, 1, 1); |
||
593 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
594 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
595 | elseif (msg == "") then |
||
596 | if (Nurfed_ColorPlayerHealthBar == 1) then |
||
597 | Nurfed_ColorPlayerHealthBar = 0; |
||
598 | DEFAULT_CHAT_FRAME:AddMessage("Coloring player health bar normally.", 1, 1, 1); |
||
599 | else |
||
600 | Nurfed_ColorPlayerHealthBar = 1; |
||
601 | DEFAULT_CHAT_FRAME:AddMessage("Coloring player health bar progressively.", 1, 1, 1); |
||
602 | end |
||
603 | else |
||
604 | DEFAULT_CHAT_FRAME:AddMessage("Valid parameters for: /unitbarcolorplayerhealthbar /ubcolorplayerhealthbar", 1, 0.89, 0.01); |
||
605 | DEFAULT_CHAT_FRAME:AddMessage(" help - This listing.", 1, 1, 1); |
||
606 | DEFAULT_CHAT_FRAME:AddMessage(" yes, true, or 1 - Color player health bar progressively.", 1, 1, 1); |
||
607 | DEFAULT_CHAT_FRAME:AddMessage(" no, false, or 0 - Do not color player health bar progressively.", 1, 1, 1); |
||
608 | DEFAULT_CHAT_FRAME:AddMessage(" default, reset, or revert - Revert to default state.", 1, 1, 1); |
||
609 | DEFAULT_CHAT_FRAME:AddMessage(" blank - Toggle based on current state.", 1, 1, 1); |
||
610 | end |
||
611 | end |