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 having |
||
7 | -- specifically to do with textures, |
||
8 | -- such as the PvP Rank Icon or buffs and debuffs. |
||
9 | --]] |
||
10 | |||
11 | local _G = getfenv(0) |
||
12 | local GameTooltip, UIParent,GTStatusBar = _G.GameTooltip, _G.UIParent, _G.GameTooltipStatusBar |
||
13 | local fClearAllPoints, fSetPoint, fHide,fShow,fGetScale = UIParent.ClearAllPoints, UIParent.SetPoint, UIParent.Hide, UIParent.Show, UIParent.GetScale |
||
14 | local txSetTexture, txSetTexCoord, txShow, txHide = _G.CharacterFramePortrait.SetTexture, _G.CharacterFramePortrait.SetTexCoord, _G.CharacterFramePortrait.Show, _G.CharacterFramePortrait.Hide |
||
15 | local db,EventFrame,ExtrasFrame |
||
16 | local tooltip = GameTooltip |
||
17 | local gtAddLine = GameTooltip.AddLine |
||
18 | local fsSetText, fsGetText, fsShow, fsHide = _G.GameTooltipTextLeft1.SetText, _G.GameTooltipTextLeft1.GetText, _G.GameTooltipTextLeft1.Show, _G.GameTooltipTextLeft1.Hide |
||
19 | local strformat= string.format |
||
20 | |||
21 | local TextureTable,NumTextures, NumUnusedTextures, BuffFrame, PvPTexture, PvPIconFrame, RTIcon, RTIconFrame |
||
22 | |||
23 | local i,dtable,tmp,tmp2 |
||
24 | |||
25 | _G.TinyTipIconsExists = true |
||
26 | |||
27 | local function SetTextureTable(path,count) |
||
28 | local tx |
||
29 | if NumUnusedTextures > 0 then |
||
30 | tx = TextureTable[ (NumTextures - NumUnusedTextures) + 1 ] |
||
31 | txSetTexture(tx, path) |
||
32 | if count and count > 0 then fsSetText(tx.fs, count ) else fsHide(tx.fs) end |
||
33 | txShow(tx) |
||
34 | NumUnusedTextures = NumUnusedTextures - 1 |
||
35 | else |
||
36 | NumTextures = NumTextures + 1 |
||
37 | tinsert(TextureTable, BuffFrame:CreateTexture()) |
||
38 | tx = TextureTable[ NumTextures ] |
||
39 | txSetTexture(tx, path) |
||
40 | tx.fs = ExtrasFrame:CreateFontString(nil, "ARTWORK", "NumberFontNormal") |
||
41 | if count and count > 0 then fsSetText(tx.fs, count) else fsHide(tx.fs) end |
||
42 | fsShow(tx.fs) |
||
43 | txShow(tx) |
||
44 | end |
||
45 | |||
46 | return tx |
||
47 | end |
||
48 | |||
49 | function TinyTipIcons_ResetTextureTable() |
||
50 | NumUnusedTextures = NumTextures |
||
51 | end |
||
52 | |||
53 | function TinyTipIcons_Init(_db,_EventFrame, _ExtrasFrame, _gtAddLine, _tooltip) |
||
54 | if _db then db = _db end |
||
55 | if _EventFrame then EventFrame = _EventFrame end |
||
56 | if _ExtrasFrame then ExtrasFrame = _ExtrasFrame end |
||
57 | if _gtAddLine then gtAddLine = _gtAddLine end |
||
58 | if _tooltip then tooltip = _tooltip end |
||
59 | |||
60 | if db["PvPIcon"] then |
||
61 | if not PvPIconFrame then PvPIconFrame = _G.CreateFrame("Frame", nil, ExtrasFrame) PvPIconFrame:Show() end |
||
62 | if not PvPTexture then PvPTexture = PvPIconFrame:CreateTexture(nil, "ARTWORK") end |
||
63 | PvPTexture:SetPoint(db["PvPIconAnchor1"] or "TOPRIGHT", tooltip, db["PvPIconAnchor2"] or "TOPLEFT", db["PvPIconOffX"] or 0, db["PvPIconOffY"] or 0) |
||
64 | txHide(PvPTexture) |
||
65 | PvPIconFrame:SetScale(db["PvPIconScale"] or 0.7) |
||
66 | end |
||
67 | if db["RTIcon"] then |
||
68 | if not RTIconFrame then |
||
69 | RTIconFrame = _G.CreateFrame("Frame", nil, ExtrasFrame) |
||
70 | RTIconFrame:Show() |
||
71 | end |
||
72 | RTIconFrame:SetScale(db["RTIconScale"] or 0.1) |
||
73 | if not RTIcon then |
||
74 | RTIcon = RTIconFrame:CreateTexture(nil, "ARTWORK") |
||
75 | txSetTexture(RTIcon, "Interface\\TargetingFrame\\UI-RaidTargetingIcons") |
||
76 | txHide(RTIcon) |
||
77 | end |
||
78 | if db["PvPIcon"] and PvPTexture then |
||
79 | RTIcon:SetPoint(db["RTIconAnchor1"] or "TOPLEFT", PvPTexture, db["RTIconAnchor2"] or "BOTTOMLEFT", db["RTIconOffX"] or 0, db["RTIconOffY"] or 0) |
||
80 | else |
||
81 | RTIcon:SetPoint(db["RTIconAnchor1"] or "TOPRIGHT", tooltip, db["RTIconAnchor2"] or "TOPLEFT", db["RTIconOffX"] or 0, db["RTIconOffY"] or 0) |
||
82 | end |
||
83 | end |
||
84 | if (db["Buffs"] or db["Debuffs"]) then |
||
85 | if not BuffFrame then |
||
86 | BuffFrame = _G.CreateFrame("Frame", nil, ExtrasFrame) |
||
87 | BuffFrame:Show() |
||
88 | end |
||
89 | BuffFrame:SetScale(db["BuffScale"] or 0.2) |
||
90 | if not TextureTable then |
||
91 | TextureTable = {} |
||
92 | NumTextures,NumUnusedTextures = 0,0 |
||
93 | end |
||
94 | else |
||
95 | TextureTable = nil |
||
96 | end |
||
97 | end |
||
98 | |||
99 | function TinyTipIcons_ResetRTIcon(unit,numRaid) |
||
100 | tmp = GetRaidTargetIndex(unit) |
||
101 | if numRaid and numRaid > 0 and tmp and tmp > 0 then |
||
102 | tmp = _G.UnitPopupButtons["RAID_TARGET_" .. tmp] |
||
103 | if tmp then |
||
104 | txSetTexCoord(RTIcon, tmp.tCoordLeft, tmp.tCoordRight, tmp.tCoordTop, tmp.tCoordBottom ) |
||
105 | txShow(RTIcon) |
||
106 | fShow(ExtrasFrame) |
||
107 | end |
||
108 | else |
||
109 | txHide(RTIcon) |
||
110 | end |
||
111 | end |
||
112 | |||
113 | function TinyTipIcons_ResetPvPIcon(rank,isplayer) |
||
114 | if isplayer and rank > 0 then |
||
115 | txSetTexture(PvPTexture, strformat("%s%02d", |
||
116 | "Interface\\PvPRankBadges\\PvPRank", |
||
117 | rank)) |
||
118 | txShow(PvPTexture) |
||
119 | fShow(ExtrasFrame) |
||
120 | else |
||
121 | txHide(PvPTexture) |
||
122 | end |
||
123 | end |
||
124 | |||
125 | function TinyTipIcons_HideUnusedTextures() |
||
126 | local tx |
||
127 | i = NumUnusedTextures |
||
128 | while i > 0 do |
||
129 | tx = TextureTable[ NumTextures - i + 1 ] |
||
130 | txHide(tx) |
||
131 | fsHide(tx.fs) |
||
132 | i = i - 1 |
||
133 | end |
||
134 | end |
||
135 | |||
136 | local lastTx |
||
137 | function TinyTipIcons_ShowBuffs(unit) |
||
138 | local flag, count = db["Buffs"], 0 |
||
139 | tmp,tmp2 = nil,nil |
||
140 | if flag then |
||
141 | if flag == 1 then num = 8 |
||
142 | else num = 32 end |
||
143 | for i = 1,num,1 do |
||
144 | tmp,tmp2 = _G.UnitBuff(unit, i, flag ~= 1) |
||
145 | if tmp then |
||
146 | count = count + 1 |
||
147 | if flag ~= 3 then |
||
148 | tmp = SetTextureTable( tmp,tmp2 ) |
||
149 | fClearAllPoints(tmp) |
||
150 | if count == 1 then |
||
151 | fSetPoint(tmp, db["BuffAnchor1"] or "BOTTOM", (db["ExtraTooltip"] and _G.TinyTipExtras_Tooltip) or GameTooltip, db["BuffAnchor2"] or "TOPLEFT", db["BuffOffX"] or 0, db["BuffOffY"] or (-2 / fGetScale(UIParent)) ) |
||
152 | else |
||
153 | fSetPoint(tmp, "LEFT", lastTx, "RIGHT", 0, 0) |
||
154 | end |
||
155 | fSetPoint(tmp.fs, "BOTTOM", tmp, "TOP", 0, 0) |
||
156 | lastTx = tmp |
||
157 | end |
||
158 | end |
||
159 | end |
||
160 | if flag == 3 and count > 0 then |
||
161 | gtAddLine( tooltip, strformat("%s %s: (|cFFFFFFFF%d|r)", _G.UnitClass("player"), TinyTipExtrasLocale_Buffs, count) ) |
||
162 | end |
||
163 | fShow(ExtrasFrame) |
||
164 | end |
||
165 | end |
||
166 | function TinyTipIcons_ShowDebuffs(unit) |
||
167 | local flag, count = db["Debuffs"], 0 |
||
168 | tmp,tmp2 = nil,nil |
||
169 | if flag then |
||
170 | if flag >= 4 then |
||
171 | if not dtable then dtable = {} end |
||
172 | for i,_ in TinyTipExtrasLocale_DebuffMap do |
||
173 | dtable[i] = 0 |
||
174 | end |
||
175 | end |
||
176 | if flag == 1 then num = 8 |
||
177 | else num = 32 end |
||
178 | for i = 1,num,1 do |
||
179 | if flag >= 4 and _G.UnitIsFriend(unit,"player") then |
||
180 | _,_,tmp = _G.UnitDebuff(unit,i,flag ~= 5) |
||
181 | if tmp then dtable[ tmp ] = dtable[ tmp ] + 1 end |
||
182 | else |
||
183 | tmp,tmp2 = _G.UnitDebuff(unit, i, flag ~= 1) |
||
184 | if tmp then |
||
185 | count = count + 1 |
||
186 | if flag ~= 3 then |
||
187 | tmp = SetTextureTable( tmp,tmp2 ) |
||
188 | fClearAllPoints(tmp) |
||
189 | if count == 1 then |
||
190 | fSetPoint(tmp, db["DebuffAnchor1"] or "TOP", (db["ManaBar"] and _G.TinyTipExtras_ManaBar) or GTStatusBar, db["DebuffAnchor2"] or "BOTTOMLEFT", db["DebuffOffX"] or 0, db["DebuffOffY"] or (2 / fGetScale(UIParent)) ) |
||
191 | else |
||
192 | fSetPoint(tmp, "LEFT", lastTx, "RIGHT", 0, 0) |
||
193 | end |
||
194 | fSetPoint(tmp.fs, "TOP", tmp, "BOTTOM", 0, 0) |
||
195 | lastTx = tmp |
||
196 | end |
||
197 | end |
||
198 | end |
||
199 | end |
||
200 | if dtable then |
||
201 | for i,num in dtable do |
||
202 | if num > 0 then |
||
203 | gtAddLine(tooltip, strformat( "%s: (|cFFFFFFFF%d|r)", TinyTipExtrasLocale_DebuffMap[ i ], num) ) |
||
204 | end |
||
205 | end |
||
206 | elseif flag == 3 and count > 0 then |
||
207 | gtAddLine(tooltip, strformat("%s: (|cFFFFFFFF%d|r)", TinyTipExtrasLocale_DispellableDebuffs, count) ) |
||
208 | end |
||
209 | fShow(ExtrasFrame) |
||
210 | end |
||
211 | end |