Nenue@62: -- Veneer Nenue@62: -- PaperDoll.lua Nenue@62: -- Created: 8/16/2016 8:18 AM Nenue@62: -- %file-revision% Nenue@65: -- Displays item levels by equipment slots Nenue@65: -- Requires tooltip scraping to obtain these numbers, meaning any currently active tooltip will be cleared. Nenue@62: Nenue@62: local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) Nenue@62: local vn, print = LibStub("LibKraken").register(VeneerController, plugin) Nenue@62: Nenue@64: local slot_anchors = { Nenue@64: [1] = 'TOPLEFT', Nenue@64: [2] = 'TOPLEFT', Nenue@64: [3] = 'TOPLEFT', Nenue@64: [15] = 'TOPLEFT', Nenue@64: [5] = 'TOPLEFT', Nenue@64: [9] = 'TOPLEFT', Nenue@62: Nenue@64: [10] = 'TOPRIGHT', Nenue@64: [6] = 'TOPRIGHT', Nenue@64: [7] = 'TOPRIGHT', Nenue@64: [8] = 'TOPRIGHT', Nenue@64: [11] = 'TOPRIGHT', Nenue@64: [12] = 'TOPRIGHT', Nenue@64: [13] = 'TOPRIGHT', Nenue@64: [14] = 'TOPRIGHT', Nenue@64: Nenue@64: [16] = 'BOTTOMRIGHT', Nenue@64: [17] = 'BOTTOMLEFT', Nenue@64: } Nenue@64: Nenue@64: local slot_relative = { Nenue@64: [1] = 'TOPRIGHT', Nenue@64: [2] = 'TOPRIGHT', Nenue@64: [3] = 'TOPRIGHT', Nenue@64: [15] = 'TOPRIGHT', Nenue@64: [5] = 'TOPRIGHT', Nenue@64: [9] = 'TOPRIGHT', Nenue@64: Nenue@64: [10] = 'TOPLEFT', Nenue@64: [6] = 'TOPLEFT', Nenue@64: [7] = 'TOPLEFT', Nenue@64: [8] = 'TOPLEFT', Nenue@64: [11] = 'TOPLEFT', Nenue@64: [12] = 'TOPLEFT', Nenue@64: [13] = 'TOPLEFT', Nenue@64: [14] = 'TOPLEFT', Nenue@64: Nenue@64: [16] = 'TOPRIGHT', Nenue@64: [17] = 'TOPLEFT', Nenue@64: } Nenue@64: local ticker Nenue@64: local vnslot = {} Nenue@64: local pendingSlots = {} Nenue@64: Nenue@65: Nenue@71: local jewel = {} Nenue@64: local UpdateVeneer = function(itemslot, frame) Nenue@64: local slot = itemslot:GetID() Nenue@64: if itemslot.hasItem then Nenue@62: frame.link = GetInventoryItemLink('player', slot) Nenue@71: Nenue@64: local name, link, something, ilevel = GetItemInfo(frame.link) Nenue@64: frame.label:SetText(ilevel) Nenue@62: -- todo: test GetExtendedItemInfo() Nenue@62: Nenue@71: local item = {strsplit(":", link)} Nenue@71: local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId, Nenue@71: uniqueId, linkLevel, specializationID, instanceDifficultyId, numBonusIds, bonusId1, bonusId2, upgradeValue Nenue@64: Nenue@71: specializationID, instanceDifficultyId, numBonusIds = item[11], item[12], item[13] Nenue@71: jewel[1], jewel[2], jewel[3], jewel[4] = item[4], item[5], item[6], item[7] Nenue@71: --vn:print(jewelId1, jewelId2, jewelId3, jewelId4) Nenue@71: for i = 1, 4 do Nenue@71: local gemslot = frame.gemslot[i] Nenue@71: if tonumber(jewel[i]) ~= nil then Nenue@71: if not gemslot then Nenue@71: gemslot = frame:CreateTexture(itemslot:GetName()..'Gem'..i, 'ARTWORK') Nenue@71: gemslot:SetSize(16,16) Nenue@71: local posx = 3 + (i-1)*16 Nenue@71: if slot_anchors[slot]:match('RIGHT') then Nenue@71: posx = posx * -1 Nenue@71: end Nenue@71: gemslot:SetPoint(slot_anchors[slot], frame.label, slot_relative[slot], posx, 0) Nenue@71: frame.gemslot[i] = gemslot Nenue@71: end Nenue@71: gemslot:SetTexture(GetItemIcon(jewel[i])) Nenue@71: gemslot:Show() Nenue@71: else Nenue@71: if gemslot then Nenue@71: gemslot:Hide() Nenue@71: end Nenue@71: Nenue@62: end Nenue@62: end Nenue@71: --[[ Nenue@71: print(link) Nenue@71: local difftag = '?' Nenue@71: if tonumber(numBonusIds) ~= nil then Nenue@71: local name, groupType, isHeroic, isChallengeMode, displayHeroic, displayMythic, toggleDifficultyID = GetDifficultyInfo(numBonusIds) Nenue@71: difftag = (name or '??') .. (isHeroic and ' (Heroic)' or '') Nenue@71: end Nenue@71: Nenue@71: print(instanceDifficultyId, '|cFF00FFFF', difftag, numBonusIds) Nenue@71: --if tonumber(numBonusIds) ~= nil then Nenue@71: for i = 8, #item do Nenue@71: print(i..'-', item[i]) Nenue@71: end Nenue@71: --end Nenue@71: Nenue@71: --]] Nenue@71: Nenue@62: frame:Show() Nenue@62: else Nenue@62: frame:Hide() Nenue@62: end Nenue@62: end Nenue@62: Nenue@64: local UpdateAll = function() Nenue@64: for index, frame in pairs(vnslot) do Nenue@64: if frame:IsVisible() then Nenue@64: print('forcing', index, frame:GetName()) Nenue@64: tinsert(pendingSlots, frame) Nenue@64: end Nenue@64: end Nenue@64: plugin.ticker() Nenue@62: end Nenue@62: Nenue@64: local UpdateNext = function() Nenue@64: Nenue@64: local frame = tremove(pendingSlots) Nenue@64: if frame and frame:IsVisible() then Nenue@64: print('updating', frame:GetName()) Nenue@64: UpdateVeneer(frame:GetParent(), frame) Nenue@64: else Nenue@65: Nenue@64: ticker:Cancel() Nenue@64: ticker = nil Nenue@64: end Nenue@64: Nenue@64: end Nenue@64: Nenue@71: Nenue@64: -- PaperDollFrame is separate from InspectUI handlers Nenue@64: local PaperDollItemSlotButton_Update = function(self) Nenue@64: local name = self:GetName() Nenue@64: local slot = self:GetID() Nenue@64: if not slot_anchors[slot] then Nenue@64: return Nenue@64: end Nenue@64: Nenue@64: Nenue@64: local frame = _G[name .. 'Veneer'] Nenue@64: Nenue@64: if not frame then Nenue@64: Nenue@64: frame = CreateFrame('Frame', name..'Veneer', self) Nenue@64: vnslot[slot] = frame Nenue@64: Nenue@64: frame.label = frame:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFont') Nenue@64: frame.gemslot = {} Nenue@64: Nenue@64: local anchor, relative, x, y = slot_anchors[slot], slot_relative[slot], 8, -4 Nenue@64: if anchor:match('RIGHT') then Nenue@64: x = -x Nenue@64: end Nenue@64: if anchor:match('BOTTOM') then Nenue@64: y = 4 Nenue@64: end Nenue@64: Nenue@71: frame.gemslot = {} Nenue@64: frame:SetPoint(anchor, self, relative, x, y) Nenue@64: frame:SetSize(200,24) Nenue@64: frame.label:ClearAllPoints() Nenue@64: frame.label:SetPoint(slot_anchors[slot], frame, slot_anchors[slot]) Nenue@64: Nenue@64: tinsert(pendingSlots, frame) Nenue@64: end Nenue@66: Nenue@66: plugin.ticker() Nenue@64: end Nenue@64: Nenue@64: Nenue@64: plugin.ticker = function() Nenue@64: if (not ticker) and #pendingSlots >= 1 then Nenue@64: ticker = C_Timer.NewTicker(0, UpdateNext) Nenue@64: end Nenue@64: end Nenue@64: Nenue@64: Nenue@65: plugin.event = function(self, event, ...) Nenue@64: print(self, event, flag, slot) Nenue@64: Nenue@65: if event == 'PLAYER_EQUIPMENT_CHANGED' then Nenue@65: local slot, hasItem = ... Nenue@65: if vnslot[slot] then Nenue@65: UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot]) Nenue@65: plugin.ticker() Nenue@65: end Nenue@64: Nenue@66: elseif event == 'PLAYER_ENTERING_WORLD' then Nenue@66: UpdateAll() Nenue@66: Nenue@65: end Nenue@65: Nenue@64: end Nenue@66: Nenue@64: plugin:SetScript('OnEvent', plugin.event) Nenue@65: plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') Nenue@66: plugin:RegisterEvent('PLAYER_ENTERING_WORLD') Nenue@64: Nenue@66: Nenue@64: hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update)