vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Set both the parent and the position of GameTooltip |
2 | function TitanTooltip_SetOwnerPosition(parent, anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset) |
||
3 | GameTooltip:SetOwner(parent, "ANCHOR_NONE"); |
||
4 | GameTooltip:SetPoint(anchorPoint, relativeToFrame, relativePoint, xOffset, yOffset); |
||
5 | end |
||
6 | |||
7 | function TitanTooltip_SetGameTooltip() |
||
8 | local fontscale = TitanPanelGetVar("FontScale"); |
||
9 | if ( this.tooltipCustomFunction ) then |
||
10 | this.tooltipCustomFunction(); |
||
11 | elseif ( this.tooltipTitle ) then |
||
12 | GameTooltip:SetText(this.tooltipTitle, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
13 | if ( this.tooltipText ) then |
||
14 | TitanTooltip_AddTooltipText(this.tooltipText); |
||
15 | end |
||
16 | end |
||
17 | if not TitanPanelGetVar("DisableFont") then |
||
18 | GameTooltip:SetScale(fontscale); |
||
19 | end |
||
20 | |||
21 | GameTooltip:Show(); |
||
22 | end |
||
23 | |||
24 | function TitanTooltip_SetPanelTooltip(id) |
||
25 | if not TitanPanelGetVar("ToolTipsShown") then |
||
26 | return; |
||
27 | end |
||
28 | |||
29 | if ( not this.tooltipCustomFunction and not this.tooltipTitle ) then |
||
30 | return; |
||
31 | end |
||
32 | |||
33 | TITAN_PANEL_DROPOFF_ADDON = id; |
||
34 | |||
35 | -- Set GameTooltip |
||
36 | local button = TitanUtils_GetButton(id); |
||
37 | local position = TitanPanelGetVar("Position"); |
||
38 | local scale = TitanPanelGetVar("Scale"); |
||
39 | local offscreenX, offscreenY; |
||
40 | local i = TitanPanel_GetButtonNumber(id); |
||
41 | |||
42 | if (TitanPanelSettings.Location[i] == "Bar") then |
||
43 | if position == TITAN_PANEL_PLACE_TOP then |
||
44 | TitanTooltip_SetOwnerPosition(button, "TOPLEFT", button:GetName(), "BOTTOMLEFT", -10, -4 * scale); |
||
45 | TitanTooltip_SetGameTooltip(); |
||
46 | |||
47 | -- Adjust GameTooltip position if it's off the screen |
||
48 | offscreenX, offscreenY = TitanUtils_GetOffscreen(GameTooltip); |
||
49 | if ( offscreenX == -1 ) then |
||
50 | TitanTooltip_SetOwnerPosition(button, "TOPLEFT", "TitanPanelBarButton", "BOTTOMLEFT", 0, 0); |
||
51 | TitanTooltip_SetGameTooltip(); |
||
52 | elseif ( offscreenX == 1 ) then |
||
53 | TitanTooltip_SetOwnerPosition(button, "TOPRIGHT", "TitanPanelBarButton", "BOTTOMRIGHT", 0, 0); |
||
54 | TitanTooltip_SetGameTooltip(); |
||
55 | end |
||
56 | else |
||
57 | TitanTooltip_SetOwnerPosition(button, "BOTTOMLEFT", button:GetName(), "TOPLEFT", -10, 4 * scale); |
||
58 | TitanTooltip_SetGameTooltip(); |
||
59 | |||
60 | -- Adjust GameTooltip position if it's off the screen |
||
61 | offscreenX, offscreenY = TitanUtils_GetOffscreen(GameTooltip); |
||
62 | if ( offscreenX == -1 ) then |
||
63 | TitanTooltip_SetOwnerPosition(button, "BOTTOMLEFT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "TOPLEFT", 0, 0); |
||
64 | TitanTooltip_SetGameTooltip(); |
||
65 | elseif ( offscreenX == 1 ) then |
||
66 | TitanTooltip_SetOwnerPosition(button, "BOTTOMRIGHT", "TitanPanel" .. TitanPanelSettings.Location[i] .."Button", "TOPRIGHT", 0, 0); |
||
67 | TitanTooltip_SetGameTooltip(); |
||
68 | end |
||
69 | end |
||
70 | else |
||
71 | TitanTooltip_SetOwnerPosition(button, "BOTTOMLEFT", button:GetName(), "TOPLEFT", -10, 4 * scale); |
||
72 | TitanTooltip_SetGameTooltip(); |
||
73 | |||
74 | -- Adjust GameTooltip position if it's off the screen |
||
75 | offscreenX, offscreenY = TitanUtils_GetOffscreen(GameTooltip); |
||
76 | if ( offscreenX == -1 ) then |
||
77 | TitanTooltip_SetOwnerPosition(button, "BOTTOMLEFT", "TitanPanelAuxBarButton", "TOPLEFT", 0, 0); |
||
78 | TitanTooltip_SetGameTooltip(); |
||
79 | elseif ( offscreenX == 1 ) then |
||
80 | TitanTooltip_SetOwnerPosition(button, "BOTTOMRIGHT", "TitanPanelAuxBarButton", "TOPRIGHT", 0, 0); |
||
81 | TitanTooltip_SetGameTooltip(); |
||
82 | end |
||
83 | end |
||
84 | end |
||
85 | |||
86 | function TitanTooltip_AddTooltipText(text) |
||
87 | if ( text ) then |
||
88 | -- Append a "\n" to the end |
||
89 | if ( string.sub(text, -1, -1) ~= "\n" ) then |
||
90 | text = text.."\n"; |
||
91 | end |
||
92 | |||
93 | for text1, text2 in string.gfind(text, "([^\t\n]*)\t?([^\t\n]*)\n") do |
||
94 | if ( text2 ~= "" ) then |
||
95 | GameTooltip:AddDoubleLine(text1, text2); |
||
96 | elseif ( text1 ~= "" ) then |
||
97 | GameTooltip:AddLine(text1); |
||
98 | else |
||
99 | GameTooltip:AddLine("\n"); |
||
100 | end |
||
101 | end |
||
102 | end |
||
103 | end |