Nenue@62: -- Veneer Nenue@62: -- PaperDoll.lua Nenue@62: -- Created: 8/16/2016 8:18 AM Nenue@62: -- %file-revision% Nenue@80: -- Displays the item level and modifications of character sheet equipment, including artifact power Nenue@62: Nenue@62: local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) Nenue@75: local vn, print = LibStub("LibKraken").register(Veneer, 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@80: local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo Nenue@80: local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank Nenue@80: local tooltip = CreateFrame('GameTooltip', 'VeneerTooltip', UIParent, 'GameTooltipTemplate') Nenue@71: local jewel = {} Nenue@80: Nenue@80: local artifactBar_OnEvent = function (self) Nenue@80: local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() Nenue@80: if not itemID then Nenue@80: self:Hide() Nenue@80: return Nenue@80: end Nenue@80: Nenue@80: local numRelicSlots = C_ArtifactUI.GetNumRelicSlots() or 0; Nenue@80: Nenue@80: Nenue@80: local pointsAvailable = 0 Nenue@80: local nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 Nenue@80: Nenue@80: while totalXP >= nextRankCost do Nenue@80: totalXP = totalXP - nextRankCost Nenue@80: pointsAvailable = pointsAvailable + 1 Nenue@80: nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 Nenue@80: end Nenue@80: self.Header:SetText(name) Nenue@81: self.Level:SetText((pointsAvailable >= 1) and (pointsSpent .. ' ('.. pointsAvailable..')') or (pointsSpent)) Nenue@80: self.ProgressText:SetFormattedText("|cFF00FFFF%d|r / %d", totalXP, nextRankCost) Nenue@80: Nenue@80: self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()*(totalXP/nextRankCost), 0) Nenue@80: self.ProgressBar:SetColorTexture(1,.5,0) Nenue@80: Nenue@80: self:Show() Nenue@80: end Nenue@80: Nenue@80: Nenue@80: local artifactBar = CreateFrame('Frame', 'VnPaperDollArtifact', CharacterModelFrame, 'VeneerStatusBarTemplate') Nenue@80: artifactBar:ClearAllPoints() Nenue@80: artifactBar:SetHeight(28) Nenue@80: artifactBar:SetPoint('LEFT', CharacterModelFrame, 'LEFT', 30, 0) Nenue@80: artifactBar:SetPoint('RIGHT', CharacterModelFrame, 'RIGHT', -30, 0) Nenue@80: artifactBar:SetPoint('BOTTOM', CharacterMainHandSlotFrame, 'TOP', 0, 1) Nenue@80: artifactBar.ProgressBG:SetColorTexture(0.5, 0.5, 0.5) Nenue@80: artifactBar.Header:Show() Nenue@80: artifactBar:RegisterEvent('ARTIFACT_UPDATE') Nenue@80: artifactBar:SetScript('OnEvent', artifactBar_OnEvent) Nenue@80: Nenue@80: plugin.artifactBar = artifactBar Nenue@80: print(CharacterMainHandSlotFrame:GetPoint(1)) Nenue@80: print(artifactBar:GetPoint(3)) Nenue@80: Nenue@80: for i = 1, 3 do Nenue@80: local relicSlot = CreateFrame('Frame', 'VnPaperDollRelic'..i, artifactBar) Nenue@80: relicSlot:SetSize(40,40) Nenue@80: relicSlot:SetPoint('BOTTOM', artifactBar, 'TOP', (i-2)*40, 24) Nenue@80: relicSlot.relicArt = relicSlot:CreateTexture(nil, 'BACKGROUND') Nenue@80: artifactBar['RelicSlot'..i] = relicSlot Nenue@80: end Nenue@80: Nenue@80: Nenue@80: artifactBar:EnableMouse(true) Nenue@80: artifactBar:SetScript('OnMouseUp', function() Nenue@80: SocketInventoryItem(16) Nenue@80: end) Nenue@80: Nenue@64: local UpdateVeneer = function(itemslot, frame) Nenue@64: local slot = itemslot:GetID() Nenue@64: if itemslot.hasItem then Nenue@80: local unit = frame.target.unit or 'player' Nenue@80: frame.link = GetInventoryItemLink(unit, slot) Nenue@80: tooltip:SetOwner(frame, 'ANCHOR_NONE') Nenue@80: tooltip:SetInventoryItem(unit, slot) Nenue@80: tooltip:Show() Nenue@80: --print(tooltip:NumLines()) Nenue@80: if tooltip:NumLines() >= 3 then Nenue@71: Nenue@80: local ilvl Nenue@80: if _G['VeneerTooltipTextLeft2'] then Nenue@80: ilvl = _G['VeneerTooltipTextLeft2']:GetText():match("Item Level (%d+)") Nenue@80: --print('l2', ilvl) Nenue@80: end Nenue@62: Nenue@80: if _G['VeneerTooltipTextLeft3'] then Nenue@80: if not ilvl then Nenue@80: ilvl = _G['VeneerTooltipTextLeft3']:GetText():match("Item Level (%d+)") Nenue@80: --print('l3', ilvl) Nenue@80: end Nenue@80: end Nenue@64: Nenue@80: if ilvl then Nenue@80: frame.label:SetText(ilvl) Nenue@62: end Nenue@62: end Nenue@80: Nenue@80: local quality = GetInventoryItemQuality(unit, slot) Nenue@80: if slot == 16 and quality == LE_ITEM_QUALITY_ARTIFACT then Nenue@80: artifactBar_OnEvent(plugin.artifactBar) Nenue@71: end Nenue@71: Nenue@71: Nenue@80: Nenue@71: Nenue@62: frame:Show() Nenue@62: else Nenue@62: frame:Hide() Nenue@62: end Nenue@62: end Nenue@62: Nenue@76: local UpdateNext = function(frame) Nenue@76: Nenue@76: plugin.next(function() Nenue@76: print('updating', frame:GetName()) Nenue@76: UpdateVeneer(frame:GetParent(), frame) Nenue@76: end) Nenue@76: end Nenue@76: Nenue@76: 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@76: UpdateNext(frame) Nenue@64: end Nenue@64: end 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@80: print(self:GetName()) 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: Nenue@80: frame.target = self Nenue@71: frame.gemslot = {} Nenue@80: frame:SetAllPoints(self) Nenue@80: frame:SetParent(self) Nenue@80: frame.label:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 2, 2) Nenue@64: Nenue@64: tinsert(pendingSlots, frame) Nenue@64: end Nenue@66: Nenue@80: UpdateVeneer(self, frame) Nenue@80: Nenue@64: end Nenue@64: Nenue@80: local PaperDollFrame_UpdateStats = function() Nenue@80: Nenue@80: end Nenue@64: Nenue@64: Nenue@64: Nenue@65: plugin.event = function(self, event, ...) Nenue@80: print(self, event, ...) 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@80: 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@80: local artifactBarCreated Nenue@80: plugin.init = function() Nenue@80: LoadAddOn('Blizzard_ArtifactUI') Nenue@80: end Nenue@66: Nenue@72: --plugin:SetScript('OnEvent', plugin.event) Nenue@65: plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') Nenue@66: plugin:RegisterEvent('PLAYER_ENTERING_WORLD') Nenue@64: Nenue@66: Nenue@80: hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) Nenue@80: Nenue@80: hooksecurefunc("PaperDollFrame_UpdateStats", PaperDollFrame_UpdateStats)