Mercurial > wow > buffalo2
comparison Modules/PaperDoll.lua @ 93:caded2668701
Curseforge migration and source tree cleaning
| author | Nenue |
|---|---|
| date | Sun, 01 Jan 2017 18:25:26 -0500 |
| parents | 74e714637d6a |
| children | bb38bc0e787f |
comparison
equal
deleted
inserted
replaced
| 92:d41c7dc3012f | 93:caded2668701 |
|---|---|
| 1 -- Veneer | 1 -- Veneer |
| 2 -- PaperDoll.lua | 2 -- PaperDoll.lua |
| 3 -- Created: 8/16/2016 8:18 AM | 3 -- Created: 8/16/2016 8:18 AM |
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 -- Displays the item level and modifications of character sheet equipment, including artifact power | 5 -- Displays the item level and modifications of character sheet equipment, including artifact power |
| 6 | 6 local print = DEVIAN_WORKSPACE and function(...) print('PaperDoll', ...) end or nop |
| 7 local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) | 7 |
| 8 local vn, print = LibStub("LibKraken").register(Veneer, plugin) | 8 local slot_overlays = {} |
| 9 VeneerPaperDollMixin = { | |
| 10 anchorFrame = 'CharacterFrame', | |
| 11 anchorPoint = 'TOPLEFT', | |
| 12 KnownRelics = {}, | |
| 13 } | |
| 14 | |
| 15 local relic_slot_paths = { | |
| 16 Arcane = {"Relic-Arcane-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.849609375, 0.919921875, 0.1181640625, 0.1884765625, false, false}, | |
| 17 Blood = {"Relic-Blood-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.921875, 0.9921875, 0.1181640625, 0.1884765625, false, false}, | |
| 18 Fel = {"Relic-Fel-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.59765625, 0.66796875, 0.572265625, 0.642578125, false, false}, | |
| 19 Fire = {"Relic-Fire-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.669921875, 0.740234375, 0.572265625, 0.642578125, false, false}, | |
| 20 Frost = {"Relic-Frost-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.7421875, 0.8125, 0.572265625, 0.642578125, false, false}, | |
| 21 Holy = {"Relic-Holy-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.814453125, 0.884765625, 0.572265625, 0.642578125, false, false}, | |
| 22 Iron = {"Relic-Iron-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.88671875, 0.95703125, 0.572265625, 0.642578125, false, false}, | |
| 23 Life = {"Relic-Life-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.59765625, 0.66796875, 0.64453125, 0.71484375, false, false}, | |
| 24 Shadow = {"Relic-Shadow-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.59765625, 0.66796875, 0.716796875, 0.787109375, false, false}, | |
| 25 Water = {"Relic-Water-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.59765625, 0.66796875, 0.7890625, 0.859375, false, false}, | |
| 26 Wind = {"Relic-Wind-Slot", [[Interface\Artifacts\Artifacts.BLP]], 72, 72, 0.59765625, 0.66796875, 0.861328125, 0.931640625, false, false}, | |
| 27 } | |
| 28 | |
| 29 local slots_left = {'TOPLEFT', 'TOPRIGHT', 1, 0, 'TOPLEFT', 'BOTTOMLEFT', 0, -1} | |
| 30 local slots_right = {'TOPRIGHT', 'TOPLEFT', -1, 0, 'TOPRIGHT', 'BOTTOMRIGHT', 0, -1} | |
| 31 local slots_bottomleft = {'BOTTOMRIGHT', 'TOPRIGHT', 0, 1, 'BOTTOMRIGHT', 'TOPRIGHT', 0, 1 } | |
| 32 local slots_bottomright = {'BOTTOMLEFT', 'TOPLEFT', 0, -1, 'BOTTOMLEFT', 'TOPLEFT', 0, 1} | |
| 9 | 33 |
| 10 local slot_anchors = { | 34 local slot_anchors = { |
| 11 [1] = 'TOPLEFT', | 35 [1] = slots_left, |
| 12 [2] = 'TOPLEFT', | 36 [2] = slots_left, |
| 13 [3] = 'TOPLEFT', | 37 [3] = slots_left, |
| 14 [15] = 'TOPLEFT', | 38 [15] = slots_left, |
| 15 [5] = 'TOPLEFT', | 39 [5] = slots_left, |
| 16 [9] = 'TOPLEFT', | 40 [9] = slots_left, |
| 17 | 41 |
| 18 [10] = 'TOPRIGHT', | 42 [10] = slots_right, |
| 19 [6] = 'TOPRIGHT', | 43 [6] = slots_right, |
| 20 [7] = 'TOPRIGHT', | 44 [7] = slots_right, |
| 21 [8] = 'TOPRIGHT', | 45 [8] = slots_right, |
| 22 [11] = 'TOPRIGHT', | 46 [11] = slots_right, |
| 23 [12] = 'TOPRIGHT', | 47 [12] = slots_right, |
| 24 [13] = 'TOPRIGHT', | 48 [13] = slots_right, |
| 25 [14] = 'TOPRIGHT', | 49 [14] = slots_right, |
| 26 | 50 |
| 27 [16] = 'BOTTOMRIGHT', | 51 [16] = slots_bottomleft, |
| 28 [17] = 'BOTTOMLEFT', | 52 [17] = slots_bottomright, |
| 29 } | 53 } |
| 30 | 54 |
| 31 local slot_relative = { | 55 |
| 32 [1] = 'TOPRIGHT', | 56 function VeneerPaperDollMixin:OnLoad() |
| 33 [2] = 'TOPRIGHT', | 57 hooksecurefunc("PaperDollItemSlotButton_Update", function(...) |
| 34 [3] = 'TOPRIGHT', | 58 self:GetSlotButton(PaperDollItemsFrame, ...) |
| 35 [15] = 'TOPRIGHT', | 59 end) |
| 36 [5] = 'TOPRIGHT', | 60 |
| 37 [9] = 'TOPRIGHT', | 61 hooksecurefunc("PaperDollFrame_UpdateStats", function(...) |
| 38 | 62 self:GetStats(PaperDollItemsFrame, ...) |
| 39 [10] = 'TOPLEFT', | 63 end) |
| 40 [6] = 'TOPLEFT', | 64 |
| 41 [7] = 'TOPLEFT', | 65 self:RegisterEvent('ADDON_LOADED') |
| 42 [8] = 'TOPLEFT', | 66 self:RegisterEvent('INSPECT_READY') |
| 43 [11] = 'TOPLEFT', | 67 |
| 44 [12] = 'TOPLEFT', | 68 self.SocketType = {} |
| 45 [13] = 'TOPLEFT', | 69 end |
| 46 [14] = 'TOPLEFT', | 70 |
| 47 | 71 function VeneerPaperDollMixin:SetupInspectFrame() |
| 48 [16] = 'TOPRIGHT', | 72 hooksecurefunc("InspectPaperDollItemSlotButton_Update", function(...) |
| 49 [17] = 'TOPLEFT', | 73 self:GetSlotButton(InspectFrame, ...) |
| 50 } | 74 end) |
| 51 local ticker | 75 self:RegisterEvent('INSPECT_READY') |
| 52 local vnslot = {} | 76 end |
| 53 local pendingSlots = {} | 77 function VeneerPaperDollMixin:SetupArtifactUI() |
| 54 | 78 self:RegisterEvent('ARTIFACT_UPDATE') |
| 55 | 79 end |
| 56 local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo | 80 |
| 57 local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank | 81 function VeneerPaperDollMixin:Setup() |
| 58 local tooltip = CreateFrame('GameTooltip', 'VeneerTooltip', UIParent, 'GameTooltipTemplate') | 82 VeneerData.PaperDoll = VeneerData.PaperDoll or {} |
| 59 local jewel = {} | 83 VeneerData.PaperDoll.KnownRelics = VeneerData.PaperDoll.KnownRelics or {} |
| 60 | 84 self.KnownRelics = VeneerData.PaperDoll.KnownRelics |
| 61 local artifactBar_OnEvent = function (self) | 85 |
| 62 local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() | 86 self:RegisterEvent('UNIT_INVENTORY_CHANGED') |
| 87 self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') | |
| 88 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED') | |
| 89 | |
| 90 self:MarkForUpdate() | |
| 91 end | |
| 92 | |
| 93 function VeneerPaperDollMixin:MarkForUpdate() | |
| 94 for frame, overlays in pairs(slot_overlays) do | |
| 95 for slot, overlay in pairs(overlays) do | |
| 96 if overlay:IsVisible() then | |
| 97 overlay:Update() | |
| 98 else | |
| 99 overlay.isDirty = true | |
| 100 end | |
| 101 end | |
| 102 end | |
| 103 end | |
| 104 | |
| 105 function VeneerPaperDollMixin:GetStats() | |
| 106 end | |
| 107 function VeneerPaperDollMixin:GetSlotButton(panel, frame) | |
| 108 print('|cFF00FF88'..self:GetName()..':GetSlotButton()', frame:GetName(), frame:GetID()) | |
| 109 local slot = frame:GetID() | |
| 110 local unit = panel.unit or 'player' | |
| 111 if slot_anchors[slot] then | |
| 112 slot_overlays[panel] = slot_overlays[panel] or {} | |
| 113 local overlay = slot_overlays[panel][slot] | |
| 114 if not overlay then | |
| 115 overlay = CreateFrame('Frame', 'VeneerPaperDollSlot' .. unit .. slot, frame, 'VeneerPaperDollSlotInfoTemplate') | |
| 116 overlay:SetID(slot) | |
| 117 slot_overlays[panel][slot] = overlay | |
| 118 overlay.checkRelic = frame.checkRelic | |
| 119 | |
| 120 local anchorPoint, relativePoint, dX, dY, statPoint, statRelative, statdX, statdY = unpack(slot_anchors[slot]) | |
| 121 local offset = 7 | |
| 122 overlay:SetPoint(anchorPoint, frame, relativePoint, dX * offset, dY * offset) | |
| 123 overlay:SetSize(frame:GetWidth()*3, frame:GetHeight()) | |
| 124 | |
| 125 local relativeFrame = overlay | |
| 126 for i, region in ipairs(overlay.StatsLeft) do | |
| 127 region:ClearAllPoints() | |
| 128 print(statPoint, relativeFrame, (i == 1) and statPoint or statRelative) | |
| 129 region:SetPoint(statPoint, relativeFrame, (i == 1) and statPoint or statRelative, 0, 0) | |
| 130 relativeFrame = region | |
| 131 end | |
| 132 if slot == 16 then | |
| 133 overlay.Sockets:ClearAllPoints() | |
| 134 overlay.Sockets:SetPoint('BOTTOM', CharacterFrameInsetBg, 'BOTTOM', 0, frame:GetHeight() + 14) | |
| 135 overlay.ItemLevel:SetFontObject(VeneerNumberFontLarge) | |
| 136 overlay.ItemLevel:ClearAllPoints() | |
| 137 overlay.ItemLevel:SetPoint('BOTTOM', overlay.Sockets, 'TOP', 0, 4) | |
| 138 end | |
| 139 | |
| 140 print(overlay.Sockets:GetPoint(1)) | |
| 141 overlay.anchors = slot_anchors[slot] | |
| 142 end | |
| 143 | |
| 144 overlay.unit = unit | |
| 145 overlay.checkRelic = (unit == 'player' and slot == 16) | |
| 146 | |
| 147 | |
| 148 if frame.hasItem then | |
| 149 overlay.isDirty = true | |
| 150 overlay:Show() | |
| 151 else | |
| 152 overlay:Hide() | |
| 153 end | |
| 154 end | |
| 155 end | |
| 156 | |
| 157 | |
| 158 | |
| 159 function VeneerPaperDollMixin:OnEvent(event, arg) | |
| 160 print(event, arg) | |
| 161 if event == 'ADDON_LOADED' then | |
| 162 if IsLoggedIn() and not self.initialized then | |
| 163 self:Setup() | |
| 164 self.initialized = true | |
| 165 end | |
| 166 | |
| 167 | |
| 168 if arg == 'Blizzard_InspectUI' then | |
| 169 self:SetupInspectFrame() | |
| 170 end | |
| 171 if arg == 'Blizzard_ArtifactUI' then | |
| 172 self:SetupArtifactUI() | |
| 173 self:MarkForUpdate() | |
| 174 end | |
| 175 elseif event == 'ARTIFACT_UPDATE' then | |
| 176 self:MarkForUpdate() | |
| 177 else | |
| 178 if (event == 'PLAYER_SPECIALIZATION_CHANGED' or event == 'UNIT_INVENTORY_CHANGED') then | |
| 179 if arg ~= 'player' then | |
| 180 return | |
| 181 end | |
| 182 elseif event == 'INSPECT_READY' then | |
| 183 | |
| 184 end | |
| 185 | |
| 186 self:MarkForUpdate() | |
| 187 | |
| 188 end | |
| 189 end | |
| 190 | |
| 191 | |
| 192 VeneerPaperDollSlotMixin = {} | |
| 193 | |
| 194 function VeneerPaperDollSlotMixin:OnLoad() | |
| 195 self.SocketText = {} | |
| 196 self.SocketType = {} | |
| 197 self.SocketLink = {} | |
| 198 end | |
| 199 function VeneerPaperDollSlotMixin:OnShow() | |
| 200 if self.isDirty then | |
| 201 self:Update() | |
| 202 end | |
| 203 end | |
| 204 function VeneerPaperDollSlotMixin:OnUpdate() | |
| 205 if self.isDirty then | |
| 206 --print('|cFF00FF00pushing update for', self:GetID()) | |
| 207 self:Update() | |
| 208 end | |
| 209 | |
| 210 if self.checkRelic then | |
| 211 self.tooltipLink = nil | |
| 212 for i = 1, 3 do | |
| 213 if self.SocketLink[i] and self.Sockets.SocketIcon[i]:IsMouseOver() then | |
| 214 self.tooltipLink = self.SocketLink[i] | |
| 215 end | |
| 216 end | |
| 217 | |
| 218 if self.tooltipLink then | |
| 219 if not GameTooltip:IsOwned(self) then | |
| 220 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | |
| 221 GameTooltip:SetHyperlink(self.tooltipLink) | |
| 222 | |
| 223 GameTooltip:Show() | |
| 224 end | |
| 225 else | |
| 226 if GameTooltip:IsOwned(self) then | |
| 227 GameTooltip:Hide() | |
| 228 end | |
| 229 end | |
| 230 end | |
| 231 end | |
| 232 | |
| 233 function VeneerPaperDollSlotMixin:UpdateRelicInfo() | |
| 234 | |
| 235 | |
| 236 local itemID = GetInventoryItemID(self.unit, 16) | |
| 63 if not itemID then | 237 if not itemID then |
| 64 self:Hide() | |
| 65 return | 238 return |
| 66 end | 239 end |
| 67 | 240 print('|cFF00FFFFRelic Sweep:', itemID) |
| 68 local numRelicSlots = C_ArtifactUI.GetNumRelicSlots() or 0; | 241 |
| 69 for i = 1, numRelicSlots do | 242 |
| 70 | 243 local guid = UnitGUID(self.unit or 'player') |
| 71 end | 244 local relicCache = VeneerPaperDoll.KnownRelics[guid] and VeneerPaperDoll.KnownRelics[guid][itemID] |
| 72 | 245 if VeneerPaperDoll.KnownRelics[guid] then |
| 73 local pointsAvailable = 0 | 246 for k, v in pairs(VeneerPaperDoll.KnownRelics[guid]) do |
| 74 local nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 | 247 if tonumber(k) and tonumber(k) < 72 then |
| 75 | 248 VeneerPaperDoll.KnownRelics[guid][k] = nil |
| 76 while totalXP >= nextRankCost do | 249 end |
| 77 totalXP = totalXP - nextRankCost | 250 end |
| 78 pointsAvailable = pointsAvailable + 1 | 251 end |
| 79 nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 | 252 |
| 80 end | 253 |
| 81 self.Header:SetText(name) | 254 if not relicCache then |
| 82 self.Level:SetText((pointsAvailable >= 1) and (pointsSpent .. ' ('.. pointsAvailable..')') or (pointsSpent)) | 255 relicCache = {} |
| 83 self.ProgressText:SetFormattedText("|cFF00FFFF%d|r / %d", totalXP, nextRankCost) | 256 VeneerPaperDoll.KnownRelics[guid] = VeneerPaperDoll.KnownRelics[guid] or {} |
| 84 | 257 VeneerPaperDoll.KnownRelics[guid][itemID] = relicCache |
| 85 self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()*(totalXP/nextRankCost), 0) | 258 end |
| 86 self.ProgressBar:SetColorTexture(1,.5,0) | 259 |
| 87 | 260 local numRelics = C_ArtifactUI.GetNumRelicSlots() |
| 88 self:Show() | 261 local isEquipped = C_ArtifactUI.IsViewedArtifactEquipped() |
| 89 end | 262 local tooltip = VeneerPaperDollTooltip |
| 90 | 263 tooltip:SetOwner(self, 'ANCHOR_NONE') |
| 91 | 264 self.hasRelicSlots = true |
| 92 local artifactBar = CreateFrame('Frame', 'VnPaperDollArtifact', CharacterModelFrame, 'VeneerStatusBarTemplate') | 265 if numRelics and isEquipped then |
| 93 artifactBar:ClearAllPoints() | 266 print('Relic Query:', itemID, numRelics) |
| 94 artifactBar:SetHeight(28) | 267 self.checkRelic = nil |
| 95 artifactBar:SetPoint('LEFT', CharacterModelFrame, 'LEFT', 30, 0) | 268 for i = 1, numRelics do |
| 96 artifactBar:SetPoint('RIGHT', CharacterModelFrame, 'RIGHT', -30, 0) | 269 local lockedReason, relicName, relicIcon, relicLink = C_ArtifactUI.GetRelicInfo(i); |
| 97 artifactBar:SetPoint('BOTTOM', CharacterMainHandSlotFrame, 'TOP', 0, 1) | 270 local relicType = C_ArtifactUI.GetRelicSlotType(i); |
| 98 artifactBar.ProgressBG:SetColorTexture(0.5, 0.5, 0.5) | 271 if relicIcon then |
| 99 artifactBar.Header:Show() | 272 tooltip:SetHyperlink(relicLink) |
| 100 artifactBar:RegisterEvent('ARTIFACT_UPDATE') | 273 print(tooltip:NumLines()) |
| 101 artifactBar:SetScript('OnEvent', artifactBar_OnEvent) | 274 |
| 102 | 275 local line1 = _G['VeneerPaperDollTooltipTextLeft2'] |
| 103 plugin.artifactBar = artifactBar | 276 local line2 = _G['VeneerPaperDollTooltipTextLeft3'] |
| 104 print(CharacterMainHandSlotFrame:GetPoint(1)) | 277 local text1 = line1 and line1:GetText() |
| 105 print(artifactBar:GetPoint(3)) | 278 local text2 = line2 and line2:GetText() |
| 106 | 279 if text1 or text2 then |
| 107 for i = 1, 3 do | 280 self.SocketText[i] = text1:match('Item Level (%d+)') or text2:match('Item Level (%d+)') |
| 108 local relicSlot = CreateFrame('Frame', 'VnPaperDollRelic'..i, artifactBar) | |
| 109 relicSlot:SetSize(40,40) | |
| 110 relicSlot:SetPoint('BOTTOM', artifactBar, 'TOP', (i-2)*40, 24) | |
| 111 relicSlot.relicArt = relicSlot:CreateTexture(nil, 'BACKGROUND') | |
| 112 artifactBar['RelicSlot'..i] = relicSlot | |
| 113 end | |
| 114 | |
| 115 | |
| 116 artifactBar:EnableMouse(true) | |
| 117 artifactBar:SetScript('OnMouseUp', function() | |
| 118 SocketInventoryItem(16) | |
| 119 end) | |
| 120 | |
| 121 local UpdateVeneer = function(itemslot, frame) | |
| 122 local slot = itemslot:GetID() | |
| 123 if itemslot.hasItem then | |
| 124 local unit = frame.target.unit or 'player' | |
| 125 frame.link = GetInventoryItemLink(unit, slot) | |
| 126 tooltip:SetOwner(frame, 'ANCHOR_NONE') | |
| 127 tooltip:SetInventoryItem(unit, slot) | |
| 128 tooltip:Show() | |
| 129 --print(tooltip:NumLines()) | |
| 130 if tooltip:NumLines() >= 3 then | |
| 131 | |
| 132 local ilvl | |
| 133 if _G['VeneerTooltipTextLeft2'] then | |
| 134 ilvl = _G['VeneerTooltipTextLeft2']:GetText():match("Item Level (%d+)") | |
| 135 --print('l2', ilvl) | |
| 136 end | |
| 137 | |
| 138 if _G['VeneerTooltipTextLeft3'] then | |
| 139 if not ilvl then | |
| 140 ilvl = _G['VeneerTooltipTextLeft3']:GetText():match("Item Level (%d+)") | |
| 141 --print('l3', ilvl) | |
| 142 end | 281 end |
| 143 end | 282 |
| 144 | 283 self.SocketInfo[i] = relicIcon |
| 145 if ilvl then | 284 self.SocketType[i] = relicType |
| 146 frame.label:SetText(ilvl) | 285 self.SocketLink[i] = relicLink |
| 147 end | 286 print('storing', i, self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]) |
| 148 end | 287 else |
| 149 | 288 |
| 150 local quality = GetInventoryItemQuality(unit, slot) | 289 self.SocketInfo[i] = "Interface\\CharacterFrame\\TempPortraitAlphaMask" |
| 151 if slot == 16 and quality == LE_ITEM_QUALITY_ARTIFACT then | 290 self.SocketType[i] = relicType |
| 152 artifactBar_OnEvent(plugin.artifactBar) | 291 self.SocketLink[i] = nil |
| 153 end | 292 end |
| 154 | 293 |
| 155 | 294 relicCache[i] = {self.SocketInfo[i], self.SocketText[i], self.SocketType[i], self.SocketLink[i]} |
| 156 | 295 end |
| 157 | 296 end |
| 158 frame:Show() | 297 |
| 159 else | 298 for i = 1, 3 do |
| 160 frame:Hide() | 299 if relicCache[i] then |
| 161 end | 300 local relicIcon, relicLevel, relicType, relicLink = unpack(relicCache[i]) |
| 162 end | 301 |
| 163 | 302 print('loading', i, relicIcon, relicLevel, relicType, relicLink) |
| 164 local UpdateNext = function(frame) | 303 self.SocketInfo[i] = relicIcon |
| 165 | 304 self.SocketText[i] = relicLevel |
| 166 plugin.next(function() | 305 self.SocketType[i] = relicType |
| 167 print('updating', frame:GetName()) | 306 self.SocketLink[i] = relicLink |
| 168 UpdateVeneer(frame:GetParent(), frame) | 307 end |
| 169 end) | 308 end |
| 170 end | 309 end |
| 171 | 310 |
| 172 | 311 local SocketIcon_Update = function(frame) |
| 173 local UpdateAll = function() | 312 end |
| 174 for index, frame in pairs(vnslot) do | 313 |
| 175 if frame:IsVisible() then | 314 function VeneerPaperDollSlotMixin:Update() |
| 176 print('forcing', index, frame:GetName()) | 315 local id = self:GetID() |
| 177 UpdateNext(frame) | 316 |
| 178 end | 317 self.SocketInfo = self.SocketInfo or {} |
| 179 end | 318 table.wipe(self.SocketInfo) |
| 180 end | 319 self.ItemLevel:SetText(nil) |
| 181 | 320 |
| 182 | 321 local tooltip = VeneerPaperDollTooltip |
| 183 -- PaperDollFrame is separate from InspectUI handlers | 322 tooltip:SetOwner(self, 'ANCHOR_NONE') |
| 184 local PaperDollItemSlotButton_Update = function(self) | 323 print('refresh', self.unit, id) |
| 185 local name = self:GetName() | 324 tooltip:SetInventoryItem(self.unit or 'player', id) |
| 186 local slot = self:GetID() | 325 tooltip:Show() |
| 187 if not slot_anchors[slot] then | 326 |
| 188 return | 327 local numLines = tooltip:NumLines() |
| 189 end | 328 local numTextures = 0 |
| 190 print(self:GetName()) | 329 local itemLevel |
| 191 | 330 local itemLevelLine |
| 192 local frame = _G[name .. 'Veneer'] | 331 print('|cFFFFFF00Sockets scan:', numLines) |
| 193 | 332 for i = 1, numLines do |
| 194 if not frame then | 333 local line = _G['VeneerPaperDollTooltipTextLeft'..i] |
| 195 | 334 local text = line and line:GetText() |
| 196 frame = CreateFrame('Frame', name..'Veneer', self) | 335 if text then |
| 197 vnslot[slot] = frame | 336 itemLevel = text:match('Item Level (%d+)') |
| 198 | 337 if itemLevel then |
| 199 frame.label = frame:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFont') | 338 self.ItemLevel:SetText(itemLevel) |
| 200 frame.gemslot = {} | 339 break |
| 201 | 340 end |
| 202 | 341 end |
| 203 frame.target = self | 342 |
| 204 frame.gemslot = {} | 343 local texture = _G['VeneerPaperDollTooltipTexture'..i] |
| 205 frame:SetAllPoints(self) | 344 if texture and texture:IsShown() then |
| 206 frame:SetParent(self) | 345 numTextures = numTextures + 1 |
| 207 frame.label:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 2, 2) | 346 print('picked up socket', numTextures, texture:GetTexture()) |
| 208 | 347 self.SocketInfo[numTextures] = texture:GetTexture() |
| 209 tinsert(pendingSlots, frame) | 348 end |
| 210 end | 349 end |
| 211 | 350 if self.checkRelic then |
| 212 UpdateVeneer(self, frame) | 351 self:UpdateRelicInfo() |
| 213 | 352 end |
| 214 end | 353 |
| 215 | 354 |
| 216 local PaperDollFrame_UpdateStats = function() | 355 local relativeIcon |
| 217 | 356 local socketsWidth = 0 |
| 218 end | 357 local socketsHeight = 24 |
| 219 | 358 for index, icon in ipairs(self.Sockets.SocketIcon) do |
| 220 | 359 if self.SocketInfo[index] then |
| 221 | 360 print('|cFF0088FFsocketInfo|r', index, self.SocketInfo[index]) |
| 222 plugin.event = function(self, event, ...) | 361 icon:ClearAllPoints() |
| 223 print(self, event, ...) | 362 |
| 224 | 363 icon:SetTexture(self.SocketInfo[index]) |
| 225 if event == 'PLAYER_EQUIPMENT_CHANGED' then | 364 icon:SetSize(16, 16) |
| 226 local slot, hasItem = ... | 365 icon:Show() |
| 227 if vnslot[slot] then | 366 if index == 1 then |
| 228 UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot]) | 367 icon:SetPoint('LEFT', self.Sockets, 'LEFT', 0, 0) |
| 229 | 368 socketsWidth = socketsWidth + icon:GetWidth() |
| 230 end | 369 socketsHeight = icon:GetHeight() |
| 231 | 370 else |
| 232 elseif event == 'PLAYER_ENTERING_WORLD' then | 371 if id == 16 then |
| 233 UpdateAll() | 372 icon:SetPoint('LEFT', relativeIcon, 'RIGHT', 14, 0) |
| 234 | 373 socketsWidth = socketsWidth + 14 |
| 235 end | 374 else |
| 236 | 375 icon:SetPoint('LEFT', relativeIcon, 'RIGHT', 2, 0) |
| 237 end | 376 socketsWidth = socketsWidth + 2 |
| 238 local artifactBarCreated | 377 end |
| 239 plugin.init = function() | 378 socketsWidth = socketsWidth + icon:GetWidth() |
| 240 LoadAddOn('Blizzard_ArtifactUI') | 379 end |
| 241 end | 380 |
| 242 | 381 local label = self.Sockets.SocketLabel[index] |
| 243 --plugin:SetScript('OnEvent', plugin.event) | 382 label:ClearAllPoints() |
| 244 plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') | 383 label:SetPoint('BOTTOM', icon, 'TOP',0, 2) |
| 245 plugin:RegisterEvent('PLAYER_ENTERING_WORLD') | 384 label:SetFontObject(VeneerNumberFont) |
| 246 | 385 label:SetText(self.SocketText[index]) |
| 247 | 386 |
| 248 hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) | 387 if self.checkRelic then |
| 249 | 388 local relicAtlasName = ("Relic-%s-Slot"):format(self.SocketType[index]); |
| 250 hooksecurefunc("PaperDollFrame_UpdateStats", PaperDollFrame_UpdateStats) | 389 self.Sockets.SocketBg = self.Sockets.SocketBg or {} |
| 390 self.Sockets.SocketBg[index] = self.Sockets.SocketBg[index] or self.Sockets:CreateTexture() | |
| 391 self.Sockets.SocketBg[index]:SetAtlas(relicAtlasName) | |
| 392 self.Sockets.SocketBg[index]:SetPoint('TOPRIGHT', icon, 'TOPRIGHT', 12, 12) | |
| 393 self.Sockets.SocketBg[index]:SetPoint('BOTTOMLEFT', icon, 'BOTTOMLEFT', -12,-12) | |
| 394 print('', self.SocketType[index], relicAtlasName) | |
| 395 | |
| 396 socketsHeight = self.Sockets.SocketBg[index]:GetHeight() | |
| 397 end | |
| 398 | |
| 399 | |
| 400 relativeIcon = icon | |
| 401 else | |
| 402 if self.checkRelic and self.Sockets.SocketBg and self.Sockets.SocketBg[index] then | |
| 403 self.Sockets.SocketBg[index]:SetTexture(nil) | |
| 404 self.Sockets.SocketLabel[index]:SetText(nil) | |
| 405 end | |
| 406 | |
| 407 icon:Hide() | |
| 408 end | |
| 409 | |
| 410 | |
| 411 end | |
| 412 self.Sockets:SetWidth(socketsWidth) | |
| 413 self.Sockets:SetHeight(socketsHeight) | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 self.isDirty = nil | |
| 420 end |
