Mercurial > wow > buffalo2
changeset 65:4fe16cb3f5d6
- paper doll item levels
author | Nenue |
---|---|
date | Wed, 17 Aug 2016 18:01:42 -0400 |
parents | ba9c13261bb2 |
children | 6ccacc927ef6 |
files | Modules/PaperDoll.lua |
diffstat | 1 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/PaperDoll.lua Wed Aug 17 15:26:54 2016 -0400 +++ b/Modules/PaperDoll.lua Wed Aug 17 18:01:42 2016 -0400 @@ -2,7 +2,8 @@ -- 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(VeneerController, plugin) @@ -52,6 +53,8 @@ local vnslot = {} local pendingSlots = {} + + local UpdateVeneer = function(itemslot, frame) local slot = itemslot:GetID() if itemslot.hasItem then @@ -61,11 +64,9 @@ frame.label:SetText(ilevel) -- todo: test GetExtendedItemInfo() - local lastOwner = GameTooltip:GetOwner() - print(lastOwner) - GameTooltip:SetOwner(plugin) GameTooltip:SetInventoryItem('player', slot) + GameTooltip:Hide() for i = 1, 3 do local gname = 'gem'..i @@ -97,6 +98,7 @@ print('updating', frame:GetName()) UpdateVeneer(frame:GetParent(), frame) else + ticker:Cancel() ticker = nil end @@ -148,22 +150,38 @@ end -plugin.event = function(self, event, flag, slot) +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 - plugin.ticker() + end + end plugin:SetScript('OnEvent', plugin.event) -plugin:RegisterUnitEvent('UNIT_INVENTORY_CHANGED', 'player') +plugin:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') -hooksecurefunc("ToggleCharacter", UpdateAll) +hooksecurefunc("ToggleCharacter", function() + if PaperDollFrame:IsVisible() then + UpdateAll() + end +end) hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update) hooksecurefunc(GameTooltip, "SetInventoryItem", function(self, unit, slot) if self:GetOwner() == plugin then if unit == 'player' and vnslot[slot] then - vnslot[slot].label:SetText(GameTooltipTextLeft3:GetText():match('%d+')) + + local text = GameTooltipTextLeft3:GetText():match('Item Level (%d+)') + if not text then + text = GameTooltipTextLeft2:GetText():match('Item Level (%d+)') + end + vnslot[slot].label:SetText(text or '???') end end end)