Skip to content

Commit

Permalink
Fixed a bug in pawn arrow's that would cause them to be inconsistent …
Browse files Browse the repository at this point in the history
…when equipping items. (#228)
  • Loading branch information
Cidan authored Feb 25, 2024
1 parent c38a427 commit ca2d17b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions frames/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function bagFrame.bagProto:Draw(dirtyItems)
local text = search:GetText()
self:Search(text)
self:OnResize()
events:SendMessage('bag/Rendered', self)
end

function bagFrame.bagProto:KeepBagInBounds()
Expand Down
27 changes: 16 additions & 11 deletions integrations/pawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,41 @@ local events = addon:GetModule('Events')
---@class Pawn: AceModule
local pawn = addon:NewModule('Pawn')

---@param event string
---@param item Item
local function onItemUpdateRetail(event, item)
local function onItemUpdateRetail(item)
local bagid, slotid = item.data.bagid, item.data.slotid
if item.data.isItemEmpty or event == 'item/Clearing' or not bagid or not slotid then
if item.data.isItemEmpty or not bagid or not slotid then
item.button.UpgradeIcon:SetShown(false)
else
item.button.UpgradeIcon:SetShown(PawnIsContainerItemAnUpgrade(bagid, slotid) or false)
end
end

---@param event string
---@param item Item
local function onItemUpdateClassic(event, item)
if item.data.isItemEmpty or event == 'item/Clearing' or not item.data.slotid or not item.data.bagid then
local function onItemUpdateClassic(item)
if item.data.isItemEmpty or not item.data.slotid or not item.data.bagid then
item.button.UpgradeIcon:SetShown(false)
else
local isUpgrade = PawnShouldItemLinkHaveUpgradeArrow(item.data.itemInfo.itemLink)
item.button.UpgradeIcon:SetShown(isUpgrade or false)
end
end

---@param bag Bag
local function onBagRendered(_, bag)
for _, item in pairs(bag.currentView.itemsByBagAndSlot) do
if addon.isRetail then
onItemUpdateRetail(item)
else
onItemUpdateClassic(item)
end
end
end

function pawn:OnEnable()
if not PawnIsContainerItemAnUpgrade and not PawnGetItemData then
return
end
events:RegisterMessage('bag/Rendered', onBagRendered)
print("BetterBags: Pawn integration enabled.")
if addon.isRetail then
events:RegisterMessage('item/Updated', onItemUpdateRetail)
else
events:RegisterMessage('item/Updated', onItemUpdateClassic)
end
end

0 comments on commit ca2d17b

Please sign in to comment.