vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | TipBuddy: --------- |
||
4 | copyright 2005 by Chester |
||
5 | |||
6 | ]] |
||
7 | |||
8 | |||
9 | function TipBuddy_OnLoad() |
||
10 | |||
11 | this:RegisterEvent("VARIABLES_LOADED"); |
||
12 | this:RegisterEvent("PLAYER_LOGIN"); |
||
13 | |||
14 | this:RegisterEvent("UPDATE_MOUSEOVER_UNIT"); |
||
15 | this:RegisterEvent("UNIT_LEVEL"); |
||
16 | this:RegisterEvent("UNIT_FACTION"); |
||
17 | this:RegisterEvent("UNIT_DYNAMIC_FLAGS"); |
||
18 | this:RegisterEvent("UNIT_CLASSIFICATION_CHANGED"); |
||
19 | this:RegisterEvent("PLAYER_PVPLEVEL_CHANGED"); |
||
20 | this:RegisterEvent("UNIT_AURA"); |
||
21 | this:RegisterEvent("PLAYER_FLAGS_CHANGED"); |
||
22 | this:RegisterEvent("UNIT_HEALTH"); |
||
23 | this:RegisterEvent("UNIT_MAXHEALTH"); |
||
24 | this:RegisterEvent("UNIT_MANA"); |
||
25 | this:RegisterEvent("UNIT_RAGE"); |
||
26 | this:RegisterEvent("UNIT_FOCUS"); |
||
27 | this:RegisterEvent("UNIT_ENERGY"); |
||
28 | this:RegisterEvent("UNIT_HAPPINESS"); |
||
29 | this:RegisterEvent("UNIT_MAXMANA"); |
||
30 | this:RegisterEvent("UNIT_MAXRAGE"); |
||
31 | this:RegisterEvent("UNIT_MAXFOCUS"); |
||
32 | this:RegisterEvent("UNIT_MAXENERGY"); |
||
33 | this:RegisterEvent("UNIT_MAXHAPPINESS"); |
||
34 | this:RegisterEvent("UNIT_DISPLAYPOWER"); |
||
35 | this:RegisterEvent("UNIT_PVP_UPDATE"); |
||
36 | this:RegisterEvent("UPDATE_SHAPESHIFT_FORMS"); |
||
37 | |||
38 | SLASH_TIPBUDDY1 = "/tipbuddy"; |
||
39 | SLASH_TIPBUDDY2 = "/tbuddy"; |
||
40 | SLASH_TIPBUDDY3 = "/tip"; |
||
41 | SlashCmdList["TIPBUDDY"] = function(msg) |
||
42 | TipBuddy_SlashCommand(msg); |
||
43 | end |
||
44 | |||
45 | -- commented out cause it fucked up my buttons |
||
46 | -- Add TipBuddy_OptionsFrame to the UIPanelWindows list |
||
47 | --UIPanelWindows['TipBuddy_OptionsFrame'] = {area = 'center', pushable = 0}; |
||
48 | end |
||
49 | |||
50 | local lGameTooltip_OnEvent_Orig; |
||
51 | local lGameTooltip_OnShow_Orig; |
||
52 | local lGameTooltip_FadeOut_Orig; |
||
53 | function TipBuddy_OnEvent() |
||
54 | if( event == "VARIABLES_LOADED" ) then |
||
55 | --TB_AddMessage(TB_WHT_TXT.."VARIABLES_LOADED"); |
||
56 | TipBuddy_Variable_Initialize(); |
||
57 | TB_GameTooltip_IniHooks(); |
||
58 | |||
59 | TipBuddy.uiscale = TipBuddy_GetUIScale(); |
||
60 | |||
61 | --hooking GameTooltip's OnEvent |
||
62 | lGameTooltip_OnEvent_Orig = GameTooltip:GetScript("OnEvent"); |
||
63 | GameTooltip:SetScript( "OnEvent", TipBuddy_GameTooltip_OnEvent ); |
||
64 | |||
65 | --hooking GameTooltip's OnShow |
||
66 | lGameTooltip_OnShow_Orig = GameTooltip:GetScript("OnShow"); |
||
67 | GameTooltip:SetScript( "OnShow", TipBuddy_GameTooltip_OnShow ); |
||
68 | |||
69 | if (TipBuddy_SavedVars["general"].framepos_L or TipBuddy_SavedVars["general"].framepos_T) then |
||
70 | TipBuddy_Header_Frame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", TipBuddy_SavedVars["general"].framepos_L, TipBuddy_SavedVars["general"].framepos_T); |
||
71 | end |
||
72 | if (not TipBuddy_SavedVars["general"].delaytime) then |
||
73 | TipBuddy_SavedVars["general"].delaytime = "0.5"; |
||
74 | end |
||
75 | if (not TipBuddy_SavedVars["general"].fadetime) then |
||
76 | TipBuddy_SavedVars["general"].fadetime = "0.3"; |
||
77 | end |
||
78 | if (not TipBuddy_SavedVars["general"].gtt_anchored) then |
||
79 | TipBuddy_SavedVars["general"].gtt_anchored = 0; |
||
80 | end |
||
81 | |||
82 | if (TipBuddy_SavedVars["general"].anchored == 1) then |
||
83 | if (not TipBuddy_SavedVars["general"].anchor_vis_first or TipBuddy_SavedVars["general"].anchor_vis == 1) then |
||
84 | TipBuddy_SavedVars["general"].anchor_vis_first = 1; |
||
85 | TipBuddy_Header_Frame:Show(); |
||
86 | else |
||
87 | TipBuddy_Header_Frame:Show(); |
||
88 | TipBuddy_Header_Frame:Hide(); |
||
89 | end |
||
90 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
91 | this:SetPoint(TipBuddy.anchor, "TipBuddy_Header_Frame", TipBuddy.fanchor, 0, 1); |
||
92 | else |
||
93 | if (not TipBuddy_SavedVars["general"].anchor_vis_first) then |
||
94 | TipBuddy_ResetAnchorPos(); |
||
95 | TipBuddy_Header_Frame:Hide(); |
||
96 | else |
||
97 | TipBuddy_Header_Frame:Show(); |
||
98 | TipBuddy_Header_Frame:Hide(); |
||
99 | end |
||
100 | end |
||
101 | |||
102 | if( DEFAULT_CHAT_FRAME ) then |
||
103 | DEFAULT_CHAT_FRAME:AddMessage("|cffffd200TipBuddy |cffffff00v"..TIPBUDDY_VERSION.." loaded."); |
||
104 | end |
||
105 | |||
106 | TipBuddy_InitializeTextColors(); |
||
107 | |||
108 | elseif( event == "PLAYER_LOGIN" ) then |
||
109 | -- Add TipBuddy to myAddOns addons list |
||
110 | if (myAddOnsFrame) then |
||
111 | myAddOnsList.TipBuddy = { |
||
112 | name = "|cff20ff20TipBuddy", |
||
113 | description = "Enhanced, configurable unit tooltip.", |
||
114 | version = "|cffffff00"..TIPBUDDY_VERSION, |
||
115 | author = "chester", |
||
116 | email = "chester.dent@gmail.com", |
||
117 | category = MYADDONS_CATEGORY_OTHERS, |
||
118 | frame = "TipBuddy_OptionsFrame", |
||
119 | optionsframe = "TipBuddy_OptionsFrame" |
||
120 | }; |
||
121 | end |
||
122 | |||
123 | TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset(); |
||
124 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
125 | GameTooltip:SetOwner(UIParent, "ANCHOR_RIGHT"); |
||
126 | GameTooltip:SetPoint("BOTTOM", "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
127 | GameTooltip:SetText(" "); |
||
128 | GameTooltip:SetBackdrop({bgFile="Interface\\AddOns\\TipBuddy\\gfx\\UI-Tooltip-Background",edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",tile=true,tileSize=32,edgeSize=16,insets={ left = 4, right = 4, top = 4, bottom = 4 }}); |
||
129 | GameTooltip:Hide(); |
||
130 | TipBuddyTooltip:SetOwner(UIParent, "ANCHOR_RIGHT"); |
||
131 | TipBuddyTooltip:SetPoint("BOTTOM", "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
132 | TipBuddyTooltip:SetText(" "); |
||
133 | TipBuddyTooltip:SetBackdrop({bgFile="Interface\\AddOns\\TipBuddy\\gfx\\UI-Tooltip-Background",edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",tile=true,tileSize=32,edgeSize=16,insets={ left = 4, right = 4, top = 4, bottom = 4 }}); |
||
134 | TipBuddyTooltip:Hide(); |
||
135 | --TB_AddMessage("loading: ("..TipBuddyTooltip:GetTop()..")"); |
||
136 | TipBuddy_Main_Frame:SetBackdrop({bgFile="Interface\\AddOns\\TipBuddy\\gfx\\UI-Tooltip-Background",edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",tile=true,tileSize=32,edgeSize=8,insets={ left = 2, right = 2, top = 2, bottom = 2 }}); |
||
137 | |||
138 | --/script TipBuddyTooltip:SetOwner(TipBuddy_Parent_Frame); TipBuddyTooltip:SetPoint("BOTTOM", "TipBuddy_Parent_Frame", "CENTER", 0, 0); TipBuddyTooltip:SetText("player"); |
||
139 | --/script TipBuddyTooltip:SetOwner(TipBuddy_Parent_Frame); TipBuddyTooltip:SetPoint("BOTTOM", "TipBuddy_Parent_Frame"); TipBuddyTooltip:SetText("player"); |
||
140 | |||
141 | --/script TipBuddyTooltip:SetPoint("BOTTOM", "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
142 | |||
143 | elseif (event == "UPDATE_MOUSEOVER_UNIT" or |
||
144 | event == "UNIT_LEVEL" or |
||
145 | event == "UNIT_FACTION" or |
||
146 | event == "PLAYER_PVPLEVEL_CHANGED" or |
||
147 | event == "UNIT_DYNAMIC_FLAGS" or |
||
148 | event == "UNIT_MAXHEALTH") then |
||
149 | if (UnitExists("mouseover")) then |
||
150 | --TB_AddMessage(TB_WHT_TXT.."UPDATE_MOUSEOVER_UNIT"); |
||
151 | TipBuddy.hasTarget = 1; |
||
152 | TipBuddy_ShowUnitTooltip(); |
||
153 | elseif (TipBuddy.targetUnit and TipBuddy.targetUnit == arg1) then |
||
154 | TipBuddy.hasTarget = 1; |
||
155 | TipBuddy_ShowUnitTooltip(); |
||
156 | end |
||
157 | |||
158 | --this fires after mouseover_unit when buffs change |
||
159 | elseif ( event == "UNIT_AURA" and (arg1 == "mouseover" or string.find(arg1, "party"))) then |
||
160 | if ((arg1 == "mouseover") or (TipBuddy.targetUnit and TipBuddy.targetUnit == arg1)) then |
||
161 | ----TB_AddMessage(TB_WHT_TXT.."UNIT_AURA"); |
||
162 | TipBuddy_TargetBuffs_Update( TipBuddy.targetType, arg1 ); |
||
163 | end |
||
164 | elseif ( event == "UNIT_HEALTH" ) then |
||
165 | if ((arg1 == "mouseover") or (TipBuddy.targetUnit and TipBuddy.targetUnit == arg1)) then |
||
166 | ----TB_AddMessage(TB_WHT_TXT.."UNIT_HEALTH or UNIT_MAXHEALTH"); |
||
167 | if (UnitHealth(arg1) <= 0) then |
||
168 | TipBuddy_ShowUnitTooltip(); |
||
169 | return; |
||
170 | end |
||
171 | |||
172 | if (TipBuddy.compactvis) then |
||
173 | TipBuddy_UpdateHealthText( TipBuddy_HealthText, TipBuddy.targetType, arg1 ); |
||
174 | TipBuddy_UpdateManaText( TipBuddy_ManaText, TipBuddy.targetType, arg1 ); |
||
175 | TipBuddy_TargetInfo_FindExtras( arg1 ); |
||
176 | else |
||
177 | TipBuddyTooltipStatusBar:SetValue(UnitHealth(arg1)); |
||
178 | TipBuddy_UpdateHealthText( TipBuddy_HealthTextGTT, TipBuddy.targetType, arg1 ); |
||
179 | TipBuddy_UpdateManaText( TipBuddy_ManaTextGTT, TipBuddy.targetType, arg1 ); |
||
180 | end |
||
181 | end |
||
182 | elseif ( event == "UNIT_MANA" or event == "UNIT_RAGE" or event == "UNIT_FOCUS" or event == "UNIT_ENERGY" or event == "UNIT_HAPPINESS" or event == "UNIT_MAXMANA" or event == "UNIT_MAXRAGE" or event == "UNIT_MAXFOCUS" or event == "UNIT_MAXENERGY" or event == "UNIT_MAXHAPPINESS" or event == "UNIT_DISPLAYPOWER" or event == "UPDATE_SHAPESHIFT_FORMS") then |
||
183 | if ( arg1 == "mouseover" or UnitIsPlayer("mouseover")) then |
||
184 | ----TB_AddMessage("UNIT_MANA"); |
||
185 | if (not TipBuddy.targetType) then |
||
186 | TipBuddy.targetType = TipBuddy_TargetInfo_GetTargetType( arg1 ); |
||
187 | end |
||
188 | if (not TipBuddy_SavedVars[TipBuddy.targetType]) then |
||
189 | return; |
||
190 | elseif ( TipBuddy_SavedVars[TipBuddy.targetType].off ~= 0 ) then |
||
191 | ------TB_AddMessage(TB_WHT_TXT.."UNIT_MANA - go"); |
||
192 | TipBuddy_SetFrame_Visibility( TipBuddy.targetType, arg1, 1 ); |
||
193 | TipBuddy_SetFrame_BackgroundColor( TipBuddy.targetType, arg1 ); |
||
194 | end |
||
195 | end |
||
196 | end |
||
197 | end |
||
198 | |||
199 | function TipBuddy_SlashCommand(msg) |
||
200 | if( not msg or msg == "" ) then |
||
201 | TipBuddy_ToggleOptionsFrame(); |
||
202 | end |
||
203 | if( msg == "rankname" ) then |
||
204 | if (TipBuddy_SavedVars["general"].rankname == 1) then |
||
205 | TipBuddy_SavedVars["general"].rankname = 0; |
||
206 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: No longer showing full rank title in name."); |
||
207 | else |
||
208 | TipBuddy_SavedVars["general"].rankname = 1; |
||
209 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Showing full rank titles in name."); |
||
210 | end |
||
211 | end |
||
212 | if( msg == "resetanchor" ) then |
||
213 | TipBuddy_ResetAnchorPos(); |
||
214 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Resetting TipBuddyAnchor position."); |
||
215 | end |
||
216 | if( msg == "report" ) then |
||
217 | TipBuddy_ReportVarStats(); |
||
218 | end |
||
219 | if( msg == "blizdefault" ) then |
||
220 | if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
221 | TipBuddy_SavedVars["general"].blizdefault = 0; |
||
222 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Default tooltips are now enhanced."); |
||
223 | else |
||
224 | TipBuddy_SavedVars["general"].blizdefault = 1; |
||
225 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Default tooltips are no longer enhanced."); |
||
226 | end |
||
227 | end |
||
228 | if (string.find(msg, "extras") ~= nil) then |
||
229 | local type = ""; |
||
230 | for type in string.gfind(msg, "extras%s(.+)") do |
||
231 | type = TipBuddy_ToggleExtras(type); |
||
232 | ----TB_AddMessage(type); |
||
233 | end |
||
234 | if (not type) then |
||
235 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Please specify a target type (ex: /tip extras pc_friend)"); |
||
236 | return; |
||
237 | end |
||
238 | return; |
||
239 | end |
||
240 | if (string.find(msg, "scale") ~= nil) then |
||
241 | --local i, s = string.find(msg, "%d+"); |
||
242 | for scale in string.gfind(msg, "scale%s(%d.*)") do |
||
243 | TipBuddy.s = tonumber(scale); |
||
244 | end |
||
245 | if (TipBuddy.s) then |
||
246 | if (TipBuddy.s > 2) then |
||
247 | TipBuddy.s = 2; |
||
248 | elseif (TipBuddy.s < 0.25) then |
||
249 | TipBuddy.s = 0.25; |
||
250 | end |
||
251 | GameTooltip:SetScale(2); |
||
252 | TipBuddyTooltip:SetScale(2); |
||
253 | --GameTooltip:SetScale(UIParent:GetScale() * TipBuddy.s); |
||
254 | TipBuddy_SetEffectiveScale(GameTooltip, TipBuddy.s, UIParent); |
||
255 | TipBuddy_SetEffectiveScale(TipBuddyTooltip, TipBuddy.s, UIParent); |
||
256 | --TipBuddy_SavedVars["general"].gtt_scale = (UIParent:GetScale() * TipBuddy.s); |
||
257 | TipBuddy_SavedVars["general"].gtt_scale = TipBuddy.s; |
||
258 | else |
||
259 | DEFAULT_CHAT_FRAME:AddMessage("|cff20ff20TipBuddy: Please type a scale number after 'scale' (valid numbers: 0.25-2)"); |
||
260 | end |
||
261 | return; |
||
262 | end |
||
263 | |||
264 | end |
||
265 | |||
266 | |||
267 | |||
268 | function TipBuddy_ShowUnitTooltip(unit, refresh) |
||
269 | if (not unit) then |
||
270 | unit = "mouseover"; |
||
271 | end |
||
272 | if (not refresh) then |
||
273 | TipBuddy.targetUnit = unit; |
||
274 | TipBuddy.uName = UnitName(unit); |
||
275 | TipBuddy.uLevel = UnitLevel(unit); |
||
276 | TipBuddy.uClass = UnitClass(unit); |
||
277 | TipBuddy.uRace = UnitRace(unit); |
||
278 | TipBuddy.uGuild = GetGuildInfo(unit); |
||
279 | TipBuddy.uReaction = TipBuddy_GetUnitReaction(unit); |
||
280 | |||
281 | --TB_AddMessage("ShowUnitTooltip"); |
||
282 | TipBuddy.targetType = TipBuddy_TargetInfo_GetTargetType( unit ); |
||
283 | else |
||
284 | --TB_AddMessage("ShowUnitTooltip -- refresh!"); |
||
285 | end |
||
286 | |||
287 | TipBuddy_SetFrame_Visibility( TipBuddy.targetType, unit, refresh ); |
||
288 | TipBuddy_SetFrame_BackgroundColor( TipBuddy.targetType, unit ); |
||
289 | TipBuddy_ShowRank( TipBuddy.targetType, unit ); |
||
290 | TipBuddy_TargetBuffs_Update( TipBuddy.targetType, unit ); |
||
291 | |||
292 | --local text = getglobal("GameTooltipTextLeft1"); |
||
293 | --if (not text or not TipBuddy.uName or not string.find(text:GetText(), TipBuddy_FixMagicChars(TipBuddy.uName)) ) then |
||
294 | --end |
||
295 | end |
||
296 | |||
297 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
298 | -- CHECK PET |
||
299 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
300 | --[[ |
||
301 | UNITNAME_TITLE_CHARM = "%s's Minion"; -- %s is the name of the unit's charmer |
||
302 | UNITNAME_TITLE_CREATION = "%s's Creation"; |
||
303 | UNITNAME_TITLE_GUARDIAN = "%s's Guardian"; |
||
304 | UNITNAME_TITLE_MINION = "%s's Minion"; |
||
305 | UNITNAME_TITLE_PET = "%s's Pet"; -- %s is the name of the unit's summoner |
||
306 | ]]-- |
||
307 | function TipBuddy_TargetInfo_CheckPet() |
||
308 | for i=1, (GameTooltip:NumLines()), 1 do |
||
309 | local tipstring = getglobal("GameTooltipTextLeft"..i); |
||
310 | if (not tipstring or not tipstring:GetText()) then |
||
311 | return; |
||
312 | end |
||
313 | if ( string.find(tipstring:GetText(), TB_minion) ) then |
||
314 | return 1; |
||
315 | end |
||
316 | if ( string.find(tipstring:GetText(), TB_creation) ) then |
||
317 | return 1; |
||
318 | end |
||
319 | if ( string.find(tipstring:GetText(), TB_guardian) ) then |
||
320 | return 1; |
||
321 | end |
||
322 | if ( string.find(tipstring:GetText(), TB_pet) ) then |
||
323 | return 1; |
||
324 | end |
||
325 | end |
||
326 | return; |
||
327 | end |
||
328 | |||
329 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
330 | -- GET TARGET TYPE |
||
331 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
332 | function TipBuddy_TargetInfo_GetTargetType( unit ) |
||
333 | if (not unit) then |
||
334 | return; |
||
335 | end |
||
336 | if ( ( UnitHealth(unit) <= 0 ) ) then |
||
337 | return ( "corpse" ); |
||
338 | elseif ( ( UnitHealthMax(unit) > 0 ) ) then |
||
339 | if (string.find(unit, "party.+")) then |
||
340 | return ( "pc_party" ); |
||
341 | end |
||
342 | if (UnitPlayerControlled(unit)) then |
||
343 | if (UnitIsFriend(unit, "player")) then |
||
344 | if ( UnitIsUnit(unit, "pet") or TipBuddy_TargetInfo_CheckPet() ) then |
||
345 | TB_AddMessage("1 - pet_friend"); |
||
346 | return ( "pet_friend" ); |
||
347 | end |
||
348 | |||
349 | if (UnitInParty(unit)) then |
||
350 | TB_AddMessage("1 - pc_party"); |
||
351 | return ( "pc_party" ); |
||
352 | else |
||
353 | return ( "pc_friend" ); |
||
354 | end |
||
355 | elseif (UnitIsEnemy(unit, "player")) then |
||
356 | if ( TipBuddy_TargetInfo_CheckPet() ) then |
||
357 | return ( "pet_enemy" ); |
||
358 | else |
||
359 | return ( "pc_enemy" ); |
||
360 | end |
||
361 | else |
||
362 | TB_AddMessage("2 - pet_friend"); |
||
363 | return ( "pet_friend" ); |
||
364 | end |
||
365 | else |
||
366 | if (UnitIsFriend(unit, "player")) then |
||
367 | if ( TipBuddy_TargetInfo_CheckPet() ) then |
||
368 | return ( "pet_friend" ); |
||
369 | else |
||
370 | return ( "npc_friend" ); |
||
371 | end |
||
372 | elseif (UnitIsEnemy(unit, "player")) then |
||
373 | if ( TipBuddy_TargetInfo_CheckPet() ) then |
||
374 | return ( "pet_enemy" ); |
||
375 | else |
||
376 | return ( "npc_enemy" ); |
||
377 | end |
||
378 | else --neutral |
||
379 | return ( "npc_neutral" ); |
||
380 | end |
||
381 | end |
||
382 | else |
||
383 | TipBuddy_Hide( TipBuddy_Main_Frame ); |
||
384 | return; |
||
385 | end |
||
386 | end |
||
387 | |||
388 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
389 | -- GET EXTRAS |
||
390 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
391 | |||
392 | function TipBuddy_TargetInfo_FindExtras( unit ) |
||
393 | TipBuddy_GTT_GetExtraLines(20, unit); |
||
394 | TipBuddy_TargetInfo_ShowExtras(); |
||
395 | end |
||
396 | |||
397 | function TipBuddy_TargetInfo_ShowExtras() |
||
398 | ----TB_AddMessage("SHOWING_EXTRAS"); |
||
399 | if (TipBuddy.gtt_xtra) then |
||
400 | local lineL, LineR; |
||
401 | for i=1, 20, 1 do |
||
402 | getglobal("TipBuddy_Xtra"..i.."_Text"):Hide(); |
||
403 | getglobal("TipBuddy_Xtra"..i.."_Text"):SetText(""); |
||
404 | getglobal("TipBuddy_XtraR"..i.."_Text"):Hide(); |
||
405 | getglobal("TipBuddy_XtraR"..i.."_Text"):SetText(""); |
||
406 | end |
||
407 | for i=1, table.getn(TipBuddy.gtt_xtra), 1 do |
||
408 | lineL = getglobal("TipBuddy_Xtra"..i.."_Text"); |
||
409 | ----TB_AddMessage(TEXT(TipBuddy.gtt_xtra[i])) |
||
410 | if (TipBuddy.gtt_xtra[i.."color"]) then |
||
411 | lineL:SetVertexColor(TipBuddy.gtt_xtra[i.."color"].r, TipBuddy.gtt_xtra[i.."color"].g, TipBuddy.gtt_xtra[i.."color"].b); |
||
412 | else |
||
413 | lineL:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
414 | end |
||
415 | if (TipBuddy.gtt_xtraR[i.."color"]) then |
||
416 | lineR:SetVertexColor(TipBuddy.gtt_xtraR[i.."color"].r, TipBuddy.gtt_xtraR[i.."color"].g, TipBuddy.gtt_xtraR[i.."color"].b); |
||
417 | else |
||
418 | lineR:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
419 | end |
||
420 | if (TipBuddy.gtt_xtraR) then |
||
421 | lineL:SetText(TEXT(TipBuddy.gtt_xtra[i])); |
||
422 | lineL:Show(); |
||
423 | lineR = getglobal("TipBuddy_XtraR"..i.."_Text"); |
||
424 | ------TB_AddMessage(TEXT(TipBuddy.gtt_xtraR[i])) |
||
425 | lineR:SetText(TEXT(TipBuddy.gtt_xtraR[i])); |
||
426 | lineR:Show(); |
||
427 | else |
||
428 | lineL:SetText(TEXT(TipBuddy.gtt_xtra[i])); |
||
429 | lineL:Show(); |
||
430 | end |
||
431 | end |
||
432 | end |
||
433 | end |
||
434 | |||
435 | function TipBuddy_GTT_GetExtraLines( numlines, unit ) |
||
436 | TB_AddMessage("getting extra lines"); |
||
437 | if (not numlines) then |
||
438 | return; |
||
439 | end |
||
440 | TipBuddy.gtt_xtra = {}; |
||
441 | TipBuddy.gtt_xtraR = {}; |
||
442 | if (not TipBuddy.gtt_lastline) then |
||
443 | if (GameTooltip:IsVisible()) then |
||
444 | TipBuddy.gtt_lastline = GameTooltip:NumLines(); |
||
445 | else |
||
446 | TipBuddy.gtt_lastline = 2; |
||
447 | end |
||
448 | end |
||
449 | TB_AddMessage("!! lastline: "..TipBuddy.gtt_lastline..", numlines (stored): "..TipBuddy.gtt_numlines..", numlines (real): "..GameTooltip:NumLines()); |
||
450 | if (numlines > TipBuddy.gtt_lastline) then |
||
451 | TB_AddMessage("numlines > TipBuddy.gtt_lastline"); |
||
452 | --/script GameTooltipTextLeft1:SetText(GameTooltipTextLeft1:GetText().."\nSecondLine");GameTooltip:Show(); |
||
453 | local line, text; |
||
454 | local j = 1; |
||
455 | for i=TipBuddy.gtt_lastline + 1, numlines, 1 do |
||
456 | line = getglobal("GameTooltipTextLeft"..i); |
||
457 | lineR = getglobal("GameTooltipTextRight"..i); |
||
458 | if (not line or not line:GetText() or string.find(line:GetText(), PVP_ENABLED)) then |
||
459 | return; |
||
460 | else |
||
461 | TipBuddy.gtt_xtra[j.."color"] = {}; |
||
462 | TipBuddy.gtt_xtra[j.."color"].r, TipBuddy.gtt_xtra[j.."color"].g, TipBuddy.gtt_xtra[j.."color"].b = line:GetTextColor(); |
||
463 | text = line:GetText(); |
||
464 | end |
||
465 | --GREEN_FONT_COLOR_CODE..PVP_RANK_CIVILIAN..FONT_COLOR_CODE_CLOSE |
||
466 | TipBuddy.gtt_xtra[j] = text; |
||
467 | if (lineR:GetText() and lineR:IsShown()) then |
||
468 | TipBuddy.gtt_xtraR[j.."color"] = {}; |
||
469 | TipBuddy.gtt_xtraR[j.."color"].r, TipBuddy.gtt_xtraR[j.."color"].g, TipBuddy.gtt_xtraR[j.."color"].b = lineR:GetTextColor(); |
||
470 | TipBuddy.gtt_xtraR[j] = lineR:GetText(); |
||
471 | else |
||
472 | TipBuddy.gtt_xtraR[j] = ""; |
||
473 | end |
||
474 | TB_AddMessage(line:GetText()); |
||
475 | j = j + 1; |
||
476 | --/script ----TB_AddMessage(GameTooltipTextLeft2:GetText()); |
||
477 | end |
||
478 | else |
||
479 | return; |
||
480 | end |
||
481 | end |
||
482 | |||
483 | function TipBuddy_GTT_AddExtras() |
||
484 | if (TipBuddy.gtt_xtra) then |
||
485 | --TB_AddMessage(TB_WHT_TXT.."Adding Extras"); |
||
486 | for i=1, table.getn(TipBuddy.gtt_xtra), 1 do |
||
487 | local lCr, lCg, lCb, rCr, rCg, rCb; |
||
488 | if (TipBuddy.gtt_xtra[i.."color"]) then |
||
489 | lCr, lCg, lCb = TipBuddy.gtt_xtra[i.."color"].r, TipBuddy.gtt_xtra[i.."color"].g, TipBuddy.gtt_xtra[i.."color"].b; |
||
490 | else |
||
491 | lCr, lCg, lCb = HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b; |
||
492 | end |
||
493 | if (TipBuddy.gtt_xtraR and TipBuddy.gtt_xtraR[i.."color"]) then |
||
494 | rCr, rCg, rCb = TipBuddy.gtt_xtraR[i.."color"].r, TipBuddy.gtt_xtraR[i.."color"].g, TipBuddy.gtt_xtraR[i.."color"].b; |
||
495 | else |
||
496 | rCr, rCg, rCb = HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b; |
||
497 | end |
||
498 | |||
499 | if (TipBuddy.gtt_xtraR) then |
||
500 | TipBuddyTooltip:AddDoubleLine(TipBuddy.gtt_xtra[i], TipBuddy.gtt_xtraR[i], lCr, lCg, lCb, rCr, rCg, rCb); |
||
501 | else |
||
502 | TipBuddyTooltip:AddLine(TipBuddy.gtt_xtra[i], lCr, lCg, lCb); |
||
503 | end |
||
504 | end |
||
505 | end |
||
506 | end |
||
507 | |||
508 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
509 | -- VISIBILITY |
||
510 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
511 | -- Target Types are: |
||
512 | -- pc_friend |
||
513 | -- pc_party |
||
514 | -- pc_enemy |
||
515 | -- npc_friend |
||
516 | -- npc_neutral |
||
517 | -- npc_enemy |
||
518 | -- pet_friend |
||
519 | -- pet_enemy |
||
520 | |||
521 | function TipBuddy_SetFrame_Visibility( type, unit, refresh ) |
||
522 | if (not type or not unit) then |
||
523 | return; |
||
524 | end |
||
525 | |||
526 | local targettype = TipBuddy_SavedVars[type]; |
||
527 | if (not targettype) then |
||
528 | ----TB_AddMessage("BUG! NO SAVED VARS FOR: "..type); |
||
529 | TipBuddy_SetFrame_BackgroundColor( "corpse", unit ); |
||
530 | return; |
||
531 | end |
||
532 | |||
533 | local targettype = TipBuddy_SavedVars[type]; |
||
534 | ----TB_AddMessage("1: "..GameTooltipTextLeft2:GetText()); |
||
535 | if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
536 | |||
537 | elseif ( targettype.off == 1 ) then |
||
538 | |||
539 | TipBuddy_ForceHide(TipBuddy_Main_Frame); |
||
540 | if (not TipBuddy_Main_Frame:IsVisible()) then |
||
541 | TipBuddy_Main_Frame:Show(); |
||
542 | TipBuddy_Main_Frame:SetAlpha(1); |
||
543 | end |
||
544 | TipBuddy.compactvis = 1; |
||
545 | else |
||
546 | TipBuddy_ForceHide( TipBuddy_Main_Frame ); |
||
547 | end |
||
548 | TipBuddy_SetFrame_TargetType( type, unit, refresh ); |
||
549 | TipBuddy.vis = 1; |
||
550 | TipBuddy.gotextras = 1; |
||
551 | end |
||
552 | |||
553 | function TipBuddy_TargetInfo_CheckName( type, unit ) |
||
554 | |||
555 | TipBuddy.gtt_namecolor = ""; |
||
556 | local targettype = TipBuddy_SavedVars[type]; |
||
557 | if (targettype.off == 2) then |
||
558 | return; |
||
559 | end |
||
560 | |||
561 | if (not type or not unit) then |
||
562 | TipBuddy.gtt_namecolor = tbcolor_unknown; |
||
563 | if (UnitName(unit)) then |
||
564 | TipBuddy.gtt_name = UnitName(unit); |
||
565 | else |
||
566 | TipBuddy.gtt_name = TB_notspecified; |
||
567 | end |
||
568 | return; |
||
569 | end |
||
570 | |||
571 | if (UnitHealth(unit) <= 0) then |
||
572 | TipBuddy.gtt_namecolor = tbcolor_corpse; |
||
573 | elseif (TipBuddy.uReaction) then |
||
574 | TipBuddy.gtt_namecolor = getglobal("tbcolor_nam_"..TipBuddy.uReaction); |
||
575 | elseif ( UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) ) then |
||
576 | TipBuddy.gtt_namecolor = (tbcolor_nam_tappedother.." >"); |
||
577 | elseif (UnitIsTappedByPlayer(unit)) then |
||
578 | TipBuddy.gtt_namecolor = (tbcolor_nam_tappedplayer); |
||
579 | else |
||
580 | TipBuddy.gtt_namecolor = tbcolor_unknown; |
||
581 | end |
||
582 | |||
583 | if (TipBuddy.refresh == 1 and TipBuddy.gtt_name ~= nil) then |
||
584 | return; |
||
585 | end |
||
586 | |||
587 | if (TipBuddy.uName) then |
||
588 | TipBuddy.gtt_name = TipBuddy.uName; |
||
589 | else |
||
590 | TipBuddy.gtt_name = TB_notspecified; |
||
591 | end |
||
592 | if (UnitPlayerControlled(unit) and targettype.rnm == 1) then |
||
593 | if (unit == "player" or unit == "mouseover" or unit == "target" ) then |
||
594 | TipBuddy.gtt_name = UnitPVPName(unit); |
||
595 | elseif (getglobal("GameTooltipTextLeft1"):GetText()) then |
||
596 | TipBuddy.gtt_name = getglobal("GameTooltipTextLeft1"):GetText(); |
||
597 | end |
||
598 | end |
||
599 | end |
||
600 | |||
601 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
602 | -- GET TARGET's TARGET |
||
603 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
604 | |||
605 | function TipBuddy_TargetInfo_TargetsTarget( type, unit ) |
||
606 | if (not TipBuddy.gtt_target) then |
||
607 | TipBuddy.gtt_target = ""; |
||
608 | end |
||
609 | if (TipBuddy_SavedVars[type].trg == 0 and TipBuddy_SavedVars[type].off ~= 2) then |
||
610 | ------TB_AddMessage("TT for "..type.." is turned off"); |
||
611 | return; |
||
612 | end |
||
613 | local tunit = unit.."target"; |
||
614 | local target = UnitName(tunit); |
||
615 | if (target) then |
||
616 | if (target == UNKNOWNOBJECT) then |
||
617 | return; |
||
618 | end |
||
619 | local treaction = TipBuddy_GetUnitReaction( tunit ); |
||
620 | local tcolor = ""; |
||
621 | TipBuddy.tt = 1; |
||
622 | if (target == UnitName("player")) then |
||
623 | tcolor = TB_WHT_TXT; |
||
624 | if (TipBuddy_SavedVars[type].trg_2l and TipBuddy_SavedVars[type].trg_2l == 1) then |
||
625 | TipBuddy.gtt_target = "\n"..tcolor.." [YOU]"; |
||
626 | else |
||
627 | TipBuddy.gtt_target = tcolor.." : [YOU]"; |
||
628 | end |
||
629 | ------TB_AddMessage("target = "..tcolor.." [YOU]"); |
||
630 | return; |
||
631 | elseif (target == UnitInParty(tunit)) then |
||
632 | if (TipBuddy_SavedVars[type].trg_pa == 0) then |
||
633 | return; |
||
634 | else |
||
635 | tcolor = TB_PNK_TXT; |
||
636 | end |
||
637 | elseif (UnitHealth(tunit) <= 0) then |
||
638 | tcolor = TB_DGY_TXT; |
||
639 | --elseif (treaction) then |
||
640 | elseif ( UnitPlayerControlled(tunit) ) then |
||
641 | --[[ |
||
642 | TB_NML_TXT = "|cffffd200" |
||
643 | TB_WHT_TXT = "|cffffffff" |
||
644 | TB_GRY_TXT = "|cffC0C0C0" |
||
645 | TB_DGY_TXT = "|cff585858" |
||
646 | TB_RED_TXT = "|cffff2020" |
||
647 | TB_GRN_TXT = "|cff20ff20" |
||
648 | TB_YLW_TXT = "|cffffff00" |
||
649 | TB_BLE_TXT = "|cff3366ff" |
||
650 | TB_PNK_TXT = "|cffff00ff" |
||
651 | TB_DBL_TXT = "|cff3399ff" |
||
652 | TB_DGN_TXT = "|cff339900" |
||
653 | TB_DRD_TXT = "|cffcc0000" |
||
654 | ]] |
||
655 | if ( UnitCanAttack(tunit, "player") or UnitCanAttack("player", tunit) ) then |
||
656 | if (TipBuddy_SavedVars[type].trg_en == 0) then |
||
657 | return; |
||
658 | else |
||
659 | tcolor = TB_RED_TXT; |
||
660 | end |
||
661 | --return "hostile"; |
||
662 | else |
||
663 | -- All other players are green |
||
664 | if (TipBuddy_SavedVars[type].trg_pl == 0) then |
||
665 | return; |
||
666 | else |
||
667 | tcolor = TB_GRN_TXT; |
||
668 | --return "friendly"; |
||
669 | end |
||
670 | end |
||
671 | elseif ( UnitIsEnemy(tunit, "player") ) then |
||
672 | if (TipBuddy_SavedVars[type].trg_en == 0) then |
||
673 | return; |
||
674 | else |
||
675 | tcolor = TB_RED_TXT; |
||
676 | --return "pvp"; |
||
677 | end |
||
678 | else |
||
679 | if (TipBuddy_SavedVars[type].trg_np == 0) then |
||
680 | return; |
||
681 | else |
||
682 | tcolor = TB_BLE_TXT; |
||
683 | end |
||
684 | end |
||
685 | --TipBuddy.gtt_target = tcolor.." ["..TB_WHT_TXT..UnitName(unit.."target")..tcolor.."]"; |
||
686 | if (TipBuddy_SavedVars[type].trg_2l and TipBuddy_SavedVars[type].trg_2l == 1) then |
||
687 | TipBuddy.gtt_target = "\n"..TB_WHT_TXT.." "..tcolor.."["..UnitName(unit.."target").."]"; |
||
688 | else |
||
689 | TipBuddy.gtt_target = TB_WHT_TXT.." : "..tcolor.."["..UnitName(unit.."target").."]"; |
||
690 | ------TB_AddMessage("target = "..tcolor.."["..UnitName(unit.."target").."]"); |
||
691 | end |
||
692 | else |
||
693 | TipBuddy.tt = 0; |
||
694 | end |
||
695 | end |
||
696 | |||
697 | function TipBuddy_Adv_TargetsTarget( unit ) |
||
698 | local tunit = unit.."target"; |
||
699 | local target = UnitName(tunit); |
||
700 | if (target) then |
||
701 | local treaction = TipBuddy_GetUnitReaction( tunit ); |
||
702 | local tcolor = ""; |
||
703 | if (target == UnitName("player")) then |
||
704 | return "YOU", TB_WHT_TXT; |
||
705 | elseif (target == UnitInParty(tunit)) then |
||
706 | return target, TB_PNK_TXT; |
||
707 | elseif (UnitHealth(tunit) <= 0) then |
||
708 | return target, TB_DGY_TXT; |
||
709 | elseif ( UnitPlayerControlled(tunit) ) then |
||
710 | if ( UnitCanAttack(tunit, "player") or UnitCanAttack("player", tunit) ) then |
||
711 | --return "hostile"; |
||
712 | return target, TB_RED_TXT; |
||
713 | else |
||
714 | --return "friendly"; |
||
715 | return target, TB_GRN_TXT; |
||
716 | end |
||
717 | elseif ( UnitIsEnemy(tunit, "player") ) then |
||
718 | --return "pvp"; |
||
719 | return target, TB_RED_TXT; |
||
720 | else |
||
721 | return target, TB_BLE_TXT; |
||
722 | end |
||
723 | else |
||
724 | return "", ""; |
||
725 | end |
||
726 | end |
||
727 | |||
728 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
729 | -- GET GUILD |
||
730 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
731 | function TipBuddy_TargetInfo_GetGuild( type, unit ) |
||
732 | if (not unit or not type) then |
||
733 | return; |
||
734 | end |
||
735 | if (TipBuddy.refresh == 1) then |
||
736 | ------TB_AddMessage("REFRESH == 1"); |
||
737 | if (TipBuddy.gtt_guild == "" or TipBuddy.gtt_guild == nil) then |
||
738 | return; |
||
739 | end |
||
740 | end |
||
741 | |||
742 | --/script GameTooltip_SetDefaultAnchor(GameTooltip, UIParent);GameTooltip:SetUnit("partypet1"); ----TB_AddMessage(GameTooltipTextLeft2:GetText()); |
||
743 | local targettype = TipBuddy_SavedVars[type]; |
||
744 | TipBuddy.gtt_guildcolor = ""; |
||
745 | if (targettype.off ~= 2) then |
||
746 | if (TipBuddy.uGuild and GetGuildInfo("player") and TipBuddy.uGuild == GetGuildInfo("player")) then |
||
747 | TipBuddy.gtt_guildcolor = tbcolor_gld_mate; |
||
748 | elseif ( UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) ) then |
||
749 | TipBuddy.gtt_guildcolor = (tbcolor_gld_tappedother); |
||
750 | elseif (UnitIsTappedByPlayer(unit)) then |
||
751 | TipBuddy.gtt_guildcolor = (tbcolor_gld_tappedplayer); |
||
752 | elseif (TipBuddy.uReaction) then |
||
753 | TipBuddy.gtt_guildcolor = getglobal("tbcolor_gld_"..TipBuddy.uReaction); |
||
754 | else |
||
755 | TipBuddy.gtt_guildcolor = tbcolor_unknown; |
||
756 | end |
||
757 | if (TipBuddy.refresh == 1) then |
||
758 | return; |
||
759 | end |
||
760 | end |
||
761 | |||
762 | if (unit == "party1" or unit == "partypet1" or unit == "party2" or unit == "partypet2" or unit == "party3" or unit == "partypet3" or unit == "party4" or unit == "partypet4" or unit == "party5" or unit == "partypet5" ) then |
||
763 | if ( TipBuddy.uGuild ) then |
||
764 | TipBuddy.gtt_guild = TipBuddy.uGuild; |
||
765 | ------TB_AddMessage(GetGuildInfo(unit)); |
||
766 | end |
||
767 | if (not TipBuddy.gtt_guild) then |
||
768 | TipBuddy.gtt_guild = ""; |
||
769 | end |
||
770 | return; |
||
771 | elseif (UnitPlayerControlled(unit) or (GameTooltipTextLeft2:GetText() and string.find(GameTooltipTextLeft2:GetText(), PLAYER ) ) ) then |
||
772 | if ( type == "pet_friend" or type == "pet_enemy" ) then |
||
773 | TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText()); |
||
774 | ------TB_AddMessage("player pet guild: "..TipBuddy.gtt_guild); |
||
775 | return; |
||
776 | elseif ( TipBuddy.uGuild ) then |
||
777 | TipBuddy.gtt_guild = TipBuddy.uGuild; |
||
778 | ------TB_AddMessage("player guild: "..TipBuddy.gtt_guild); |
||
779 | end |
||
780 | return; |
||
781 | else |
||
782 | ------TB_AddMessage("GUILD: npc, testing..."); |
||
783 | if (not GameTooltipTextLeft2:GetText()) then |
||
784 | ------TB_AddMessage("GUILD: npc, line 2 is blank"); |
||
785 | return; |
||
786 | end |
||
787 | if ( type == "pet_friend" or type == "pet_enemy" ) then |
||
788 | TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText()); |
||
789 | ------TB_AddMessage("pet guild: "..TipBuddy.gtt_guild); |
||
790 | return; |
||
791 | end |
||
792 | if (string.find(GameTooltipTextLeft2:GetText(), TB_level ) ) then |
||
793 | ------TB_AddMessage("GUILD: npc, line 2 is level"); |
||
794 | return; |
||
795 | else |
||
796 | TipBuddy.gtt_guild = (GameTooltipTextLeft2:GetText()); |
||
797 | ----TB_AddMessage("title guild: "..TipBuddy.gtt_guild); |
||
798 | end |
||
799 | end |
||
800 | |||
801 | end |
||
802 | |||
803 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
804 | -- GET CLASS/TYPE |
||
805 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
806 | function TipBuddy_TargetInfo_GetClass( type, unit ) |
||
807 | --TipBuddy.uClass |
||
808 | local targettype = TipBuddy_SavedVars[type]; |
||
809 | TipBuddy.gtt_classlvlcolor = ""; |
||
810 | TipBuddy.gtt_classcorpse = ""; |
||
811 | TipBuddy.gtt_classcolor = ""; |
||
812 | TipBuddy.gtt_class = ""; |
||
813 | TipBuddy.gtt_race = ""; |
||
814 | if (targettype.off == 2) then |
||
815 | return; |
||
816 | elseif (TipBuddy_SavedVars["general"].classcolor == 1) then |
||
817 | TipBuddy.gtt_classlvlcolor = ""; |
||
818 | elseif ( UnitCanAttack(unit, "player") or UnitCanAttack("player", unit) or UnitIsPVP(unit) ) then |
||
819 | -- Hostile Units, use con color system |
||
820 | TipBuddy.gtt_classlvlcolor = TipBuddy_GetDifficultyColor(TipBuddy.uLevel); |
||
821 | else |
||
822 | -- Friendly (non-PvP flagged) Units, we don't want to use the con color cause we don't care |
||
823 | TipBuddy.gtt_classlvlcolor = tbcolor_lvl_same_faction; |
||
824 | end |
||
825 | if (UnitHealth(unit) <= 0) then |
||
826 | TipBuddy.gtt_classlvlcolor = tbcolor_corpse; |
||
827 | TipBuddy.gtt_classcorpse = " "..CORPSE.."|r"; |
||
828 | end |
||
829 | |||
830 | if ( UnitPlayerControlled(unit) or TipBuddy.uRace) then |
||
831 | if (targettype.rac == 1 and TipBuddy.uRace ~= nil) then |
||
832 | TipBuddy.gtt_race = (tbcolor_race..TipBuddy.uRace.." |r"); |
||
833 | else |
||
834 | TipBuddy.gtt_race = "|r"; |
||
835 | end |
||
836 | |||
837 | --coloring class text |
||
838 | if (UnitClass(unit) == TB_mage) then |
||
839 | TipBuddy.gtt_classcolor = tbcolor_cls_mage; |
||
840 | elseif (UnitClass(unit) == TB_warlock) then |
||
841 | TipBuddy.gtt_classcolor = tbcolor_cls_warlock; |
||
842 | elseif (UnitClass(unit) == TB_priest) then |
||
843 | TipBuddy.gtt_classcolor = tbcolor_cls_priest; |
||
844 | elseif (UnitClass(unit) == TB_druid) then |
||
845 | TipBuddy.gtt_classcolor = tbcolor_cls_druid; |
||
846 | elseif (UnitClass(unit) == TB_shaman) then |
||
847 | TipBuddy.gtt_classcolor = tbcolor_cls_shaman; |
||
848 | elseif (UnitClass(unit) == TB_paladin) then |
||
849 | TipBuddy.gtt_classcolor = tbcolor_cls_paladin; |
||
850 | elseif (UnitClass(unit) == TB_rogue) then |
||
851 | TipBuddy.gtt_classcolor = tbcolor_cls_rogue; |
||
852 | elseif (UnitClass(unit) == TB_hunter) then |
||
853 | TipBuddy.gtt_classcolor = tbcolor_cls_hunter; |
||
854 | elseif (UnitClass(unit) == TB_warrior) then |
||
855 | TipBuddy.gtt_classcolor = tbcolor_cls_warrior; |
||
856 | else |
||
857 | TipBuddy.gtt_classcolor = tbcolor_cls_other; |
||
858 | end |
||
859 | else |
||
860 | TipBuddy.gtt_classcolor = tbcolor_cls_other; |
||
861 | end |
||
862 | --/script ----TB_AddMessage(UnitCreatureFamily("mouseover")); |
||
863 | if ( type == "pet_friend" or type == "pet_enemy" ) then |
||
864 | TipBuddy.gtt_race = ""; |
||
865 | if (UnitCreatureFamily(unit)) then |
||
866 | TipBuddy.gtt_class = UnitCreatureFamily(unit).."|r"; |
||
867 | return; |
||
868 | else |
||
869 | TipBuddy.gtt_class = "|r"; |
||
870 | end |
||
871 | return; |
||
872 | end |
||
873 | |||
874 | ------TB_AddMessage("Get Class - "..unit); |
||
875 | -- /script ----TB_AddMessage(UnitCreatureType(unit)); |
||
876 | if ( UnitPlayerControlled(unit) or TipBuddy.uRace) then |
||
877 | TipBuddy.gtt_class = TipBuddy.uClass.."|r"; |
||
878 | elseif ( UnitCreatureFamily(unit) ) then |
||
879 | TipBuddy.gtt_class = UnitCreatureFamily(unit).."|r"; |
||
880 | else |
||
881 | if ( UnitCreatureType(unit) == TB_notspecified) then |
||
882 | TipBuddy.gtt_class = TB_creature.."|r"; |
||
883 | else |
||
884 | if (not UnitCreatureType(unit)) then |
||
885 | TipBuddy.gtt_class = "|r"; |
||
886 | else |
||
887 | TipBuddy.gtt_class = UnitCreatureType(unit).."|r"; |
||
888 | end |
||
889 | end |
||
890 | end |
||
891 | end |
||
892 | |||
893 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
894 | -- GET LEVEL |
||
895 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
896 | function TipBuddy_TargetInfo_GetLevel( type, unit ) |
||
897 | local targettype = TipBuddy_SavedVars[type]; |
||
898 | if (not unit or targettype.off == 2) then |
||
899 | return; |
||
900 | end |
||
901 | |||
902 | local targetLevel = TipBuddy.uLevel; |
||
903 | if ( targetLevel == -1 ) then |
||
904 | targetLevel = 100; |
||
905 | end |
||
906 | |||
907 | -- Color level number |
||
908 | local color; |
||
909 | if (UnitHealth(unit) <= 0) then |
||
910 | color = tbcolor_corpse; |
||
911 | ------TB_AddMessage("level color = corpse"); |
||
912 | elseif ( UnitCanAttack(unit, "player") or UnitCanAttack("player", unit) or UnitIsPVP(unit) ) then |
||
913 | -- Hostile unit of friendly unit flagged for PvP |
||
914 | color = TipBuddy_GetDifficultyColor(targetLevel); |
||
915 | ------TB_AddMessage("level color = hostile or pvp"); |
||
916 | else |
||
917 | color = tbcolor_lvl_same_faction; |
||
918 | ------TB_AddMessage("level color = same fac"); |
||
919 | end |
||
920 | |||
921 | if ( targetLevel == 100 ) then |
||
922 | targetLevel = "??"; |
||
923 | end |
||
924 | |||
925 | TipBuddy.classification = UnitClassification(unit); |
||
926 | if ( not targetLevel or targetLevel == 0 ) then |
||
927 | TipBuddy.gtt_level = ("|r"); |
||
928 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
929 | elseif ( TipBuddy.classification == "worldboss" ) then |
||
930 | TipBuddy.gtt_level = (color..targetLevel..tbcolor_elite_worldboss.." ("..TB_worldboss..")|r"); |
||
931 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
932 | elseif ( TipBuddy.classification == "rareelite" ) then |
||
933 | TipBuddy.gtt_level = (color.."+"..targetLevel..tbcolor_elite_rare.." ("..TB_rare..")|r"); |
||
934 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
935 | elseif ( TipBuddy.classification == "elite" ) then |
||
936 | TipBuddy.gtt_level = (color.."+"..targetLevel.."|r"); |
||
937 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
938 | elseif ( TipBuddy.classification == "rare" ) then |
||
939 | TipBuddy.gtt_level = (color..targetLevel..tbcolor_elite_rare.." ("..TB_rare..")|r"); |
||
940 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
941 | else |
||
942 | TipBuddy.gtt_level = (color..targetLevel.."|r"); |
||
943 | TipBuddy_TargetLevel_Text:SetText(TipBuddy.gtt_level); |
||
944 | end |
||
945 | end |
||
946 | |||
947 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
948 | -- GET/SHOW CITY FACTION |
||
949 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
950 | function TipBuddy_TargetInfo_ShowCityFaction( type, unit ) |
||
951 | if (UnitPlayerControlled(unit) or unit == "player" or unit == "party1" or unit == "partypet1" or unit == "party2" or unit == "partypet2" or unit == "party3" or unit == "partypet3" or unit == "party4" or unit == "partypet4" or unit == "party5" or unit == "partypet5" ) then |
||
952 | ------TB_AddMessage("CityFac: found a player"); |
||
953 | return; |
||
954 | end |
||
955 | local line; |
||
956 | for i=1, (GameTooltip:NumLines()), 1 do |
||
957 | local tipline = getglobal("GameTooltipTextLeft"..i); |
||
958 | if (not tipline or not tipline:GetText()) then |
||
959 | ------TB_AddMessage("tipline: "..i.." is empty"); |
||
960 | return; |
||
961 | end |
||
962 | if ( string.find(tipline:GetText(), TB_level..".+") ) then |
||
963 | line = getglobal("GameTooltipTextLeft"..(i + 1)); |
||
964 | if (line:GetText() == "\n" or line:GetText() == nil) then |
||
965 | ------TB_AddMessage("Line after Level is empty"); |
||
966 | break; |
||
967 | end |
||
968 | |||
969 | if (string.find(line:GetText(), PVP_ENABLED) or line:GetText() == nil) then |
||
970 | ------TB_AddMessage("CityFac: found PvP or something"); |
||
971 | break; |
||
972 | else |
||
973 | local first = string.sub(line:GetText(), 0 , 1); |
||
974 | if (first and TB_Factions[first]) then |
||
975 | ------TB_AddMessage("testing cityfac: ("..line:GetText()..") Line: "..(i+1)); |
||
976 | for j=1, table.getn(TB_Factions[first]), 1 do |
||
977 | if (line:GetText() == TB_Factions[first][j]) then |
||
978 | ------TB_AddMessage("found cityfac: ("..line:GetText()..") Line: "..(i+1)); |
||
979 | TipBuddy.gtt_lastline = i+1; |
||
980 | TipBuddy.gtt_cityfac = tbcolor_cityfac..line:GetText(); |
||
981 | break; |
||
982 | end |
||
983 | end |
||
984 | end |
||
985 | end |
||
986 | end |
||
987 | end |
||
988 | end |
||
989 | |||
990 | function TipBuddy_ConfirmLastLine(unit) |
||
991 | local line; |
||
992 | if (not unit) then |
||
993 | unit = "mouseover"; |
||
994 | TipBuddy.targetUnit = unit; |
||
995 | end |
||
996 | if (not TipBuddy.gtt_numlines) then |
||
997 | if (GameTooltip:IsVisible()) then |
||
998 | TipBuddy.gtt_numlines = GameTooltip:NumLines(); |
||
999 | else |
||
1000 | TipBuddy.gtt_numlines = 2; |
||
1001 | end |
||
1002 | end |
||
1003 | for i=TipBuddy.gtt_numlines, 1, -1 do |
||
1004 | line = getglobal("GameTooltipTextLeft"..i); |
||
1005 | if (not line or not line:GetText()) then |
||
1006 | return; |
||
1007 | end |
||
1008 | ----TB_AddMessage("LASTLINE: i = "..i..", text: "..line:GetText()); |
||
1009 | if (string.find(line:GetText(), PVP_ENABLED) |
||
1010 | or string.find(line:GetText(), TB_level ) |
||
1011 | or (TipBuddy.gtt_cityfac ~= "" and string.find(line:GetText(), TipBuddy.gtt_cityfac ) ) ) then |
||
1012 | if (i > TipBuddy.gtt_lastline) then |
||
1013 | TipBuddy.gtt_lastline = i; |
||
1014 | ------TB_AddMessage("i>LL: "..TipBuddy.gtt_lastline); |
||
1015 | break; |
||
1016 | else |
||
1017 | ------TB_AddMessage("i!>LL: "..TipBuddy.gtt_lastline); |
||
1018 | break; |
||
1019 | end |
||
1020 | end |
||
1021 | end |
||
1022 | end |
||
1023 | |||
1024 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1025 | -- HEALTH / MANA |
||
1026 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1027 | function TipBuddy_UnitFrame_UpdateHealth( unit ) |
||
1028 | UnitFrameHealthBar_Update(TipBuddy_TargetFrameHealthBar, unit); |
||
1029 | end |
||
1030 | |||
1031 | function TipBuddy_UnitFrame_UpdateMana( unit ) |
||
1032 | |||
1033 | local manatype = UnitPowerType(unit); |
||
1034 | local info = ManaBarColor[manatype]; |
||
1035 | |||
1036 | info = ManaBarColor[manatype]; |
||
1037 | TipBuddy_TargetFrameManaBar:SetStatusBarColor(info.r, info.g, info.b); |
||
1038 | UnitFrameManaBar_Update(TipBuddy_TargetFrameManaBar, unit); |
||
1039 | end |
||
1040 | |||
1041 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1042 | -- HEALTH TEXT |
||
1043 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1044 | function TipBuddy_UpdateHealthText( frame, type, unit ) |
||
1045 | if (not type) then |
||
1046 | if (frame) then |
||
1047 | frame:Hide(); |
||
1048 | end |
||
1049 | return; |
||
1050 | elseif (not frame) then |
||
1051 | return |
||
1052 | elseif (not TipBuddy_SavedVars[type] or not TipBuddy_SavedVars[type].txt_hth or TipBuddy_SavedVars[type].txt_hth == 0) then |
||
1053 | TipBuddy_SavedVars[type].txt_hth = 0; |
||
1054 | frame:Hide(); |
||
1055 | return; |
||
1056 | end |
||
1057 | --/script DEFAULT_CHAT_FRAME:AddMessage(UnitInParty("target")); |
||
1058 | --TipBuddy_HealthTextGTT, TipBuddy_UpdateHealthTextGTT( TipBuddy_HealthTextGTT, unit ) |
||
1059 | --TipBuddy_HealthText |
||
1060 | local health = UnitHealth(unit); |
||
1061 | --local percent = tonumber(format("%.0f", ( (health / UnitHealthMax(unit)) * 100 ) )); |
||
1062 | local text = getglobal(frame:GetName().."Text"); |
||
1063 | TB_AddMessage("health of: "..unit); |
||
1064 | if ( unit == "player" or UnitInParty(unit) or UnitInRaid(unit) ) then |
||
1065 | text:SetText( health.." / "..UnitHealthMax(unit) ); |
||
1066 | elseif ( type == "pet_friend" and UnitName("mouseover") == UnitName("pet") ) then |
||
1067 | text:SetText( health.." / "..UnitHealthMax(unit) ); |
||
1068 | --/script DEFAULT_CHAT_FRAME:AddMessage(UnitName("partypet1")); |
||
1069 | else |
||
1070 | if (MobHealthDB) then |
||
1071 | local ppp = MobHealth_PPP(UnitName(unit)..":"..UnitLevel(unit)); |
||
1072 | local curHP = math.floor(health * ppp + 0.5); |
||
1073 | local maxHP = math.floor(100 * ppp + 0.5); |
||
1074 | |||
1075 | if (curHP and maxHP and maxHP ~= 0) then |
||
1076 | text:SetText( curHP.." / "..maxHP ); |
||
1077 | ------TB_AddMessage(curHP.." / "..maxHP); |
||
1078 | else |
||
1079 | text:SetText( health.."%" ); |
||
1080 | end |
||
1081 | else |
||
1082 | text:SetText( health.."%" ); |
||
1083 | end |
||
1084 | end |
||
1085 | frame:Show(); |
||
1086 | end |
||
1087 | |||
1088 | function TipBuddy_UpdateManaText( frame, type, unit ) |
||
1089 | if (not frame or not unit or TipBuddy_SavedVars[type].txt_mna == 0) then |
||
1090 | return; |
||
1091 | end |
||
1092 | frame:Hide(); |
||
1093 | --local percent = (UnitMana(unit) / UnitManaMax(unit)) * 100; |
||
1094 | --local mana = UnitMana(unit); |
||
1095 | local text = getglobal(frame:GetName().."Text"); |
||
1096 | if (UnitMana(unit) and UnitMana(unit) > 0) then |
||
1097 | frame:Show(); |
||
1098 | text:SetText( UnitMana(unit).." / "..UnitManaMax(unit) ); |
||
1099 | end |
||
1100 | end |
||
1101 | |||
1102 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1103 | -- GET/SHOW BUFFS |
||
1104 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1105 | function TipBuddy_TargetBuffs_Initialize() |
||
1106 | local frame, bframe; |
||
1107 | for i=1, 8 do |
||
1108 | frame = "TipBuddy_BuffFrame"; |
||
1109 | bframe = getglobal(frame.."B"..i); |
||
1110 | bframe:Hide(); |
||
1111 | bframe = getglobal(frame.."D"..i); |
||
1112 | bframe:Hide(); |
||
1113 | frame = "TipBuddy_BuffFrameGTT"; |
||
1114 | bframe = getglobal(frame.."B"..i); |
||
1115 | bframe:Hide(); |
||
1116 | bframe = getglobal(frame.."D"..i); |
||
1117 | bframe:Hide(); |
||
1118 | end |
||
1119 | end |
||
1120 | |||
1121 | function TipBuddy_TargetBuffs_Update( type, unit ) |
||
1122 | if (not unit or not type) then |
||
1123 | TipBuddy_TargetBuffs_Initialize(type, unit); |
||
1124 | return; |
||
1125 | end |
||
1126 | local debuff, buff; |
||
1127 | local frame, bframe; |
||
1128 | local targettype = TipBuddy_SavedVars[type]; |
||
1129 | if ( TipBuddy_SavedVars["general"].blizdefault == 1 or targettype.off ~= 1 ) then |
||
1130 | frame = "TipBuddy_BuffFrameGTT"; |
||
1131 | else |
||
1132 | frame = "TipBuddy_BuffFrame"; |
||
1133 | end |
||
1134 | for i=1, 8 do |
||
1135 | buff = UnitBuff(unit, i); |
||
1136 | bframe = getglobal(frame.."B"..i); |
||
1137 | if ( buff ) then |
||
1138 | --/script ----TB_AddMessage(UnitCreatureFamily("mouseover")); |
||
1139 | ----TB_AddMessage(buff); |
||
1140 | if ( targettype.bff == 1 ) then |
||
1141 | getglobal(frame.."B"..i.."Icon"):SetTexture(buff); |
||
1142 | bframe:Show(); |
||
1143 | bframe.id = i; |
||
1144 | --TB_AddMessage(buff); |
||
1145 | else |
||
1146 | bframe:Hide(); |
||
1147 | end |
||
1148 | else |
||
1149 | bframe:Hide(); |
||
1150 | end |
||
1151 | end |
||
1152 | for i=1, 8 do |
||
1153 | debuff = UnitDebuff(unit, i); |
||
1154 | bframe = getglobal(frame.."D"..i); |
||
1155 | if ( debuff ) then |
||
1156 | if ( targettype.bff == 1 ) then |
||
1157 | getglobal(frame.."D"..i.."Icon"):SetTexture(debuff); |
||
1158 | bframe:Show(); |
||
1159 | else |
||
1160 | bframe:Hide(); |
||
1161 | end |
||
1162 | else |
||
1163 | bframe:Hide(); |
||
1164 | end |
||
1165 | bframe.id = i; |
||
1166 | end |
||
1167 | end |
||
1168 | |||
1169 | |||
1170 | function TipBuddy_ShowRank( type, unit ) |
||
1171 | ------TB_AddMessage("TipBuddy_ShowRank"); |
||
1172 | TipBuddy_RankFrameGTT:Hide(); |
||
1173 | TipBuddy_RankFrame:Hide(); |
||
1174 | |||
1175 | if (not type or not unit or ( TipBuddy_SavedVars[type].rnk == 0 )) then |
||
1176 | ------TB_AddMessage("no type or unit"); |
||
1177 | return; |
||
1178 | end |
||
1179 | |||
1180 | local rankName, rankNumber = GetPVPRankInfo(UnitPVPRank(unit)); |
||
1181 | local rankFrame, srankFrame; |
||
1182 | |||
1183 | if ( TipBuddy_SavedVars[type].off == 1 ) then |
||
1184 | rankFrame = getglobal("TipBuddy_RankFrame"); |
||
1185 | srankFrame = "TipBuddy_RankFrame"; |
||
1186 | else |
||
1187 | rankFrame = getglobal("TipBuddy_RankFrameGTT"); |
||
1188 | srankFrame = "TipBuddy_RankFrameGTT"; |
||
1189 | end |
||
1190 | local rankFrameIcon = getglobal(srankFrame.."Icon"); |
||
1191 | |||
1192 | -- /script DEFAULT_CHAT_FRAME:AddMessage(UnitPVPRank("target")); |
||
1193 | if (not UnitPlayerControlled(unit) or rankNumber == 0) then |
||
1194 | rankFrame:Hide(); |
||
1195 | return; |
||
1196 | end |
||
1197 | -- Set icon |
||
1198 | if ( rankNumber > 0 ) then |
||
1199 | rankFrameIcon:SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber)); |
||
1200 | rankFrame:Show(); |
||
1201 | else |
||
1202 | rankFrame:Hide(); |
||
1203 | end |
||
1204 | end |
||
1205 | |||
1206 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1207 | -- GET/SHOW FACTION |
||
1208 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1209 | function TipBuddy_TargetInfo_ShowFaction( type, unit ) |
||
1210 | TipBuddy_FactionFrameGTT:Hide(); |
||
1211 | TipBuddy_FactionFrame:Hide(); |
||
1212 | if (not unit) then |
||
1213 | return; |
||
1214 | end |
||
1215 | |||
1216 | local factionGroup = UnitFactionGroup(unit); |
||
1217 | if (not factionGroup) then |
||
1218 | return; |
||
1219 | end |
||
1220 | |||
1221 | local frame, sframe; |
||
1222 | if ( TipBuddy_SavedVars[TipBuddy.targetType].off == 1 ) then |
||
1223 | frame = getglobal("TipBuddy_FactionFrame"); |
||
1224 | sframe = "TipBuddy_FactionFrame"; |
||
1225 | else |
||
1226 | frame = getglobal("TipBuddy_FactionFrameGTT"); |
||
1227 | sframe = "TipBuddy_FactionFrameGTT"; |
||
1228 | end |
||
1229 | local frameIcon = getglobal(sframe.."Icon"); |
||
1230 | local frameText = getglobal(sframe.."Text"); |
||
1231 | --how in the world does this happen? |
||
1232 | |||
1233 | if ( UnitIsPVPFreeForAll(unit) ) then |
||
1234 | frameIcon:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA"); |
||
1235 | frame:Show(); |
||
1236 | if (TipBuddy_SavedVars[TipBuddy.targetType].txt_pvp == 1) then |
||
1237 | frameIcon:Hide(); |
||
1238 | frameText:Show(); |
||
1239 | frameText:SetText("FFA"); |
||
1240 | else |
||
1241 | frameIcon:Show(); |
||
1242 | frameText:Hide(); |
||
1243 | end |
||
1244 | elseif ( UnitIsPVP(unit) ) then |
||
1245 | ------TB_AddMessage("txt_pvp = "..TipBuddy_SavedVars[TipBuddy.targetType].txt_pvp); |
||
1246 | frameIcon:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..factionGroup); |
||
1247 | frame:Show(); |
||
1248 | if (TipBuddy_SavedVars[TipBuddy.targetType].txt_pvp == 1) then |
||
1249 | frameIcon:Hide(); |
||
1250 | frameText:Show(); |
||
1251 | frameText:SetText("PvP"); |
||
1252 | else |
||
1253 | frameIcon:Show(); |
||
1254 | frameText:Hide(); |
||
1255 | end |
||
1256 | else |
||
1257 | frame:Hide(); |
||
1258 | end |
||
1259 | end |
||
1260 | |||
1261 | function TipBuddy_SetFrame_TargetType( type, unit, refresh ) |
||
1262 | |||
1263 | if (TipBuddy_SavedVars.debug == 1 and TipBuddy.uName) then |
||
1264 | ------TB_AddMessage(TipBuddy.uName.." == TT: "..GameTooltipTextLeft1:GetText()); |
||
1265 | end |
||
1266 | |||
1267 | local targettype = TipBuddy_SavedVars[type]; |
||
1268 | if (TipBuddy_SavedVars["general"].blizdefault ~= 1) then |
||
1269 | if (refresh) then |
||
1270 | ------TB_AddMessage("!! lastline: "..TipBuddy.gtt_lastline..", numlines (stored): "..TipBuddy.gtt_numlines..", numlines (real): "..GameTooltip:NumLines()); |
||
1271 | TipBuddy.refresh = 1; |
||
1272 | ----TB_AddMessage("!! REFRESH"); |
||
1273 | else |
||
1274 | ----TB_AddMessage("!! CLEARING ALL DATA"); |
||
1275 | TipBuddy.refresh = nil; |
||
1276 | TipBuddy.gtt_numlines = GameTooltip:NumLines(); |
||
1277 | TipBuddy.gtt_lastline = 1; |
||
1278 | TipBuddy.gtt_xtra = nil; |
||
1279 | TipBuddy.gtt_name = ""; |
||
1280 | TipBuddy.gtt_target = ""; |
||
1281 | TipBuddy.gtt_guild = ""; |
||
1282 | TipBuddy.gtt_level = ""; |
||
1283 | TipBuddy.gtt_race = ""; |
||
1284 | TipBuddy.gtt_class = ""; |
||
1285 | TipBuddy.gtt_cityfac = ""; |
||
1286 | end |
||
1287 | |||
1288 | if (not TipBuddy.gtt_numlines) then |
||
1289 | TipBuddy.gtt_numlines = 0; |
||
1290 | end |
||
1291 | |||
1292 | TipBuddy_TargetInfo_CheckName( type, unit ); |
||
1293 | TipBuddy_TargetInfo_TargetsTarget( type, unit ); |
||
1294 | TipBuddy_TargetInfo_GetGuild( type, unit ); |
||
1295 | TipBuddy_TargetInfo_GetClass( type, unit ); |
||
1296 | TipBuddy_TargetInfo_GetLevel( type, unit ); |
||
1297 | if (TipBuddy.refresh ~= 1) then |
||
1298 | TipBuddy_TargetInfo_ShowCityFaction( type, unit ); |
||
1299 | TipBuddy_ConfirmLastLine(unit); |
||
1300 | if ( targettype.off ~= 1 ) then |
||
1301 | TipBuddy_GTT_GetExtraLines(TipBuddy.gtt_numlines); |
||
1302 | end |
||
1303 | end |
||
1304 | end |
||
1305 | |||
1306 | if ( targettype.off == 1 ) then |
||
1307 | if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
1308 | TipBuddy_ClearFade(TipBuddyTooltip, 1); |
||
1309 | TipBuddyTooltip:SetUnit(unit); |
||
1310 | TipBuddy_GTT_AddExtras(); |
||
1311 | TipBuddyTooltip:Show(); |
||
1312 | else |
||
1313 | TipBuddy_TargetName_Text:SetText(TipBuddy.gtt_namecolor..TipBuddy.gtt_name..TipBuddy.gtt_target); |
||
1314 | TipBuddy_TargetName_Text:Show(); |
||
1315 | |||
1316 | if ( targettype.gld == 1 ) then |
||
1317 | if (TipBuddy.gtt_guildcolor and TipBuddy.gtt_guild and TipBuddy.gtt_guild ~= "" ) then |
||
1318 | ----TB_AddMessage(TB_RED_TXT.."Guild text = "..TB_YLW_TXT..TipBuddy.gtt_guild); |
||
1319 | TipBuddy_TargetGuild_Text:SetText(TipBuddy.gtt_guildcolor.."<"..TipBuddy.gtt_guild..TipBuddy.gtt_guildcolor..">"); |
||
1320 | TipBuddy_TargetGuild_Text:Show(); |
||
1321 | else |
||
1322 | TipBuddy_TargetGuild_Text:Hide(); |
||
1323 | end |
||
1324 | else |
||
1325 | TipBuddy_TargetGuild_Text:Hide(); |
||
1326 | end |
||
1327 | if ( targettype.hth == 1 ) then |
||
1328 | TipBuddy_TargetFrameHealthBar:Show(); |
||
1329 | ------TB_AddMessage(unit); |
||
1330 | if (UnitMana( unit ) > 0) then |
||
1331 | TipBuddy_TargetFrameManaBar:Show(); |
||
1332 | else |
||
1333 | TipBuddy_TargetFrameManaBar:Hide(); |
||
1334 | end |
||
1335 | TipBuddy_UnitFrame_UpdateHealth( unit ); |
||
1336 | TipBuddy_UnitFrame_UpdateMana( unit ); |
||
1337 | TipBuddy_UpdateHealthText( TipBuddy_HealthText, type, unit ); |
||
1338 | TipBuddy_UpdateManaText( TipBuddy_ManaText, type, unit ); |
||
1339 | else |
||
1340 | TipBuddy_TargetFrameHealthBar:Hide(); |
||
1341 | TipBuddy_TargetFrameManaBar:Hide(); |
||
1342 | end |
||
1343 | if ( targettype.cfc == 1 and TipBuddy.gtt_cityfac ~= "" ) then |
||
1344 | TipBuddy_TargetCityFac_Text:SetText(tbcolor_cityfac..TipBuddy.gtt_cityfac); |
||
1345 | TipBuddy_TargetCityFac_Text:Show(); |
||
1346 | else |
||
1347 | TipBuddy_TargetCityFac_Text:Hide(); |
||
1348 | end |
||
1349 | if ( targettype.cls == 1 ) then |
||
1350 | if (TipBuddy.gtt_class == "" and TipBuddy.gtt_level == "") then |
||
1351 | TipBuddy_TargetClass_Text:Hide(); |
||
1352 | TipBuddy_TargetLevel_Text:Hide(); |
||
1353 | elseif (TipBuddy.gtt_class and TipBuddy.gtt_class ~= "" ) then |
||
1354 | TipBuddy_TargetClass_Text:SetText(TipBuddy.gtt_race..TipBuddy.gtt_classcolor..TipBuddy.gtt_classlvlcolor..TipBuddy.gtt_class..TipBuddy.gtt_classcorpse); |
||
1355 | TipBuddy_TargetClass_Text:Show(); |
||
1356 | else |
||
1357 | TipBuddy_TargetClass_Text:Hide(); |
||
1358 | TipBuddy_TargetLevel_Text:Hide(); |
||
1359 | end |
||
1360 | |||
1361 | TipBuddy_TargetLevel_Text:Show(); |
||
1362 | else |
||
1363 | TipBuddy_TargetClass_Text:Hide(); |
||
1364 | TipBuddy_TargetLevel_Text:Hide(); |
||
1365 | end |
||
1366 | TipBuddy_TargetInfo_FindExtras( unit ); |
||
1367 | |||
1368 | TipBuddy_FrameHeights_Initialize(type); |
||
1369 | TipBuddy_SetFrame_Width(); |
||
1370 | end |
||
1371 | else |
||
1372 | --TB_AddMessage(getglobal("TipBuddyTooltipTextLeft1"):GetText()); |
||
1373 | TipBuddy_ClearFade(TipBuddyTooltip, 1); |
||
1374 | TipBuddyTooltip:SetUnit(unit); |
||
1375 | ----TB_AddMessage("setunit show: ("..TipBuddyTooltip:GetTop()..")"); |
||
1376 | |||
1377 | --/script TipBuddy_SavedVars.npc_friend.off = 2 |
||
1378 | if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
1379 | |||
1380 | elseif (targettype.off == 2) then |
||
1381 | GameTooltip.variables1 = {}; |
||
1382 | GameTooltip.variables2 = {}; |
||
1383 | if (not targettype.ebx1) then |
||
1384 | targettype.ebx1 = ""; |
||
1385 | end |
||
1386 | if (not targettype.ebx2) then |
||
1387 | targettype.ebx2 = ""; |
||
1388 | end |
||
1389 | local ebtext1 = targettype.ebx1; |
||
1390 | local ebtext2 = targettype.ebx2; |
||
1391 | for variable, value in TB_VARIABLE_FUNCTIONS do |
||
1392 | if (string.find(ebtext1, variable)) then |
||
1393 | GameTooltip.variables1[variable] = true; |
||
1394 | end |
||
1395 | if (string.find(ebtext2, variable)) then |
||
1396 | GameTooltip.variables2[variable] = true; |
||
1397 | end |
||
1398 | end |
||
1399 | |||
1400 | local maxchar = 256; |
||
1401 | TipBuddyTooltipTextLeft1:SetTextColor(1, 1, 1); |
||
1402 | if ((not ebtext1) or ebtext1 == "") then |
||
1403 | TipBuddyTooltip:SetText(" "); |
||
1404 | --TipBuddyTooltipTextLeft1:Show(); |
||
1405 | else |
||
1406 | for var in GameTooltip.variables1 do |
||
1407 | ebtext1 = TB_VARIABLE_FUNCTIONS[var].func(ebtext1, unit); |
||
1408 | end |
||
1409 | if (maxchar and string.len(ebtext1) > maxchar) then |
||
1410 | ebtext1 = string.sub(ebtext1, 1, maxchar); |
||
1411 | end |
||
1412 | TipBuddyTooltip:SetText(ebtext1); |
||
1413 | --TipBuddyTooltipTextLeft1:Show(); |
||
1414 | end |
||
1415 | |||
1416 | maxchar = 2048; |
||
1417 | if ((not ebtext2) or ebtext2 == "") then |
||
1418 | --TipBuddyTooltipTextLeft2:SetText(" "); |
||
1419 | --TipBuddyTooltipTextLeft1:Show(); |
||
1420 | else |
||
1421 | for var in GameTooltip.variables2 do |
||
1422 | ebtext2 = TB_VARIABLE_FUNCTIONS[var].func(ebtext2, unit); |
||
1423 | end |
||
1424 | if (maxchar and string.len(ebtext2) > maxchar) then |
||
1425 | ebtext2 = string.sub(ebtext2, 1, maxchar); |
||
1426 | end |
||
1427 | |||
1428 | --strip out the empty lines |
||
1429 | ebtext2 = string.gsub(ebtext2, "|r\n|r\n", "|r\n"); |
||
1430 | ebtext2 = string.gsub(ebtext2, "^|r\n", ""); |
||
1431 | |||
1432 | TipBuddyTooltip:AddLine(ebtext2); |
||
1433 | TipBuddyTooltipTextLeft2:SetTextColor(1, 1, 1); |
||
1434 | end |
||
1435 | else |
||
1436 | |||
1437 | TipBuddyTooltip:SetText(TipBuddy.gtt_namecolor..TipBuddy.gtt_name..TipBuddy.gtt_target); |
||
1438 | |||
1439 | if ( targettype.gld == 1 and TipBuddy.gtt_guild and TipBuddy.gtt_guild ~= "" ) then |
||
1440 | if (TipBuddy.gtt_guild ~= nil) then |
||
1441 | TipBuddyTooltip:AddLine(TipBuddy.gtt_guildcolor.."<"..TipBuddy.gtt_guild..TipBuddy.gtt_guildcolor..">".."|r"); |
||
1442 | end |
||
1443 | end |
||
1444 | if ( targettype.cls == 1 ) then |
||
1445 | if (TipBuddy.gtt_class == nil) then |
||
1446 | TipBuddy.gtt_class = ""; |
||
1447 | end |
||
1448 | if (TipBuddy.gtt_class == "" and TipBuddy.gtt_level == "") then |
||
1449 | |||
1450 | else |
||
1451 | TipBuddyTooltip:AddLine(TipBuddy.gtt_level.."|r "..TipBuddy.gtt_race..TipBuddy.gtt_classcolor..TipBuddy.gtt_classlvlcolor..TipBuddy.gtt_class..TipBuddy.gtt_classcorpse.."|r"); |
||
1452 | end |
||
1453 | end |
||
1454 | if ( targettype.cfc == 1 and TipBuddy.gtt_cityfac ~= "" ) then |
||
1455 | TipBuddyTooltip:AddLine(TipBuddy.gtt_cityfac.."|r"); |
||
1456 | end |
||
1457 | end |
||
1458 | |||
1459 | TipBuddy_GTT_AddExtras(); |
||
1460 | |||
1461 | if ( targettype.hth == 1 ) then |
||
1462 | TipBuddyTooltipStatusBar:Show(); |
||
1463 | else |
||
1464 | TipBuddyTooltipStatusBar:Hide(); |
||
1465 | end |
||
1466 | |||
1467 | TipBuddyTooltip:Show(); |
||
1468 | TipBuddy_UpdateHealthText( TipBuddy_HealthTextGTT, type, unit ); |
||
1469 | end |
||
1470 | if ( targettype.fac == 1 ) then |
||
1471 | TipBuddy_TargetInfo_ShowFaction( type, unit ); |
||
1472 | else |
||
1473 | TipBuddy_FactionFrameGTT:Hide(); |
||
1474 | TipBuddy_FactionFrame:Hide(); |
||
1475 | end |
||
1476 | end |
||
1477 | |||
1478 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1479 | -- SET BACKGROUND COLOR |
||
1480 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1481 | function TipBuddy_SetFrame_BackgroundColor( type, unit ) |
||
1482 | --TB_AddMessage(TB_WHT_TXT.."Background Color"); |
||
1483 | if (not unit or not type) then |
||
1484 | TipBuddy_SetFrame_NonUnit_BackgroundColor( type ); |
||
1485 | ------TB_AddMessage("NO UNIT OR TYPE - SETTING BG"); |
||
1486 | return; |
||
1487 | end |
||
1488 | local targettype = TipBuddy_SavedVars[type]; |
||
1489 | local r, br, g, bg, b, bb, a, ba; |
||
1490 | |||
1491 | if (not targettype.c_bdp) then |
||
1492 | targettype.c_bdp = 0; |
||
1493 | end |
||
1494 | if (not targettype.c_bdb) then |
||
1495 | targettype.c_bdb = 0; |
||
1496 | end |
||
1497 | |||
1498 | ----TB_AddMessage("bdp = "..targettype.c_bdp); |
||
1499 | if (GetGuildInfo("player") and GetGuildInfo(unit) == GetGuildInfo("player")) then |
||
1500 | type = "guild"; |
||
1501 | targettype = TipBuddy_SavedVars[type]; |
||
1502 | r, g, b, a = targettype.bgcolor.r, targettype.bgcolor.g, targettype.bgcolor.b, targettype.bgcolor.a; |
||
1503 | ----TB_AddMessage("setting BG color to Guild"); |
||
1504 | elseif (targettype.c_bdp and targettype.c_bdp == 1) then |
||
1505 | --[[ |
||
1506 | tbcolor_lvl_impossible = TipBuddy_RGBToHexColor(colors.lvl_imp.r, colors.lvl_imp.g, colors.lvl_imp.b); |
||
1507 | tbcolor_lvl_verydifficult = TipBuddy_RGBToHexColor(colors.lvl_vdf.r, colors.lvl_vdf.g, colors.lvl_vdf.b); |
||
1508 | tbcolor_lvl_difficult = TipBuddy_RGBToHexColor(colors.lvl_dif.r, colors.lvl_dif.g, colors.lvl_dif.b); |
||
1509 | tbcolor_lvl_standard = TipBuddy_RGBToHexColor(colors.lvl_stn.r, colors.lvl_stn.g, colors.lvl_stn.b); |
||
1510 | tbcolor_lvl_trivial = TipBuddy_RGBToHexColor(colors.lvl_trv.r, colors.lvl_trv.g, colors.lvl_trv.b); |
||
1511 | ]] |
||
1512 | local levelDiff = UnitLevel(unit) - UnitLevel("player"); |
||
1513 | local colors = TipBuddy_SavedVars["textcolors"]; |
||
1514 | if ( levelDiff >= 5 ) then |
||
1515 | r, g, b = colors.lvl_imp.r, colors.lvl_imp.g, colors.lvl_imp.b; |
||
1516 | elseif ( levelDiff >= 3 ) then |
||
1517 | r, g, b = colors.lvl_vdf.r, colors.lvl_vdf.g, colors.lvl_vdf.b; |
||
1518 | elseif ( levelDiff >= -2 ) then |
||
1519 | r, g, b = colors.lvl_dif.r, colors.lvl_dif.g, colors.lvl_dif.b; |
||
1520 | elseif ( -levelDiff <= GetQuestGreenRange() ) then |
||
1521 | r, g, b = colors.lvl_stn.r, colors.lvl_stn.g, colors.lvl_stn.b; |
||
1522 | else |
||
1523 | r, g, b = colors.lvl_trv.r, colors.lvl_trv.g, colors.lvl_trv.b; |
||
1524 | end |
||
1525 | r, g, b = TB_NoNegative(r - 0.35), TB_NoNegative(g - 0.35), TB_NoNegative(b - 0.35); |
||
1526 | a = targettype.bgcolor.a; |
||
1527 | elseif (targettype.c_bdp and targettype.c_bdp == 2) then |
||
1528 | local reaction = TipBuddy_GetUnitReaction( unit ); |
||
1529 | local colors = TipBuddy_SavedVars["textcolors"]; |
||
1530 | ----TB_AddMessage("reaction = "..reaction); |
||
1531 | --[[ tbcolor_nam_hostile = TipBuddy_RGBToHexColor(colors.nam_hos.r, colors.nam_hos.g, colors.nam_hos.b); |
||
1532 | tbcolor_nam_neutral = TipBuddy_RGBToHexColor(colors.nam_neu.r, colors.nam_neu.g, colors.nam_neu.b); |
||
1533 | tbcolor_nam_friendly = TipBuddy_RGBToHexColor(colors.nam_fri.r, colors.nam_fri.g, colors.nam_fri.b); |
||
1534 | tbcolor_nam_caution = TipBuddy_RGBToHexColor(colors.nam_cau.r, colors.nam_cau.g, colors.nam_cau.b); |
||
1535 | tbcolor_nam_pvp = TipBuddy_RGBToHexColor(colors.nam_pvp.r, colors.nam_pvp.g, colors.nam_pvp.b); |
||
1536 | tbcolor_nam_tappedplayer = TipBuddy_RGBToHexColor(colors.nam_tpp.r, colors.nam_tpp.g, colors.nam_tpp.b); |
||
1537 | tbcolor_nam_tappedother = TipBuddy_RGBToHexColor(colors.nam_tpo.r, colors.nam_tpo.g, colors.nam_tpo.b);]] |
||
1538 | if (reaction == "hostile") then |
||
1539 | r, g, b = colors.nam_hos.r, colors.nam_hos.g, colors.nam_hos.b; |
||
1540 | elseif (reaction == "neutral") then |
||
1541 | r, g, b = colors.nam_neu.r, colors.nam_neu.g, colors.nam_neu.b; |
||
1542 | elseif (reaction == "friendly") then |
||
1543 | r, g, b = colors.nam_fri.r, colors.nam_fri.g, colors.nam_fri.b; |
||
1544 | elseif (reaction == "caution") then |
||
1545 | r, g, b = colors.nam_cau.r, colors.nam_cau.g, colors.nam_cau.b; |
||
1546 | elseif (reaction == "pvp") then |
||
1547 | r, g, b = colors.nam_pvp.r, colors.nam_pvp.g, colors.nam_pvp.b; |
||
1548 | elseif (reaction == "tappedplayer") then |
||
1549 | r, g, b = colors.nam_tpp.r, colors.nam_tpp.g, colors.nam_tpp.b; |
||
1550 | elseif (reaction == "tappedother") then |
||
1551 | r, g, b = colors.nam_tpo.r, colors.nam_tpo.g, colors.nam_tpo.b; |
||
1552 | else |
||
1553 | r, g, b = targettype.bgcolor.r, targettype.bgcolor.g, targettype.bgcolor.b; |
||
1554 | end |
||
1555 | r, g, b = TB_NoNegative(r - 0.35), TB_NoNegative(g - 0.35), TB_NoNegative(b - 0.35); |
||
1556 | a = targettype.bgcolor.a; |
||
1557 | else |
||
1558 | r, g, b, a = targettype.bgcolor.r, targettype.bgcolor.g, targettype.bgcolor.b, targettype.bgcolor.a; |
||
1559 | ----TB_AddMessage("setting BG color to Custom"); |
||
1560 | end |
||
1561 | |||
1562 | if (targettype.c_bdb and targettype.c_bdb == 1) then |
||
1563 | --[[ |
||
1564 | tbcolor_lvl_impossible = TipBuddy_RGBToHexColor(colors.lvl_imp.r, colors.lvl_imp.g, colors.lvl_imp.b); |
||
1565 | tbcolor_lvl_verydifficult = TipBuddy_RGBToHexColor(colors.lvl_vdf.r, colors.lvl_vdf.g, colors.lvl_vdf.b); |
||
1566 | tbcolor_lvl_difficult = TipBuddy_RGBToHexColor(colors.lvl_dif.r, colors.lvl_dif.g, colors.lvl_dif.b); |
||
1567 | tbcolor_lvl_standard = TipBuddy_RGBToHexColor(colors.lvl_stn.r, colors.lvl_stn.g, colors.lvl_stn.b); |
||
1568 | tbcolor_lvl_trivial = TipBuddy_RGBToHexColor(colors.lvl_trv.r, colors.lvl_trv.g, colors.lvl_trv.b); |
||
1569 | ]] |
||
1570 | local levelDiff = UnitLevel(unit) - UnitLevel("player"); |
||
1571 | local colors = TipBuddy_SavedVars["textcolors"]; |
||
1572 | if ( levelDiff >= 5 ) then |
||
1573 | br, bg, bb = colors.lvl_imp.r, colors.lvl_imp.g, colors.lvl_imp.b; |
||
1574 | elseif ( levelDiff >= 3 ) then |
||
1575 | br, bg, bb = colors.lvl_vdf.r, colors.lvl_vdf.g, colors.lvl_vdf.b; |
||
1576 | elseif ( levelDiff >= -2 ) then |
||
1577 | br, bg, bb = colors.lvl_dif.r, colors.lvl_dif.g, colors.lvl_dif.b; |
||
1578 | elseif ( -levelDiff <= GetQuestGreenRange() ) then |
||
1579 | br, bg, bb = colors.lvl_stn.r, colors.lvl_stn.g, colors.lvl_stn.b; |
||
1580 | else |
||
1581 | br, bg, bb = colors.lvl_trv.r, colors.lvl_trv.g, colors.lvl_trv.b; |
||
1582 | end |
||
1583 | ba = targettype.bgbcolor.a; |
||
1584 | elseif (targettype.c_bdb and targettype.c_bdb == 2) then |
||
1585 | local reaction = TipBuddy_GetUnitReaction( unit ); |
||
1586 | local colors = TipBuddy_SavedVars["textcolors"]; |
||
1587 | --[[ tbcolor_nam_hostile = TipBuddy_RGBToHexColor(colors.nam_hos.r, colors.nam_hos.g, colors.nam_hos.b); |
||
1588 | tbcolor_nam_neutral = TipBuddy_RGBToHexColor(colors.nam_neu.r, colors.nam_neu.g, colors.nam_neu.b); |
||
1589 | tbcolor_nam_friendly = TipBuddy_RGBToHexColor(colors.nam_fri.r, colors.nam_fri.g, colors.nam_fri.b); |
||
1590 | tbcolor_nam_caution = TipBuddy_RGBToHexColor(colors.nam_cau.r, colors.nam_cau.g, colors.nam_cau.b); |
||
1591 | tbcolor_nam_pvp = TipBuddy_RGBToHexColor(colors.nam_pvp.r, colors.nam_pvp.g, colors.nam_pvp.b); |
||
1592 | tbcolor_nam_tappedplayer = TipBuddy_RGBToHexColor(colors.nam_tpp.r, colors.nam_tpp.g, colors.nam_tpp.b); |
||
1593 | tbcolor_nam_tappedother = TipBuddy_RGBToHexColor(colors.nam_tpo.r, colors.nam_tpo.g, colors.nam_tpo.b);]] |
||
1594 | if (reaction == "hostile") then |
||
1595 | br, bg, bb = colors.nam_hos.r, colors.nam_hos.g, colors.nam_hos.b; |
||
1596 | elseif (reaction == "neutral") then |
||
1597 | br, bg, bb = colors.nam_neu.r, colors.nam_neu.g, colors.nam_neu.b; |
||
1598 | elseif (reaction == "friendly") then |
||
1599 | br, bg, bb = colors.nam_fri.r, colors.nam_fri.g, colors.nam_fri.b; |
||
1600 | elseif (reaction == "caution") then |
||
1601 | br, bg, bb = colors.nam_cau.r, colors.nam_cau.g, colors.nam_cau.b; |
||
1602 | elseif (reaction == "pvp") then |
||
1603 | br, bg, bb = colors.nam_pvp.r, colors.nam_pvp.g, colors.nam_pvp.b; |
||
1604 | elseif (reaction == "tappedplayer") then |
||
1605 | br, bg, bb = colors.nam_tpp.r, colors.nam_tpp.g, colors.nam_tpp.b; |
||
1606 | elseif (reaction == "tappedother") then |
||
1607 | br, bg, bb = colors.nam_tpo.r, colors.nam_tpo.g, colors.nam_tpo.b; |
||
1608 | else |
||
1609 | br, bg, bb = targettype.bgcolor.r, targettype.bgcolor.g, targettype.bgcolor.b; |
||
1610 | end |
||
1611 | ba = targettype.bgbcolor.a; |
||
1612 | else |
||
1613 | targettype = TipBuddy_SavedVars[type]; |
||
1614 | if (not targettype.bgbcolor) then |
||
1615 | targettype.bgbcolor = {}; |
||
1616 | targettype.bgbcolor.r = 0.8; |
||
1617 | targettype.bgbcolor.g = 0.8; |
||
1618 | targettype.bgbcolor.b = 0.9; |
||
1619 | targettype.bgbcolor.a = 1; |
||
1620 | end |
||
1621 | br, bg, bb, ba = targettype.bgbcolor.r, targettype.bgbcolor.g, targettype.bgbcolor.b, targettype.bgbcolor.a; |
||
1622 | end |
||
1623 | |||
1624 | --if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
1625 | -- GameTooltip:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 1); |
||
1626 | -- GameTooltip:SetBackdropBorderColor(0.8, 0.8, 0.9, 1); |
||
1627 | if (TipBuddy.compactvis) then |
||
1628 | TipBuddy_Main_Frame:SetBackdropColor( r, g, b, a ); |
||
1629 | TipBuddy_Main_Frame:SetBackdropBorderColor( 0, 0, 0, 0.9 ); |
||
1630 | else |
||
1631 | TipBuddyTooltip:SetBackdropColor( r, g, b, a ); |
||
1632 | --/script GameTooltip:SetBackdropBorderColor( 1, 1, 1, 1 ); |
||
1633 | TipBuddyTooltip:SetBackdropBorderColor( br, bg, bb, ba ); |
||
1634 | end |
||
1635 | if (TipBuddy_SavedVars["general"].blizdefault == 1) then |
||
1636 | TipBuddyTooltipTextLeft1:SetTextColor(GameTooltip_UnitColor(unit)); |
||
1637 | end |
||
1638 | ----TB_AddMessage(r.." - "..g.." - "..b.." - "..a); |
||
1639 | end |
||
1640 | |||
1641 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1642 | -- SET NON-UNIT BACKGROUND COLOR |
||
1643 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1644 | function TipBuddy_SetFrame_NonUnit_BackgroundColor( type ) |
||
1645 | if (not type) then |
||
1646 | type = "general"; |
||
1647 | end |
||
1648 | local targettype = TipBuddy_SavedVars[type]; |
||
1649 | if (not targettype.bgcolor) then |
||
1650 | targettype.bgcolor = {}; |
||
1651 | targettype.bgcolor.r = 0.1; |
||
1652 | targettype.bgcolor.g = 0.1; |
||
1653 | targettype.bgcolor.b = 0.1; |
||
1654 | targettype.bgcolor.a = 0.78; |
||
1655 | end |
||
1656 | if (not targettype.bgbcolor) then |
||
1657 | targettype.bgbcolor = {}; |
||
1658 | targettype.bgbcolor.r = 0.8; |
||
1659 | targettype.bgbcolor.g = 0.8; |
||
1660 | targettype.bgbcolor.b = 0.9; |
||
1661 | targettype.bgbcolor.a = 1; |
||
1662 | end |
||
1663 | |||
1664 | --TB_AddMessage("NU: "..targettype.bgcolor.r.." - "..targettype.bgcolor.g.." - "..targettype.bgcolor.b.." - "..targettype.bgcolor.a); |
||
1665 | GameTooltip:SetBackdropColor( targettype.bgcolor.r, targettype.bgcolor.g, targettype.bgcolor.b, targettype.bgcolor.a ); |
||
1666 | GameTooltip:SetBackdropBorderColor( targettype.bgbcolor.r, targettype.bgbcolor.g, targettype.bgbcolor.b, targettype.bgbcolor.a ); |
||
1667 | end |
||
1668 | |||
1669 | |||
1670 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1671 | -- PARENT ON UPDATE |
||
1672 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1673 | function TipBuddy_ParentTip_OnUpdate() |
||
1674 | --if (TipBuddy_Main_Frame:IsVisible() or GameTooltip:IsVisible()) then |
||
1675 | this:ClearAllPoints(); |
||
1676 | |||
1677 | local x, y = TipBuddy_PositionFrameToCursor(); |
||
1678 | |||
1679 | if (not TipBuddy.xpoint or not TipBuddy.xpos or not TipBuddy.anchor or not TipBuddy.fanchor) then |
||
1680 | TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset(); |
||
1681 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
1682 | end |
||
1683 | |||
1684 | if ( UnitExists("mouseover") or TipBuddy.anchorparent == "UIParent") then |
||
1685 | if (TipBuddy_SavedVars["general"].anchored == 1) then |
||
1686 | this:SetPoint(TipBuddy.anchor, "TipBuddy_Header_Frame", TipBuddy.fanchor, 0, 0); |
||
1687 | else |
||
1688 | this:SetPoint(TipBuddy.xpoint, "UIParent", "BOTTOMLEFT", x, y); |
||
1689 | end |
||
1690 | else |
||
1691 | if (TipBuddy_SavedVars["general"].nonunit_anchor == 0) then |
||
1692 | this:SetPoint(TipBuddy.xpoint, "UIParent", "BOTTOMLEFT", x, y); |
||
1693 | elseif (TipBuddy_SavedVars["general"].nonunit_anchor == 1) then |
||
1694 | this:SetPoint(TipBuddy.anchor, "TipBuddy_Header_Frame", TipBuddy.fanchor, 0, 0); |
||
1695 | else |
||
1696 | this:SetPoint(TipBuddy.xpoint, "UIParent", "BOTTOMLEFT", x, y); |
||
1697 | end |
||
1698 | --/script TipBuddyTooltipx:SetOwner(TipBuddy_Parent_Frame, "ANCHOR_RIGHT"); TipBuddyTooltipx:SetUnit("player"); |
||
1699 | end |
||
1700 | |||
1701 | if ( UnitExists("mouseover") or TipBuddy.unitframe == 1) then |
||
1702 | if (TipBuddy.hasTarget and TipBuddy.hasTarget == 1) then |
||
1703 | --TB_AddMessage(TB_WHT_TXT.."ParentTip_OnUpdate"); |
||
1704 | GameTooltip:SetAlpha(0); |
||
1705 | end |
||
1706 | elseif (TipBuddy.hasTarget == 1) then |
||
1707 | local text1 = getglobal("GameTooltipTextLeft1"):GetText(); |
||
1708 | --TB_AddMessage(tbcolor_nam_hostile..TipBuddy.uName.." - "..getglobal("GameTooltipTextLeft1"):GetText()); |
||
1709 | if (text1 == nil or TipBuddy.gtt_name == nil or string.find(text1, TipBuddy_FixMagicChars(TipBuddy.gtt_name))) then |
||
1710 | GameTooltip:Hide(); |
||
1711 | ------TB_AddMessage(TEXT(text1).." - "..TEXT(TipBuddy.gtt_name)); |
||
1712 | if (TipBuddy_SavedVars["general"].gtt_fade == 1) then |
||
1713 | --TipBuddyTooltip:FadeOut(); |
||
1714 | ----TB_AddMessage("fading tt"); |
||
1715 | |||
1716 | TipBuddy_Hide( TipBuddyTooltip ); |
||
1717 | else |
||
1718 | TipBuddy_ForceHide( TipBuddyTooltip ); |
||
1719 | --TB_AddMessage("hiding tt"); |
||
1720 | end |
||
1721 | end |
||
1722 | --/script GameTooltipTextLeft1:SetTextColor(GameTooltip_UnitColor("mouseover")); |
||
1723 | if (TipBuddy_Main_Frame:IsVisible()) then |
||
1724 | TipBuddy_Hide( TipBuddy_Main_Frame ); |
||
1725 | end |
||
1726 | |||
1727 | TipBuddy.hasTarget = 0; |
||
1728 | --TB_AddMessage("TipBuddy.hasTarget = 0"); |
||
1729 | TipBuddy.uName = nil; |
||
1730 | TipBuddy.vis = nil; |
||
1731 | end |
||
1732 | |||
1733 | if (not TipBuddy.first) then |
||
1734 | GameTooltip.default = nil; |
||
1735 | TipBuddy.first = 1; |
||
1736 | --TB_AddMessage("first time: ("..TipBuddyTooltip:GetTop()..")"); |
||
1737 | end |
||
1738 | end |
||
1739 | |||
1740 | function TipBuddyTooltip_OnUpdate() |
||
1741 | if ( this.fadingout ) then |
||
1742 | if ( this:GetAlpha() <= 0 ) then |
||
1743 | TipBuddy_FadeOut_Finished(this); |
||
1744 | end |
||
1745 | elseif ( this.fadingin ) then |
||
1746 | if ( this:GetAlpha() >= 1 ) then |
||
1747 | TipBuddy_FadeIn_Finished(this); |
||
1748 | end |
||
1749 | end |
||
1750 | if (this:IsVisible()) then |
||
1751 | if ((TipBuddy.hasTarget ~= 1) and (not this.fadingout)) then |
||
1752 | |||
1753 | if (not this.startTime or not this.endTime) then |
||
1754 | TipBuddy_ForceHide( this ); |
||
1755 | return; |
||
1756 | end |
||
1757 | GameTooltip:SetAlpha(0); |
||
1758 | local fraction = (GetTime() - this.startTime) / (this.endTime - this.startTime); |
||
1759 | if ( fraction >= 1.0 ) then |
||
1760 | TipBuddy_FadeOut( this ); |
||
1761 | end |
||
1762 | end |
||
1763 | end |
||
1764 | end |
||
1765 | |||
1766 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1767 | -- MAIN ON UPDATE |
||
1768 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1769 | function TipBuddy_MainTip_OnUpdate() |
||
1770 | --/script TipBuddy_SavedVars["general"].cursorpos = 1; |
||
1771 | --/script TipBuddy_SavedVars["general"].cursorpos = 0; |
||
1772 | |||
1773 | if ( this.fadingout ) then |
||
1774 | if ( this:GetAlpha() <= 0 ) then |
||
1775 | TipBuddy_FadeOut_Finished(this); |
||
1776 | end |
||
1777 | elseif ( this.fadingin ) then |
||
1778 | if ( this:GetAlpha() >= 1 ) then |
||
1779 | TipBuddy_FadeIn_Finished(this); |
||
1780 | end |
||
1781 | end |
||
1782 | if (this:IsVisible()) then |
||
1783 | if ((TipBuddy.hasTarget ~= 1) and (not this.fadingout)) then |
||
1784 | TipBuddy.compactvis = nil; |
||
1785 | --/script ----TB_AddMessage(TipBuddy_Main_Frame.fadingout); |
||
1786 | if (not this.startTime or not this.endTime) then |
||
1787 | TipBuddy_SetFrame_NonUnit_BackgroundColor(); |
||
1788 | TipBuddy_ForceHide( this ); |
||
1789 | return; |
||
1790 | end |
||
1791 | GameTooltip:SetAlpha(0); |
||
1792 | local fraction = (GetTime() - this.startTime) / (this.endTime - this.startTime); |
||
1793 | if ( fraction >= 1.0 ) then |
||
1794 | TipBuddy_FadeOut( this ); |
||
1795 | elseif (GameTooltip:IsVisible() and TipBuddy.compactvis ~= 1) then |
||
1796 | TipBuddy_SetFrame_NonUnit_BackgroundColor(); |
||
1797 | TipBuddy_ForceHide( this ); |
||
1798 | end |
||
1799 | elseif (GameTooltip:IsVisible() and TipBuddy.compactvis ~= 1) then |
||
1800 | TipBuddy_SetFrame_NonUnit_BackgroundColor(); |
||
1801 | TipBuddy_ForceHide( this ); |
||
1802 | end |
||
1803 | end |
||
1804 | end |
||
1805 | |||
1806 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1807 | -- SET ANCHOR |
||
1808 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1809 | -- if it is set to be anchored, anchor it to TipBuddyAnchor |
||
1810 | -- otherwise, set it to the cursor |
||
1811 | function TipBuddy_SetFrame_Anchor( frame ) |
||
1812 | --TB_AddMessage(TB_WHT_TXT.."SetFrame_Anchor"); |
||
1813 | if (not TipBuddy.xpoint or not TipBuddy.anchor) then |
||
1814 | TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset(); |
||
1815 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
1816 | end |
||
1817 | frame:ClearAllPoints(); |
||
1818 | if (TipBuddy_SavedVars["general"].anchored == 1) then |
||
1819 | frame:SetPoint(TipBuddy.anchor, "TipBuddy_Parent_Frame", TipBuddy.fanchor, 0, TipBuddy.offset); |
||
1820 | else |
||
1821 | frame:SetPoint(TipBuddy.xpoint, "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
1822 | end |
||
1823 | end |
||
1824 | |||
1825 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1826 | -- SET HEIGHTS (COMPACT) |
||
1827 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
1828 | -- /script TipBuddy_SavedVars["general"].scalemod = "1"; |
||
1829 | -- /script TipBuddy_SavedVars["general"].scalemod = "0"; |
||
1830 | |||
1831 | function TipBuddy_FrameHeights_Initialize( type ) |
||
1832 | local scale = TipBuddy_SavedVars["general"].scalemod; |
||
1833 | |||
1834 | TipBuddy_FactionFrameIcon:SetHeight( 30 + (scale * 1.5) ); |
||
1835 | TipBuddy_FactionFrameIcon:SetWidth( 30 + (scale * 1.5) ); |
||
1836 | |||
1837 | TipBuddy_TargetName_Text:SetTextHeight( 11 + scale ); |
||
1838 | TipBuddy_TargetName_TextR:SetTextHeight( 11 + scale ); |
||
1839 | if (type and TipBuddy.tt and TipBuddy.tt == 1 and TipBuddy_SavedVars[type] and TipBuddy_SavedVars[type].trg_2l and TipBuddy_SavedVars[type].trg_2l == 1) then |
||
1840 | TipBuddy_TargetName_Text:SetHeight( (11 + scale) * 2); |
||
1841 | TipBuddy_TargetName_TextR:SetHeight( (11 + scale) * 2); |
||
1842 | else |
||
1843 | TipBuddy_TargetName_Text:SetHeight( 11 + scale ); |
||
1844 | TipBuddy_TargetName_TextR:SetHeight( 11 + scale ); |
||
1845 | end |
||
1846 | |||
1847 | TipBuddy_TargetGuild_Text:SetTextHeight( 8 + scale ); |
||
1848 | TipBuddy_TargetGuild_Text:SetHeight( 8 + scale ); |
||
1849 | TipBuddy_TargetGuild_TextR:SetTextHeight( 8 + scale ); |
||
1850 | TipBuddy_TargetGuild_TextR:SetHeight( 8 + scale ); |
||
1851 | |||
1852 | TipBuddy_TargetLevel_Text:SetTextHeight( 10 + scale ); |
||
1853 | TipBuddy_TargetLevel_Text:SetHeight( 10 + scale ); |
||
1854 | --TipBuddy_TargetLevel_Text:SetTextHeight( 8 + scale ); |
||
1855 | --TipBuddy_TargetLevel_Text:SetHeight( 8 + scale ); |
||
1856 | TipBuddy_TargetClass_Text:SetTextHeight( 10 + scale ); |
||
1857 | TipBuddy_TargetClass_Text:SetHeight( 10 + scale ); |
||
1858 | |||
1859 | TipBuddy_TargetCityFac_Text:SetTextHeight( 8 + scale ); |
||
1860 | TipBuddy_TargetCityFac_Text:SetHeight( 8 + scale ); |
||
1861 | TipBuddy_TargetCityFac_TextR:SetTextHeight( 8 + scale ); |
||
1862 | TipBuddy_TargetCityFac_TextR:SetHeight( 8 + scale ); |
||
1863 | |||
1864 | for i=1, 20, 1 do |
||
1865 | local line; |
||
1866 | line = getglobal("TipBuddy_Xtra"..i.."_Text"); |
||
1867 | line:SetTextHeight( 8 + scale ); |
||
1868 | line:SetHeight( 8 + scale ); |
||
1869 | line = getglobal("TipBuddy_XtraR"..i.."_Text"); |
||
1870 | line:SetTextHeight( 8 + scale ); |
||
1871 | line:SetHeight( 8 + scale ); |
||
1872 | end |
||
1873 | |||
1874 | TipBuddy_TargetFrameHealthBar:SetHeight( 5 + scale ); |
||
1875 | TipBuddy_TargetFrameManaBar:SetHeight( 3 + scale ); |
||
1876 | TipBuddy_HealthTextText:SetTextHeight( TipBuddy_TargetFrameHealthBar:GetHeight() + 6 ); |
||
1877 | TipBuddy_ManaTextText:SetTextHeight( TipBuddy_TargetFrameManaBar:GetHeight() + 3.5 ); |
||
1878 | |||
1879 | TipBuddy_RankFrameIcon:SetHeight( 12 + scale ); |
||
1880 | TipBuddy_RankFrameIcon:SetWidth( 12 + scale ); |
||
1881 | |||
1882 | -- hack to fix the fonts scaling badly |
||
1883 | TipBuddy_Main_Frame:SetScale(2); |
||
1884 | TipBuddy_Main_Frame:SetScale(1); |
||
1885 | |||
1886 | TipBuddy_SetFrame_Height(); |
||
1887 | end |
||
1888 | |||
1889 | function TipBuddy_SetFrame_Width() |
||
1890 | local scale = TipBuddy_SavedVars["general"].scalemod; |
||
1891 | |||
1892 | local targetNameLength = TipBuddy_TargetName_Text:GetStringWidth() + (4 + scale); |
||
1893 | local targetClassLength = (TipBuddy_TargetClass_Text:GetStringWidth() + TipBuddy_TargetLevel_Text:GetStringWidth() + (scale + 10)); |
||
1894 | local targetGuildLength = TipBuddy_TargetGuild_Text:GetStringWidth() + (4 + scale); |
||
1895 | |||
1896 | if (not TipBuddy_TargetClass_Text:IsVisible()) then |
||
1897 | targetClassLength = 1; |
||
1898 | end |
||
1899 | if (not TipBuddy_TargetGuild_Text:IsVisible()) then |
||
1900 | targetGuildLength = 1; |
||
1901 | end |
||
1902 | |||
1903 | if (targetNameLength > targetGuildLength) then |
||
1904 | if (targetNameLength < targetClassLength) then |
||
1905 | targetNameLength = targetClassLength; |
||
1906 | end |
||
1907 | elseif (targetGuildLength > targetClassLength) then |
||
1908 | targetNameLength = targetGuildLength; |
||
1909 | else |
||
1910 | targetNameLength = targetClassLength; |
||
1911 | end |
||
1912 | |||
1913 | local t1 = targetNameLength; |
||
1914 | local t2; |
||
1915 | for i=1, 20, 1 do |
||
1916 | t2 = (getglobal("TipBuddy_Xtra"..i.."_Text"):GetStringWidth() + (5 + scale)) + (getglobal("TipBuddy_XtraR"..i.."_Text"):GetStringWidth() + (12 + scale)); |
||
1917 | if (t1 < t2) then |
||
1918 | t1 = t2; |
||
1919 | end |
||
1920 | end |
||
1921 | |||
1922 | if (t1 < 72) then |
||
1923 | t1 = 72; |
||
1924 | end |
||
1925 | TipBuddy_Main_Frame:SetWidth(t1 + scale); |
||
1926 | |||
1927 | TipBuddy_TargetFrameHealthBar:SetWidth(TipBuddy_Main_Frame:GetWidth() - 6); |
||
1928 | TipBuddy_TargetFrameManaBar:SetWidth(TipBuddy_Main_Frame:GetWidth() - 6); |
||
1929 | end |
||
1930 | |||
1931 | --/script foc = GetMouseFocus(); DEFAULT_CHAT_FRAME:AddMessage(foc:GetName()); |
||
1932 | |||
1933 | function TipBuddy_SetFrame_Height() |
||
1934 | local scale = TipBuddy_SavedVars["general"].scalemod; |
||
1935 | local nameFrame = TipBuddy_TargetName_Text:GetHeight(); |
||
1936 | local guildFrame = TipBuddy_TargetGuild_Text:GetHeight(); |
||
1937 | local classFrame = TipBuddy_TargetLevel_Text:GetHeight(); |
||
1938 | local healthFrame = TipBuddy_TargetFrameHealthBar:GetHeight(); |
||
1939 | local manaFrame = TipBuddy_TargetFrameManaBar:GetHeight(); |
||
1940 | local cityfacFrame = TipBuddy_TargetCityFac_Text:GetHeight(); |
||
1941 | local lastparent = "TipBuddy_TargetName_Text"; |
||
1942 | local lastparentr = "TipBuddy_TargetName_TextR"; |
||
1943 | |||
1944 | if (TipBuddy_TargetName_Text:IsVisible()) then |
||
1945 | nameFrame = TipBuddy_TargetName_Text:GetHeight(); |
||
1946 | else |
||
1947 | nameFrame = 0; |
||
1948 | end |
||
1949 | |||
1950 | if (TipBuddy_TargetGuild_Text:IsVisible()) then |
||
1951 | guildFrame = TipBuddy_TargetGuild_Text:GetHeight(); |
||
1952 | TipBuddy_TargetGuild_Text:SetPoint("TOPLEFT", lastparent, "BOTTOMLEFT", 0, 1); |
||
1953 | TipBuddy_TargetGuild_TextR:SetPoint("TOPRIGHT", lastparentr, "BOTTOMRIGHT", 0, 1); |
||
1954 | lastparent = "TipBuddy_TargetGuild_Text"; |
||
1955 | lastparentr = "TipBuddy_TargetGuild_TextR"; |
||
1956 | else |
||
1957 | guildFrame = 0; |
||
1958 | end |
||
1959 | |||
1960 | if (TipBuddy_TargetFrameHealthBar:IsVisible()) then |
||
1961 | healthFrame = (TipBuddy_TargetFrameHealthBar:GetHeight() + 5); |
||
1962 | TipBuddy_TargetFrameHealthBar:SetPoint("TOPLEFT", lastparent, "BOTTOMLEFT", 2, -4); |
||
1963 | lastparent = "TipBuddy_TargetFrameHealthBar"; |
||
1964 | lastparentr = "TipBuddy_TargetFrameHealthBar"; |
||
1965 | else |
||
1966 | healthFrame = 0; |
||
1967 | end |
||
1968 | |||
1969 | if (TipBuddy_TargetFrameManaBar:IsVisible()) then |
||
1970 | manaFrame = (TipBuddy_TargetFrameManaBar:GetHeight() + 4); |
||
1971 | lastparent = "TipBuddy_TargetFrameManaBar"; |
||
1972 | lastparentr = "TipBuddy_TargetFrameManaBar"; |
||
1973 | else |
||
1974 | manaFrame = 0; |
||
1975 | end |
||
1976 | |||
1977 | if (TipBuddy_TargetCityFac_Text:IsVisible()) then |
||
1978 | ------TB_AddMessage(lastparent); |
||
1979 | cityfacFrame = TipBuddy_TargetCityFac_Text:GetHeight(); |
||
1980 | TipBuddy_TargetCityFac_Text:SetPoint("TOPLEFT", lastparent, "BOTTOMLEFT", 0, 0); |
||
1981 | TipBuddy_TargetCityFac_TextR:SetPoint("TOPRIGHT", lastparentr, "BOTTOMRIGHT", 0, 0); |
||
1982 | lastparent = "TipBuddy_TargetCityFac_Text"; |
||
1983 | lastparentr = "TipBuddy_TargetCityFac_TextR"; |
||
1984 | else |
||
1985 | cityfacFrame = 0; |
||
1986 | end |
||
1987 | |||
1988 | if (TipBuddy_TargetLevel_Text:IsVisible()) then |
||
1989 | ------TB_AddMessage(lastparent); |
||
1990 | classFrame = (TipBuddy_TargetLevel_Text:GetHeight() + 1); |
||
1991 | TipBuddy_TargetLevel_Text:SetPoint("TOPLEFT", lastparent, "BOTTOMLEFT", 0, -1); |
||
1992 | TipBuddy_TargetClass_Text:SetPoint("TOPRIGHT", lastparentr, "BOTTOMRIGHT", 0, -1); |
||
1993 | lastparent = "TipBuddy_TargetLevel_Text"; |
||
1994 | lastparentr = "TipBuddy_TargetClass_Text"; |
||
1995 | else |
||
1996 | classFrame = 0; |
||
1997 | end |
||
1998 | |||
1999 | if (TipBuddy_Xtra1_Text:IsVisible()) then |
||
2000 | TipBuddy_Xtra1_Text:SetPoint("TOPLEFT", lastparent, "BOTTOMLEFT", 0, -3); |
||
2001 | TipBuddy_XtraR1_Text:SetPoint("TOPRIGHT", lastparentr, "BOTTOMRIGHT", 0, -3); |
||
2002 | end |
||
2003 | |||
2004 | local xtraHeight = 0; |
||
2005 | for i=1, 20, 1 do |
||
2006 | local xtraLineL = getglobal("TipBuddy_Xtra"..i.."_Text"); |
||
2007 | local xtraLineR = getglobal("TipBuddy_XtraR"..i.."_Text"); |
||
2008 | if (xtraLineL:IsVisible()) then |
||
2009 | xtraHeight = ( xtraHeight + xtraLineL:GetHeight() + 1 ); |
||
2010 | else |
||
2011 | if (xtraLineR:IsVisible()) then |
||
2012 | xtraHeight = ( xtraHeight + xtraLineL:GetHeight() + 1 ); |
||
2013 | end |
||
2014 | end |
||
2015 | end |
||
2016 | if (xtraHeight ~= 0) then |
||
2017 | xtraHeight = xtraHeight + 2; |
||
2018 | end |
||
2019 | |||
2020 | local tipFrameHeight = ((nameFrame + guildFrame + classFrame + healthFrame + manaFrame + cityfacFrame + xtraHeight) + 4); |
||
2021 | TipBuddy_Main_Frame:SetHeight(tipFrameHeight); |
||
2022 | end |
||
2023 | |||
2024 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2025 | -- POSITIONING |
||
2026 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2027 | |||
2028 | --/script ----TB_AddMessage(UIParent:GetWidth()..", "..UIParent:GetHeight()); local x, y = GetCursorPosition(UIParent); ----TB_AddMessage(x..", "..y); |
||
2029 | function TipBuddy_PositionFrameToCursor() |
||
2030 | |||
2031 | local x, y = GetCursorPosition(UIParent); |
||
2032 | |||
2033 | x = (x / TipBuddy.uiscale) + TipBuddy.xpos; |
||
2034 | y = (y / TipBuddy.uiscale) + TipBuddy.ypos; |
||
2035 | |||
2036 | local x1, x2, y1, y2, tip; |
||
2037 | if (TipBuddyTooltip:IsVisible()) then |
||
2038 | tip = getglobal("TipBuddyTooltip"); |
||
2039 | elseif (TipBuddy_Main_Frame:IsVisible()) then |
||
2040 | tip = getglobal("TipBuddy_Main_Frame"); |
||
2041 | else |
||
2042 | tip = getglobal("GameTooltip"); |
||
2043 | end |
||
2044 | |||
2045 | if ( TipBuddy.xpoint == "LEFT" ) then |
||
2046 | x1 = 0; |
||
2047 | x2 = (TipBuddy.uiwidth - tip:GetWidth()); |
||
2048 | elseif ( TipBuddy.xpoint == "RIGHT" ) then |
||
2049 | x1 = tip:GetWidth(); |
||
2050 | x2 = TipBuddy.uiwidth; |
||
2051 | else |
||
2052 | x1 = tip:GetWidth() * 0.5; |
||
2053 | x2 = (TipBuddy.uiwidth - x1); |
||
2054 | end |
||
2055 | |||
2056 | y1 = (TipBuddy.uiheight - tip:GetHeight()); |
||
2057 | if ( TipBuddy.xpoint == "TOP" ) then |
||
2058 | y2 = tip:GetHeight(); |
||
2059 | elseif ( xpoint == "BOTTOM" ) then |
||
2060 | y2 = 0; |
||
2061 | else |
||
2062 | y2 = (tip:GetHeight() * 0.5); |
||
2063 | end |
||
2064 | |||
2065 | ------TB_AddMessage(x1..", "..y2); |
||
2066 | if ( x < x1 ) then |
||
2067 | x = x1; |
||
2068 | end |
||
2069 | if ( x > x2 ) then |
||
2070 | x = x2; |
||
2071 | end |
||
2072 | if ( y > y1 ) then |
||
2073 | y = y1; |
||
2074 | end |
||
2075 | if ( y < y2 ) then |
||
2076 | y = y2; |
||
2077 | end |
||
2078 | |||
2079 | return x, y; |
||
2080 | end |
||
2081 | |||
2082 | function TipBuddy_GetIconAnchorPos( frame ) |
||
2083 | local x, y = TipBuddy_PositionFrameToCursor(); |
||
2084 | |||
2085 | if (not frame or not frame:GetLeft()) then |
||
2086 | return; |
||
2087 | end |
||
2088 | if (not TipBuddy.uiwidth) then |
||
2089 | TipBuddy.uiscale = UIParent:GetScale(); |
||
2090 | TipBuddy.uiwidth = UIParent:GetWidth() / TipBuddy.uiscale; |
||
2091 | TipBuddy.uiheight = UIParent:GetHeight() / TipBuddy.uiscale; |
||
2092 | end |
||
2093 | if (y > (TipBuddy.uiheight * 0.75)) then |
||
2094 | --topright |
||
2095 | if (x > (TipBuddy.uiwidth * 0.75)) then |
||
2096 | if (frame and frame:GetLeft() <= (TipBuddy.uiwidth * 0.2)) then |
||
2097 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2098 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2099 | end |
||
2100 | ------TB_AddMessage("ANCHOR_BOTTOMLEFT"); |
||
2101 | return "ANCHOR_BOTTOMLEFT", "TOPRIGHT", "BOTTOMLEFT"; |
||
2102 | --topmidright |
||
2103 | elseif (x > (TipBuddy.uiwidth * 0.5)) then |
||
2104 | if (frame and frame:GetLeft() <= (TipBuddy.uiwidth * 0.2)) then |
||
2105 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2106 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2107 | end |
||
2108 | ------TB_AddMessage("ANCHOR_BOTTOMLEFT"); |
||
2109 | return "ANCHOR_BOTTOMLEFT", "TOPRIGHT", "BOTTOMRIGHT"; |
||
2110 | --cursor is topmidleft |
||
2111 | elseif (x > (TipBuddy.uiwidth * 0.25)) then |
||
2112 | if (frame and frame:GetRight() >= (TipBuddy.uiwidth * 0.8)) then |
||
2113 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2114 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2115 | end |
||
2116 | ------TB_AddMessage("ANCHOR_BOTTOMRIGHT"); |
||
2117 | return "ANCHOR_BOTTOMRIGHT", "TOPLEFT", "BOTTOMLEFT"; |
||
2118 | --cursor is topleft |
||
2119 | else |
||
2120 | if (frame and frame:GetRight() >= (TipBuddy.uiwidth * 0.8)) then |
||
2121 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2122 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2123 | end |
||
2124 | ------TB_AddMessage("ANCHOR_BOTTOMRIGHT"); |
||
2125 | return "ANCHOR_BOTTOMRIGHT", "TOPLEFT", "BOTTOMRIGHT"; |
||
2126 | end |
||
2127 | |||
2128 | elseif (y > (TipBuddy.uiheight * 0.25)) then |
||
2129 | --midright |
||
2130 | if (x > (TipBuddy.uiwidth * 0.75)) then |
||
2131 | if (frame and frame:GetLeft() <= (TipBuddy.uiwidth * 0.2)) then |
||
2132 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2133 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2134 | end |
||
2135 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2136 | return "ANCHOR_NONE", "BOTTOMRIGHT", "BOTTOMLEFT"; |
||
2137 | else |
||
2138 | if (frame and frame:GetRight() >= (TipBuddy.uiwidth * 0.8)) then |
||
2139 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2140 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2141 | end |
||
2142 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2143 | return "ANCHOR_NONE", "BOTTOMLEFT", "BOTTOMRIGHT"; |
||
2144 | end |
||
2145 | else |
||
2146 | |||
2147 | if (x > (TipBuddy.uiwidth * 0.75)) then |
||
2148 | if (frame and frame:GetLeft() <= (TipBuddy.uiwidth * 0.2)) then |
||
2149 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2150 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2151 | end |
||
2152 | ------TB_AddMessage("ANCHOR_LEFT"); |
||
2153 | return "ANCHOR_LEFT", "BOTTOMRIGHT", "TOPLEFT"; |
||
2154 | else |
||
2155 | if (frame and frame:GetRight() >= (TipBuddy.uiwidth * 0.8)) then |
||
2156 | ------TB_AddMessage("ANCHOR_NONE"); |
||
2157 | return "ANCHOR_NONE", "BOTTOM", "TOP"; |
||
2158 | end |
||
2159 | ------TB_AddMessage("ANCHOR_RIGHT"); |
||
2160 | return "ANCHOR_RIGHT", "BOTTOMLEFT", "TOPRIGHT"; |
||
2161 | end |
||
2162 | end |
||
2163 | end |
||
2164 | |||
2165 | function TipBuddy_GetFrameCursorOffset() |
||
2166 | local curpos = TipBuddy_SavedVars["general"].cursorpos; |
||
2167 | TipBuddy.uiscale = UIParent:GetScale(); |
||
2168 | TipBuddy.uiwidth = UIParent:GetWidth() / TipBuddy.uiscale; |
||
2169 | TipBuddy.uiheight = UIParent:GetHeight() / TipBuddy.uiscale; |
||
2170 | |||
2171 | -- set the position of the tooltip in relation to the cursor |
||
2172 | if (curpos == "Top") then |
||
2173 | xpoint = "BOTTOM"; |
||
2174 | elseif (curpos == "Right") then |
||
2175 | xpoint = "LEFT"; |
||
2176 | elseif (curpos == "Left") then |
||
2177 | xpoint = "RIGHT"; |
||
2178 | elseif (curpos == "Bottom") then |
||
2179 | xpoint = "TOP"; |
||
2180 | else |
||
2181 | xpoint = "BOTTOM"; |
||
2182 | end |
||
2183 | return xpoint, TipBuddy_SavedVars["general"].offset_x, TipBuddy_SavedVars["general"].offset_y; |
||
2184 | end |
||
2185 | |||
2186 | function TipBuddy_GetFrameAnchorPos() |
||
2187 | local anchorpos = TipBuddy_SavedVars["general"].anchor_pos; |
||
2188 | |||
2189 | if (anchorpos == "Top Right") then |
||
2190 | anchor = "BOTTOMRIGHT"; |
||
2191 | fanchor = "TOPRIGHT"; |
||
2192 | offset = -2; |
||
2193 | elseif (anchorpos == "Top Left") then |
||
2194 | anchor = "BOTTOMLEFT"; |
||
2195 | fanchor = "TOPLEFT"; |
||
2196 | offset = -2; |
||
2197 | elseif (anchorpos == "Bottom Right") then |
||
2198 | anchor = "TOPRIGHT"; |
||
2199 | fanchor = "BOTTOMRIGHT"; |
||
2200 | offset = 2; |
||
2201 | elseif (anchorpos == "Bottom Left") then |
||
2202 | anchor = "TOPLEFT"; |
||
2203 | fanchor = "BOTTOMLEFT"; |
||
2204 | offset = 2; |
||
2205 | elseif (anchorpos == "Top Center") then |
||
2206 | anchor = "BOTTOM"; |
||
2207 | fanchor = "TOP"; |
||
2208 | offset = -2; |
||
2209 | elseif (anchorpos == "Bottom Center") then |
||
2210 | anchor = "TOP"; |
||
2211 | fanchor = "BOTTOM"; |
||
2212 | offset = 2; |
||
2213 | end |
||
2214 | return anchor, fanchor, offset; |
||
2215 | end |
||
2216 | |||
2217 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2218 | -- FADING |
||
2219 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2220 | |||
2221 | function TipBuddy_Hide( frame ) |
||
2222 | ------TB_AddMessage("TipBuddy_Hide"); |
||
2223 | TipBuddy.hasTarget = 0; |
||
2224 | --TB_AddMessage("TipBuddy.hasTarget = 0"); |
||
2225 | |||
2226 | if (frame:GetName() == "TipBuddy_Main_Frame") then |
||
2227 | if (GameTooltip:IsVisible() and TipBuddy.compactvis ~= 1 and not UnitExists("mouseover")) then |
||
2228 | TipBuddy_ForceHide(frame); |
||
2229 | return; |
||
2230 | elseif (UnitExists("mouseover")) then |
||
2231 | TipBuddy_ForceHide(frame); |
||
2232 | return; |
||
2233 | elseif ( frame.fadingout ) then |
||
2234 | return; |
||
2235 | end |
||
2236 | end |
||
2237 | |||
2238 | local delayTime; |
||
2239 | if (TipBuddy_SavedVars["general"].delaytime) then |
||
2240 | delayTime = TipBuddy_SavedVars["general"].delaytime; |
||
2241 | else |
||
2242 | delayTime = 0; |
||
2243 | end |
||
2244 | TipBuddy.uName = nil; |
||
2245 | |||
2246 | frame.startTime = GetTime(); |
||
2247 | frame.endTime = frame.startTime + (0.01 + delayTime); |
||
2248 | end |
||
2249 | |||
2250 | function TipBuddy_FadeOut( frame, func ) |
||
2251 | --TB_AddMessage("TipBuddy_FadeOut"); |
||
2252 | if (frame:GetName() == "TipBuddy_Main_Frame") then |
||
2253 | TipBuddy.compactvis = nil; |
||
2254 | end |
||
2255 | if ( frame.fadingout ) then |
||
2256 | return; |
||
2257 | end |
||
2258 | |||
2259 | frame.fadingout = 1; |
||
2260 | frame.fadingin = nil; |
||
2261 | frame.targetalpha = 0; |
||
2262 | frame.animfunc_fade = func; |
||
2263 | |||
2264 | local fadeTime; |
||
2265 | if (TipBuddy_SavedVars["general"].fadetime) then |
||
2266 | fadeTime = TipBuddy_SavedVars["general"].fadetime; |
||
2267 | else |
||
2268 | fadeTime = 0; |
||
2269 | end |
||
2270 | UIFrameFadeRemoveFrame(frame); |
||
2271 | UIFrameFadeOut( frame, (0.01 + fadeTime), frame:GetAlpha(), frame.targetalpha ); |
||
2272 | end |
||
2273 | |||
2274 | function TipBuddy_FadeOut_Finished() |
||
2275 | --TB_AddMessage("TipBuddy_FadeOut_Finished"); |
||
2276 | this:Hide(); |
||
2277 | this:SetAlpha( 1 ); |
||
2278 | |||
2279 | this.fadingout = nil; |
||
2280 | if ( this.animfunc_fade ) then |
||
2281 | this.animfunc_fade(); |
||
2282 | end |
||
2283 | end |
||
2284 | |||
2285 | function TipBuddy_FadeIn( frame, func ) |
||
2286 | ------TB_AddMessage("TipBuddy_FadeIn"); |
||
2287 | if ( frame.fadingin ) then |
||
2288 | return; |
||
2289 | end |
||
2290 | if ( frame.fadingout ) then |
||
2291 | UIFrameFadeRemoveFrame(frame); |
||
2292 | end |
||
2293 | |||
2294 | frame.fadingin = 1; |
||
2295 | frame.fadingout = nil; |
||
2296 | frame.targetalpha = 1; |
||
2297 | frame.animfunc_fade = func; |
||
2298 | UIFrameFadeRemoveFrame(frame); |
||
2299 | UIFrameFadeIn( frame, 0.01, 0.9, frame.targetalpha ); |
||
2300 | end |
||
2301 | |||
2302 | function TipBuddy_FadeIn_Finished() |
||
2303 | ------TB_AddMessage("TipBuddy_FadeIn_Finished"); |
||
2304 | this:SetAlpha( 1 ); |
||
2305 | |||
2306 | this.fadingin = nil; |
||
2307 | if ( this.animfunc_fade ) then |
||
2308 | this.animfunc_fade(); |
||
2309 | end |
||
2310 | end |
||
2311 | |||
2312 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2313 | -- GAMETOOLTIP |
||
2314 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2315 | function TB_GameTooltip_IniHooks() |
||
2316 | TB_AddMessage("GameTooltip_OnLoad"); |
||
2317 | --hooking GameTooltip's AddLine |
||
2318 | if( not GameTooltip.tborgAddLine ) then |
||
2319 | GameTooltip.tborgAddLine = GameTooltip.AddLine; |
||
2320 | GameTooltip.AddLine = TipBuddy_GameTooltip_AddLine; |
||
2321 | end |
||
2322 | --hooking GameTooltip's AddDoubleLine |
||
2323 | if( not GameTooltip.tborgAddDoubleLine ) then |
||
2324 | GameTooltip.tborgAddDoubleLine = GameTooltip.AddDoubleLine; |
||
2325 | GameTooltip.AddDoubleLine = TipBuddy_GameTooltip_AddDoubleLine; |
||
2326 | ----TB_AddMessage("adding double line hook"); |
||
2327 | end |
||
2328 | --hooking GameTooltip's SetUnit |
||
2329 | if( not GameTooltip.orgSetUnit ) then |
||
2330 | GameTooltip.orgSetUnit = GameTooltip.SetUnit; |
||
2331 | GameTooltip.SetUnit = TipBuddy_GameTooltip_SetUnit; |
||
2332 | end |
||
2333 | --hooking GameTooltip's FadeOut |
||
2334 | if( not GameTooltip.orgFadeOut ) then |
||
2335 | GameTooltip.orgFadeOut = GameTooltip.FadeOut; |
||
2336 | GameTooltip.FadeOut = TipBuddy_GameTooltip_FadeOut; |
||
2337 | end |
||
2338 | --hooking GameTooltip's SetOwner |
||
2339 | if( not GameTooltip.orgSetOwner ) then |
||
2340 | --TB_AddMessage( tbcolor_nam_hostile.."hooking setowner" ) |
||
2341 | GameTooltip.orgSetOwner = GameTooltip.SetOwner; |
||
2342 | GameTooltip.SetOwner = TipBuddy_GameTooltip_SetOwner; |
||
2343 | end |
||
2344 | --hooking GameTooltip's SetPoint |
||
2345 | if( not GameTooltip.orgSetPoint ) then |
||
2346 | --TB_AddMessage( tbcolor_nam_hostile.."hooking setpoint" ) |
||
2347 | GameTooltip.orgSetPoint = GameTooltip.SetPoint; |
||
2348 | GameTooltip.SetPoint = TipBuddy_GameTooltip_SetPoint; |
||
2349 | end |
||
2350 | end |
||
2351 | --hook |
||
2352 | local originalGameTooltip_SetDefaultAnchor; |
||
2353 | originalGameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor; |
||
2354 | function GameTooltip_SetDefaultAnchor(tooltip, parent) |
||
2355 | TB_AddMessage(TB_WHT_TXT.."GTT SETANCHOR"); |
||
2356 | TipBuddy.defanch = 1; |
||
2357 | originalGameTooltip_SetDefaultAnchor( tooltip, parent ); |
||
2358 | if (tooltip:GetName() ~= "GameTooltip" and tooltip:GetName() ~= "TipBuddyTooltip") then |
||
2359 | TipBuddy.defanch = nil; |
||
2360 | return; |
||
2361 | end |
||
2362 | if (parent) then |
||
2363 | TipBuddy.anchorparent = parent:GetName(); |
||
2364 | --TB_AddMessage("GTT_PARENT = "..parent:GetName()); |
||
2365 | else |
||
2366 | --TB_AddMessage("GTT HAS NO PARENT "); |
||
2367 | end |
||
2368 | --/script GameTooltip:SetOwner(PetActionButton5, "ANCHOR_NONE"); |
||
2369 | if (not TipBuddy.first) then |
||
2370 | tooltip:Show(); |
||
2371 | end |
||
2372 | if (not TipBuddy.xpoint or not TipBuddy.anchor) then |
||
2373 | TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset(); |
||
2374 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
2375 | end |
||
2376 | TipBuddyTooltip:ClearAllPoints(); |
||
2377 | GameTooltip:ClearAllPoints(); |
||
2378 | TB_AddMessage("GameTooltip:ClearAllPoints()"); |
||
2379 | if (UnitExists("mouseover") or TipBuddy.unitframe == 1) then |
||
2380 | GameTooltip:orgSetOwner(parent, "ANCHOR_NONE"); |
||
2381 | GameTooltip:orgSetPoint("TOPLEFT", "UIParent", "BOTTOMRIGHT", 256, -256); |
||
2382 | GameTooltip.default = 0; |
||
2383 | TB_AddMessage("GameTooltip:orgSetPoint"); |
||
2384 | local newparent = TipBuddy_Parent_Frame; |
||
2385 | if (parent.unit) then |
||
2386 | GameTooltip:SetUnit(parent.unit); |
||
2387 | TB_AddMessage(parent:GetName()); |
||
2388 | newparent = parent; |
||
2389 | end |
||
2390 | if ( TipBuddy_SavedVars["general"].anchored == 1) then |
||
2391 | TB_AddMessage("GTT-ANCHORED = 1 "..TipBuddy.offset); |
||
2392 | TipBuddyTooltip:SetOwner(newparent, "ANCHOR_NONE"); |
||
2393 | TipBuddyTooltip:SetPoint(TipBuddy.anchor, "TipBuddy_Parent_Frame", TipBuddy.fanchor, 0, TipBuddy.offset); |
||
2394 | else |
||
2395 | TipBuddyTooltip:SetOwner(newparent, "ANCHOR_NONE"); |
||
2396 | TipBuddyTooltip:SetPoint(TipBuddy.xpoint, "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
2397 | TB_AddMessage("GTT-ANCHORED = 0 "..TipBuddy.xpoint); |
||
2398 | end |
||
2399 | else |
||
2400 | if (parent == getglobal("UIParent")) then |
||
2401 | if ( TipBuddy_SavedVars["general"].anchored == 1) then |
||
2402 | TB_AddMessage("GTT-ANCHORED = 1"); |
||
2403 | tooltip:SetOwner(parent, "ANCHOR_NONE"); |
||
2404 | tooltip:SetPoint(TipBuddy.anchor, "TipBuddy_Parent_Frame", TipBuddy.fanchor, 0, TipBuddy.offset); |
||
2405 | tooltip.default = nil; |
||
2406 | else |
||
2407 | if (TipBuddy_SavedVars["general"].gtt_fade == 1) then |
||
2408 | tooltip:SetOwner(parent, "ANCHOR_NONE"); |
||
2409 | tooltip:SetPoint(TipBuddy.xpoint, "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
2410 | tooltip.default = nil; |
||
2411 | TB_AddMessage("GTT-ANCHORED = 0"); |
||
2412 | else |
||
2413 | TB_AddMessage("GTT-ANCHORED = CURSOR"); |
||
2414 | tooltip:SetOwner(parent, "ANCHOR_CURSOR"); |
||
2415 | tooltip.default = nil; |
||
2416 | end |
||
2417 | end |
||
2418 | elseif (TipBuddy_SavedVars["general"].nonunit_anchor == 0) then |
||
2419 | -- -- Or to the cursor |
||
2420 | tooltip:SetOwner(parent, "ANCHOR_NONE"); |
||
2421 | tooltip:SetPoint(TipBuddy.xpoint, "TipBuddy_Parent_Frame", "CENTER", 0, 0); |
||
2422 | tooltip.default = nil; |
||
2423 | TB_AddMessage("GTT-NONUNIT_ANCHOR = 0"); |
||
2424 | elseif (TipBuddy_SavedVars["general"].nonunit_anchor == 1) then |
||
2425 | tooltip:SetOwner(parent, "ANCHOR_NONE"); |
||
2426 | tooltip:SetPoint(TipBuddy.anchor, "TipBuddy_Parent_Frame", TipBuddy.fanchor, 0, TipBuddy.offset); |
||
2427 | tooltip.default = nil; |
||
2428 | TB_AddMessage("GTT-NONUNIT_ANCHOR = xxx"); |
||
2429 | elseif (TipBuddy_SavedVars["general"].nonunit_anchor == 2) then |
||
2430 | local oanchor, ganchor, panchor = TipBuddy_GetIconAnchorPos(parent); |
||
2431 | tooltip:ClearAllPoints(); |
||
2432 | tooltip:SetOwner(parent, oanchor); |
||
2433 | tooltip:SetPoint(ganchor, parent:GetName(), panchor, 0, 0); |
||
2434 | tooltip.default = nil; |
||
2435 | end |
||
2436 | TipBuddy_ForceHide( TipBuddyTooltip ); |
||
2437 | end |
||
2438 | TipBuddy.defanch = nil; |
||
2439 | end |
||
2440 | |||
2441 | function TipBuddy_GTT_ClearExtras() |
||
2442 | TipBuddy.gotextras = nil; |
||
2443 | TipBuddy.gtt_xtra = nil; |
||
2444 | TipBuddy.gtt_xtraR = nil; |
||
2445 | TipBuddy.vis = nil; |
||
2446 | end |
||
2447 | |||
2448 | -- hook for GameTooltip_OnShow |
||
2449 | function TipBuddy_GameTooltip_OnShow() |
||
2450 | TB_AddMessage(TB_WHT_TXT.."GTT OnShow"); |
||
2451 | TipBuddy.xpoint, TipBuddy.xpos, TipBuddy.ypos = TipBuddy_GetFrameCursorOffset(); |
||
2452 | TipBuddy.anchor, TipBuddy.fanchor, TipBuddy.offset = TipBuddy_GetFrameAnchorPos(); |
||
2453 | |||
2454 | if (lGameTooltip_OnShow_Orig) then |
||
2455 | lGameTooltip_OnShow_Orig(); |
||
2456 | end |
||
2457 | TB_AddMessage(TB_WHT_TXT.."end GTT OnShow"); |
||
2458 | if (TipBuddy_SavedVars["general"].reposmods and TipBuddy_SavedVars["general"].reposmods == 1) then |
||
2459 | --this adjusts the xy of the tooltip position ONLY if GameTooltip_SetDefaultAnchor hasn't |
||
2460 | --been called and then ONLY if it extends off the screen. |
||
2461 | if (TipBuddy.d_own and (TipBuddy.d_own):GetName()) then |
||
2462 | local owner = TipBuddy.d_own or this:GetParent(); |
||
2463 | TB_AddMessage("reposmods"); |
||
2464 | if (UnitExists("mouseover") or TipBuddy.unitframe == 1) then |
||
2465 | |||
2466 | else |
||
2467 | --local x2, y2 = TipBuddy_PositionFrameToCursor(); |
||
2468 | if (not TipBuddy.uiwidth or not TipBuddy.uiheight) then |
||
2469 | TipBuddy.uiscale = UIParent:GetScale(); |
||
2470 | TipBuddy.uiwidth = UIParent:GetWidth() / TipBuddy.uiscale; |
||
2471 | TipBuddy.uiheight = UIParent:GetHeight() / TipBuddy.uiscale; |
||
2472 | end |
||
2473 | if (GameTooltip:IsVisible() and GameTooltip:GetLeft()) then |
||
2474 | local scale = TipBuddy_SavedVars["general"].gtt_scale; |
||
2475 | local left = GameTooltip:GetLeft()* scale; |
||
2476 | local right = GameTooltip:GetRight()* scale; |
||
2477 | local top = GameTooltip:GetTop()* scale; |
||
2478 | local bottom = GameTooltip:GetBottom()* scale; |
||
2479 | local x, y = 0, 0; |
||
2480 | local off = false; |
||
2481 | if (left and left < -4) then |
||
2482 | x = (left * -1)/scale; |
||
2483 | off = true; |
||
2484 | elseif (right and right > TipBuddy.uiwidth+8) then |
||
2485 | x = (TipBuddy.uiwidth - right)/scale; |
||
2486 | off = true; |
||
2487 | end |
||
2488 | if (top and top > TipBuddy.uiheight+16) then |
||
2489 | y = (TipBuddy.uiheight - top)/scale; |
||
2490 | off = true; |
||
2491 | elseif (bottom and bottom < -4) then |
||
2492 | y = (bottom * -1)/scale; |
||
2493 | off = true; |
||
2494 | end |
||
2495 | TB_AddMessage("scale="..scale.." x="..x.." - y="..y.." - top="..top.." - height="..TipBuddy.uiheight); |
||
2496 | --only readjust it if it extends off the screen |
||
2497 | if (owner and owner:GetName() and off == true) then |
||
2498 | TB_AddMessage("GameTooltip off edge"); |
||
2499 | --local _, ganchor, panchor = TipBuddy_GetIconAnchorPos(owner); |
||
2500 | GameTooltip:ClearAllPoints(); |
||
2501 | GameTooltip:SetPoint(TipBuddy.d_anch1, owner:GetName(), TipBuddy.d_anch2, x, y); |
||
2502 | --GameTooltip:orgSetPoint(ganchor, owner:GetName(), panchor, 0, 0); |
||
2503 | --/script GameTooltip:ClearAllPoints();GameTooltip:SetPoint(TipBuddy.anchor, this:GetParent():GetName(), TipBuddy.fanchor, 100, 0); |
||
2504 | --GameTooltip.default = nil; |
||
2505 | end |
||
2506 | end |
||
2507 | TipBuddy_ForceHide( TipBuddyTooltip ); |
||
2508 | end |
||
2509 | end |
||
2510 | end |
||
2511 | if (not UnitExists("mouseover") and TipBuddy.unitframe ~= 1) then |
||
2512 | TipBuddy_SetFrame_BackgroundColor(); |
||
2513 | TipBuddy_ForceHide( TipBuddyTooltip ); |
||
2514 | end |
||
2515 | end |
||
2516 | |||
2517 | --hook |
||
2518 | local originalGameTooltip_OnHide; |
||
2519 | originalGameTooltip_OnHide = GameTooltip_OnHide; |
||
2520 | function GameTooltip_OnHide() |
||
2521 | originalGameTooltip_OnHide(); |
||
2522 | TipBuddy_GTT_ClearExtras(); |
||
2523 | TipBuddy.d_own = nil; |
||
2524 | TipBuddy.d_point = nil; |
||
2525 | |||
2526 | --TipBuddyTooltip:Hide(); |
||
2527 | TB_AddMessage("hiding GTT"); |
||
2528 | |||
2529 | --TipBuddy_TargetBuffs_Update(); |
||
2530 | --TipBuddy_ShowRank( TipBuddy.targetType, this.unit ); |
||
2531 | --TipBuddy_TargetInfo_ShowFaction( TipBuddy.targetType, this.unit ); |
||
2532 | end |
||
2533 | |||
2534 | -- hook for GameTooltip_OnEvent |
||
2535 | function TipBuddy_GameTooltip_OnEvent() |
||
2536 | lGameTooltip_OnEvent_Orig(event); |
||
2537 | --TB_AddMessage("GTT_0NEVENT called"); |
||
2538 | end |
||
2539 | |||
2540 | -- hook for GameTooltip_SetUnit |
||
2541 | function TipBuddy_GameTooltip_SetUnit(this, unit) |
||
2542 | --TB_AddMessage( "SET UNIT!!" ) |
||
2543 | TipBuddy_GTT_ClearExtras(); |
||
2544 | GameTooltip:orgSetUnit(unit); |
||
2545 | end |
||
2546 | |||
2547 | -- hook for GameTooltip_FadeOut |
||
2548 | function TipBuddy_GameTooltip_FadeOut() |
||
2549 | TB_AddMessage( "FadeOut" ) |
||
2550 | GameTooltip:orgFadeOut(); |
||
2551 | end |
||
2552 | |||
2553 | -- hook for GameTooltip_SetOwner |
||
2554 | function TipBuddy_GameTooltip_SetOwner( this, owner, position, x, y ) |
||
2555 | TipBuddy.d_own = nil; |
||
2556 | TipBuddy.d_point = nil; |
||
2557 | GameTooltip:orgSetOwner(owner, position, x, y); |
||
2558 | TB_AddMessage(TB_WHT_TXT.."SetOwner"); |
||
2559 | --if this tooltip has had its default anchor set, then don't modify it any further |
||
2560 | if (TipBuddy_SavedVars["general"].gtt_scale) then |
||
2561 | GameTooltip:SetScale(2); |
||
2562 | local ttScale = TipBuddy_SavedVars["general"].gtt_scale; |
||
2563 | if (EnhancedTooltip and EnhancedTooltip:IsVisible()) then |
||
2564 | ttScale = 1.0; |
||
2565 | end |
||
2566 | TipBuddy_SetEffectiveScale(GameTooltip, ttScale, UIParent); |
||
2567 | end |
||
2568 | if (TipBuddy.defanch) then |
||
2569 | return; |
||
2570 | end |
||
2571 | --/script if (GameTooltip:IsOwned(BrowseButton1Item)) then TB_AddMessage("0wn3d")end; |
||
2572 | TB_AddMessage(TB_WHT_TXT.."SetOwner Modify"); |
||
2573 | if (owner and owner:GetName() and TipBuddy_SavedVars["general"].reposmods and TipBuddy_SavedVars["general"].reposmods == 1) then |
||
2574 | --need to check for the position because some mods don't set a position |
||
2575 | if (position) then |
||
2576 | TB_AddMessage(position..GetTime()); |
||
2577 | position = string.gsub(position, "ANCHOR_", ""); |
||
2578 | --TB_AddMessage(position); |
||
2579 | if (TB_ANCHOR[position]) then |
||
2580 | TipBuddy.d_anch1 = TB_ANCHOR[position].a; |
||
2581 | TipBuddy.d_anch2 = TB_ANCHOR[position].b; |
||
2582 | elseif (position == "NONE") then |
||
2583 | --don't do anything |
||
2584 | return; |
||
2585 | else |
||
2586 | TipBuddy.d_anch1 = "BOTTOMRIGHT"; |
||
2587 | TipBuddy.d_anch2 = "BOTTOMLEFT"; |
||
2588 | end |
||
2589 | else |
||
2590 | --if no positioned was passed, use the default position for anchoring |
||
2591 | TipBuddy.d_anch1 = "BOTTOMRIGHT"; |
||
2592 | TipBuddy.d_anch2 = "BOTTOMLEFT"; |
||
2593 | end |
||
2594 | --TB_AddMessage(owner:GetName()); |
||
2595 | TipBuddy.d_own = owner; |
||
2596 | --we have to set the anchor to NONE because otherwise, we can't reposition it with SetPoint |
||
2597 | GameTooltip:orgSetOwner(owner, "ANCHOR_NONE"); |
||
2598 | if (not x) then |
||
2599 | x = 0; |
||
2600 | end |
||
2601 | if (not y) then |
||
2602 | y = 0; |
||
2603 | end |
||
2604 | GameTooltip:ClearAllPoints(); |
||
2605 | GameTooltip:orgSetPoint(TipBuddy.d_anch1, owner:GetName(), TipBuddy.d_anch2, x, y); |
||
2606 | --TB_AddMessage(TipBuddy.d_anch1); |
||
2607 | end |
||
2608 | TB_AddMessage(TB_WHT_TXT.."endSetOwner"); |
||
2609 | --"ANCHOR_NONE" |
||
2610 | end |
||
2611 | |||
2612 | -- hook for GameTooltip_SetPoint |
||
2613 | function TipBuddy_GameTooltip_SetPoint( this, pos1, parent, pos2, x, y ) |
||
2614 | if (not pos1 or not parent) then |
||
2615 | return; |
||
2616 | end |
||
2617 | TipBuddy.d_point = 1; |
||
2618 | if (TipBuddy_SavedVars["general"].gtt_scale) then |
||
2619 | TipBuddyTooltip:SetScale(2); |
||
2620 | TipBuddy_SetEffectiveScale(TipBuddyTooltip, TipBuddy_SavedVars["general"].gtt_scale, UIParent); |
||
2621 | TB_AddMessage("SCALE = "..TipBuddy_SavedVars["general"].gtt_scale); |
||
2622 | end |
||
2623 | GameTooltip:orgSetPoint(pos1, parent, pos2, x, y); |
||
2624 | TB_AddMessage(TB_WHT_TXT.."SetPoint"); |
||
2625 | end |
||
2626 | |||
2627 | --/script GameTooltip:AddDoubleLine("text", "something", 1, 0, 1, 0, 0, 1); |
||
2628 | function TipBuddy_GameTooltip_AddLine( frame, text, r, g, b, nowrap ) |
||
2629 | if (not TipBuddy.targetUnit) then |
||
2630 | TipBuddy.targetUnit = "mouseover"; |
||
2631 | end |
||
2632 | |||
2633 | GameTooltip:tborgAddLine(text, r, g, b, nowrap); |
||
2634 | if (not text or text == "") then |
||
2635 | return; |
||
2636 | end |
||
2637 | --TB_AddMessage("GTTADDLINE!!!!!!!!!: adding = "..string.gsub(text, " ", "_")); |
||
2638 | if (not TipBuddyTooltip:IsVisible() and not TipBuddy_Main_Frame:IsVisible() and not TipBuddy.vis) then |
||
2639 | if (TipBuddy_SavedVars["general"].blizdefault == 1 and not TipBuddy.gotextras) then |
||
2640 | if (not TipBuddy.gtt_xtra) then |
||
2641 | TipBuddy.gtt_xtra = {}; |
||
2642 | end |
||
2643 | for i=1, 32, 1 do |
||
2644 | if (not TipBuddy.gtt_xtra[i]) then |
||
2645 | TipBuddy.gtt_xtra[i.."color"] = {}; |
||
2646 | TipBuddy.gtt_xtra[i.."color"].r, TipBuddy.gtt_xtra[i.."color"].g, TipBuddy.gtt_xtra[i.."color"].b = r, g, b; |
||
2647 | TipBuddy.gtt_xtra[i] = text; |
||
2648 | --TB_AddMessage("GTTADDLINE!!!!!!!!!: adding = "..text); |
||
2649 | break; |
||
2650 | end |
||
2651 | end |
||
2652 | end |
||
2653 | return; |
||
2654 | end |
||
2655 | |||
2656 | if (not TipBuddy.targetType) then |
||
2657 | TipBuddy.targetType = TipBuddy_TargetInfo_GetTargetType( TipBuddy.targetUnit ); |
||
2658 | end |
||
2659 | --TB_AddMessage("GTTADDLINE!!!!!!!!!: "..TipBuddy.targetType.." = '"..string.gsub(text, " ", "_").."'"); |
||
2660 | |||
2661 | if (TipBuddy_Main_Frame:IsVisible()) then |
||
2662 | local line; |
||
2663 | for i=1, 20, 1 do |
||
2664 | line = getglobal("TipBuddy_Xtra"..i.."_Text"); |
||
2665 | if (line:GetText() and line:IsShown()) then |
||
2666 | ----TB_AddMessage("line: "..i.." = occupied"); |
||
2667 | --return; |
||
2668 | else |
||
2669 | ----TB_AddMessage("line: "..i.." = free.....setting text: "..text); |
||
2670 | line:SetText(text); |
||
2671 | if (not r) then |
||
2672 | r, g, b = NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b; |
||
2673 | end |
||
2674 | line:SetTextColor(r, g, b); |
||
2675 | line:Show(); |
||
2676 | break; |
||
2677 | end |
||
2678 | end |
||
2679 | |||
2680 | TipBuddy_FrameHeights_Initialize(TipBuddy.targetType); |
||
2681 | TipBuddy_SetFrame_Width(); |
||
2682 | else |
||
2683 | if (text == " ") then |
||
2684 | return; |
||
2685 | end |
||
2686 | TipBuddyTooltip:AddLine(text, r, g, b, nowrap); |
||
2687 | TipBuddyTooltip:Show(); |
||
2688 | end |
||
2689 | |||
2690 | end |
||
2691 | |||
2692 | --/script GameTooltip:AddDoubleLine("text", "something", 1, 0, 1, 0, 0, 1); |
||
2693 | function TipBuddy_GameTooltip_AddDoubleLine( frame, textL, textR, Lr, Lg, Lb, Rr, Rg, Rb ) |
||
2694 | if (not TipBuddy.targetUnit) then |
||
2695 | TipBuddy.targetUnit = "mouseover"; |
||
2696 | end |
||
2697 | |||
2698 | GameTooltip:tborgAddDoubleLine(textL, textR, Lr, Lg, Lb, Rr, Rg, Rb); |
||
2699 | if (not textL or textL == "") then |
||
2700 | return; |
||
2701 | end |
||
2702 | --TB_AddMessage("GTTADDDOUBLELINE!!!!!!!!!: adding = "..textL); |
||
2703 | if (not TipBuddyTooltip:IsVisible() and not TipBuddy_Main_Frame:IsVisible() and not TipBuddy.vis) then |
||
2704 | if (TipBuddy_SavedVars["general"].blizdefault == 1 and not TipBuddy.gotextras) then |
||
2705 | if (not TipBuddy.gtt_xtra) then |
||
2706 | TipBuddy.gtt_xtra = {}; |
||
2707 | end |
||
2708 | if (not TipBuddy.gtt_xtraR) then |
||
2709 | TipBuddy.gtt_xtraR = {}; |
||
2710 | end |
||
2711 | for i=1, 32, 1 do |
||
2712 | if (not TipBuddy.gtt_xtra[i]) then |
||
2713 | TipBuddy.gtt_xtra[i.."color"] = {}; |
||
2714 | TipBuddy.gtt_xtra[i.."color"].r, TipBuddy.gtt_xtra[i.."color"].g, TipBuddy.gtt_xtra[i.."color"].b = Lr, Lg, Lb; |
||
2715 | TipBuddy.gtt_xtra[i] = textL; |
||
2716 | if (textR) then |
||
2717 | TipBuddy.gtt_xtraR[i.."color"] = {}; |
||
2718 | TipBuddy.gtt_xtraR[i.."color"].r, TipBuddy.gtt_xtraR[i.."color"].g, TipBuddy.gtt_xtraR[i.."color"].b = Rr, Rg, Rb; |
||
2719 | TipBuddy.gtt_xtraR[i] = textR; |
||
2720 | end |
||
2721 | --TB_AddMessage("GTTADDDOUBLELINE!!!!!!!!!: adding = "..textL.." : "..textR); |
||
2722 | break; |
||
2723 | end |
||
2724 | end |
||
2725 | end |
||
2726 | return; |
||
2727 | end |
||
2728 | if (not TipBuddy.targetType) then |
||
2729 | TipBuddy.targetType = TipBuddy_TargetInfo_GetTargetType( TipBuddy.targetUnit ); |
||
2730 | end |
||
2731 | ----TB_AddMessage("GTTADDDOUBLELINE!!!!!!!!!: "..TipBuddy.targetType.." = "..textL.." : "..textR); |
||
2732 | |||
2733 | if (TipBuddy_Main_Frame:IsVisible()) then |
||
2734 | local lineL, lineR; |
||
2735 | for i=1, 20, 1 do |
||
2736 | lineL = getglobal("TipBuddy_Xtra"..i.."_Text"); |
||
2737 | lineR = getglobal("TipBuddy_XtraR"..i.."_Text"); |
||
2738 | if (lineL:GetText() and lineL:IsShown()) then |
||
2739 | --return; |
||
2740 | else |
||
2741 | lineL:SetText(textL); |
||
2742 | if (not Lr) then |
||
2743 | Lr, Lg, Lb = NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b; |
||
2744 | end |
||
2745 | lineL:SetTextColor(Lr, Lg, Lb); |
||
2746 | lineL:Show(); |
||
2747 | lineR:SetText(textR); |
||
2748 | if (not Rr) then |
||
2749 | Rr, Rg, Rb = NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b; |
||
2750 | end |
||
2751 | lineR:SetTextColor(Rr, Rg, Rb); |
||
2752 | lineR:Show(); |
||
2753 | break; |
||
2754 | end |
||
2755 | end |
||
2756 | TipBuddy_FrameHeights_Initialize(TipBuddy.targetType); |
||
2757 | TipBuddy_SetFrame_Width(); |
||
2758 | else |
||
2759 | TipBuddyTooltip:AddDoubleLine(textL, textR, Lr, Lg, Lb, Rr, Rg, Rb); |
||
2760 | TipBuddyTooltip:Show(); |
||
2761 | --/script TipBuddyTooltip:AddDoubleLine("what", "the fuck");TipBuddyTooltip:Show(); |
||
2762 | end |
||
2763 | end |
||
2764 | |||
2765 | |||
2766 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2767 | -- UNITFRAME HOOKS |
||
2768 | -------------------------------------------------------------------------------------------------------------------------------------- |
||
2769 | --hook |
||
2770 | local originalUnitFrame_OnEnter; |
||
2771 | originalUnitFrame_OnEnter = UnitFrame_OnEnter; |
||
2772 | function UnitFrame_OnEnter() |
||
2773 | originalUnitFrame_OnEnter(); |
||
2774 | this.elapsed = 1.0; |
||
2775 | |||
2776 | TipBuddy.unitframe = 1; |
||
2777 | TipBuddy.hasTarget = 1; |
||
2778 | TipBuddy.targetUnit = this.unit; |
||
2779 | ----TB_AddMessage("entering unit frame: "..this.unit); |
||
2780 | --TipBuddy.targetType = TipBuddy_TargetInfo_GetTargetType( this.unit ); |
||
2781 | |||
2782 | GameTooltip_SetDefaultAnchor(TipBuddyTooltip, this); |
||
2783 | --GameTooltip:SetUnit(this.unit); |
||
2784 | TipBuddy_ShowUnitTooltip(this.unit); |
||
2785 | --/script TipBuddy_ShowUnitTooltip("target"); |
||
2786 | |||
2787 | -- hiding health and mana bars because they won't update |
||
2788 | if ( TipBuddy_SavedVars[TipBuddy.targetType].off == 1 ) then |
||
2789 | TipBuddy_TargetFrameHealthBar:Hide(); |
||
2790 | TipBuddy_TargetFrameManaBar:Hide(); |
||
2791 | -- setting frame size again |
||
2792 | TipBuddy_FrameHeights_Initialize(TipBuddy.targetType); |
||
2793 | TipBuddy_SetFrame_Width(); |
||
2794 | end |
||
2795 | end |
||
2796 | |||
2797 | --hook |
||
2798 | local originalUnitFrame_OnLeave; |
||
2799 | originalUnitFrame_OnLeave = UnitFrame_OnLeave; |
||
2800 | function UnitFrame_OnLeave() |
||
2801 | originalUnitFrame_OnLeave(); |
||
2802 | TipBuddy.unitframe = 0; |
||
2803 | TipBuddy.hasTarget = 0; |
||
2804 | TipBuddy.targetUnit = nil; |
||
2805 | ------TB_AddMessage("leaving unit frame"); |
||
2806 | TipBuddy.uName = nil; |
||
2807 | TipBuddy.vis = nil; |
||
2808 | end |
||
2809 | |||
2810 | --hook |
||
2811 | local originalUnitFrame_OnUpdate; |
||
2812 | originalUnitFrame_OnUpdate = UnitFrame_OnUpdate; |
||
2813 | function UnitFrame_OnUpdate(elapsed) |
||
2814 | originalUnitFrame_OnUpdate(elapsed); |
||
2815 | |||
2816 | if ( TipBuddy.unitframe == 1 and TipBuddyTooltip:IsOwned(this)) then |
||
2817 | this.elapsed = this.elapsed - elapsed; |
||
2818 | if ( this.elapsed <= 0 ) then |
||
2819 | this.elapsed = 1.0; |
||
2820 | --TB_AddMessage(this.unit); |
||
2821 | |||
2822 | TipBuddy_ShowUnitTooltip(this.unit, 1); |
||
2823 | -- hiding health and mana bars because they won't update |
||
2824 | TipBuddy_TargetFrameHealthBar:Hide(); |
||
2825 | TipBuddy_TargetFrameManaBar:Hide(); |
||
2826 | -- setting frame size again |
||
2827 | TipBuddy_FrameHeights_Initialize(TipBuddy.targetType); |
||
2828 | TipBuddy_SetFrame_Width(); |
||
2829 | |||
2830 | TipBuddy.hasTarget = 1; |
||
2831 | ----TB_AddMessage("TipBuddy.hasTarget = 1"); |
||
2832 | end |
||
2833 | end |
||
2834 | end |
||
2835 | |||
2836 | --hook |
||
2837 | local originalPlayerFrame_OnUpdate; |
||
2838 | originalPlayerFrame_OnUpdate = PlayerFrame_OnUpdate; |
||
2839 | function PlayerFrame_OnUpdate(elapsed) |
||
2840 | originalPlayerFrame_OnUpdate(elapsed); |
||
2841 | |||
2842 | if ( TipBuddy.unitframe == 1 and TipBuddyTooltip:IsOwned(this)) then |
||
2843 | this.elapsed = this.elapsed - elapsed; |
||
2844 | if ( this.elapsed <= 0 ) then |
||
2845 | this.elapsed = 1.0; |
||
2846 | ------TB_AddMessage(this.unit); |
||
2847 | TipBuddy_ShowUnitTooltip(this.unit, 1); |
||
2848 | -- hiding health and mana bars because they won't update |
||
2849 | TipBuddy_TargetFrameHealthBar:Hide(); |
||
2850 | TipBuddy_TargetFrameManaBar:Hide(); |
||
2851 | -- setting frame size again |
||
2852 | TipBuddy_FrameHeights_Initialize(TipBuddy.targetType); |
||
2853 | TipBuddy_SetFrame_Width(); |
||
2854 | TipBuddy.hasTarget = 1; |
||
2855 | ----TB_AddMessage("TipBuddy.hasTarget = 1"); |
||
2856 | end |
||
2857 | end |
||
2858 | end |