vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local name = "ToolTip";
2 local version = "5.8";
3 --Author's Notes------------------------------------------------------------------------------------------------
4 ----------------------------------------------------------------------------------------------------------------
5 --[[
6 Description: Drastically improves the game's tooltip.
7 Author: AquaFlare7 (AquaFlare7@comcast.net)
8 --]]
9  
10  
11  
12 --onEvent Routines----------------------------------------------------------------------------------------------
13 ----------------------------------------------------------------------------------------------------------------
14 function aftt_toggleFrames()
15 if (aftt_optionFrame:IsVisible()) then
16 aftt_optionFrame:Hide();
17 else
18 aftt_optionFrame:Show();
19 end
20 end
21  
22 function aftt_buttonToggle(option)
23 if (option == "guild") then
24 --0, hide -> toggles to show
25 --1, show -> toggles to showbottom
26 --2, showbottom -> toggles to hide
27 if (AF_ToolTip[aftt_localUser]["Guild"] == 0 or AF_ToolTip[aftt_localUser]["Guild"] == nil) then
28 AF_ToolTip[aftt_localUser]["Guild"] = 1;
29 elseif (AF_ToolTip[aftt_localUser]["Guild"] == 1) then
30 AF_ToolTip[aftt_localUser]["Guild"] = 2;
31 elseif (AF_ToolTip[aftt_localUser]["Guild"] == 2) then
32 AF_ToolTip[aftt_localUser]["Guild"] = 0;
33 end
34 elseif (option == "reaction") then
35 if (AF_ToolTip[aftt_localUser]["ReactionText"] == 1) then
36 AF_ToolTip[aftt_localUser]["ReactionText"] = 0;
37 else
38 AF_ToolTip[aftt_localUser]["ReactionText"] = 1;
39 end
40 elseif (option == "tapped") then
41 if (AF_ToolTip[aftt_localUser]["Tapped"] == 1) then
42 AF_ToolTip[aftt_localUser]["Tapped"] = 0;
43 else
44 AF_ToolTip[aftt_localUser]["Tapped"] = 1;
45 end
46 elseif (option == "pvp") then
47 if (AF_ToolTip[aftt_localUser]["PvP"] == 1) then
48 AF_ToolTip[aftt_localUser]["PvP"] = 0;
49 else
50 AF_ToolTip[aftt_localUser]["PvP"] = 1;
51 end
52 elseif (option == "fade") then
53 if (AF_ToolTip[aftt_localUser]["Fade"] == 1) then
54 AF_ToolTip[aftt_localUser]["Fade"] = 0;
55 else
56 AF_ToolTip[aftt_localUser]["Fade"] = 1;
57 end
58 elseif (option == "rank") then
59 if (AF_ToolTip[aftt_localUser]["Rank"] == 1) then
60 AF_ToolTip[aftt_localUser]["Rank"] = 2;
61 elseif (AF_ToolTip[aftt_localUser]["Rank"] == 2) then
62 AF_ToolTip[aftt_localUser]["Rank"] = 0;
63 else
64 AF_ToolTip[aftt_localUser]["Rank"] = 1;
65 end
66 elseif (option == "anchor") then
67 --mouse -> topleft
68 --topleft -> top
69 --top -> topright
70 --topright -> left
71 --left -> center
72 --center -> right
73 --right -> bottomleft
74 --bottomleft -> bottom
75 --bottom -> bottomright
76 --bottomright -> mouse
77 if (AF_ToolTip[aftt_localUser]["Anchor"] == "mouse") then
78 AF_ToolTip[aftt_localUser]["Anchor"] = "topleft";
79 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
80 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "topleft") then
81 AF_ToolTip[aftt_localUser]["Anchor"] = "top";
82 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
83 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "top") then
84 AF_ToolTip[aftt_localUser]["Anchor"] = "topright";
85 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
86 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "topright") then
87 AF_ToolTip[aftt_localUser]["Anchor"] = "left";
88 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
89 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "left") then
90 AF_ToolTip[aftt_localUser]["Anchor"] = "center";
91 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
92 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "center") then
93 AF_ToolTip[aftt_localUser]["Anchor"] = "right";
94 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
95 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "right") then
96 AF_ToolTip[aftt_localUser]["Anchor"] = "bottomleft";
97 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
98 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "bottomleft") then
99 AF_ToolTip[aftt_localUser]["Anchor"] = "bottom";
100 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
101 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "bottom") then
102 AF_ToolTip[aftt_localUser]["Anchor"] = "bottomright";
103 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
104 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "bottomright") then
105 AF_ToolTip[aftt_localUser]["Anchor"] = "none";
106 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
107 elseif (AF_ToolTip[aftt_localUser]["Anchor"] == "none") then
108 AF_ToolTip[aftt_localUser]["Anchor"] = "mouse";
109 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
110 end
111 elseif (option == "x+") then
112 AF_ToolTip[aftt_localUser]["PositionX"] = AF_ToolTip[aftt_localUser]["PositionX"] + 5;
113 elseif (option == "y+") then
114 AF_ToolTip[aftt_localUser]["PositionY"] = AF_ToolTip[aftt_localUser]["PositionY"] + 5;
115 elseif (option == "x-") then
116 if (AF_ToolTip[aftt_localUser]["PositionX"] <= 5) then
117 AF_ToolTip[aftt_localUser]["PositionX"] = 0;
118 else
119 AF_ToolTip[aftt_localUser]["PositionX"] = AF_ToolTip[aftt_localUser]["PositionX"] - 5;
120 end
121 elseif (option == "y-") then
122 if (AF_ToolTip[aftt_localUser]["PositionY"] <= 5) then
123 AF_ToolTip[aftt_localUser]["PositionY"] = 0;
124 else
125 AF_ToolTip[aftt_localUser]["PositionY"] = AF_ToolTip[aftt_localUser]["PositionY"] - 5;
126 end
127 end
128 end
129  
130 function aftt_onEvent()
131 if (event == "UPDATE_MOUSEOVER_UNIT") then
132 if (UnitName("mouseover")) then
133 AF_ToolTipRefresh:Show();
134 end
135 end
136 end
137  
138 function aftt_GameTooltip_OnEvent()
139 aftt_Old_GameTooltip_OnEvent();
140 if (event ~= "CLEAR_TOOLTIP" and UnitExists("mouseover")) then
141 aftt_format("mouseover");
142 end
143 end
144  
145 function aftt_onRefresh()
146 --Set our options frame refresh
147 if (aftt_optionFrame:IsVisible()) then
148 aftt_TextLeft1:SetText("Anchor:");
149 aftt_TextRight1:SetText(AF_ToolTip[aftt_localUser]["Anchor"]);
150 aftt_TextLeft2:SetText("Offset X:");
151 aftt_TextRight2:SetText(AF_ToolTip[aftt_localUser]["PositionX"]);
152 aftt_TextLeft3:SetText("Offset Y:");
153 aftt_TextRight3:SetText(AF_ToolTip[aftt_localUser]["PositionY"]);
154 if (AF_ToolTip[aftt_localUser]["Anchor"] ~= "mouse" and AF_ToolTip[aftt_localUser]["Anchor"] ~= "none") then
155 aftt_previous2:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up");
156 aftt_previous3:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up");
157 aftt_next2:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
158 aftt_next3:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
159 aftt_TextLeft2:SetVertexColor(1.0, 0.8, 0.0);
160 aftt_TextRight2:SetVertexColor(1.0, 0.8, 0.0);
161 aftt_TextLeft3:SetVertexColor(1.0, 0.8, 0.0);
162 aftt_TextRight3:SetVertexColor(1.0, 0.8, 0.0);
163 else
164 aftt_previous2:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled");
165 aftt_previous3:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled");
166 aftt_next2:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
167 aftt_next3:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
168 aftt_TextLeft2:SetVertexColor(0.3, 0.3, 0.3);
169 aftt_TextRight2:SetVertexColor(0.3, 0.3, 0.3);
170 aftt_TextLeft3:SetVertexColor(0.3, 0.3, 0.3);
171 aftt_TextRight3:SetVertexColor(0.3, 0.3, 0.3);
172 end
173 aftt_TextLeft4:SetText("Fade:");
174 if (AF_ToolTip[aftt_localUser]["Fade"] == 1) then
175 aftt_TextLeft4:SetVertexColor(1.0, 0.8, 0.0);
176 aftt_TextRight4:SetVertexColor(1.0, 0.8, 0.0);
177 aftt_TextRight4:SetText("Enabled");
178 else
179 aftt_TextLeft4:SetVertexColor(0.4, 0.4, 0.0);
180 aftt_TextRight4:SetVertexColor(0.4, 0.4, 0.0);
181 aftt_TextRight4:SetText("Disabled");
182 end
183  
184 aftt_TextLeft5:SetText("PvP:");
185 if (AF_ToolTip[aftt_localUser]["PvP"] == 1) then
186 aftt_TextLeft5:SetVertexColor(1.0, 0.8, 0.0);
187 aftt_TextRight5:SetVertexColor(1.0, 0.8, 0.0);
188 aftt_TextRight5:SetText("Shown");
189 else
190 aftt_TextLeft5:SetVertexColor(0.4, 0.4, 0.0);
191 aftt_TextRight5:SetVertexColor(0.4, 0.4, 0.0);
192 aftt_TextRight5:SetText("Hidden");
193 end
194  
195 aftt_TextLeft6:SetText("Tapped:");
196 if (AF_ToolTip[aftt_localUser]["Tapped"] == 1) then
197 aftt_TextLeft6:SetVertexColor(1.0, 0.8, 0.0);
198 aftt_TextRight6:SetVertexColor(1.0, 0.8, 0.0);
199 aftt_TextRight6:SetText("Shown");
200 else
201 aftt_TextLeft6:SetVertexColor(0.4, 0.4, 0.0);
202 aftt_TextRight6:SetVertexColor(0.4, 0.4, 0.0);
203 aftt_TextRight6:SetText("Hidden");
204 end
205  
206 aftt_TextLeft7:SetText("Reaction:");
207 if (AF_ToolTip[aftt_localUser]["ReactionText"] == 1) then
208 aftt_TextLeft7:SetVertexColor(1.0, 0.8, 0.0);
209 aftt_TextRight7:SetVertexColor(1.0, 0.8, 0.0);
210 aftt_TextRight7:SetText("Shown");
211 else
212 aftt_TextLeft7:SetVertexColor(0.4, 0.4, 0.0);
213 aftt_TextRight7:SetVertexColor(0.4, 0.4, 0.0);
214 aftt_TextRight7:SetText("Hidden");
215 end
216  
217 aftt_TextLeft8:SetText("Guild:");
218 if (AF_ToolTip[aftt_localUser]["Guild"] == 1) then
219 aftt_TextLeft8:SetVertexColor(1.0, 0.8, 0.0);
220 aftt_TextRight8:SetVertexColor(1.0, 0.8, 0.0);
221 aftt_TextRight8:SetText("Top");
222 elseif (AF_ToolTip[aftt_localUser]["Guild"] == 2) then
223 aftt_TextLeft8:SetVertexColor(1.0, 0.8, 0.0);
224 aftt_TextRight8:SetVertexColor(1.0, 0.8, 0.0);
225 aftt_TextRight8:SetText("Bottom");
226 else
227 aftt_TextLeft8:SetVertexColor(0.4, 0.4, 0.0);
228 aftt_TextRight8:SetVertexColor(0.4, 0.4, 0.0);
229 aftt_TextRight8:SetText("Hidden");
230 end
231  
232 aftt_TextLeft9:SetText("Rank:");
233 if (AF_ToolTip[aftt_localUser]["Rank"] == 1) then
234 aftt_TextLeft9:SetVertexColor(1.0, 0.8, 0.0);
235 aftt_TextRight9:SetVertexColor(1.0, 0.8, 0.0);
236 aftt_TextRight9:SetText("Text");
237 elseif (AF_ToolTip[aftt_localUser]["Rank"] == 2) then
238 aftt_TextLeft9:SetVertexColor(1.0, 0.8, 0.0);
239 aftt_TextRight9:SetVertexColor(1.0, 0.8, 0.0);
240 aftt_TextRight9:SetText("Numeric");
241 else
242 aftt_TextLeft9:SetVertexColor(0.4, 0.4, 0.0);
243 aftt_TextRight9:SetVertexColor(0.4, 0.4, 0.0);
244 aftt_TextRight9:SetText("Hidden");
245 end
246  
247 aftt_TextLeft10:SetText(aftt_color_chart_name);
248 aftt_TextLeft11:SetText(aftt_color_chart_author);
249 end
250 if (UnitExists("mouseover") == nil) then
251 aftt_updateFlag = {
252 ["Previous"] = "none";
253 ["Current"] = "none";
254 ["Reaction"] = 0;
255 ["EasterEgg"] = 0;
256 ["Guild"] = 0;
257 ["PvP"] = 0;
258 ["RankFlag"] = 0;
259 }
260 if (AF_ToolTip[aftt_localUser]["Fade"] == 0 or AF_ToolTip[aftt_localUser]["Fade"] == nil) then
261 GameTooltip:Hide();
262 end
263 AF_ToolTipRefresh:Hide();
264 else
265 aftt_format("mouseover");
266 end
267 end
268  
269 function aftt_UnitFrame_OnEnter()
270 aftt_Old_UnitFrame_OnEnter();
271 aftt_updateFlag["Previous"] = "none";
272 if (SHOW_NEWBIE_TIPS ~= "1") then
273 aftt_format(this.unit);
274 end
275 aftt_updateFlag["Previous"] = "none";
276 end
277  
278 function aftt_UnitFrame_OnLeave()
279 if ( SpellIsTargeting() ) then
280 SetCursor("CAST_ERROR_CURSOR");
281 end
282 this.updateTooltip = nil;
283 if (SHOW_NEWBIE_TIPS == "1" or AF_ToolTip[aftt_localUser]["Fade"] == 0) then
284 GameTooltip:Hide();
285 else
286 GameTooltip:FadeOut();
287 end
288 end
289  
290 function aftt_TargetFrame_OnEnter()
291 aftt_Old_TargetFrame_OnEnter();
292 aftt_updateFlag["Previous"] = "none";
293 aftt_format("mouseover");
294 aftt_updateFlag["Previous"] = "none";
295 end
296  
297 --preLoad Timer Setup-------------------------------------------------------------------------------------------
298 ----------------------------------------------------------------------------------------------------------------
299 function aftt_unitInit()
300 local playerName = UnitName("player");
301 local realmName = GetCVar("realmName");
302 if (playerName == nil or playerName == UNKNOWNBEING or playerName == UKNOWNBEING or playerName == UNKNOWNOBJECT) then
303 return;
304 end
305 aftt_playerName = playerName;
306 aftt_realmName = realmName;
307 aftt_timerDone = 1;
308 AF_ToolTipFrame:Hide();
309 end
310 aftt_Timer = 0;
311 aftt_timerDone = nil;
312 function aftt_onUpdate(arg1)
313 aftt_Timer = aftt_Timer + arg1
314 if not aftt_timerDone and aftt_Timer>0.2 then
315 aftt_unitInit();
316 aftt_Timer = 0;
317 end
318 if (aftt_timerDone == 1) then
319 aftt_onLoad();
320 end
321 end
322  
323  
324  
325 --onLoad Routine------------------------------------------------------------------------------------------------
326 ----------------------------------------------------------------------------------------------------------------
327 function aftt_onLoad()
328  
329 --Set our frame with the name and version
330 aftt_TextHeader:SetText("AF_" .. name .. " v" .. version);
331 aftt_TextHeader2:SetText("Color Chart Details");
332 aftt_TextHeader:SetVertexColor(1.0, 1.0, 1.0);
333 aftt_TextHeader2:SetVertexColor(1.0, 1.0, 1.0);
334 aftt_TextLeft9:SetVertexColor(1.0, 0.8, 0.0);
335 aftt_TextLeft10:SetVertexColor(0.0, 0.6, 1.0);
336 --Create update table
337 aftt_updateFlag = {
338 ["Previous"] = "none";
339 ["Current"] = "none";
340 ["Reaction"] = 0;
341 ["EasterEgg"] = 0;
342 ["Guild"] = 0;
343 ["PvP"] = 0;
344 ["RankFlag"] = 0;
345 }
346  
347 --Create user table if it doesnt exist
348 aftt_localUser = (aftt_playerName .. "|" .. aftt_realmName);
349 if (AF_ToolTip == nil) then
350 AF_ToolTip = {};
351 end
352 if (AF_ToolTip[aftt_localUser] == nil) then
353 AF_ToolTip[aftt_localUser] = {
354 ["Anchor"] = "none";
355 ["PositionX"] = 0;
356 ["PositionY"] = 15;
357 ["Fade"] = 1;
358 ["PvP"] = 0;
359 ["ReactionText"] = 0;
360 ["Guild"] = 1;
361 ["Rank"] = 1;
362 ["Tapped"] = 1;
363 }
364 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00<AF>|rToolTip: User Table for " .. aftt_playerName .. " created successfully!");
365 end
366  
367 --Register our slash commands for use
368 aftt_slashCommands();
369  
370 --Swap Blizzard's unit frame mouseover function out for our own (making sure to backup the old function)
371 aftt_Old_UnitFrame_OnEnter = UnitFrame_OnEnter;
372 UnitFrame_OnEnter = aftt_UnitFrame_OnEnter;
373 aftt_Old_UnitFrame_OnLeave = UnitFrame_OnLeave;
374 UnitFrame_OnLeave = aftt_UnitFrame_OnLeave;
375  
376 --Swap Blizzard's target frame mouseover function out for our own (making sure to backup the old function)
377 aftt_Old_TargetFrame_OnEnter = TargetFrame_OnEnter;
378 TargetFrame_OnEnter = aftt_TargetFrame_OnEnter;
379  
380 --Swap Blizzard's tooltip anchor function out for our own (making sure to backup the old function)
381 aftt_OriginalGameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
382 GameTooltip_SetDefaultAnchor = aftt_GameTooltip_SetDefaultAnchor;
383  
384 --Swap Blizzard's tooltip event function out for our own (making sure to backup the old function)
385 aftt_Old_GameTooltip_OnEvent = GameTooltip_OnEvent;
386 GameTooltip_OnEvent = aftt_GameTooltip_OnEvent;
387  
388 --Set colors
389 --loaded from colorChart.lua
390  
391 --Output message to let player know AF_ToolTip has loaded, and if there were any missing colors
392 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00<AF>|rToolTip: v" .. version .. " " .. aftt_translate_loaded .. " for " .. aftt_playerName .. " of " .. aftt_realmName);
393 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00<AF>|rToolTip: Theme: |cff0099FF" .. aftt_color_chart_name .. "|r by |cff0099FF" .. aftt_color_chart_author .. "|r applied");
394 if (aftt_variableChecker_Flag == 1) then
395 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00<AF>|rToolTip: |cffFF0000[WARNING]|r: some colors are missing from current color chart, defaulting them to white");
396 end
397 end
398  
399  
400  
401 --Unit MouseOver Routine----------------------------------------------------------------------------------------
402 ----------------------------------------------------------------------------------------------------------------
403 function aftt_format(unit)
404  
405  
406 --Data Collection------------------------------------------
407 -----------------------------------------------------------
408 --detect if on same unit from previous refresh
409 aftt_updateFlag["Current"] = UnitName(unit);
410 if (aftt_updateFlag["Current"] == aftt_updateFlag["Previous"] and aftt_updateFlag["Previous"] ~= "none") then
411 --do not reset flags, we're on the same unit
412 else
413 aftt_updateFlag = {
414 ["EasterEgg"] = 0;
415 ["Guild"] = 0;
416 ["PvP"] = 0;
417 ["RankFlag"] = 0;
418 }
419 end
420  
421 --[[
422 --detect Blizzard's tooltip bug that shows bogus data instead of a unit
423 --currently disabled due to issues with non enUS client
424 local firstLine = GameTooltipTextLeft1:GetText();
425 local nameLine, matched;
426 if (firstLine) then
427 nameLine, matched = string.gsub(GameTooltipTextLeft1:GetText(), (UnitName(unit) .. ".*"), "");
428 if (matched == 1) then
429 --not bugged
430 else
431 --bugged, lets hide it
432 GameTooltip:Hide();
433 --DEFAULT_CHAT_FRAME:AddMessage("Found item bug: " .. firstLine);
434 end
435 end
436 --]]
437  
438 --unit race
439 if (UnitRace(unit) and UnitIsPlayer(unit)) then
440 --race, it is a player
441 aftt_text_race = UnitRace(unit);
442 elseif (UnitPlayerControlled(unit)) then
443 --creature family, its is a pet
444 aftt_text_race = UnitCreatureFamily(unit);
445 aftt_color_race = aftt_color_race_mob;
446 else
447 --creature type, it is a mob
448 if (UnitCreatureType(unit) == aftt_translate_notspecified) then
449 aftt_text_race = ""
450 aftt_color_race = aftt_color_race_mob;
451 else
452 aftt_text_race = UnitCreatureType(unit);
453 aftt_color_race = aftt_color_race_mob;
454 end
455 end
456 if (aftt_text_race == nil) then
457 aftt_text_race = ("");
458 else
459 aftt_text_race = (aftt_text_race .. " ");
460 end
461 aftt_color_race = "FFFFFF";
462  
463 --unit class
464 if (UnitClass(unit) and UnitIsPlayer(unit)) then
465 aftt_text_class = (UnitClass(unit) .. " ");
466 if (UnitClass(unit) == aftt_translate_mage) then
467 aftt_color_class = aftt_color_class_mage;
468 elseif (UnitClass(unit) == aftt_translate_warlock) then
469 aftt_color_class = aftt_color_class_warlock;
470 elseif (UnitClass(unit) == aftt_translate_priest) then
471 aftt_color_class = aftt_color_class_priest;
472 elseif (UnitClass(unit) == aftt_translate_druid) then
473 aftt_color_class = aftt_color_class_druid;
474 elseif (UnitClass(unit) == aftt_translate_shaman) then
475 aftt_color_class = aftt_color_class_shaman;
476 elseif (UnitClass(unit) == aftt_translate_paladin) then
477 aftt_color_class = aftt_color_class_paladin;
478 elseif (UnitClass(unit) == aftt_translate_rogue) then
479 aftt_color_class = aftt_color_class_rogue;
480 elseif (UnitClass(unit) == aftt_translate_hunter) then
481 aftt_color_class = aftt_color_class_hunter;
482 elseif (UnitClass(unit) == aftt_translate_warrior) then
483 aftt_color_class = aftt_color_class_warrior;
484 else
485 aftt_color_class = aftt_color_unknown;
486 end
487 else
488 aftt_text_class = "";
489 aftt_color_class = aftt_color_unknown;
490 end
491  
492 --unit elite
493 if (UnitClassification(unit) and UnitClassification(unit) ~= "normal" and UnitHealth(unit) > 0) then
494 if (UnitClassification(unit) == "elite") then
495 aftt_text_elite = ("(" .. aftt_translate_elite .. ")");
496 aftt_color_elite = aftt_color_elite_elite;
497 elseif (UnitClassification(unit) == "worldboss") then
498 aftt_text_elite = ("(" .. aftt_translate_worldboss .. ")");
499 aftt_color_elite = aftt_color_elite_worldboss;
500 elseif (UnitClassification(unit) == "rare") then
501 aftt_text_elite = ("(" .. aftt_translate_rare .. ")");
502 aftt_color_elite = aftt_color_elite_rare;
503 elseif (UnitClassification(unit) == "rareelite") then
504 aftt_text_elite = ("(" .. aftt_translate_rareelite .. ")");
505 aftt_color_elite = aftt_color_elite_rareelite;
506 else
507 aftt_text_elite = ("(" .. UnitClassification(unit) .. ")");
508 aftt_color_elite = aftt_color_unknown;
509 end
510 else
511 aftt_text_elite = "";
512 aftt_color_elite = aftt_color_unknown;
513 end
514  
515 --unit name, description and bg color
516 if (UnitPlayerControlled(unit)) then
517 if (UnitCanAttack(unit, "player") and UnitCanAttack ("player",unit)) then
518 --red, hostile, both can attack
519 GameTooltip:SetBackdropColor(aftt_background_color["Player_Hostile"]["red"], aftt_background_color["Player_Hostile"]["green"], aftt_background_color["Player_Hostile"]["blue"]);
520 aftt_color_name = aftt_color_name_hostile;
521 aftt_color_description = aftt_color_description_hostile;
522 aftt_text_reaction = aftt_translate_hostile;
523 elseif (not UnitCanAttack(unit, "player") and UnitCanAttack("player",unit)) then
524 --yellow, neutral, only I can attack
525 GameTooltip:SetBackdropColor(aftt_background_color["Player_Neutral"]["red"], aftt_background_color["Player_Neutral"]["green"], aftt_background_color["Player_Neutral"]["blue"]);
526 aftt_color_name = aftt_color_name_neutral;
527 aftt_color_description = aftt_color_description_neutral;
528 aftt_text_reaction = aftt_translate_neutral;
529 elseif (UnitCanAttack(unit, "player") and not UnitCanAttack("player",unit)) then
530 --purple, caution, only they can attack
531 GameTooltip:SetBackdropColor(aftt_background_color["Player_Caution"]["red"], aftt_background_color["Player_Caution"]["green"], aftt_background_color["Player_Caution"]["blue"]);
532 aftt_color_name = aftt_color_name_caution;
533 aftt_color_description = aftt_color_description_caution;
534 aftt_text_reaction = aftt_translate_caution;
535 elseif (not UnitCanAttack(unit, "player") and not UnitCanAttack("player",unit)) then
536 if (UnitIsPVP(unit)) then
537 --green, friendly pvp, neither can attack
538 GameTooltip:SetBackdropColor(aftt_background_color["Player_Friendly_PvP"]["red"], aftt_background_color["Player_Friendly_PvP"]["green"], aftt_background_color["Player_Friendly_PvP"]["blue"]);
539 aftt_color_name = aftt_color_name_pvp;
540 aftt_color_description = aftt_color_description_pvp;
541 aftt_text_reaction = aftt_translate_friendly;
542 else
543 --blue, friendly, neither can attack
544 GameTooltip:SetBackdropColor(aftt_background_color["Player_Friendly"]["red"], aftt_background_color["Player_Friendly"]["green"], aftt_background_color["Player_Friendly"]["blue"]);
545 aftt_color_name = aftt_color_name_friendly;
546 aftt_color_description = aftt_color_description_friendly;
547 aftt_text_reaction = aftt_translate_friendly;
548 end
549 end
550 elseif (UnitReaction(unit,"player") and UnitReaction(unit,"player") <= 3) then
551 --red, they are hostile
552 GameTooltip:SetBackdropColor(aftt_background_color["Mob_Hostile"]["red"], aftt_background_color["Mob_Hostile"]["green"], aftt_background_color["Mob_Hostile"]["blue"]);
553 aftt_color_name = aftt_color_name_hostile;
554 aftt_text_reaction = aftt_translate_hostile;
555 aftt_color_description = aftt_color_description_hostile
556 elseif (UnitReaction(unit,"player") and UnitReaction(unit,"player") == 4) then
557 --yellow, they are neutral
558 GameTooltip:SetBackdropColor(aftt_background_color["Mob_Neutral"]["red"], aftt_background_color["Mob_Neutral"]["green"], aftt_background_color["Mob_Neutral"]["blue"]);
559 aftt_color_name = aftt_color_name_neutral;
560 aftt_text_reaction = aftt_translate_neutral;
561 aftt_color_description = aftt_color_description_neutral
562 else
563 if (UnitIsPVP(unit)) then
564 --green, pvp enabled friend
565 GameTooltip:SetBackdropColor(aftt_background_color["Mob_Friendly_PvP"]["red"], aftt_background_color["Mob_Friendly_PvP"]["green"], aftt_background_color["Mob_Friendly_PvP"]["blue"]);
566 aftt_color_name = aftt_color_name_pvp;
567 aftt_color_description = aftt_color_description_pvp
568 else
569 --blue, they are friendly
570 GameTooltip:SetBackdropColor(aftt_background_color["Mob_Friendly"]["red"], aftt_background_color["Mob_Friendly"]["green"], aftt_background_color["Mob_Friendly"]["blue"]);
571 aftt_color_name = aftt_color_name_friendly;
572 aftt_color_description = aftt_color_description_friendly;
573 end
574 aftt_text_reaction = aftt_translate_friendly;
575 end
576 --unit tapped?
577 if (AF_ToolTip[aftt_localUser]["Tapped"] == 1) then
578 if (UnitIsTapped(unit)and (not UnitIsTappedByPlayer(unit))) then
579 aftt_color_name = aftt_color_name_tapped_by_other;
580 aftt_color_description = aftt_color_description_tapped_by_other;
581 aftt_text_reaction = aftt_translate_tapped;
582 elseif (UnitIsTappedByPlayer(unit)) then
583 GameTooltip:SetBackdropColor(aftt_background_color["Mob_Hostile"]["red"], aftt_background_color["Mob_Hostile"]["green"], aftt_background_color["Mob_Hostile"]["blue"]);
584 aftt_color_name = aftt_color_name_tapped_by_me;
585 aftt_color_description = aftt_color_description_tapped_by_me;
586 aftt_text_reaction = aftt_translate_hostile;
587 end
588 end
589  
590 --unit level and level difference color
591 if (UnitLevel(unit) and UnitLevel(unit) >= 1) then
592 aftt_text_level = UnitLevel(unit);
593 else
594 aftt_text_level = "??";
595 end
596 aftt_text_level = (aftt_translate_level .. " " .. aftt_text_level .. " ");
597 local levelDiff = UnitLevel(unit) - UnitLevel("player");
598 if (UnitFactionGroup(unit) ~= UnitFactionGroup("player")) then
599 if ( levelDiff >= 5 or UnitLevel(unit) == -1) then
600 aftt_color_level = aftt_color_level_impossible
601 elseif ( levelDiff >= 3 ) then
602 aftt_color_level = aftt_color_level_hard;
603 elseif ( levelDiff >= -2 ) then
604 aftt_color_level = aftt_color_level_normal;
605 elseif ( -levelDiff <= GetQuestGreenRange() ) then
606 aftt_color_level = aftt_color_level_easy;
607 else
608 aftt_color_level = aftt_color_level_trivial;
609 end
610 else
611 aftt_color_level = aftt_color_level_same_faction;
612 end
613  
614 --pvp honor rank
615 if (aftt_updateFlag["RankFlag"] == 0) then
616 if (UnitPVPRank(unit)) then
617 aftt_rankName, aftt_rankNumber = GetPVPRankInfo(UnitPVPRank("mouseover"), "mouseover");
618 end
619 if (aftt_rankName == nil) then
620 aftt_rankName = "";
621 else
622 aftt_rankName = ("[" .. aftt_rankName .. "] ");
623 end
624 if (aftt_rankNumber == nil or aftt_rankNumber < 1) then
625 aftt_rankNumber = "";
626 else
627 aftt_rankNumber = ("[" .. aftt_rankNumber .. "] ");
628 end
629  
630 if (AF_ToolTip[aftt_localUser]["Rank"] == 1) then
631 aftt_rank = aftt_rankName;
632 elseif (AF_ToolTip[aftt_localUser]["Rank"] == 2) then
633 aftt_rank = aftt_rankNumber;
634 else
635 aftt_rank = "";
636 end
637  
638 aftt_updateFlag["RankFlag"] = 1;
639 else
640 if (aftt_rank == nil) then
641 aftt_rank = "";
642 end
643 end
644  
645 --unit is corpse
646 if (UnitHealth(unit) == 0) then
647 aftt_text_corpse = aftt_translate_corpse;
648 aftt_color_class = aftt_color_corpse;
649 aftt_color_race = aftt_color_corpse;
650 aftt_color_elite = aftt_color_corpse;
651 aftt_color_name = aftt_color_corpse;
652 aftt_color_description = aftt_color_corpse;
653 aftt_color_level = aftt_color_corpse;
654 else
655 aftt_text_corpse = "";
656 end
657  
658 --Output Name Data-----------------------------------------
659 -----------------------------------------------------------
660 if (AF_ToolTip[aftt_localUser]["ReactionText"] == 1) then
661 GameTooltipTextLeft1:SetText("|cff" .. aftt_color_name .. aftt_rank .. UnitName(unit) .. " (" .. aftt_text_reaction .. ")|r")
662 else
663 GameTooltipTextLeft1:SetText("|cff" .. aftt_color_name .. aftt_rank .. UnitName(unit) .. "|r");
664 end
665  
666 --Output Level Line Data-----------------------------------
667 -----------------------------------------------------------
668 local levelLine, matched;
669 if (GameTooltipTextLeft2:GetText() == nil) then
670 GameTooltip:Hide();
671 else
672 levelLine, matched = string.gsub(GameTooltipTextLeft2:GetText(), (aftt_translate_level .. ".*"), "");
673 if (matched == 1) then
674 levelLine = 2;
675 else
676 if (GameTooltipTextLeft3:GetText()) then
677 levelLine, matched = string.gsub(GameTooltipTextLeft3:GetText(), (aftt_translate_level .. ".*"), "");
678 if (matched == 1) then
679 levelLine = 3;
680 else
681 levelLine = nil;
682 end
683 else
684 levelLine = nil;
685 end
686 end
687 end
688 if (levelLine) then
689 getglobal("GameTooltipTextLeft" .. levelLine):SetText("|cff" .. aftt_color_level .. aftt_text_level .. "|r" .. "|cff" .. aftt_color_race .. aftt_text_race .. "|r" .. "|cff" .. aftt_color_class .. aftt_text_class .. "|r" .. "|cff" .. aftt_color_elite .. aftt_text_elite .. "|r" .. "|cff" .. aftt_color_corpse .. aftt_text_corpse .. "|r");
690 if (levelLine == 3) then
691 GameTooltipTextLeft2:SetText("|cff" .. aftt_color_description .. GameTooltipTextLeft2:GetText() .. "|r")
692 end
693 end
694  
695 --Append Easter Eggs---------------------------------------
696 -----------------------------------------------------------
697 if (aftt_updateFlag["EasterEgg"] == 0 and UnitName(unit) == "Iniko" and (GetCVar("realmName") == "Chromaggus")) then
698 GameTooltip:AddLine("|cff" .. aftt_color_name .. "The Author of AF_ToolTip|r");
699 aftt_updateFlag["EasterEgg"] = 1;
700 end
701  
702 --Show/Hide Guild------------------------------------------
703 -----------------------------------------------------------
704 if (aftt_updateFlag["Guild"] == 0 and GetGuildInfo(unit)) then
705 --Are they guildmates?
706 if (GetGuildInfo(unit) == GetGuildInfo("player")) then
707 aftt_color_guild = aftt_color_guildmate;
708 else
709 aftt_color_guild = aftt_color_description;
710 end
711 if (AF_ToolTip[aftt_localUser]["Guild"] == 0 or AF_ToolTip[aftt_localUser]["Guild"] == nil) then
712 --do nothing
713 elseif (AF_ToolTip[aftt_localUser]["Guild"] == 1) then
714 --Show
715 aftt_old_line2 = GameTooltipTextLeft2:GetText();
716 aftt_old_line3 = GameTooltipTextLeft3:GetText();
717 if (GameTooltipTextLeft3:GetText() ~= nil) then
718 GameTooltipTextLeft3:SetText(aftt_old_line2);
719 else
720 GameTooltip:AddLine(aftt_old_line2);
721 end
722 if (GameTooltipTextLeft4:GetText() ~= nil) then
723 GameTooltipTextLeft3:SetText(aftt_old_line3);
724 else
725 GameTooltip:AddLine(aftt_old_line3);
726 end
727 GameTooltipTextLeft2:SetText("|cff" .. aftt_color_guild .. GetGuildInfo(unit) .. "|r");
728 elseif (AF_ToolTip[aftt_localUser]["Guild"] == 2) then
729 --Show at Bottom
730 GameTooltip:AddLine("|cff" .. aftt_color_guild .. GetGuildInfo(unit) .. "|r");
731 end
732 aftt_updateFlag["Guild"] = 1;
733 end
734  
735 --Show/Hide PvP--------------------------------------------
736 -----------------------------------------------------------
737 aftt_lineCount = 1;
738 for i = 1, 10 do
739 aftt_getLine = getglobal("GameTooltipTextLeft" .. aftt_lineCount);
740 if (aftt_getLine:GetText()) then
741 local pvpLine, matchPVP;
742 pvpLine, matchPVP = string.gsub(aftt_getLine:GetText(), (aftt_translate_pvp .. ".*"), "");
743 if (matchPVP == 1) then
744 aftt_getLine:SetText("");
745 break;
746 else
747 aftt_lineCount = aftt_lineCount + 1;
748 end
749 end
750 end
751 if (AF_ToolTip[aftt_localUser]["PvP"] ~= 1) then
752  
753 else
754 if (UnitIsPVP(unit)) then
755 if (aftt_updateFlag["PvP"] == 0) then
756 GameTooltip:AddLine("|cffFFFFFFPvP|r");
757 aftt_updateFlag["PvP"] = 1;
758 end
759 end
760 end
761  
762 --Show Tooltip---------------------------------------------
763 -----------------------------------------------------------
764 GameTooltip:Show();
765 aftt_updateFlag["Previous"] = UnitName(unit);
766 end
767  
768  
769  
770 --Frame Mouseover Routines--------------------------------------------------------------------------------------
771 ----------------------------------------------------------------------------------------------------------------