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