comparison Modules/PaperDoll.lua @ 133:86621c60512b v7.3.2-20171222

- Fixed AP calc tooltip appearing while hidden - Fixed PaperDoll relic tooltips missing nether crucible info
author Nenue
date Fri, 22 Dec 2017 20:36:40 -0500
parents 15a7f27b11e6
children 4979b5cca6de
comparison
equal deleted inserted replaced
132:4cb1d2a0c110 133:86621c60512b
85 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') 85 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
86 self:RegisterEvent('ARTIFACT_RELIC_INFO_RECEIVED') 86 self:RegisterEvent('ARTIFACT_RELIC_INFO_RECEIVED')
87 self:RegisterEvent('ARTIFACT_UPDATE') 87 self:RegisterEvent('ARTIFACT_UPDATE')
88 88
89 self:MarkForUpdate() 89 self:MarkForUpdate()
90
91
90 end 92 end
91 93
92 function VeneerPaperDollMixin:MarkForUpdate() 94 function VeneerPaperDollMixin:MarkForUpdate()
93 for frame, overlays in pairs(slot_overlays) do 95 for frame, overlays in pairs(slot_overlays) do
94 for slot, overlay in pairs(overlays) do 96 for slot, overlay in pairs(overlays) do
156 overlay:Hide() 158 overlay:Hide()
157 end 159 end
158 end 160 end
159 end 161 end
160 162
161
162
163 function VeneerPaperDollMixin:OnEvent(event, arg) 163 function VeneerPaperDollMixin:OnEvent(event, arg)
164 print(event, arg) 164 print(event, arg)
165 if event == 'ADDON_LOADED' then 165 if event == 'ADDON_LOADED' then
166 if arg == 'Blizzard_InspectUI' then 166 if arg == 'Blizzard_InspectUI' then
167 self:SetupInspectFrame() 167 self:SetupInspectFrame()
169 if arg == 'Blizzard_ArtifactUI' then 169 if arg == 'Blizzard_ArtifactUI' then
170 self:SetupArtifactUI() 170 self:SetupArtifactUI()
171 self:MarkForUpdate() 171 self:MarkForUpdate()
172 end 172 end
173 elseif event == 'ARTIFACT_UPDATE' then 173 elseif event == 'ARTIFACT_UPDATE' then
174 self:ScoopRelics()
174 if artifactSlot then 175 if artifactSlot then
175 artifactSlot:Update(true) 176 artifactSlot.isDirty = true
176 end 177 end
177 elseif event == 'ARTIFACT_RELIC_INFO_RECEIVED' then 178 elseif event == 'ARTIFACT_RELIC_INFO_RECEIVED' then
178 if artifactSlot then 179 if artifactSlot then
179 artifactSlot:Update(true) 180 artifactSlot.isDirty = true
180 end 181 end
181 else 182 else
182 if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then 183 if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then
183 if arg ~= 'player' then 184 if arg ~= 'player' then
184 return 185 return
193 194
194 function VeneerPaperDollSlotMixin:OnLoad() 195 function VeneerPaperDollSlotMixin:OnLoad()
195 self.SocketText = {} 196 self.SocketText = {}
196 self.SocketType = {} 197 self.SocketType = {}
197 self.SocketLink = {} 198 self.SocketLink = {}
199 self.SocketForge = {}
198 end 200 end
199 function VeneerPaperDollSlotMixin:OnShow() 201 function VeneerPaperDollSlotMixin:OnShow()
200 if self.isDirty then 202 if self.isDirty then
201 self:Update() 203 self:Update()
202 end 204 end
203 end 205 end
206
207 function VeneerPaperDollSlotMixin:OnHide()
208 if GameTooltip:IsOwned(self) then
209 GameTooltip:Hide()
210 end
211 end
212
204 function VeneerPaperDollSlotMixin:OnUpdate() 213 function VeneerPaperDollSlotMixin:OnUpdate()
205 if self.isDirty then 214 if self.isDirty then
206 --print('|cFF00FF00pushing update for', self:GetID()) 215 --print('|cFF00FF00pushing update for', self:GetID())
207 self:Update() 216 self:Update()
208 end 217 end
209 218
210 if self.checkRelic then 219 if self.checkRelic then
211 self.tooltipLink = nil 220 local setTip
212 for i = 1, 3 do 221 for i = 1, 3 do
213 if self.SocketLink[i] and self.Sockets.SocketIcon[i]:IsMouseOver() then 222 if self.SocketType[i] and self.Sockets.SocketIcon[i]:IsMouseOver() then
214 self.tooltipLink = self.SocketLink[i] 223 setTip = self.SocketForge[i]
215 end 224 end
216 end 225 end
217 226 if setTip then
218 if self.tooltipLink then 227 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
219 if not GameTooltip:IsOwned(self) then 228 for _, info in ipairs(setTip) do
220 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') 229 if type(info) == 'table' then
221 GameTooltip:SetHyperlink(self.tooltipLink) 230 GameTooltip:AddLine(unpack(info))
222 231 elseif type(info) == 'string' then
223 GameTooltip:Show() 232 GameTooltip:AddLine(info)
224 end 233 end
225 else 234 end
226 if GameTooltip:IsOwned(self) then 235 GameTooltip:Show()
227 GameTooltip:Hide() 236 elseif GameTooltip:IsOwned(self) then
228 end 237 GameTooltip:Hide()
229 end 238 end
230 end 239 end
231 end 240 end
232 241
242 local tooltipName= 'VeneerPaperDollTooltip'
233 function VeneerPaperDollSlotMixin:UpdateRelicInfo() 243 function VeneerPaperDollSlotMixin:UpdateRelicInfo()
234 244
235 245
236 local itemID = GetInventoryItemID(self.unit, 16) 246 local itemID = GetInventoryItemID(self.unit, 16)
237 if not itemID then 247 if not itemID then
238 return 248 return
239 end 249 end
240 print('|cFF00FFFFRelic Sweep:', itemID) 250
241 251 print('|cFF00FFFFRelic Info:', itemID)
242 252 local guid = UnitGUID(self.unit or 'player')
253 local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID]
254
255 if not relicCache then
256 relicCache = {}
257 VeneerPaperDoll.KnownRelics[guid] = VeneerPaperDoll.KnownRelics[guid] or {}
258 VeneerPaperDoll.KnownRelics[guid][itemID] = relicCache
259 end
260
261 for i = 1, 3 do
262 if relicCache[i] then
263 local relicIcon, relicLevel, relicType, relicLink, relicForge = unpack(relicCache[i])
264
265 print('reading', i, unpack(relicCache[i]))
266 self.SocketInfo[i] = relicIcon
267 self.SocketText[i] = relicLevel
268 self.SocketType[i] = relicType
269 self.SocketLink[i] = relicLink
270 self.SocketForge[i] = self.SocketForge[i] or {}
271 if relicForge then
272 for l, info in ipairs(relicForge) do
273 self.SocketForge[i][l] = info
274 end
275 end
276
277 end
278 end
279 end
280
281 function VeneerPaperDollMixin:ScoopRelics()
282
283 -- not a viewed artifact
284 local itemID = C_ArtifactUI.GetArtifactInfo()
285 if not itemID then
286 return
287 end
288
289 print('|cFFFF00FFScoopRelics:|r', itemID)
243 local guid = UnitGUID(self.unit or 'player') 290 local guid = UnitGUID(self.unit or 'player')
244 local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID] 291 local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID]
245 if VeneerPaperDoll.KnownRelics[guid] then 292 if VeneerPaperDoll.KnownRelics[guid] then
246 for k, v in pairs(VeneerPaperDoll.KnownRelics[guid]) do 293 for k, v in pairs(VeneerPaperDoll.KnownRelics[guid]) do
247 if tonumber(k) and tonumber(k) < 72 then 294 if tonumber(k) and tonumber(k) < 72 then
258 end 305 end
259 306
260 local numRelics = C_ArtifactUI.GetNumRelicSlots() 307 local numRelics = C_ArtifactUI.GetNumRelicSlots()
261 local isEquipped = C_ArtifactUI.IsViewedArtifactEquipped() 308 local isEquipped = C_ArtifactUI.IsViewedArtifactEquipped()
262 local tooltip = VeneerPaperDollTooltip 309 local tooltip = VeneerPaperDollTooltip
263 tooltip:SetOwner(self, 'ANCHOR_NONE') 310
264 self.hasRelicSlots = true 311 for i = 1, numRelics do
265 if numRelics and isEquipped then 312 local relicName, relicIcon, relicType, relicLink = C_ArtifactUI.GetRelicInfo(i);
266 print('Relic Query:', itemID, numRelics) 313 local relicLevel = relicCache[i][2] or ""
267 for i = 1, numRelics do 314 local relicForge = relicCache[i][5] or {}
268 local relicName, relicIcon, relicType, relicLink = C_ArtifactUI.GetRelicInfo(i); 315 local relicType = C_ArtifactUI.GetRelicSlotType(i);
269 local relicType = C_ArtifactUI.GetRelicSlotType(i); 316
270 print(relicType) 317 if relicType then
271 if relicType then 318 if relicLink then
272 if relicLink then 319 tooltip:SetSocketedRelic(i)
273 tooltip:SetHyperlink(relicLink) 320 print(tooltip:NumLines())
274 print(tooltip:NumLines()) 321
275 322 local numLines = tooltip:NumLines()
276 local line1 = _G['VeneerPaperDollTooltipTextLeft2'] 323 if numLines >= 1 then
277 local line2 = _G['VeneerPaperDollTooltipTextLeft3'] 324 wipe(relicForge)
278 local text1 = line1 and line1:GetText() 325 local foundRank = 0
279 local text2 = line2 and line2:GetText() 326 for line = 1, numLines do
280 if text1 or text2 then 327 --print( _G[tooltipName .. 'TextLeft' .. line]:GetText(), _G[tooltipName .. 'TextLeft' .. line]:GetTextColor())
281 self.SocketText[i] = text1:match('Item Level (%d+)') or text2:match('Item Level (%d+)') 328 local lineText = _G[tooltipName .. 'TextLeft' .. line]:GetText()
329
330 if lineText then
331 local iLevel = lineText:match('Item Level (%d+)')
332 local rank = lineText:match('+1 Rank: (.+)')
333
334 if iLevel then
335 relicLevel = iLevel
336 print('iLevel = ',iLevel)
337 end
338
339 tinsert(relicForge, {lineText, _G[tooltipName .. 'TextLeft' .. line]:GetTextColor()})
340 end
282 end 341 end
283 end 342 end
284 343 end
285 self.SocketInfo[i] = relicIcon or 0 344
286 self.SocketType[i] = relicType 345 print('storing', i, relicIcon, relicLevel, relicType, relicLink, relicForge)
287 self.SocketLink[i] = relicLink 346
288 print('storing', i, self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]) 347 relicCache[i] = {relicIcon, relicLevel, relicType, relicLink, relicForge}
289 else 348 end
290 349 end
291 350
292 self.SocketInfo[i] = "Interface\\CharacterFrame\\TempPortraitAlphaMask" 351
293 self.SocketType[i] = nil 352 end
294 self.SocketLink[i] = nil 353
295 end 354 function VeneerPaperDollSlotMixin:OnLeave()
296 355
297 relicCache[i] = {self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]}
298 end
299 else
300
301 for i = 1, 3 do
302 if relicCache[i] then
303 local relicIcon, relicText, relicType, relicLink = unpack(relicCache[i])
304
305 print('loading', i, relicIcon, relicText, relicType, relicLink)
306 self.SocketInfo[i] = relicIcon
307 self.SocketText[i] = relicText
308 self.SocketType[i] = relicType
309 self.SocketLink[i] = relicLink
310 end
311 end
312 end
313 end 356 end
314 357
315 function VeneerPaperDollSlotMixin:Update(forced) 358 function VeneerPaperDollSlotMixin:Update(forced)
316 local id = self:GetID() 359 local id = self:GetID()
317 360
332 local numTextures = 0 375 local numTextures = 0
333 local itemLevel 376 local itemLevel
334 local ignoreIL = IsAddOnLoaded("DejaCharacterStats") 377 local ignoreIL = IsAddOnLoaded("DejaCharacterStats")
335 local itemLevelLine 378 local itemLevelLine
336 --print('|cFFFFFF00Sockets scan:', numLines) 379 --print('|cFFFFFF00Sockets scan:', numLines)
337 for i = 1, numLines do 380 for i = 1, numLines do
338 local line = _G['VeneerPaperDollTooltipTextLeft'..i] 381 local line = _G['VeneerPaperDollTooltipTextLeft'..i]
339 local text = line and line:GetText() 382 local text = line and line:GetText()
340 if text and not ignoreIL then 383 if text and not ignoreIL then
341 itemLevel = text:match('Item Level (%d+)') 384 itemLevel = text:match('Item Level (%d+)')
342 if itemLevel then 385 if itemLevel then
343 self.ItemLevel:SetText(itemLevel) 386 self.ItemLevel:SetText(itemLevel)
344 break 387 break
345 end 388 end
346 end 389 end
347 390
348 local texture = _G['VeneerPaperDollTooltipTexture'..i] 391 local texture = _G['VeneerPaperDollTooltipTexture'..i]
349 if texture and texture:IsShown() then 392 if texture and texture:IsShown() then
350 numTextures = numTextures + 1 393 numTextures = numTextures + 1
351 --print('picked up socket', numTextures, texture:GetTexture()) 394 --print('picked up socket', numTextures, texture:GetTexture())
352 self.SocketInfo[numTextures] = texture:GetTexture() 395 self.SocketInfo[numTextures] = texture:GetTexture()
353 end 396 end
354 end 397 end
398
355 if self.checkRelic then 399 if self.checkRelic then
356 self:UpdateRelicInfo() 400 self:UpdateRelicInfo()
357 end 401 end
358 402
359 403