Mercurial > wow > buffalo2
diff 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 |
line wrap: on
line diff
--- a/Modules/PaperDoll.lua Mon Nov 20 12:02:18 2017 -0500 +++ b/Modules/PaperDoll.lua Fri Dec 22 20:36:40 2017 -0500 @@ -87,6 +87,8 @@ self:RegisterEvent('ARTIFACT_UPDATE') self:MarkForUpdate() + + end function VeneerPaperDollMixin:MarkForUpdate() @@ -158,8 +160,6 @@ end end - - function VeneerPaperDollMixin:OnEvent(event, arg) print(event, arg) if event == 'ADDON_LOADED' then @@ -171,12 +171,13 @@ self:MarkForUpdate() end elseif event == 'ARTIFACT_UPDATE' then + self:ScoopRelics() if artifactSlot then - artifactSlot:Update(true) + artifactSlot.isDirty = true end elseif event == 'ARTIFACT_RELIC_INFO_RECEIVED' then if artifactSlot then - artifactSlot:Update(true) + artifactSlot.isDirty = true end else if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then @@ -195,12 +196,20 @@ self.SocketText = {} self.SocketType = {} self.SocketLink = {} + self.SocketForge = {} end function VeneerPaperDollSlotMixin:OnShow() if self.isDirty then self:Update() end end + +function VeneerPaperDollSlotMixin:OnHide() + if GameTooltip:IsOwned(self) then + GameTooltip:Hide() + end +end + function VeneerPaperDollSlotMixin:OnUpdate() if self.isDirty then --print('|cFF00FF00pushing update for', self:GetID()) @@ -208,28 +217,29 @@ end if self.checkRelic then - self.tooltipLink = nil + local setTip for i = 1, 3 do - if self.SocketLink[i] and self.Sockets.SocketIcon[i]:IsMouseOver() then - self.tooltipLink = self.SocketLink[i] + if self.SocketType[i] and self.Sockets.SocketIcon[i]:IsMouseOver() then + setTip = self.SocketForge[i] end end - - if self.tooltipLink then - if not GameTooltip:IsOwned(self) then - GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') - GameTooltip:SetHyperlink(self.tooltipLink) - - GameTooltip:Show() + if setTip then + GameTooltip:SetOwner(self, 'ANCHOR_RIGHT') + for _, info in ipairs(setTip) do + if type(info) == 'table' then + GameTooltip:AddLine(unpack(info)) + elseif type(info) == 'string' then + GameTooltip:AddLine(info) + end end - else - if GameTooltip:IsOwned(self) then - GameTooltip:Hide() - end + GameTooltip:Show() + elseif GameTooltip:IsOwned(self) then + GameTooltip:Hide() end end end +local tooltipName= 'VeneerPaperDollTooltip' function VeneerPaperDollSlotMixin:UpdateRelicInfo() @@ -237,9 +247,46 @@ if not itemID then return end - print('|cFF00FFFFRelic Sweep:', itemID) + print('|cFF00FFFFRelic Info:', itemID) + local guid = UnitGUID(self.unit or 'player') + local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID] + if not relicCache then + relicCache = {} + VeneerPaperDoll.KnownRelics[guid] = VeneerPaperDoll.KnownRelics[guid] or {} + VeneerPaperDoll.KnownRelics[guid][itemID] = relicCache + end + + for i = 1, 3 do + if relicCache[i] then + local relicIcon, relicLevel, relicType, relicLink, relicForge = unpack(relicCache[i]) + + print('reading', i, unpack(relicCache[i])) + self.SocketInfo[i] = relicIcon + self.SocketText[i] = relicLevel + self.SocketType[i] = relicType + self.SocketLink[i] = relicLink + self.SocketForge[i] = self.SocketForge[i] or {} + if relicForge then + for l, info in ipairs(relicForge) do + self.SocketForge[i][l] = info + end + end + + end + end +end + +function VeneerPaperDollMixin:ScoopRelics() + + -- not a viewed artifact + local itemID = C_ArtifactUI.GetArtifactInfo() + if not itemID then + return + end + + print('|cFFFF00FFScoopRelics:|r', itemID) local guid = UnitGUID(self.unit or 'player') local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID] if VeneerPaperDoll.KnownRelics[guid] then @@ -260,56 +307,52 @@ local numRelics = C_ArtifactUI.GetNumRelicSlots() local isEquipped = C_ArtifactUI.IsViewedArtifactEquipped() local tooltip = VeneerPaperDollTooltip - tooltip:SetOwner(self, 'ANCHOR_NONE') - self.hasRelicSlots = true - if numRelics and isEquipped then - print('Relic Query:', itemID, numRelics) - for i = 1, numRelics do - local relicName, relicIcon, relicType, relicLink = C_ArtifactUI.GetRelicInfo(i); - local relicType = C_ArtifactUI.GetRelicSlotType(i); - print(relicType) - if relicType then - if relicLink then - tooltip:SetHyperlink(relicLink) - print(tooltip:NumLines()) - local line1 = _G['VeneerPaperDollTooltipTextLeft2'] - local line2 = _G['VeneerPaperDollTooltipTextLeft3'] - local text1 = line1 and line1:GetText() - local text2 = line2 and line2:GetText() - if text1 or text2 then - self.SocketText[i] = text1:match('Item Level (%d+)') or text2:match('Item Level (%d+)') + for i = 1, numRelics do + local relicName, relicIcon, relicType, relicLink = C_ArtifactUI.GetRelicInfo(i); + local relicLevel = relicCache[i][2] or "" + local relicForge = relicCache[i][5] or {} + local relicType = C_ArtifactUI.GetRelicSlotType(i); + + if relicType then + if relicLink then + tooltip:SetSocketedRelic(i) + print(tooltip:NumLines()) + + local numLines = tooltip:NumLines() + if numLines >= 1 then + wipe(relicForge) + local foundRank = 0 + for line = 1, numLines do + --print( _G[tooltipName .. 'TextLeft' .. line]:GetText(), _G[tooltipName .. 'TextLeft' .. line]:GetTextColor()) + local lineText = _G[tooltipName .. 'TextLeft' .. line]:GetText() + + if lineText then + local iLevel = lineText:match('Item Level (%d+)') + local rank = lineText:match('+1 Rank: (.+)') + + if iLevel then + relicLevel = iLevel + print('iLevel = ',iLevel) + end + + tinsert(relicForge, {lineText, _G[tooltipName .. 'TextLeft' .. line]:GetTextColor()}) + end end end - - self.SocketInfo[i] = relicIcon or 0 - self.SocketType[i] = relicType - self.SocketLink[i] = relicLink - print('storing', i, self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]) - else - - - self.SocketInfo[i] = "Interface\\CharacterFrame\\TempPortraitAlphaMask" - self.SocketType[i] = nil - self.SocketLink[i] = nil end - relicCache[i] = {self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]} - end - else + print('storing', i, relicIcon, relicLevel, relicType, relicLink, relicForge) - for i = 1, 3 do - if relicCache[i] then - local relicIcon, relicText, relicType, relicLink = unpack(relicCache[i]) - - print('loading', i, relicIcon, relicText, relicType, relicLink) - self.SocketInfo[i] = relicIcon - self.SocketText[i] = relicText - self.SocketType[i] = relicType - self.SocketLink[i] = relicLink - end + relicCache[i] = {relicIcon, relicLevel, relicType, relicLink, relicForge} end end + + +end + +function VeneerPaperDollSlotMixin:OnLeave() + end function VeneerPaperDollSlotMixin:Update(forced) @@ -334,24 +377,25 @@ local ignoreIL = IsAddOnLoaded("DejaCharacterStats") local itemLevelLine --print('|cFFFFFF00Sockets scan:', numLines) - for i = 1, numLines do - local line = _G['VeneerPaperDollTooltipTextLeft'..i] - local text = line and line:GetText() - if text and not ignoreIL then - itemLevel = text:match('Item Level (%d+)') - if itemLevel then - self.ItemLevel:SetText(itemLevel) - break - end - end - - local texture = _G['VeneerPaperDollTooltipTexture'..i] - if texture and texture:IsShown() then - numTextures = numTextures + 1 - --print('picked up socket', numTextures, texture:GetTexture()) - self.SocketInfo[numTextures] = texture:GetTexture() + for i = 1, numLines do + local line = _G['VeneerPaperDollTooltipTextLeft'..i] + local text = line and line:GetText() + if text and not ignoreIL then + itemLevel = text:match('Item Level (%d+)') + if itemLevel then + self.ItemLevel:SetText(itemLevel) + break end end + + local texture = _G['VeneerPaperDollTooltipTexture'..i] + if texture and texture:IsShown() then + numTextures = numTextures + 1 + --print('picked up socket', numTextures, texture:GetTexture()) + self.SocketInfo[numTextures] = texture:GetTexture() + end + end + if self.checkRelic then self:UpdateRelicInfo() end