annotate Modules/PaperDoll.lua @ 78:08951972041a

- adjust top anchors for OrderHallCommandBar
author Nenue
date Tue, 30 Aug 2016 03:32:22 -0400
parents 83b3cdaae6a5
children bb6b532c5d2f
rev   line source
Nenue@62 1 -- Veneer
Nenue@62 2 -- PaperDoll.lua
Nenue@62 3 -- Created: 8/16/2016 8:18 AM
Nenue@62 4 -- %file-revision%
Nenue@65 5 -- Displays item levels by equipment slots
Nenue@65 6 -- Requires tooltip scraping to obtain these numbers, meaning any currently active tooltip will be cleared.
Nenue@62 7
Nenue@62 8 local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent)
Nenue@75 9 local vn, print = LibStub("LibKraken").register(Veneer, plugin)
Nenue@62 10
Nenue@64 11 local slot_anchors = {
Nenue@64 12 [1] = 'TOPLEFT',
Nenue@64 13 [2] = 'TOPLEFT',
Nenue@64 14 [3] = 'TOPLEFT',
Nenue@64 15 [15] = 'TOPLEFT',
Nenue@64 16 [5] = 'TOPLEFT',
Nenue@64 17 [9] = 'TOPLEFT',
Nenue@62 18
Nenue@64 19 [10] = 'TOPRIGHT',
Nenue@64 20 [6] = 'TOPRIGHT',
Nenue@64 21 [7] = 'TOPRIGHT',
Nenue@64 22 [8] = 'TOPRIGHT',
Nenue@64 23 [11] = 'TOPRIGHT',
Nenue@64 24 [12] = 'TOPRIGHT',
Nenue@64 25 [13] = 'TOPRIGHT',
Nenue@64 26 [14] = 'TOPRIGHT',
Nenue@64 27
Nenue@64 28 [16] = 'BOTTOMRIGHT',
Nenue@64 29 [17] = 'BOTTOMLEFT',
Nenue@64 30 }
Nenue@64 31
Nenue@64 32 local slot_relative = {
Nenue@64 33 [1] = 'TOPRIGHT',
Nenue@64 34 [2] = 'TOPRIGHT',
Nenue@64 35 [3] = 'TOPRIGHT',
Nenue@64 36 [15] = 'TOPRIGHT',
Nenue@64 37 [5] = 'TOPRIGHT',
Nenue@64 38 [9] = 'TOPRIGHT',
Nenue@64 39
Nenue@64 40 [10] = 'TOPLEFT',
Nenue@64 41 [6] = 'TOPLEFT',
Nenue@64 42 [7] = 'TOPLEFT',
Nenue@64 43 [8] = 'TOPLEFT',
Nenue@64 44 [11] = 'TOPLEFT',
Nenue@64 45 [12] = 'TOPLEFT',
Nenue@64 46 [13] = 'TOPLEFT',
Nenue@64 47 [14] = 'TOPLEFT',
Nenue@64 48
Nenue@64 49 [16] = 'TOPRIGHT',
Nenue@64 50 [17] = 'TOPLEFT',
Nenue@64 51 }
Nenue@64 52 local ticker
Nenue@64 53 local vnslot = {}
Nenue@64 54 local pendingSlots = {}
Nenue@64 55
Nenue@65 56
Nenue@71 57 local jewel = {}
Nenue@64 58 local UpdateVeneer = function(itemslot, frame)
Nenue@64 59 local slot = itemslot:GetID()
Nenue@64 60 if itemslot.hasItem then
Nenue@62 61 frame.link = GetInventoryItemLink('player', slot)
Nenue@71 62
Nenue@64 63 local name, link, something, ilevel = GetItemInfo(frame.link)
Nenue@64 64 frame.label:SetText(ilevel)
Nenue@62 65 -- todo: test GetExtendedItemInfo()
Nenue@62 66
Nenue@71 67 local item = {strsplit(":", link)}
Nenue@71 68 local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId,
Nenue@71 69 uniqueId, linkLevel, specializationID, instanceDifficultyId, numBonusIds, bonusId1, bonusId2, upgradeValue
Nenue@64 70
Nenue@71 71 specializationID, instanceDifficultyId, numBonusIds = item[11], item[12], item[13]
Nenue@71 72 jewel[1], jewel[2], jewel[3], jewel[4] = item[4], item[5], item[6], item[7]
Nenue@71 73 --vn:print(jewelId1, jewelId2, jewelId3, jewelId4)
Nenue@71 74 for i = 1, 4 do
Nenue@71 75 local gemslot = frame.gemslot[i]
Nenue@71 76 if tonumber(jewel[i]) ~= nil then
Nenue@71 77 if not gemslot then
Nenue@71 78 gemslot = frame:CreateTexture(itemslot:GetName()..'Gem'..i, 'ARTWORK')
Nenue@71 79 gemslot:SetSize(16,16)
Nenue@71 80 local posx = 3 + (i-1)*16
Nenue@71 81 if slot_anchors[slot]:match('RIGHT') then
Nenue@71 82 posx = posx * -1
Nenue@71 83 end
Nenue@71 84 gemslot:SetPoint(slot_anchors[slot], frame.label, slot_relative[slot], posx, 0)
Nenue@71 85 frame.gemslot[i] = gemslot
Nenue@71 86 end
Nenue@71 87 gemslot:SetTexture(GetItemIcon(jewel[i]))
Nenue@71 88 gemslot:Show()
Nenue@71 89 else
Nenue@71 90 if gemslot then
Nenue@71 91 gemslot:Hide()
Nenue@71 92 end
Nenue@71 93
Nenue@62 94 end
Nenue@62 95 end
Nenue@71 96 --[[
Nenue@71 97 print(link)
Nenue@71 98 local difftag = '?'
Nenue@71 99 if tonumber(numBonusIds) ~= nil then
Nenue@71 100 local name, groupType, isHeroic, isChallengeMode, displayHeroic, displayMythic, toggleDifficultyID = GetDifficultyInfo(numBonusIds)
Nenue@71 101 difftag = (name or '??') .. (isHeroic and ' (Heroic)' or '')
Nenue@71 102 end
Nenue@71 103
Nenue@71 104 print(instanceDifficultyId, '|cFF00FFFF', difftag, numBonusIds)
Nenue@71 105 --if tonumber(numBonusIds) ~= nil then
Nenue@71 106 for i = 8, #item do
Nenue@71 107 print(i..'-', item[i])
Nenue@71 108 end
Nenue@71 109 --end
Nenue@71 110
Nenue@71 111 --]]
Nenue@71 112
Nenue@62 113 frame:Show()
Nenue@62 114 else
Nenue@62 115 frame:Hide()
Nenue@62 116 end
Nenue@62 117 end
Nenue@62 118
Nenue@76 119 local UpdateNext = function(frame)
Nenue@76 120
Nenue@76 121 plugin.next(function()
Nenue@76 122 print('updating', frame:GetName())
Nenue@76 123 UpdateVeneer(frame:GetParent(), frame)
Nenue@76 124 end)
Nenue@76 125 end
Nenue@76 126
Nenue@76 127
Nenue@64 128 local UpdateAll = function()
Nenue@64 129 for index, frame in pairs(vnslot) do
Nenue@64 130 if frame:IsVisible() then
Nenue@64 131 print('forcing', index, frame:GetName())
Nenue@76 132 UpdateNext(frame)
Nenue@64 133 end
Nenue@64 134 end
Nenue@64 135 end
Nenue@64 136
Nenue@71 137
Nenue@64 138 -- PaperDollFrame is separate from InspectUI handlers
Nenue@64 139 local PaperDollItemSlotButton_Update = function(self)
Nenue@64 140 local name = self:GetName()
Nenue@64 141 local slot = self:GetID()
Nenue@64 142 if not slot_anchors[slot] then
Nenue@64 143 return
Nenue@64 144 end
Nenue@64 145
Nenue@64 146
Nenue@64 147 local frame = _G[name .. 'Veneer']
Nenue@64 148
Nenue@64 149 if not frame then
Nenue@64 150
Nenue@64 151 frame = CreateFrame('Frame', name..'Veneer', self)
Nenue@64 152 vnslot[slot] = frame
Nenue@64 153
Nenue@64 154 frame.label = frame:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFont')
Nenue@64 155 frame.gemslot = {}
Nenue@64 156
Nenue@64 157 local anchor, relative, x, y = slot_anchors[slot], slot_relative[slot], 8, -4
Nenue@64 158 if anchor:match('RIGHT') then
Nenue@64 159 x = -x
Nenue@64 160 end
Nenue@64 161 if anchor:match('BOTTOM') then
Nenue@64 162 y = 4
Nenue@64 163 end
Nenue@64 164
Nenue@71 165 frame.gemslot = {}
Nenue@64 166 frame:SetPoint(anchor, self, relative, x, y)
Nenue@64 167 frame:SetSize(200,24)
Nenue@64 168 frame.label:ClearAllPoints()
Nenue@64 169 frame.label:SetPoint(slot_anchors[slot], frame, slot_anchors[slot])
Nenue@64 170
Nenue@64 171 tinsert(pendingSlots, frame)
Nenue@64 172 end
Nenue@66 173
Nenue@64 174 end
Nenue@64 175
Nenue@64 176
Nenue@64 177
Nenue@64 178
Nenue@65 179 plugin.event = function(self, event, ...)
Nenue@64 180 print(self, event, flag, slot)
Nenue@64 181
Nenue@65 182 if event == 'PLAYER_EQUIPMENT_CHANGED' then
Nenue@65 183 local slot, hasItem = ...
Nenue@65 184 if vnslot[slot] then
Nenue@65 185 UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot])
Nenue@65 186 plugin.ticker()
Nenue@65 187 end
Nenue@64 188
Nenue@66 189 elseif event == 'PLAYER_ENTERING_WORLD' then
Nenue@66 190 UpdateAll()
Nenue@66 191
Nenue@65 192 end
Nenue@65 193
Nenue@64 194 end
Nenue@66 195
Nenue@72 196 --plugin:SetScript('OnEvent', plugin.event)
Nenue@65 197 plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED')
Nenue@66 198 plugin:RegisterEvent('PLAYER_ENTERING_WORLD')
Nenue@64 199
Nenue@66 200
Nenue@72 201 --hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update)