vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | -- Name: TinyTip |
||
3 | -- Author: Thrae of Maelstrom (aka "Matthew Carras") |
||
4 | -- Release Date: 6-25-06 |
||
5 | -- |
||
6 | -- These functions include more extragant features, |
||
7 | -- such as the PvP Rank Icon or buffs and debuffs, or |
||
8 | -- and extra tooltip. This is LoadedOnDemand by TinyTip. |
||
9 | --]] |
||
10 | |||
11 | local _G = getfenv(0) |
||
12 | local GameTooltip, UIParent,GTStatusBar = _G.GameTooltip, _G.UIParent, _G.GameTooltipStatusBar |
||
13 | local fClearAllPoints, fSetPoint, fHide,fShow, fGetScript, fSetScript = UIParent.ClearAllPoints, UIParent.SetPoint, UIParent.Hide, UIParent.Show, UIParent.GetScript, UIParent.SetScript |
||
14 | local db,EventFrame,ExtrasFrame |
||
15 | local tooltip = GameTooltip |
||
16 | local gtAddLine, gtNumLines = GameTooltip.AddLine, GameTooltip.NumLines |
||
17 | local fsSetText, fsGetText, fsShow, fsHide, fsIsShown, fsGetTextColor = _G.GameTooltipTextLeft1.SetText, _G.GameTooltipTextLeft1.GetText, _G.GameTooltipTextLeft1.Show, _G.GameTooltipTextLeft1.Hide, _G.GameTooltipTextLeft1.IsShown, _G.GameTooltipTextLeft1.GetTextColor |
||
18 | local strformat= string.format |
||
19 | |||
20 | local acehook |
||
21 | |||
22 | local tiplib = _G.AceLibrary:GetInstance("TipLib-1.0") |
||
23 | |||
24 | local PvPTexture, ExtraTooltip, ManaBar |
||
25 | |||
26 | local i,tmp,tmp2,tmp3 |
||
27 | |||
28 | _G.TinyTipExtrasExists = true |
||
29 | |||
30 | local SetUnit_IsHooked, FadeOut_IsHooked |
||
31 | |||
32 | --[[ |
||
33 | -- This is the AnchorTooltipTable table. As it requires you know the frame name |
||
34 | -- of the tooltip you wish to anchor, I am going to make it static. Add entries |
||
35 | -- into the table as so: |
||
36 | |||
37 | ["TooltipName"] = { |
||
38 | ["Anchor"] = "BOTTOMRIGHT", |
||
39 | ["OffX"] = -50, |
||
40 | ["OffY"] = 13 |
||
41 | } |
||
42 | -- |
||
43 | --]] |
||
44 | |||
45 | --[[ |
||
46 | local AnchorTooltipTable = { |
||
47 | ["TooltipName"] = { |
||
48 | ["Anchor"] = "BOTTOMRIGHT", |
||
49 | ["OffX"] = -50, |
||
50 | ["OffY"] = 13 |
||
51 | } |
||
52 | } |
||
53 | --]] |
||
54 | |||
55 | |||
56 | local Original_GameTooltip_OnTooltipCleared, OnTooltipCleared_IsHooked |
||
57 | local function OnTooltipCleared(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) |
||
58 | if Original_GameTooltip_OnTooltipCleared then |
||
59 | Original_GameTooltip_OnTooltipCleared(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) |
||
60 | end |
||
61 | |||
62 | _G.TinyTip_OnTooltipCleared(this,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) |
||
63 | |||
64 | if ExtraTooltip then |
||
65 | ExtraTooltip:Hide() |
||
66 | end |
||
67 | if ExtrasFrame then |
||
68 | fHide(ExtrasFrame) |
||
69 | if TinyTipIcons_ResetTextureTable then TinyTipIcons_ResetTextureTable() end |
||
70 | end |
||
71 | if ManaBar then |
||
72 | fHide(ManaBar) |
||
73 | end |
||
74 | end |
||
75 | |||
76 | local function ManaBar_Init() |
||
77 | if GameTooltip.unit then |
||
78 | tmp = _G.UnitManaMax( GameTooltip.unit ) |
||
79 | ManaBar:SetMinMaxValues(0, tmp or 100) |
||
80 | -- If disconnected |
||
81 | if not _G.UnitIsConnected(GameTooltip.unit) then |
||
82 | ManaBar:SetValue( tmp or 100 ) |
||
83 | ManaBar:SetStatusBarColor(0.5, 0.5, 0.5) |
||
84 | else |
||
85 | ManaBar:SetValue( _G.UnitMana( GameTooltip.unit ) or 100) |
||
86 | tmp = _G.ManaBarColor[ _G.UnitPowerType( GameTooltip.unit ) ] |
||
87 | ManaBar:SetStatusBarColor( tmp.r, tmp.g, tmp.b ) |
||
88 | end |
||
89 | end |
||
90 | end |
||
91 | local function ManaBar_OnEvent() |
||
92 | if _G.event == "UNIT_MANA" or _G.event == "UNIT_ENERGY" or _G.event == "UNIT_RAGE" then |
||
93 | if _G.arg1 and _G.arg1 == GameTooltip.unit then |
||
94 | ManaBar_Init() |
||
95 | end |
||
96 | elseif _G.event == "UNIT_DISPLAYPOWER" then |
||
97 | if _G.arg1 and _G.arg1 == GameTooltip.unit and _G.UnitPowerType( GameTooltip.unit ) and _G.UnitPowerType( GameTooltip.unit ) > 0 then |
||
98 | tmp = _G.ManaBarColor[ _G.UnitPowerType( GameTooltip.unit ) ] |
||
99 | ManaBar:SetStatusBarColor( tmp.r, tmp.g, tmp.b ) |
||
100 | end |
||
101 | end |
||
102 | end |
||
103 | |||
104 | local function ATTOnUpdate() |
||
105 | fClearAllPoints(this) |
||
106 | fSetPoint(this, this.TTAnchor or "BOTTOMRIGHT", UIParent, this.TTAnchor or "BOTTOMRIGHT", this.TTOffX or 0, this.TTOffY or 0) |
||
107 | end |
||
108 | |||
109 | function TinyTipExtras_CopyGameTooltip() |
||
110 | tmp = gtNumLines(GameTooltip) |
||
111 | for i = 1, tmp do |
||
112 | tmp2 = _G[ strformat("GameTooltipTextLeft%d", i) ] |
||
113 | tmp3 = _G[ strformat("GameTooltipTextRight%d", i) ] |
||
114 | if tmp2 and tmp3 and fsIsShown(tmp2) and fsIsShown(tmp3) and fsGetText(tmp2) and fsGetText(tmp3) then |
||
115 | ExtraTooltip:AddLine( fsGetText(tmp2), fsGetTextColor(tmp2) or unpack{1,1,1}, nil, fsGetText(tmp3), fsGetTextColor(tmp3) ) |
||
116 | elseif tmp2 and fsGetText(tmp2) then |
||
117 | ExtraTooltip:AddLine( fsGetText(tmp2), fsGetTextColor(tmp2) or unpack{1,1,1} ) |
||
118 | end |
||
119 | end |
||
120 | end |
||
121 | |||
122 | function TinyTipExtras_ATTUnhook(k) |
||
123 | if db["AnchorTooltipTable"] and db["AnchorTooltipTable"][ k ] then |
||
124 | if acehook:IsHooked( AnchorTooltipTable[ k ], "OnUpdate") then |
||
125 | acehook:Unhook( AnchorTooltipTable[ k ], "OnUpdate") |
||
126 | end |
||
127 | end |
||
128 | end |
||
129 | |||
130 | function TinyTipExtras_Init(_db,_EventFrame,_acehook) |
||
131 | if _db then db = _db end |
||
132 | if _EventFrame then EventFrame = _EventFrame end |
||
133 | if _acehook then acehook = _acehook end |
||
134 | |||
135 | if acehook and not acehook:IsHooked(GameTooltip, "OnTooltipCleared") then -- most sure-fire way to hide something |
||
136 | acehook:HookScript(GameTooltip, "OnTooltipCleared", OnTooltipCleared) |
||
137 | Original_GameTooltip_OnTooltipCleared = acehook.hooks[GameTooltip]["OnTooltipCleared"].orig |
||
138 | end |
||
139 | if acehook and AnchorTooltipTable then |
||
140 | local k,v |
||
141 | for k,v in AnchorTooltipTable do |
||
142 | if _G[ k ] then |
||
143 | if not acehook:IsHooked( _G[ k ], "OnUpdate") then |
||
144 | if v then |
||
145 | if v.Anchor then |
||
146 | _G[ k ].TTAnchor = v.Anchor |
||
147 | end |
||
148 | if v.OffX then |
||
149 | _G[ k ].TTOffX = v.OffX |
||
150 | end |
||
151 | if v.OffY then |
||
152 | _G[ k ].TTOffY = v.OffY |
||
153 | end |
||
154 | end |
||
155 | acehook:HookScript( _G[ k ], "OnUpdate", ATTOnUpdate) |
||
156 | end |
||
157 | end |
||
158 | end |
||
159 | end |
||
160 | |||
161 | if db["ManaBar"] then |
||
162 | if not ManaBar then |
||
163 | ManaBar = _G.CreateFrame("StatusBar", "TinyTipExtras_ManaBar", GameTooltip) |
||
164 | ManaBar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-TargetingFrame-BarFill") |
||
165 | ManaBar:SetHeight(8) |
||
166 | ManaBar:SetPoint("TOPLEFT", GTStatusBar, "BOTTOMLEFT", 0, 0) |
||
167 | ManaBar:SetPoint("TOPRIGHT", GTStatusBar, "BOTTOMRIGHT", 0, 0) |
||
168 | ManaBar:SetScript("OnShow", ManaBar_Init) |
||
169 | ManaBar:SetScript("OnEvent", ManaBar_OnEvent) |
||
170 | ManaBar:RegisterEvent("UNIT_DISPLAYPOWER") |
||
171 | ManaBar:RegisterEvent("UNIT_MANA") |
||
172 | ManaBar:RegisterEvent("UNIT_ENERGY") |
||
173 | ManaBar:RegisterEvent("UNIT_RAGE") |
||
174 | end |
||
175 | end |
||
176 | |||
177 | if db["ExtraTooltip"] then |
||
178 | if not ExtraTooltip then |
||
179 | ExtraTooltip = tiplib:CreatePsuedoTooltip("TinyTipExtras_Tooltip", UIParent) |
||
180 | ExtraTooltip:SetScale( db["Scale"] or 1.0 ) |
||
181 | end |
||
182 | |||
183 | if db["Compact"] then _G.TinyTip_UnCompactGameTooltip() end |
||
184 | GTStatusBar:SetPoint("TOPLEFT", ExtraTooltip, "BOTTOMLEFT", 2, -1) |
||
185 | GTStatusBar:SetPoint("TOPRIGHT", ExtraTooltip, "BOTTOMRIGHT", -2, -1) |
||
186 | GTStatusBar:SetParent(ExtraTooltip) |
||
187 | if ManaBar then ManaBar:SetParent(ExtraTooltip) end |
||
188 | if ExtrasFrame then ExtrasFrame:SetParent(ExtraTooltip) end |
||
189 | if _G.TinyTipAnchor_ResetReferences then |
||
190 | _G.TinyTipAnchor_ResetReferences(ExtraTooltip.ClearAllPoints, ExtraTooltip.SetPoint, ExtraTooltip.SetOwner) |
||
191 | end |
||
192 | if db["ExtraTooltip"] == 1 then |
||
193 | _G.TinyTip_ResetReferences(ExtraTooltip.AddLine, ExtraTooltip.AddDoubleLine, ExtraTooltip, ExtraTooltip) |
||
194 | gtAddLine = ExtraTooltip.AddLine |
||
195 | tooltip = ExtraTooltip |
||
196 | if _G.TinyTipTargets_ResetReferences then |
||
197 | _G.TinyTipTargets_ResetReferences(ExtraTooltip.AddLine, ExtraTooltip.AddDoubleLines, ExtraTooltip) |
||
198 | end |
||
199 | else |
||
200 | _G.TinyTip_ResetReferences(GameTooltip.AddLine, GameTooltip.AddDoubleLine, ExtraTooltip, GameTooltip) |
||
201 | gtAddLine = GameTooltip.AddLine |
||
202 | tooltip = GameTooltip |
||
203 | if _G.TinyTipTargets_ResetReferences then |
||
204 | _G.TinyTipTargets_ResetReferences(GameTooltip.AddLine, GameTooltip.AddDoubleLines, GameTooltip) |
||
205 | end |
||
206 | end |
||
207 | else |
||
208 | GameTooltip:SetScale( db["Scale"] or 1.0 ) |
||
209 | GTStatusBar:SetPoint("TOPLEFT", GameTooltip, "BOTTOMLEFT", 2, -1) |
||
210 | GTStatusBar:SetPoint("TOPRIGHT", GameTooltip, "BOTTOMRIGHT", -2, -1) |
||
211 | GTStatusBar:SetParent(GameTooltip) |
||
212 | if ManaBar then ManaBar:SetParent(GameTooltip) end |
||
213 | if ExtrasFrame then ExtrasFrame:SetParent(GameTooltip) end |
||
214 | _G.TinyTip_ResetReferences(GameTooltip.AddLine, GameTooltip.AddDoubleLine, GameTooltip, GameTooltip) |
||
215 | gtAddLine = GameTooltip.AddLine |
||
216 | tooltip = GameTooltip |
||
217 | if _G.TinyTipAnchor_ResetReferences then |
||
218 | _G.TinyTipAnchor_ResetReferences(GameTooltip.ClearAllPoints, GameTooltip.SetPoint, GameTooltip.SetOwner) |
||
219 | end |
||
220 | if _G.TinyTipTargets_ResetReferences then |
||
221 | _G.TinyTipTargets_ResetReferences(GameTooltip.AddLine, GameTooltip.AddDoubleLines, GameTooltip) |
||
222 | end |
||
223 | end |
||
224 | |||
225 | if db["PvPIcon"] or db["Buffs"] or db["Debuffs"] or db["RTIcon"] then |
||
226 | if not ExtrasFrame then |
||
227 | ExtrasFrame = _G.CreateFrame("Frame", "TinyTipExtras_Frame", GameTooltip) |
||
228 | end |
||
229 | if TinyTipIcons_Init then TinyTipIcons_Init(db, EventFrame, ExtrasFrame, gtAddLine, tooltip) end |
||
230 | end |
||
231 | end |