Mercurial > wow > buffalo2
view Modules/PaperDoll.lua @ 83:4ec4fd89fced
- order of operations regarding frame visibility checking
- interaction with WorldPlan OrderHall module
- fancy shmancy transition fades resulting from above
author | Nenue |
---|---|
date | Tue, 18 Oct 2016 01:57:02 -0400 |
parents | 65ec88b30eb8 |
children | 74e714637d6a |
line wrap: on
line source
-- Veneer -- PaperDoll.lua -- Created: 8/16/2016 8:18 AM -- %file-revision% -- Displays the item level and modifications of character sheet equipment, including artifact power 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 GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank local tooltip = CreateFrame('GameTooltip', 'VeneerTooltip', UIParent, 'GameTooltipTemplate') local jewel = {} local artifactBar_OnEvent = function (self) local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() if not itemID then self:Hide() return end local numRelicSlots = C_ArtifactUI.GetNumRelicSlots() or 0; local pointsAvailable = 0 local nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 while totalXP >= nextRankCost do totalXP = totalXP - nextRankCost pointsAvailable = pointsAvailable + 1 nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0 end self.Header:SetText(name) self.Level:SetText((pointsAvailable >= 1) and (pointsSpent .. ' ('.. pointsAvailable..')') or (pointsSpent)) self.ProgressText:SetFormattedText("|cFF00FFFF%d|r / %d", totalXP, nextRankCost) self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()*(totalXP/nextRankCost), 0) self.ProgressBar:SetColorTexture(1,.5,0) self:Show() end local artifactBar = CreateFrame('Frame', 'VnPaperDollArtifact', CharacterModelFrame, 'VeneerStatusBarTemplate') artifactBar:ClearAllPoints() artifactBar:SetHeight(28) artifactBar:SetPoint('LEFT', CharacterModelFrame, 'LEFT', 30, 0) artifactBar:SetPoint('RIGHT', CharacterModelFrame, 'RIGHT', -30, 0) artifactBar:SetPoint('BOTTOM', CharacterMainHandSlotFrame, 'TOP', 0, 1) artifactBar.ProgressBG:SetColorTexture(0.5, 0.5, 0.5) artifactBar.Header:Show() artifactBar:RegisterEvent('ARTIFACT_UPDATE') artifactBar:SetScript('OnEvent', artifactBar_OnEvent) plugin.artifactBar = artifactBar print(CharacterMainHandSlotFrame:GetPoint(1)) print(artifactBar:GetPoint(3)) for i = 1, 3 do local relicSlot = CreateFrame('Frame', 'VnPaperDollRelic'..i, artifactBar) relicSlot:SetSize(40,40) relicSlot:SetPoint('BOTTOM', artifactBar, 'TOP', (i-2)*40, 24) relicSlot.relicArt = relicSlot:CreateTexture(nil, 'BACKGROUND') artifactBar['RelicSlot'..i] = relicSlot end artifactBar:EnableMouse(true) artifactBar:SetScript('OnMouseUp', function() SocketInventoryItem(16) end) local UpdateVeneer = function(itemslot, frame) local slot = itemslot:GetID() if itemslot.hasItem then local unit = frame.target.unit or 'player' frame.link = GetInventoryItemLink(unit, slot) tooltip:SetOwner(frame, 'ANCHOR_NONE') tooltip:SetInventoryItem(unit, slot) tooltip:Show() --print(tooltip:NumLines()) if tooltip:NumLines() >= 3 then local ilvl if _G['VeneerTooltipTextLeft2'] then ilvl = _G['VeneerTooltipTextLeft2']:GetText():match("Item Level (%d+)") --print('l2', ilvl) end if _G['VeneerTooltipTextLeft3'] then if not ilvl then ilvl = _G['VeneerTooltipTextLeft3']:GetText():match("Item Level (%d+)") --print('l3', ilvl) end end if ilvl then frame.label:SetText(ilvl) end end local quality = GetInventoryItemQuality(unit, slot) if slot == 16 and quality == LE_ITEM_QUALITY_ARTIFACT then artifactBar_OnEvent(plugin.artifactBar) 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 print(self:GetName()) 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 = {} frame.target = self frame.gemslot = {} frame:SetAllPoints(self) frame:SetParent(self) frame.label:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 2, 2) tinsert(pendingSlots, frame) end UpdateVeneer(self, frame) end local PaperDollFrame_UpdateStats = function() end plugin.event = function(self, event, ...) print(self, event, ...) if event == 'PLAYER_EQUIPMENT_CHANGED' then local slot, hasItem = ... if vnslot[slot] then UpdateVeneer(vnslot[slot]:GetParent(), vnslot[slot]) end elseif event == 'PLAYER_ENTERING_WORLD' then UpdateAll() end end local artifactBarCreated plugin.init = function() LoadAddOn('Blizzard_ArtifactUI') end --plugin:SetScript('OnEvent', plugin.event) plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') plugin:RegisterEvent('PLAYER_ENTERING_WORLD') hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) hooksecurefunc("PaperDollFrame_UpdateStats", PaperDollFrame_UpdateStats)