Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Wildbreath-135052 | ------------------------------------------------------------------------------------- |
2 | Wildbreath-135052 | --Config |
|
3 | Wildbreath-135052 | ------------------------------------------------------------------------------------- |
|
4 | Wildbreath-135052 | local scale = 1.0 |
|
5 | Wildbreath-135052 | local relpoint = "BOTTOMRIGHT" |
|
6 | Wildbreath-135052 | local point = "BOTTOMRIGHT" |
|
7 | Wildbreath-135052 | local xpoint = -10 |
|
8 | Wildbreath-135052 | local ypoint = 215 |
|
9 | Wildbreath-135052 | local cursor = false |
|
10 | Wildbreath-135052 | local playerTitles = false |
|
11 | Wildbreath-135052 | local addonName = ... |
|
12 | Wildbreath-135052 | local texture = "Interface\\AddOns\\"..addonName.."\\textures\\tex_striped" --Health Bar |
|
13 | Wildbreath-135052 | local colorStatusBar = true |
|
14 | Wildbreath-135052 | local backdrop = { |
|
15 | Wildbreath-135052 | bgFile = "Interface\\Buttons\\WHITE8x8", |
|
16 | Wildbreath-135052 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
|
17 | Wildbreath-135052 | tile = true, |
|
18 | Wildbreath-135052 | tileSize = 16, |
|
19 | Wildbreath-135052 | edgeSize = 16, |
|
20 | Wildbreath-135052 | insets = {left = 3, right = 3, top = 3, bottom = 3}, |
|
21 | Wildbreath-135052 | } |
|
22 | Wildbreath-135052 | local bdcR, bdcG, bdcB = .05, .05, .05 --Background color |
|
23 | Wildbreath-135052 | local bdbcR, bdbcG, bdbcB = .3, .3, .3 --Border color |
|
24 | Wildbreath-135052 | local gColorR, gColorG, gColorB = 255/255, 20/255, 200/255 --Guild Color |
|
25 | Wildbreath-135052 | local TARGET = "|cfffed100"..TARGET..":|r " |
|
26 | Wildbreath-135052 | local TARGETYOU = "<You>" |
|
27 | Wildbreath-135052 | local worldBoss = "??" |
|
28 | Wildbreath-135052 | local rareElite = "Rare+" |
|
29 | Wildbreath-135052 | local rare = "Rare" |
|
30 | Wildbreath-135052 | ------------------------------------------------------------------------------------- |
|
31 | Wildbreath-135052 | --End Config |
|
32 | Wildbreath-135052 | ------------------------------------------------------------------------------------- |
|
33 | Wildbreath-135052 | ||
34 | Wildbreath-135052 | local function GetHexColor(color) |
|
35 | Wildbreath-135052 | return ("|cff%.2x%.2x%.2x"):format(color.r * 255, color.g * 255, color.b * 255) |
|
36 | Wildbreath-135052 | end |
|
37 | Wildbreath-135052 | ||
38 | Wildbreath-135052 | local ClassColors = {} |
|
39 | Wildbreath-135052 | for class, color in pairs(RAID_CLASS_COLORS) do |
|
40 | Wildbreath-135052 | ClassColors[class] = GetHexColor(RAID_CLASS_COLORS[class]) |
|
41 | Wildbreath-135052 | end |
|
42 | Wildbreath-135052 | ||
43 | Wildbreath-135052 | local Reaction = {} |
|
44 | Wildbreath-135052 | for i = 1, #FACTION_BAR_COLORS do |
|
45 | Wildbreath-135052 | Reaction[i] = GetHexColor(FACTION_BAR_COLORS[i]) |
|
46 | Wildbreath-135052 | end |
|
47 | Wildbreath-135052 | ||
48 | Wildbreath-135052 | local function getTargetLine(unit) |
|
49 | Wildbreath-135052 | if UnitIsUnit(unit, "player") then |
|
50 | Wildbreath-135052 | return ("|cffff0000%s|r"):format(TARGETYOU) |
|
51 | Wildbreath-135052 | elseif UnitIsPlayer(unit, "player")then |
|
52 | Wildbreath-135052 | return ClassColors[select(2, UnitClass(unit, "player"))]..UnitName(unit).."|r" |
|
53 | Wildbreath-135052 | elseif UnitReaction(unit, "player") then |
|
54 | Wildbreath-135052 | return ("%s%s|r"):format(Reaction[UnitReaction(unit, "player")], UnitName(unit)) |
|
55 | Wildbreath-135052 | else |
|
56 | Wildbreath-135052 | return ("|cffffffff%s|r"):format(UnitName(unit)) |
|
57 | Wildbreath-135052 | end |
|
58 | Wildbreath-135052 | end |
|
59 | Wildbreath-135052 | ||
60 | Wildbreath-135052 | function GameTooltip_UnitColor(unit) |
|
61 | Wildbreath-135052 | local r, g, b |
|
62 | Wildbreath-135052 | local reaction = UnitReaction(unit, "player") |
|
63 | Wildbreath-135052 | if reaction then |
|
64 | Wildbreath-135052 | r = FACTION_BAR_COLORS[reaction].r |
|
65 | Wildbreath-135052 | g = FACTION_BAR_COLORS[reaction].g |
|
66 | Wildbreath-135052 | b = FACTION_BAR_COLORS[reaction].b |
|
67 | Wildbreath-135052 | else |
|
68 | Wildbreath-135052 | r = 1.0 |
|
69 | Wildbreath-135052 | g = 1.0 |
|
70 | Wildbreath-135052 | b = 1.0 |
|
71 | Wildbreath-135052 | end |
|
72 | Wildbreath-135052 | if UnitPlayerControlled(unit) then |
|
73 | Wildbreath-135052 | if UnitCanAttack(unit, "player") then |
|
74 | Wildbreath-135052 | if not UnitCanAttack("player", unit) then |
|
75 | Wildbreath-135052 | r = 1.0 |
|
76 | Wildbreath-135052 | g = 1.0 |
|
77 | Wildbreath-135052 | b = 1.0 |
|
78 | Wildbreath-135052 | else |
|
79 | Wildbreath-135052 | r = FACTION_BAR_COLORS[2].r |
|
80 | Wildbreath-135052 | g = FACTION_BAR_COLORS[2].g |
|
81 | Wildbreath-135052 | b = FACTION_BAR_COLORS[2].b |
|
82 | Wildbreath-135052 | end |
|
83 | Wildbreath-135052 | elseif UnitCanAttack("player", unit) then |
|
84 | Wildbreath-135052 | r = FACTION_BAR_COLORS[4].r |
|
85 | Wildbreath-135052 | g = FACTION_BAR_COLORS[4].g |
|
86 | Wildbreath-135052 | b = FACTION_BAR_COLORS[4].b |
|
87 | Wildbreath-135052 | elseif UnitIsPVP(unit) then |
|
88 | Wildbreath-135052 | r = FACTION_BAR_COLORS[6].r |
|
89 | Wildbreath-135052 | g = FACTION_BAR_COLORS[6].g |
|
90 | Wildbreath-135052 | b = FACTION_BAR_COLORS[6].b |
|
91 | Wildbreath-135052 | end |
|
92 | Wildbreath-135052 | end |
|
93 | Wildbreath-135052 | if UnitIsPlayer(unit) then |
|
94 | Wildbreath-135052 | local class = select(2, UnitClass(unit)) |
|
95 | Wildbreath-135052 | if class then |
|
96 | Wildbreath-135052 | r = RAID_CLASS_COLORS[class].r |
|
97 | Wildbreath-135052 | g = RAID_CLASS_COLORS[class].g |
|
98 | Wildbreath-135052 | b = RAID_CLASS_COLORS[class].b |
|
99 | Wildbreath-135052 | end |
|
100 | Wildbreath-135052 | end |
|
101 | Wildbreath-135052 | return r, g, b |
|
102 | Wildbreath-135052 | end |
|
103 | Wildbreath-135052 | ||
104 | Wildbreath-135052 | GameTooltip:HookScript("OnTooltipSetUnit", function(self) |
|
105 | Wildbreath-135052 | local unit = select(2, self:GetUnit()) |
|
106 | Wildbreath-135052 | if unit then |
|
107 | Wildbreath-135052 | local level = UnitLevel(unit) |
|
108 | Wildbreath-135052 | local color = GetQuestDifficultyColor(level) |
|
109 | Wildbreath-135052 | local textLevel = ("%s%d|r"):format(GetHexColor(color), level) |
|
110 | Wildbreath-135052 | local unitPvP = "" |
|
111 | Wildbreath-135052 | local pattern = "%s" |
|
112 | Wildbreath-135052 | if level == "??" or level == -1 then |
|
113 | Wildbreath-135052 | textLevel = "|cffff0000??|r" |
|
114 | Wildbreath-135052 | end |
|
115 | Wildbreath-135052 | ||
116 | Wildbreath-135052 | if UnitIsPlayer(unit) then |
|
117 | Wildbreath-135052 | local unitRace = UnitRace(unit) |
|
118 | Wildbreath-135052 | local unitClass = UnitClass(unit) |
|
119 | Wildbreath-135052 | ||
120 | Wildbreath-135052 | if UnitIsAFK(unit) then |
|
121 | Wildbreath-135052 | self:AppendText((" |cff00cc00%s|r"):format(CHAT_FLAG_AFK)) |
|
122 | Wildbreath-135052 | elseif UnitIsDND(unit) then |
|
123 | Wildbreath-135052 | self:AppendText((" |cff00cc00%s|r"):format(CHAT_FLAG_DND)) |
|
124 | Wildbreath-135052 | end |
|
125 | Wildbreath-135052 | ||
126 | Wildbreath-135052 | for i = 2, GameTooltip:NumLines() do |
|
127 | Wildbreath-135052 | if _G["GameTooltipTextLeft"..i]:GetText():find(LEVEL) then |
|
128 | Wildbreath-135052 | pattern = pattern.." %s %s %s" |
|
129 | Wildbreath-135052 | _G["GameTooltipTextLeft"..i]:SetText((pattern):format(unitPvP, textLevel, unitRace, unitClass):trim()) |
|
130 | Wildbreath-135052 | break |
|
131 | Wildbreath-135052 | end |
|
132 | Wildbreath-135052 | end |
|
133 | Wildbreath-135052 | ||
134 | Wildbreath-135052 | local unitGuild = GetGuildInfo(unit) |
|
135 | Wildbreath-135052 | local text = GameTooltipTextLeft2:GetText() |
|
136 | Wildbreath-135052 | if unitGuild and text and text:find("^"..unitGuild) then |
|
137 | Wildbreath-135052 | GameTooltipTextLeft2:SetTextColor(gColorR, gColorG, gColorB) |
|
138 | Wildbreath-135052 | end |
|
139 | Wildbreath-135052 | else |
|
140 | Wildbreath-135052 | local text = GameTooltipTextLeft2:GetText() |
|
141 | Wildbreath-135052 | local reaction = UnitReaction(unit, "player") |
|
142 | Wildbreath-135052 | if reaction and text and not text:find(LEVEL) then |
|
143 | Wildbreath-135052 | GameTooltipTextLeft2:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b) |
|
144 | Wildbreath-135052 | end |
|
145 | Wildbreath-135052 | if level ~= 0 then |
|
146 | Wildbreath-135052 | ||
147 | Wildbreath-135052 | local class = UnitClassification(unit) |
|
148 | Wildbreath-135052 | if class == "worldboss" then |
|
149 | Wildbreath-135052 | textLevel = ("|cffff0000%s|r"):format(worldBoss) |
|
150 | Wildbreath-135052 | elseif class == "rareelite" then |
|
151 | Wildbreath-135052 | if level == -1 then |
|
152 | Wildbreath-135052 | textLevel = ("|cffff0000??+|r %s"):format(rareElite) |
|
153 | Wildbreath-135052 | else |
|
154 | Wildbreath-135052 | textLevel = ("%s%d+|r %s"):format(GetHexColor(color), level, rareElite) |
|
155 | Wildbreath-135052 | end |
|
156 | Wildbreath-135052 | elseif class == "elite" then |
|
157 | Wildbreath-135052 | if level == -1 then |
|
158 | Wildbreath-135052 | textLevel = "|cffff0000??+|r" |
|
159 | Wildbreath-135052 | else |
|
160 | Wildbreath-135052 | textLevel = ("%s%d+|r"):format(GetHexColor(color), level) |
|
161 | Wildbreath-135052 | end |
|
162 | Wildbreath-135052 | elseif class == "rare" then |
|
163 | Wildbreath-135052 | if level == -1 then |
|
164 | Wildbreath-135052 | textLevel = ("|cffff0000??|r %s"):format(rare) |
|
165 | Wildbreath-135052 | else |
|
166 | Wildbreath-135052 | textLevel = ("%s%d|r %s"):format(GetHexColor(color), level, rare) |
|
167 | Wildbreath-135052 | end |
|
168 | Wildbreath-135052 | end |
|
169 | Wildbreath-135052 | ||
170 | Wildbreath-135052 | local creatureType = UnitCreatureType(unit) |
|
171 | Wildbreath-135052 | for i = 2, GameTooltip:NumLines() do |
|
172 | Wildbreath-135052 | if _G["GameTooltipTextLeft"..i]:GetText():find(LEVEL) then |
|
173 | Wildbreath-135052 | pattern = pattern.." %s %s" |
|
174 | Wildbreath-135052 | _G["GameTooltipTextLeft"..i]:SetText((pattern):format(unitPvP, textLevel, creatureType or ""):trim()) |
|
175 | Wildbreath-135052 | break |
|
176 | Wildbreath-135052 | end |
|
177 | Wildbreath-135052 | end |
|
178 | Wildbreath-135052 | end |
|
179 | Wildbreath-135052 | end |
|
180 | Wildbreath-135052 | ||
181 | Wildbreath-135052 | if UnitIsPVP(unit) then |
|
182 | Wildbreath-135052 | for i = 2, GameTooltip:NumLines() do |
|
183 | Wildbreath-135052 | if _G["GameTooltipTextLeft"..i]:GetText():find(PVP) then |
|
184 | Wildbreath-135052 | _G["GameTooltipTextLeft"..i]:SetText(nil) |
|
185 | Wildbreath-135052 | break |
|
186 | Wildbreath-135052 | end |
|
187 | Wildbreath-135052 | end |
|
188 | Wildbreath-135052 | end |
|
189 | Wildbreath-135052 | ||
190 | Wildbreath-135052 | if (UnitExists(unit .. "target")) then |
|
191 | Wildbreath-135052 | local text = ("%s%s"):format(TARGET, getTargetLine(unit.."target")) |
|
192 | Wildbreath-135052 | GameTooltip:AddLine(text) |
|
193 | Wildbreath-135052 | end |
|
194 | Wildbreath-135052 | ||
195 | Wildbreath-135052 | if colorStatusBar then |
|
196 | Wildbreath-135052 | local r, g, b = GameTooltip_UnitColor(unit) |
|
197 | Wildbreath-135052 | GameTooltipStatusBar:SetStatusBarColor(r, g, b) |
|
198 | Wildbreath-135052 | end |
|
199 | Wildbreath-135052 | ||
200 | Wildbreath-135052 | if (UnitIsDead(unit) or UnitIsGhost(unit)) then |
|
201 | Wildbreath-135052 | GameTooltipStatusBar:Hide() |
|
202 | Wildbreath-135052 | else |
|
203 | Wildbreath-135052 | self:AddLine(" ") |
|
204 | Wildbreath-135052 | GameTooltipStatusBar:Show() |
|
205 | Wildbreath-135052 | GameTooltipStatusBar:ClearAllPoints() |
|
206 | Wildbreath-135052 | GameTooltipStatusBar:SetPoint("LEFT", self:GetName().."TextLeft"..self:NumLines(), "LEFT", 0, -1) |
|
207 | Wildbreath-135052 | GameTooltipStatusBar:SetPoint("RIGHT", self, "RIGHT", -10, -1) |
|
208 | Wildbreath-135052 | end |
|
209 | Wildbreath-135052 | end |
|
210 | Wildbreath-135052 | end) |
|
211 | Wildbreath-135052 | ||
212 | Wildbreath-135052 | GameTooltipStatusBar:SetStatusBarTexture(texture) |
|
213 | Wildbreath-135052 | GameTooltipStatusBar:SetHeight(7) |
|
214 | Wildbreath-135052 | local bg = GameTooltipStatusBar:CreateTexture(nil, "BACKGROUND") |
|
215 | Wildbreath-135052 | bg:SetAllPoints(GameTooltipStatusBar) |
|
216 | Wildbreath-135052 | bg:SetTexture(texture) |
|
217 | Wildbreath-135052 | bg:SetVertexColor(0.5, 0.5, 0.5, 0.5) |
|
218 | Wildbreath-135052 | ||
219 | Wildbreath-135052 | local function ShortValue(value) |
|
220 | Wildbreath-135052 | if value >= 1e7 then |
|
221 | Wildbreath-135052 | return ('%.1fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') |
|
222 | Wildbreath-135052 | elseif value >= 1e6 then |
|
223 | Wildbreath-135052 | return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') |
|
224 | Wildbreath-135052 | elseif value >= 1e5 then |
|
225 | Wildbreath-135052 | return ('%.0fk'):format(value / 1e3) |
|
226 | Wildbreath-135052 | elseif value >= 1e3 then |
|
227 | Wildbreath-135052 | return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1') |
|
228 | Wildbreath-135052 | else |
|
229 | Wildbreath-135052 | return value |
|
230 | Wildbreath-135052 | end |
|
231 | Wildbreath-135052 | end |
|
232 | Wildbreath-135052 | ||
233 | Wildbreath-135052 | GameTooltipStatusBar:SetScript("OnValueChanged", function(self, value) |
|
234 | Wildbreath-135052 | if not value then |
|
235 | Wildbreath-135052 | return |
|
236 | Wildbreath-135052 | end |
|
237 | Wildbreath-135052 | local min, max = self:GetMinMaxValues() |
|
238 | Wildbreath-135052 | if (value < min) or (value > max) then |
|
239 | Wildbreath-135052 | return |
|
240 | Wildbreath-135052 | end |
|
241 | Wildbreath-135052 | local unit = select(2, GameTooltip:GetUnit()) |
|
242 | Wildbreath-135052 | if unit then |
|
243 | Wildbreath-135052 | min, max = UnitHealth(unit), UnitHealthMax(unit) |
|
244 | Wildbreath-135052 | if not self.text then |
|
245 | Wildbreath-135052 | self.text = self:CreateFontString(nil, "OVERLAY") |
|
246 | Wildbreath-135052 | self.text:SetPoint("CENTER", GameTooltipStatusBar) |
|
247 | Wildbreath-135052 | self.text:SetFont("Fonts\\FRIZQT__.TTF", 11, "THINOUTLINE") |
|
248 | Wildbreath-135052 | end |
|
249 | Wildbreath-135052 | self.text:Show() |
|
250 | Wildbreath-135052 | local hp = ShortValue(min).." / "..ShortValue(max) |
|
251 | Wildbreath-135052 | self.text:SetText(hp) |
|
252 | Wildbreath-135052 | end |
|
253 | Wildbreath-135052 | end) |
|
254 | Wildbreath-135052 | ||
255 | Wildbreath-135052 | local Tooltips = {GameTooltip, ItemRefTooltip, ShoppingTooltip1, ShoppingTooltip2, ShoppingTooltip3} |
|
256 | Wildbreath-135052 | for i, v in ipairs(Tooltips) do |
|
257 | Wildbreath-135052 | v:SetBackdrop(backdrop) |
|
258 | Wildbreath-135052 | v:SetScale(scale) |
|
259 | Wildbreath-135052 | v:SetScript("OnShow", function(self) |
|
260 | Wildbreath-135052 | self:SetBackdropColor(bdcR, bdcG, bdcB) |
|
261 | Wildbreath-135052 | local name, item = self:GetItem() |
|
262 | Wildbreath-135052 | if(item) then |
|
263 | Wildbreath-135052 | local quality = select(3, GetItemInfo(item)) |
|
264 | Wildbreath-135052 | if(quality) then |
|
265 | Wildbreath-135052 | local r, g, b = GetItemQualityColor(quality) |
|
266 | Wildbreath-135052 | self:SetBackdropBorderColor(r, g, b) |
|
267 | Wildbreath-135052 | end |
|
268 | Wildbreath-135052 | else |
|
269 | Wildbreath-135052 | self:SetBackdropBorderColor(bdbcR, bdbcG, bdbcB) |
|
270 | Wildbreath-135052 | end |
|
271 | Wildbreath-135052 | end) |
|
272 | Wildbreath-135052 | end |
|
273 | Wildbreath-135052 | ||
274 | Wildbreath-135052 | hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent) |
|
275 | Wildbreath-135052 | local frame = GetMouseFocus() |
|
276 | Wildbreath-135052 | if cursor and frame == WorldFrame then |
|
277 | Wildbreath-135052 | tooltip:SetOwner(parent, "ANCHOR_CURSOR") |
|
278 | Wildbreath-135052 | else |
|
279 | Wildbreath-135052 | tooltip:SetOwner(parent, "ANCHOR_NONE") |
|
280 | Wildbreath-135052 | tooltip:SetPoint(point, UIParent, relpoint, xpoint, ypoint) |
|
281 | Wildbreath-135052 | end |
|
282 | Wildbreath-135052 | tooltip.default = 1 |
|
283 | Wildbreath-135052 | end) |
|
284 | Wildbreath-135052 | ||
285 | Wildbreath-135052 | if playerTitles then return end |
|
286 | Wildbreath-135052 | GameTooltip:HookScript("OnTooltipSetUnit", function(self) |
|
287 | Wildbreath-135052 | local unitName, unit = self:GetUnit() |
|
288 | Wildbreath-135052 | if unit and UnitIsPlayer(unit) then |
|
289 | Wildbreath-135052 | local title = UnitPVPName(unit) |
|
290 | Wildbreath-135052 | if title then |
|
291 | Wildbreath-135052 | title = title:gsub(unitName, "") |
|
292 | Wildbreath-135052 | name = GameTooltipTextLeft1:GetText() |
|
293 | Wildbreath-135052 | name = name:gsub(title, "") |
|
294 | Wildbreath-135052 | if name then GameTooltipTextLeft1:SetText(name) end |
|
295 | Wildbreath-135052 | end |
|
296 | Wildbreath-135052 | end |
|
297 | Wildbreath-135052 | end) |