vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 -- Name: TinyTip
3 -- Author: Thrae of Maelstrom (aka "Matthew Carras")
4 -- Release Date: 6-25-06
5 --
6 -- Based very losely off AF_Tooltip_Mini
7 -- Some code from PerfectTooltip by cladhaire
8 --
9 -- Thanks to #wowace and #wowi-lounge on Freenode as always for
10 -- optimization assistance.
11 --]]
12  
13 local _G = getfenv(0)
14 local strformat, strfind = string.format, string.find
15 local tmp,tmp2,tmp3,i
16  
17 local UIParent,GameTooltip = _G.UIParent,_G.GameTooltip
18 local tooltip = GameTooltip
19 local fGetAlpha, fSetAlpha, fHide, fShow, fSetBDColor, fGetBDColor, fSetBDBColor, fGetBDBColor, fSetPt, fClearPts, fSetScript, fGetName = UIParent.GetAlpha, UIParent.SetAlpha, UIParent.Show, UIParent.Hide, UIParent.SetBackdropColor, UIParent.GetBackdropColor, UIParent.SetBackdropBorderColor, UIParent.GetBackdropBorderColor, UIParent.SetPoint, UIParent.ClearAllPoints, UIParent.GetScript, UIParent.GetName
20  
21 local gtIsVisible, gtNumLines, gtAddLine, gtAddDoubleLine, gtLine1, gtLine2, gtLine3, gtSetOwner = GameTooltip.IsVisible, GameTooltip.NumLines, GameTooltip.AddLine, GameTooltip.AddDoubleLine, _G.GameTooltipTextLeft1, _G.GameTooltipTextLeft2, _G.GameTooltipTextLeft3, GameTooltip.SetOwner
22  
23 local sbShow = _G.GameTooltipStatusBar.Show
24  
25 local fsGetText, fsSetTextColor, fsGetTextColor, fsSetText, fsIsShown, fsGetWidth, fsHide, fsSetHeight, fsGetHeight = _G.GameTooltipTextLeft1.GetText, _G.GameTooltipTextLeft1.SetTextColor, _G.GameTooltipTextLeft1.GetTextColor, _G.GameTooltipTextLeft1.SetText, _G.GameTooltipTextLeft1.IsShown, _G.GameTooltipTextLeft1.GetWidth, _G.GameTooltipTextLeft1.Hide, _G.GameTooltipTextLeft1.SetHeight, _G.GameTooltipTextLeft1.GetHeight
26  
27 local EventFrame
28  
29 local SpaceLevel = _G.TinyTipLocale_Level .. " "
30  
31 local acehook = {}
32 _G.AceLibrary:GetInstance("AceHook-2.0"):embed(acehook)
33  
34 local db
35 local DBVer = 33
36  
37 --------------------------------------------------------------------
38 -- Global Functions
39  
40 -- Print out a message, probably to ChatFrame1
41 local DCFAddMessage = _G.DEFAULT_CHAT_FRAME.AddMessage
42 function TinyTip_Msg(msg)
43 DCFAddMessage(_G.DEFAULT_CHAT_FRAME, "|cFFFFCC00TinyTip:|r " .. msg )
44 end
45  
46 -- Return ALL possible saved options.
47 function TinyTip_GetAllOptions()
48 return { ["_profile"] = "boolean",
49 ["Fade"] = "number",
50 ["MAnchor"] = "string",
51 ["FAnchor"] = "string",
52 ["MOffX"] = "number",
53 ["MOffY"] = "number",
54 ["FOffX"] = "number",
55 ["FOffY"] = "number",
56 ["Scale"] = "number",
57 ["HideLevelText"] = "boolean",
58 ["HideRace"] = "boolean",
59 ["PvPRank"] = "boolean",
60 ["PvPIcon"] = "boolean",
61 ["BGColor"] = "number",
62 ["Border"] = "number",
63 ["HideInFrames"] = "boolean",
64 ["HideGuild"] = "boolean",
65 ["ReactionText"] = "boolean",
66 ["Friends"] = "number",
67 ["LevelGuess"] = "boolean",
68 ["ToT"] = "number",
69 ["ToP"] = "number",
70 ["ToR"] = "number",
71 ["ExtraTooltip"] = "number",
72 ["ETAnchor"] = "string",
73 ["ETOffX"] = "number",
74 ["ETOffY"] = "number",
75 ["FormatDisabled"] = "boolean",
76 ["Buffs"] = "number",
77 ["Debuffs"] = "number",
78 ["ManaBar"] = "boolean",
79 ["Compact"] = "boolean",
80 ["RTIcon"] = "boolean",
81 ["AnchorAll"] = "boolean",
82 ["PvPIconAnchor1"] = "string",
83 ["PvPIconAnchor2"] = "string",
84 ["PvPIconOffX"] = "number",
85 ["PvPIconOffY"] = "number",
86 ["RTIconAnchor1"] = "string",
87 ["RTIconAnchor2"] = "string",
88 ["RTIconOffX"] = "number",
89 ["RTIconOffY"] = "number",
90 ["BuffAnchor1"] = "string",
91 ["BuffAnchor2"] = "string",
92 ["BuffOffX"] = "number",
93 ["BuffOffY"] = "number",
94 ["DebuffAnchor1"] = "string",
95 ["DebuffAnchor2"] = "string",
96 ["DebuffOffX"] = "number",
97 ["DebuffOffY"] = "number",
98 ["PvPIconScale"] = "number",
99 ["RTIconScale"] = "number",
100 ["BuffScale"] = "number",
101 ["KeyElite"] = "boolean",
102 ["AlwaysAnchor"] = "boolean",
103 ["SmoothBorder"] = "boolean"
104 }
105 end
106  
107 function TinyTip_LoDRun(addon,sfunc,arg1,arg2,arg3,arg4,arg5,arg6)
108 if not _G[ sfunc ] then
109 local loaded, reason = _G.LoadAddOn(addon)
110 if loaded then
111 if _G[ sfunc ] and type( _G[ sfunc] ) == "function" then
112 _G[ sfunc ](arg1,arg2,arg3,arg4,arg5,arg6)
113 end
114 else
115 _G.TinyTip_Msg( addon .. " Addon LoadOnDemand Error - " .. reason )
116 return reason
117 end
118 elseif type( _G[ sfunc] ) == "function" then
119 _G[ sfunc ](arg1,arg2,arg3,arg4,arg5,arg6)
120 end
121 end
122  
123 function TinyTip_UpdateProfiles()
124 if _G.TinyTipDB["_profile"] then
125 if not _G.TinyTipCharDB then
126 local k,v
127 _G.TinyTipCharDB = {}
128 for k,v in db do
129 _G.TinyTipCharDB[k] = v
130 end
131 end
132 db = _G.TinyTipCharDB
133 else
134 db = _G.TinyTipDB
135 end
136 if _G.TinyTipAnchor_SetLocals then
137 _G.TinyTipAnchor_SetLocals(db,EventFrame)
138 end
139 if db["PvPIcon"] or db["Buffs"] or db["Debuffs"] then
140 _G.TinyTip_LoDRun( "TinyTipExtras", "TinyTipExtras_Init", db, EventFrame)
141 end
142 end
143  
144 -- Destroy the database and reset it with
145 -- default values.
146 function TinyTip_DefaultDB()
147 local k
148 for k,_ in db do
149 if k ~= "_v" then
150 db[k] = nil
151 end
152 end
153 end
154  
155 function TinyTip_GetDB()
156 return db
157 end
158  
159 function TinyTip_SetScale(opt,v)
160 if not v then
161 if _G.TinyTipExtras_Tooltip then
162 _G.TinyTipExtras_Tooltip:SetScale( 1.0 )
163 else
164 GameTooltip:SetScale( 1.0 )
165 end
166 db["Scale"] = nil
167 else
168 if _G.TinyTipExtras_Tooltip then
169 _G.TinyTipExtras_Tooltip:SetScale( v )
170 else
171 GameTooltip:SetScale( v )
172 end
173 db["Scale"] = v
174 end
175 end
176  
177 function TinyTip_ResetReferences(_AddLine, _AddDoubleLine, _ettooltip, _tooltip)
178 gtAddLine, gtAddDoubleLine = _AddLine, _AddDoubleLine
179 EventFrame.tooltip, tooltip = _ettooltip, _tooltip
180 end
181  
182 -- Get rid of that darn fading effect
183 function TinyTip_SlimOnUpdate()
184 tmp = fGetAlpha(GameTooltip)
185 if tmp and tmp < 1 then
186 if db["Fade"] ~= 1 or tmp < 0.1 or _G.TinyTipExtras_Tooltip then
187 fSetScript(EventFrame, "OnUpdate", nil)
188 gtSetOwner(GameTooltip, UIParent, "ANCHOR_CURSOR")
189 elseif db["ExtraTooltip"] and _G.TinyTipExtras_Tooltip then
190 fSetAlpha(_G.TinyTipExtras_Tooltip, tmp )
191 end
192 end
193 end
194  
195 local TooltipCompacted
196 function TinyTip_UnCompactGameTooltip()
197 fClearPts(_G.GameTooltipStatusBar)
198 fSetPt(_G.GameTooltipStatusBar, "TOPLEFT", GameTooltip, "BOTTOMLEFT", 2, -1)
199 fSetPt(_G.GameTooltipStatusBar, "TOPRIGHT", GameTooltip, "BOTTOMRIGHT", -2, -1)
200 fClearPts(gtLine1)
201 fSetPt(gtLine1, "TOPLEFT", 10, -10)
202 tmp = gtLine1
203 for i = 2, 30 do
204 tmp2 = _G[ "GameTooltipTextLeft" .. i ]
205 fClearPts( tmp2 )
206 fSetPt( tmp2, "TOPLEFT", tmp, "BOTTOMLEFT", 0, -2)
207 tmp = tmp2
208 end
209 TooltipCompacted = nil
210 end
211  
212 --------------------------------------------------------------------
213 -- Local Functions
214  
215 --[[ Initialize the SavedVariables database.
216 * If empty, copies the default table values to it.
217 * If mismatched versions, prunes out invalid entries
218 and adds new ones.
219 * Otherwise just sets the local db.
220 --]]
221 local function InitDB()
222 local k,v
223 if not _G.TinyTipDB then
224 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB1 )
225 _G.TinyTipDB = {}
226 db = _G.TinyTipDB
227 db["_v"] = DBVer
228 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB2 )
229 elseif _G.TinyTipDB._profile and not _G.TinyTipCharDB then
230 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB1 )
231 _G.TinyTipCharDB = {}
232 db = _G.TinyTipCharDB
233 db["_v"] = DBVer
234 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB2 )
235 elseif _G.TinyTipDB._v ~= DBVer then
236 tmp = _G.TinyTip_GetAllOptions()
237 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB3 )
238 db = _G.TinyTipDB
239 for k,_ in db do -- prune
240 if not tmp[k] then
241 db[k] = nil
242 end
243 end
244 for k,v in tmp do -- check types
245 if type(db[k]) ~= v then
246 db[k] = nil
247 end
248 end
249 if db["MAnchor"] == "CURSOR" then db["MAnchor"] = nil end
250 db["_v"] = DBVer
251 if db["_profile"] then
252 if not _G.TinyTipCharDB then _G.TinyTipCharDB = {} end
253 db = _G.TinyTipCharDB
254 for k,_ in db do -- prune
255 if not tmp[k] then
256 db[k] = nil
257 end
258 end
259 for k,v in tmp do -- check types
260 if type(db[k]) ~= v then
261 db[k] = nil
262 end
263 end
264 if db["MAnchor"] == "CURSOR" then db["MAnchor"] = nil end
265 end
266 tmp = nil
267 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB4 )
268 elseif _G.TinyTipDB._profile then
269 _G.TinyTip_Msg( "Using profile data.")
270 _G.TinyTip_Msg( _G.TinyTipLocale_InitDB5 )
271 db = _G.TinyTipCharDB
272 else
273 -- _G.TinyTip_Msg( _G.TinyTipLocale_InitDB5 )
274 db = _G.TinyTipDB
275 end
276  
277 -- nil out what we don't need any longer
278 _G.TinyTipLocale_InitDB1 = nil
279 _G.TinyTipLocale_InitDB2 = nil
280 _G.TinyTipLocale_InitDB3 = nil
281 _G.TinyTipLocale_InitDB4 = nil
282 _G.TinyTipLocale_InitDB5 = nil
283  
284 -- then finally, nil out the function itself
285 InitDB = nil
286 end
287  
288 -- for Tem
289 function TinyTip_SmoothBorder(k)
290 if k then db[k] = not db[k] end
291 if db["SmoothBorder"] then
292 GameTooltip:SetBackdrop({
293 bgFile = "Interface/Tooltips/UI-Tooltip-Background",
294 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
295 tile = false,
296 tileSize = 6,
297 edgeSize = 18,
298 insets = {
299 left = 4,
300 right = 4,
301 top = 4,
302 bottom = 4,
303 }
304 }
305 )
306 fSetBDColor(GameTooltip, 0, 0, 0, 0.8)
307 fSetBDBColor(GameTooltip, 0, 0, 0, 1)
308 else
309 GameTooltip:SetBackdrop({
310 bgFile = "Interface/Tooltips/UI-Tooltip-Background",
311 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
312 tile = true,
313 tileSize = 16,
314 edgeSize = 16,
315 insets = {
316 left = 5,
317 right = 5,
318 top = 5,
319 bottom = 5,
320 }
321 }
322 )
323 fSetBDColor(GameTooltip, 0, 0, 0, 1)
324 end
325 end
326  
327 local function CompactTooltip(tooltip, unit)
328 if not TooltipCompacted then
329 local lineWidth, largestWidth, fsHHeight, fsHeight, count = 0,0,0,0
330 tmp = _G[ fGetName(tooltip) .. "TextLeft1"]
331 if tmp and fsIsShown(tmp) then
332 count = 1
333 _,fsHHeight = tmp:GetFont()
334 fClearPts(tmp)
335 fSetPt(tmp, "TOPLEFT", 1, 0)
336 lineWidth = fsGetWidth(tmp)
337 tmp2 = _G[ fGetName(tooltip) .. "TextRight1"]
338 if tmp2 and fsIsShown(tmp2) then lineWidth = lineWidth + fsGetWidth(tmp2) + 40 end
339 largestWidth = lineWidth
340 fClearPts(_G.GameTooltipStatusBar)
341 fSetPt(_G.GameTooltipStatusBar, "TOPLEFT", tmp, "BOTTOMLEFT", 0, 0)
342 fSetPt(_G.GameTooltipStatusBar, "RIGHT", _G.GameTooltipStatusBar:GetParent(), "RIGHT", 0, 0)
343 tmp = _G[ fGetName(tooltip) .. "TextLeft2"]
344 if tmp then
345 count = 2
346 _,fsHeight = tmp:GetFont()
347 fClearPts(tmp)
348 if db["ManaBar"] and _G.TinyTipExtras_ManaBar:IsShown() then
349 fSetPt(tmp, "TOPLEFT", _G.TinyTipExtras_ManaBar, "BOTTOMLEFT", 0, 0)
350 count = count + 1
351 else
352 fSetPt(tmp, "TOPLEFT", _G.GameTooltipStatusBar, "BOTTOMLEFT", 0, 0)
353 end
354 lineWidth = fsGetWidth(tmp)
355 tmp3 = tmp
356 tmp2 = _G[ fGetName(tooltip) .. "TextRight2"]
357 if tmp2 and fsIsShown(tmp2) then lineWidth = lineWidth + fsGetWidth(tmp2) + 40 end
358 if lineWidth > largestWidth then largestWidth = lineWidth end
359 tmp = tooltip:NumLines()
360 for i = 3,tmp do
361 tmp2 = _G[ fGetName(tooltip) .. "TextLeft" .. i ]
362 if tmp2 and fsIsShown(tmp2) then
363 fClearPts(tmp2)
364 fSetPt(tmp2, "TOPLEFT", tmp3, "BOTTOMLEFT", 0, 0)
365 lineWidth = fsGetWidth(tmp2)
366 count = count + 1
367 end
368 tmp3 = tmp2
369 tmp2 = _G[ fGetName(tooltip) .. "TextRight" .. i ]
370 if tmp2 and fsIsShown(tmp2) then
371 lineWidth = lineWidth + fsGetWidth(tmp2) + 40
372 end
373 if lineWidth > largestWidth then largestWidth = lineWidth end
374 end
375 tooltip:SetWidth( largestWidth + 5 )
376 tooltip:SetHeight( fsHHeight + (fsHeight * (count) ) )
377 end
378 end
379 TooltipCompacted = true
380 end
381 end
382  
383 -- Return color format in HEX from Blizzard percentage RGB
384 -- for the class.
385 function TinyTip_ColorPlayer(unit)
386 _,tmp=_G.UnitClass(unit)
387 if tmp and _G.RAID_CLASS_COLORS[tmp] then
388 return strformat("%2x%2x%2x", _G.RAID_CLASS_COLORS[tmp].r*255,
389 _G.RAID_CLASS_COLORS[tmp].g*255,
390 _G.RAID_CLASS_COLORS[tmp].b*255)
391 else
392 return "FFFFFF"
393 end
394 end
395  
396 local PvPLine, PvPBeforeLine
397 local function TooltipFormat(unit)
398 if gtIsVisible(GameTooltip) and _G.UnitExists(unit) then
399 local treac,cdeadortap,bdead,levelLine
400 local bdR,bdG,bdB = 0,0,0
401  
402 if not db["FormatDisabled"] then
403 tmp = gtNumLines(GameTooltip)
404 for i = 1,tmp,1 do
405 tmp2 = fsGetText(_G[ "GameTooltipTextLeft" .. i ])
406 if tmp2 and strfind(tmp2, _G.TinyTipLocale_Level, 1, true) then
407 levelLine = _G[ "GameTooltipTextLeft" .. i ]
408 break
409 end
410 end
411  
412 -- Get Rank, then Set Name (rankName, rankNumber)
413 tmp,tmp2 = _G.GetPVPRankInfo(_G.UnitPVPRank(unit), unit)
414 tmp3 = _G.UnitIsPlayer(unit)
415 if db["PvPIcon"] and _G.TinyTipIcons_ResetPvPIcon then
416 _G.TinyTipIcons_ResetPvPIcon(tmp2, tmp3)
417 end
418 if tmp3 and db["PvPRank"] ~= 1 and tmp2 > 0 then
419 if db["PvPRank"] == 2 then
420 fsSetText(gtLine1, tmp .. " " .. (_G.UnitName(unit) or "Unknown" ) )
421 elseif db["PvPRank"] == 3 then
422 fsSetText(gtLine1, (_G.UnitName(unit) or "Unknown") .. " [R" .. tmp2 .. "]" )
423 else
424 fsSetText(gtLine1, "[R" .. tmp2 .. "] " .. (_G.UnitName(unit) or "Unknown" ) )
425 end
426 else
427 fsSetText(gtLine1, _G.UnitName(unit) or "Unknown" )
428 end
429  
430 -- Reaction coloring
431 tmp,tmp2 = _G.UnitPlayerControlled(unit), _G.UnitReaction(unit, "player")
432 if _G.UnitIsTapped(unit) and not _G.UnitIsTappedByPlayer(unit) then
433 if not db["BGColor"] or db["BGColor"] == 2 then
434 bdR,bdG,bdB = 0.54,0.54,0.54
435 end
436 fsSetTextColor(gtLine1, 0.54,0.54,0.54)
437 cdeadortap = "888888"
438 elseif ( tmp and _G.UnitCanAttack(unit, "player") ) or
439 _G.UnitIsTappedByPlayer(unit) or
440 ( not tmp and tmp2 and tmp2 > 0 and tmp2 <= 2 ) then -- hostile
441 fsSetTextColor(gtLine1, _G.FACTION_BAR_COLORS[tmp2 or 2].r,
442 _G.FACTION_BAR_COLORS[tmp2 or 2].g,
443 _G.FACTION_BAR_COLORS[tmp2 or 2].b)
444 if db["ReactionText"] and tmp2 and tmp2 > 0 then
445 treac = _G["FACTION_STANDING_LABEL" .. tmp2]
446 else
447 treac = _G.FACTION_STANDING_LABEL2
448 end
449  
450 if not db["BGColor"] or db["BGColor"] == 2 then
451 if tmp or db["BGColor"] == 2 then
452 if tmp and not _G.UnitCanAttack("player", unit) then
453 bdR,bdG,bdB = 0.5,0.2,0.1
454 else
455 bdR,bdG,bdB = 0.5,0.0,0.0
456 end
457 end
458 end
459 elseif ( tmp and _G.UnitCanAttack("player",unit) ) or
460 ( not tmp and tmp2 and tmp2 <= 4 ) then -- neutral
461 fsSetTextColor(gtLine1, _G.FACTION_BAR_COLORS[4].r,
462 _G.FACTION_BAR_COLORS[4].g,
463 _G.FACTION_BAR_COLORS[4].b)
464 if db["ReactionText"] then treac = _G.FACTION_STANDING_LABEL4 end
465 if (tmp and not db["BGColor"]) or db["BGColor"] == 2 then
466 tooltip:SetBackdropColor( 0.5, 0.5, 0.0)
467 end
468 else -- friendly
469 treac = _G.FACTION_STANDING_LABEL5
470 if (tmp and not db["BGColor"]) or db["BGColor"] == 2 then
471 bdR,bdG,bdB = 0.0, 0.0, 0.5
472 end
473 if _G.UnitIsPVP(unit) then -- friendly, PvP-enabled
474 fsSetTextColor(gtLine1, _G.FACTION_BAR_COLORS[6].r,
475 _G.FACTION_BAR_COLORS[6].g,
476 _G.FACTION_BAR_COLORS[6].b)
477 else
478 fsSetTextColor(gtLine1, (not tmp and _G.FACTION_BAR_COLORS[tmp2 or 5].r) or 0,
479 (not tmp and _G.FACTION_BAR_COLORS[tmp2 or 5].g) or 0.67,
480 (not tmp and _G.FACTION_BAR_COLORS[tmp2 or 5].b) or 1.0)
481 end
482 end
483  
484 -- remove PvP line, if it exists
485 PvP_Line = nil
486 if not db["ReactionText"] and _G.UnitIsPVP(unit) then
487 tmp = gtNumLines(GameTooltip)
488 for i=3,tmp,1 do
489 tmp2 = _G["GameTooltipTextLeft" .. i]
490 if tmp2 then
491 tmp3 = fsGetText(tmp2)
492 if tmp3 and strfind(tmp3, _G.PVP_ENABLED, 1, true) then
493 PvPLine = tmp2
494 PvPBeforeLine = _G["GameTooltipTextLeft" .. (i-1)]
495 fsSetText(PvPLine, nil)
496 fClearPts(PvPLine)
497 fSetPt(PvPLine, "TOPLEFT", PvPBeforeLine or gtLine2, "BOTTOMLEFT", 0, 1)
498 fsHide(PvPLine)
499 break
500 end
501 end
502 end
503 end
504  
505 -- We like to know who our friends are.
506 if db["Friends"] ~= 2 and
507 _G.UnitIsPlayer(unit) and treac == _G.FACTION_STANDING_LABEL5 then
508 local num,name = _G.GetNumFriends(), _G.UnitName(unit)
509 for i = 1,num,1 do
510 tmp,tmp2 = _G.GetFriendInfo(i)
511 if tmp and tmp2 ~= 0 and name and tmp == name then
512 if db["Friends"] == 1 or db["BGColor"] == 1 or db["BGColor"] == 3 then
513 fsSetTextColor(gtLine1, 0.58, 0.0, 0.83)
514 else
515 bdR,bdG,bdB = 0.29, 0.0, 0.42
516 end
517 break
518 end
519 end
520 end
521  
522 -- Check for a dead unit, but try to leave out Hunter's Feign Death
523 if _G.UnitHealth(unit) <= 0 and
524 ( not _G.UnitIsPlayer(unit) or _G.UnitIsDeadOrGhost(unit) or _G.UnitIsCorpse(unit) ) then
525 if not db["BGColor"] or db["BGColor"] == 2 then
526 bdR,bdG,bdB = 0.54, 0.54, 0.54
527 end
528 fsSetTextColor(gtLine1, 0.54,0.54,0.54)
529 cdeadortap = "888888"
530 bdead = true
531 end
532  
533 -- set the color of line 2, if it's available
534 if levelLine == gtLine3 then
535 fsSetTextColor(gtLine2, fsGetTextColor(gtLine1) )
536 end
537  
538 if levelLine then
539 local clevel
540 local ulevel = _G.UnitLevel(unit)
541 tmp2 = ulevel - _G.UnitLevel("player") -- Level difficulty
542 if tmp2 and _G.UnitFactionGroup(unit) ~= _G.UnitFactionGroup("player") then
543 if tmp2 >= 5 or ulevel == -1 then clevel = "FF0000"
544 elseif tmp2 >= 3 then clevel = "FF6600"
545 elseif tmp2 >= -2 then clevel = "FFFF00"
546 elseif -tmp2 <= _G.GetQuestGreenRange() then clevel = "00FF00"
547 else clevel = "888888"
548 end
549 end
550  
551 tmp = (not db["HideLevelText"] and SpaceLevel) or ""
552 if ulevel and ulevel >= 1 then
553 fsSetText(levelLine, "|cFF" ..
554 (cdeadortap or clevel or "FFCC00") ..
555 tmp ..
556 ulevel ..
557 "|r")
558 elseif db["LevelGuess"] and ulevel and ulevel == -1 and ulevel < 60 then
559 fsSetText(levelLine, "|cFF" ..
560 (cdeadortap or clevel or "FFCC00") ..
561 tmp .. ">" ..
562 (_G.UnitLevel("player") + 10 ) ..
563 "|r")
564 else
565 fsSetText(levelLine, "|cFF" ..
566 (cdeadortap or clevel or "FFCC00") ..
567 tmp ..
568 "??|r")
569 end
570  
571 tmp2 = _G.UnitClassification(unit) -- Elite status
572 if tmp2 and tmp2 ~= "normal" then
573 if tmp2 == "elite" then
574 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
575 ((db["KeyElite"] and "") or " ") ..
576 "|cFF" ..
577 (cdeadortap or "FFCC00") ..
578 ((db["KeyElite"] and "*") or _G.ELITE) ..
579 "|r" )
580 elseif tmp2 == "worldboss" then
581 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
582 ((db["KeyElite"] and "") or " ") ..
583 "|cFF" ..
584 (cdeadortap or "FF0000") ..
585 ((db["KeyElite"] and "**") or _G.BOSS) ..
586 "|r" )
587 elseif tmp2 == "rare" then
588 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
589 ((db["KeyElite"] and "") or " ") ..
590 "|cFF" ..
591 (cdeadortap or "FF66FF") ..
592 ((db["KeyElite"] and "!") or _G.ITEM_QUALITY3_DESC) ..
593 "|r" )
594 elseif tmp2 == "rareelite" then
595 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
596 ((db["KeyElite"] and "") or " ") ..
597 "|cFF" ..
598 (cdeadortap or "FFAAFF") ..
599 ((db["KeyElite"] and "!*") or _G.TinyTipLocale_RareElite) ..
600 "|r" )
601 else
602 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
603 " [|cFF" ..
604 (cdeadortap or "FFFFFF") ..
605 tmp2 ..
606 "|r]" )
607 end
608 end
609  
610 -- Class And Race
611 if _G.UnitIsPlayer(unit) then
612 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
613 " |cFF" ..
614 (cdeadortap or "DDEEAA") ..
615 (( not db["HideRace"] and (_G.UnitRace(unit) .. " ") ) or "") ..
616 "|r|cFF" ..
617 (cdeadortap or TinyTip_ColorPlayer(unit)) ..
618 (_G.UnitClass(unit) or "" ) ..
619 "|r")
620 elseif not db["HideRace"] then
621 if _G.UnitPlayerControlled(unit) then
622 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
623 " |cFF" ..
624 (cdeadortap or "DDEEAA") ..
625 (_G.UnitCreatureFamily(unit) or "") ..
626 "|r")
627 else
628 fsSetText(levelLine, (fsGetText(levelLine) or "") ..
629 " |cFF" ..
630 (cdeadortap or "DDEEAA") ..
631 (_G.UnitCreatureType(unit) or "") ..
632 "|r")
633 end
634 end
635  
636 -- add corpse/tapped line
637 if cdeadortap and levelLine then
638 fsSetText(levelLine,
639 (fsGetText(levelLine) or "") ..
640 " |cFF888888(" ..
641 ( ( bdead and _G.CORPSE ) or TinyTipLocale_Tapped ) ..
642 ")|r")
643 end
644  
645 end
646 end
647  
648 if db["ExtraTooltip"] and _G.TinyTipExtras_CopyGameTooltip then
649 _G.TinyTipExtras_CopyGameTooltip()
650 end
651  
652 if not bdead then
653 -- Add Reaction Text
654 if db["ReactionText"] and treac then
655 gtAddLine( tooltip, treac, fsGetTextColor(gtLine1) )
656 end
657  
658 -- Add Guild info, if enabled
659 tmp2 = _G.GetGuildInfo(unit)
660 if not db["HideGuild"] and tmp2 then
661 tmp = "<" .. tmp2 .. ">"
662 if _G.IsInGuild() and tmp2 == _G.GetGuildInfo("player") and db["Friends"] ~= 2 then
663 if not db["Friends"] and not _G.UnitIsUnit(unit, "player") and db["BGColor"] ~= 3 and db["BGColor"] ~= 1 then
664 bdR,bdG,bdB = 0.4, 0.1, 0.5
665 gtAddLine( tooltip, tmp, fsGetTextColor(gtLine1) )
666 else
667 gtAddLine( tooltip, tmp, 0.58, 0.0, 0.83)
668 end
669 else
670 gtAddLine( tooltip, tmp, fsGetTextColor(gtLine1) )
671 end
672 end
673  
674 if db["RTIcon"] and _G.TinyTipIcons_ResetRTIcon then _G.TinyTipIcons_ResetRTIcon(unit, _G.GetNumRaidMembers()) end
675 if db["ToT"] and _G.TinyTipTargets_Mouse then _G.TinyTipTargets_Mouse(unit, db["ToT"]) end
676 if db["ToR"] or db["ToP"] then
677 tmp,tmp2 = _G.GetNumRaidMembers(), _G.GetNumPartyMembers()
678 if db["ToR"] and _G.TinyTipTargets_Raid and tmp and tmp > 0 then _G.TinyTipTargets_Raid(unit, tmp, db["ToR"])
679 elseif db["ToP"] and _G.TinyTipTargets_Party and tmp2 and tmp2 > 0 then
680 _G.TinyTipTargets_Party(unit, tmp2, db["ToP"])
681 end
682 end
683  
684 if db["Buffs"] and _G.TinyTipIcons_ShowBuffs then _G.TinyTipIcons_ShowBuffs(unit) end
685 if db["Debuffs"] and _G.TinyTipIcons_ShowDebuffs then _G.TinyTipIcons_ShowDebuffs(unit) end
686 end
687 if (db["Buffs"] or db["Debuffs"]) and _G.TinyTipIcons_HideUnusedTextures then _G.TinyTipIcons_HideUnusedTextures() end
688  
689 if db["BGColor"] ~= 1 then
690 if db["BGColor"] == 3 then
691 fSetBDColor(GameTooltip, 0, 0, 0)
692 else
693 fSetBDColor(GameTooltip, bdR, bdG, bdB )
694 end
695 end
696 if db["Border"] ~= 1 then
697 if db["Border"] == 2 then
698 fSetBDBColor(GameTooltip, 0,0,0,0)
699 else
700 local r,g,b = fGetBDColor(GameTooltip)
701 r,g,b = r * 1.5, g * 1.5, b * 1.5
702 fSetBDBColor(GameTooltip, r,g,b,1)
703 end
704 end
705  
706  
707 this.skipOnShow = nil
708 GameTooltip:Show() -- used to re-size gametooltip
709  
710 if db["ExtraTooltip"] and _G.TinyTipExtras_Tooltip then
711 fSetBDColor(_G.TinyTipExtras_Tooltip, fGetBDColor(GameTooltip) )
712 fSetBDBColor( _G.TinyTipExtras_Tooltip, fGetBDBColor(GameTooltip) )
713 fSetBDColor(GameTooltip, 0,0,0)
714 fSetBDBColor(GameTooltip, 0,0,0,0)
715 _G.TinyTipExtras_Tooltip:Show()
716 end
717 if db["Compact"] then CompactTooltip(EventFrame.tooltip, unit) end
718 end
719 end
720  
721 -- arg1=this,arg2=unit
722 _G.TinyTip_Original_GameTooltip_SetUnit = nil
723 function TinyTip_SetUnit(this,unit,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
724 this.skipOnShow = true
725 if unit ~= "mouseover" and _G.TinyTip_Original_GameTooltip_SetUnit then
726 _G.TinyTip_Original_GameTooltip_SetUnit(this,unit,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
727 end
728 GameTooltip.unit = unit
729 if db["HideInFrames"] and unit ~= "mouseover" then
730 fSetScript(EventFrame, "OnUpdate", nil)
731 fSetAlpha(GameTooltip, 0.01)
732 if GameTooltip.owner then
733 fClearPts(GameTooltip)
734 GameTooltip:SetOwner(GameTooltip.owner, "ANCHOR_NONE")
735 end
736 else
737 if db["ManaBar"] and _G.TinyTipExtras_ManaBar then sbShow(_G.TinyTipExtras_ManaBar) end
738 TooltipFormat(unit)
739 GameTooltip.unit = unit
740 if db["ExtraTooltip"] and _G.TinyTipAnchor_SetDefaultAnchor then
741 _G.TinyTipAnchor_SetDefaultAnchor(_G.TinyTipExtras_Tooltip, GameTooltip.owner)
742 end
743 end
744 this.skipOnShow = nil
745 end
746  
747 _G.TinyTip_Original_GameTooltip_FadeOut = nil
748 function TinyTip_FadeOut(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
749 if db["Fade"] == 2 or db["ExtraTooltip"] then
750 GameTooltip:Hide()
751 elseif _G.TinyTip_Original_GameTooltip_FadeOut then
752 _G.TinyTip_Original_GameTooltip_FadeOut(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
753 end
754 end
755  
756 local Original_GameTooltip_OnTooltipCleared
757 function TinyTip_OnTooltipCleared(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
758 if Original_GameTooltip_OnTooltipCleared then
759 Original_GameTooltip_OnTooltipCleared(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
760 end
761 if (db["Compact"] or TooltipCompacted) and not db["ExtraTooltip"] then
762 _G.TinyTip_UnCompactGameTooltip()
763 elseif PvPLine then
764 fClearPts(PvPLine)
765 fSetPt(PvPLine, "TOPLEFT", PvPBeforeLine or gtLine2, "BOTTOMLEFT", 0, -2)
766 PvPLine,PvPBeforeLine = nil, nil
767 end
768 GameTooltip.unit = nil
769 fSetScript(EventFrame, "OnUpdate", nil)
770 _G.GameTooltip_ClearMoney()
771 end
772  
773 _G.TinyTip_Original_GameTooltip_OnShow = nil
774 function TinyTip_OnShow(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
775 if _G.TinyTip_Original_GameTooltip_OnShow and not this.skipOnShow then
776 _G.TinyTip_Original_GameTooltip_OnShow(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)
777 end
778 if db["AlwaysAnchor"] and not GameTooltip.unit and not _G.UnitExists("mouseover") and not EventFrame:GetScript("OnUpdate") and _G.TinyTipAnchor_AlwaysAnchor then
779 fSetScript(EventFrame, "OnUpdate", _G.TinyTipAnchor_AlwaysAnchor)
780 end
781 if GameTooltip.unit then
782 _G.GameTooltip_ClearMoney()
783 end
784 end
785  
786 local function OnEvent()
787 if _G.event == "UPDATE_MOUSEOVER_UNIT" then
788 if UnitExists("mouseover") then
789 GameTooltip:SetUnit("mouseover")
790 end
791 elseif _G.event == "PLAYER_ENTERING_WORLD" and db then -- rescale
792 _G.TinyTip_SetScale("Scale", db["Scale"] )
793 if _G.TinyTipExtras_Init then _G.TinyTipExtras_Init(db) end
794 elseif _G.event == "ADDON_LOADED" and _G.arg1 == "TinyTip" then
795 InitDB()
796 if _G.TinyTipAnchor_SetLocals then
797 _G.TinyTipAnchor_SetLocals(db,EventFrame,acehook)
798 end
799 local ttextraserror = true
800 if db["UseAceHook"] or db["PvPIcon"] or db["Buffs"] or db["Debuffs"] or db["ExtraTooltip"] or db["ManaBar"] or db["RTIcon"] then
801 ttextraserror = _G.TinyTip_LoDRun( "TinyTipExtras", "TinyTipExtras_Init", db, EventFrame,acehook)
802 elseif db["ToT"] or db["ToP"] or db["ToR"] then
803 _G.TinyTip_LoDRun( "TinyTipExtras", "TinyTipTargetsExists")
804 end
805 if not acehook:IsHooked(GameTooltip, "FadeOut") and ( db["Fade"] == 2 or db["ExtraTooltip"] ) then
806 acehook:Hook(GameTooltip, "FadeOut", _G.TinyTip_FadeOut)
807 _G.TinyTip_Original_GameTooltip_FadeOut = acehook.hooks[GameTooltip]["FadeOut"].orig
808 end
809 if not acehook:IsHooked(GameTooltip, "OnShow") then
810 acehook:HookScript(GameTooltip, "OnShow", _G.TinyTip_OnShow)
811 _G.TinyTip_Original_GameTooltip_OnShow = acehook.hooks[GameTooltip]["OnShow"].orig
812 end
813 if not acehook:IsHooked(GameTooltip, "OnTooltipCleared") then -- most sure-fire way to hide something
814 acehook:HookScript(GameTooltip, "OnTooltipCleared", _G.TinyTip_OnTooltipCleared)
815 _G.TinyTip_Original_GameTooltip_OnTooltipCleared = acehook.hooks[GameTooltip]["OnTooltipCleared"].orig
816 end
817  
818 _G.TinyTip_SetScale( "Scale", db["Scale"] )
819  
820 if db["Fade"] == 2 then
821 EventFrame:SetScript("OnUpdate", _G.TinyTip_SlimOnUpdate)
822 end
823  
824 TinyTip_SmoothBorder()
825  
826 EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
827 EventFrame:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
828 GameTooltip:UnregisterEvent("UPDATE_MOUSEOVER_UNIT")
829 end
830 end
831  
832 -----------------------------------------------------------------------
833 -- WoW-Required Functions
834 --
835  
836 _G.SlashCmdList["TINYTIP"] = function(msg)
837 if db then
838 _G.TinyTip_LoDRun( "TinyTipOptions", "TinyTipChat_SlashHandler", msg, db)
839 end
840 end
841  
842 -----------------------------------------------------------------------
843 -- Ready the mod
844 --
845 EventFrame = _G.CreateFrame("Frame", "TinyTipEventFrame", GameTooltip)
846 EventFrame:SetScript("OnEvent", OnEvent)
847 EventFrame:RegisterEvent("ADDON_LOADED")
848 EventFrame:Show()
849 EventFrame.tooltip = GameTooltip
850  
851 -- hook these immediatly
852 if _G.TinyTipAnchor_Hook then TinyTipAnchor_Hook(acehook) end
853  
854 if not acehook:IsHooked(GameTooltip, "SetUnit") then
855 acehook:Hook(GameTooltip, "SetUnit", _G.TinyTip_SetUnit)
856 _G.TinyTip_Original_GameTooltip_SetUnit = acehook.hooks[GameTooltip]["SetUnit"].orig
857 end