Skip to content

Commit f7c82c3

Browse files
authored
Wrath support, fixes, currency overhaul (#656)
* Fixed several bugs in Classic related to item quality. * Complete overhaul of the currency frame. Currencies can now be stacked into columns. Currencies now show tooltips on each currency. * Prevent swapped equipment from showing up as new. * Changed CURSOR_UPDATE to CURSOR_CHANGED to fix WotLK
1 parent ebddb57 commit f7c82c3

File tree

11 files changed

+200
-36
lines changed

11 files changed

+200
-36
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ jobs:
4141
- name: Package and release TBC
4242
uses: BigWigsMods/[email protected]
4343
with:
44-
args: -g bcc
44+
args: -g bcc
45+
- name: Package and release Wrath
46+
uses: BigWigsMods/[email protected]
47+
with:
48+
args: -g wrath

AdiBags.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
## Interface-Retail: 90207
2222
## Interface-Classic: 11403
2323
## Interface-BCC: 20504
24+
## Interface-Wrath: 30400
2425

2526
## Title: AdiBags
2627
## Notes: Adirelle's bag addon.

AdiBags_Config/AdiBags_Config.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## Interface-Retail: 90207
33
## Interface-Classic: 11403
44
## Interface-BCC: 20504
5+
## Interface-Wrath: 30400
56

67
## Title: AdiBags Configuration
78
## Notes: Adirelle's bag addon.

core/Constants.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ local L = addon.L
2626
addon.isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
2727
addon.isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
2828
addon.isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC and LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_BURNING_CRUSADE
29-
addon.isWOTLK = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC and LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_NORTHREND
29+
addon.isWrath = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC and LE_EXPANSION_LEVEL_CURRENT == LE_EXPANSION_NORTHREND
3030

3131
--<GLOBALS
3232
local _G = _G

core/Utility.lua

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ local GetContainerNumFreeSlots = _G.GetContainerNumFreeSlots
3333
local geterrorhandler = _G.geterrorhandler
3434
local GetItemFamily = _G.GetItemFamily
3535
local GetItemInfo = _G.GetItemInfo
36-
local ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
37-
local ITEM_QUALITY_UNCOMMON = _G.Enum.ItemQuality.Uncommon
36+
local ITEM_QUALITY_POOR
37+
local ITEM_QUALITY_UNCOMMON
38+
39+
if addon.isRetail then
40+
ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
41+
ITEM_QUALITY_UNCOMMON = _G.Enum.ItemQuality.Uncommon
42+
else
43+
ITEM_QUALITY_POOR = _G.LE_ITEM_QUALITY_POOR
44+
ITEM_QUALITY_UNCOMMON = _G.LE_ITEM_QUALITY_UNCOMMON
45+
end
46+
3847
local pairs = _G.pairs
3948
local pcall = _G.pcall
4049
local select = _G.select
@@ -145,6 +154,12 @@ function addon.SetupTooltip(widget, content, anchor, xOffset, yOffset)
145154
end
146155
end
147156

157+
function addon.RemoveTooltip(widget)
158+
widget:SetScript('OnEnter', nil)
159+
widget:SetScript('OnLeave', nil)
160+
widget.tooltipCallback = nil
161+
widget.UpdateTooltip = nil
162+
end
148163
--------------------------------------------------------------------------------
149164
-- Item link checking
150165
--------------------------------------------------------------------------------

modules/CurrencyFrame.lua

Lines changed: 137 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ local CreateFrame = _G.CreateFrame
3535
local ExpandCurrencyList = _G.C_CurrencyInfo.ExpandCurrencyList
3636
local format = _G.format
3737
local GetCurrencyListInfo = _G.C_CurrencyInfo.GetCurrencyListInfo
38+
local GetCurrencyInfo = _G.C_CurrencyInfo.GetCurrencyInfo
3839
local GetCurrencyListSize = _G.C_CurrencyInfo.GetCurrencyListSize
3940
local hooksecurefunc = _G.hooksecurefunc
4041
local ipairs = _G.ipairs
@@ -52,13 +53,16 @@ mod.uiName = L['Currency']
5253
mod.uiDesc = L['Display character currency at bottom left of the backpack.']
5354

5455
function mod:OnInitialize()
56+
self.currencyToCell = {}
57+
self.columns = {}
5558
self.db = addon.db:RegisterNamespace(
5659
self.moduleName,
5760
{
5861
profile = {
5962
shown = { ['*'] = true },
6063
hideZeroes = true,
61-
text = addon:GetFontDefaults(NumberFontNormalLarge)
64+
text = addon:GetFontDefaults(NumberFontNormalLarge),
65+
width = 4,
6266
}
6367
}
6468
)
@@ -75,6 +79,7 @@ function mod:OnEnable()
7579
if self.widget then
7680
self.widget:Show()
7781
end
82+
7883
self:RegisterEvent('CURRENCY_DISPLAY_UPDATE', "Update")
7984
if not self.hooked then
8085
if IsAddOnLoaded('Blizzard_TokenUI') then
@@ -104,18 +109,47 @@ function mod:OnBagFrameCreated(bag)
104109
if bag.bagName ~= "Backpack" then return end
105110
local frame = bag:GetFrame()
106111

107-
local widget =CreateFrame("Button", addonName.."CurrencyFrame", frame)
112+
local widget = CreateFrame("Button", addonName.."CurrencyFrame", frame)
108113
self.widget = widget
109114
widget:SetHeight(16)
110-
widget:RegisterForClicks("RightButtonUp")
111-
widget:SetScript('OnClick', function() self:OpenOptions() end)
112-
addon.SetupTooltip(widget, { L['Currency'], L['Right-click to configure.'] }, "ANCHOR_BOTTOMLEFT")
113115

114-
local fs = widget:CreateFontString(nil, "OVERLAY")
115-
fs:SetFontObject(self.font)
116-
fs:SetPoint("BOTTOMLEFT", 0, 1)
117-
self.fontstring = fs
116+
-- Create the columns used for currency display. Each column has the maximum amount
117+
-- of possible cells for the minimum width / the max number of currencies.
118+
for i = 1, 10 do
119+
local columnFrame = CreateFrame("Button", string.format("%sCurrencyColumnFrame%d", addonName, i), widget)
120+
columnFrame:Show()
121+
if i == 1 then
122+
columnFrame:SetPoint("TOPLEFT", widget, "TOPLEFT")
123+
else
124+
columnFrame:SetPoint("TOPLEFT", self.columns[i-1].frame, "TOPRIGHT")
125+
end
126+
local column = {
127+
frame = columnFrame,
128+
cells = {}
129+
}
118130

131+
for ii = 1, ceil(GetCurrencyListSize() / 3)+1 do
132+
local cellFrame = CreateFrame("Button", string.format("%sCurrencyCellFrame%d%d", addonName, i, ii), columnFrame)
133+
if ii == 1 then
134+
cellFrame:SetPoint("TOPLEFT", columnFrame, "TOPLEFT")
135+
else
136+
cellFrame:SetPoint("TOPLEFT", column.cells[ii-1].frame, "BOTTOMLEFT")
137+
end
138+
139+
cellFrame:Show()
140+
local fs = cellFrame:CreateFontString(nil, "OVERLAY")
141+
fs:SetFontObject(self.font)
142+
fs:SetPoint("BOTTOMLEFT", 0, 1)
143+
table.insert(column.cells, {
144+
frame = cellFrame,
145+
fs = fs,
146+
text = "",
147+
icon = "",
148+
name = "",
149+
})
150+
end
151+
table.insert(self.columns, column)
152+
end
119153
self:Update()
120154
frame:AddBottomWidget(widget, "LEFT", 50)
121155
end
@@ -156,31 +190,99 @@ local ICON_STRING = " \124T%s:0:0:0:0:64:64:5:59:5:59\124t "
156190

157191
local values = {}
158192
local updating
159-
function mod:Update()
193+
function mod:Update(event, currencyType, currencyQuantity)
160194
if not self.widget or updating then return end
161195
updating = true
162196

197+
-- Refresh only the affected cell.
198+
if currencyType ~= nil then
199+
local info = GetCurrencyInfo(currencyType)
200+
local cell = self.currencyToCell[info.name]
201+
cell.text = cell.icon .. currencyQuantity
202+
cell.fs:SetText(cell.text)
203+
cell.frame:SetSize(
204+
cell.fs:GetStringWidth(),
205+
ceil(cell.fs:GetStringHeight())+3
206+
)
207+
local column = cell.frame:GetParent()
208+
if column:GetWidth() < cell.frame:GetWidth() then
209+
column:SetWidth(cell.frame:GetWidth())
210+
end
211+
updating = false
212+
return
213+
end
214+
215+
-- This is a full refresh of all cells, called on first load or layout changes.
216+
217+
-- Clear the currency -> cell map.
218+
wipe(self.currencyToCell)
219+
220+
-- Clear all cells and columns completely.
221+
for i, column in ipairs(self.columns) do
222+
for ii, cell in ipairs(column.cells) do
223+
cell.fs:SetText("")
224+
cell.text = ""
225+
cell.name = ""
226+
cell.icon = ""
227+
addon.RemoveTooltip(cell.frame)
228+
end
229+
column.frame:SetSize(0,0)
230+
end
231+
232+
-- Get all the currency information from the player and store it.
163233
local shown, hideZeroes = self.db.profile.shown, self.db.profile.hideZeroes
164234
for i, currencyListInfo in IterateCurrencies() do
165235
if shown[currencyListInfo.name] and (currencyListInfo.quantity > 0 or not hideZeroes) then
166-
tinsert(values, BreakUpLargeNumbers(currencyListInfo.quantity))
167-
tinsert(values, format(ICON_STRING, currencyListInfo.iconFileID))
236+
tinsert(values, {
237+
quantity = BreakUpLargeNumbers(currencyListInfo.quantity),
238+
icon = format(ICON_STRING, currencyListInfo.iconFileID),
239+
name = currencyListInfo.name
240+
})
168241
end
169242
end
170243

171244
local widget, fs = self.widget, self.fontstring
245+
-- Set the cell values.
172246
if #values > 0 then
173-
fs:SetText(tconcat(values, ""))
174-
widget:Show()
175-
widget:SetSize(
176-
fs:GetStringWidth(),
177-
ceil(fs:GetStringHeight()) + 3
178-
)
247+
for i, value in ipairs(values) do
248+
local columnPosition = ((i-1) % self.db.profile.width)+1
249+
local rowPosition = ceil(i / self.db.profile.width)
250+
local column = self.columns[columnPosition]
251+
local cell = column.cells[rowPosition]
252+
cell.icon = value.icon
253+
cell.name = value.name
254+
cell.text = value.icon .. value.quantity
255+
cell.fs:SetText(cell.text)
256+
cell.frame:SetSize(
257+
cell.fs:GetStringWidth(),
258+
ceil(cell.fs:GetStringHeight())+3
259+
)
260+
-- Set the cell's tooltip.
261+
addon.SetupTooltip(cell.frame, cell.name, "ANCHOR_BOTTOMLEFT")
262+
263+
-- Resize the columns as needed.
264+
if column.frame:GetWidth() < cell.frame:GetWidth() then
265+
column.frame:SetWidth(cell.frame:GetWidth())
266+
end
267+
column.frame:SetHeight(column.frame:GetHeight() + cell.frame:GetHeight())
268+
self.currencyToCell[value.name] = cell
269+
end
270+
271+
-- Loop over every active column and get the total width
272+
-- of all columns for the parent widget.
273+
local totalWidth = 0
274+
for i = 1, self.db.profile.width do
275+
totalWidth = totalWidth + self.columns[i].frame:GetWidth()
276+
end
277+
278+
-- The first column will always be the longest column, so get the height
279+
-- of the first column and set the parent widget to this size.
280+
widget:SetSize(totalWidth, self.columns[1].frame:GetHeight())
179281
wipe(values)
180282
else
181283
widget:Hide()
182284
end
183-
285+
widget:Show()
184286
updating = false
185287
end
186288

@@ -206,6 +308,21 @@ function mod:GetOptions()
206308
type = 'toggle',
207309
order = 20,
208310
},
209-
text = addon:CreateFontOptions(self.font, nil, 30)
311+
text = addon:CreateFontOptions(self.font, nil, 30),
312+
layout = {
313+
name = L['Layout'],
314+
type = 'group',
315+
order = 100,
316+
inline = true,
317+
args = {
318+
width = {
319+
name = L['Currencies per row'],
320+
type = 'range',
321+
min = 3,
322+
max = 10,
323+
step = 1
324+
}
325+
}
326+
},
210327
}, addon:GetOptionHandler(self, false, function() return self:Update() end)
211328
end

modules/FilterOverride.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ end
115115

116116
function mod:OnEnable()
117117
self:UpdateOptions()
118-
self:RegisterEvent('CURSOR_UPDATE')
118+
self:RegisterEvent('CURSOR_CHANGED')
119119
addon.RegisterSectionHeaderScript(self, 'OnTooltipUpdate', 'OnTooltipUpdateSectionHeader')
120120
addon.RegisterSectionHeaderScript(self, 'OnClick', 'OnClickSectionHeader')
121-
self:CURSOR_UPDATE()
121+
self:CURSOR_CHANGED()
122122
end
123123

124124
function mod:OnDisable()
@@ -480,7 +480,7 @@ end
480480
function mod:OnTooltipUpdateSectionHeader(_, header, tooltip)
481481
if GetCursorInfo() == "item" then
482482
if header.section.name ~= FREE_SPACE then
483-
tooltip:AddLine(L["Drop your item there to add it to this section."])
483+
tooltip:AddLine(L["Click here with your item to add it to this section."])
484484
tooltip:AddLine(L["Press Alt while doing so to open a dropdown menu."])
485485
end
486486
elseif header.section:GetKey() ~= JUNK_KEY then
@@ -521,7 +521,7 @@ function mod:OnReceiveDragSectionHeader(_, header)
521521
end
522522
end
523523

524-
function mod:CURSOR_UPDATE()
524+
function mod:CURSOR_CHANGED()
525525
if GetCursorInfo() == "item" then
526526
addon.RegisterSectionHeaderScript(self, 'OnReceiveDrag', 'OnReceiveDragSectionHeader')
527527
else

modules/ItemLevel.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ local L = addon.L
2626
local _G = _G
2727
local abs = _G.math.abs
2828
local GetItemInfo = _G.GetItemInfo
29-
local ITEM_QUALITY_HEIRLOOM = _G.Enum.ItemQuality.Heirloom
30-
local ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
29+
local ITEM_QUALITY_HEIRLOOM
30+
local ITEM_QUALITY_POOR
31+
32+
if addon.isRetail then
33+
ITEM_QUALITY_HEIRLOOM = _G.Enum.ItemQuality.Heirloom
34+
ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
35+
else
36+
ITEM_QUALITY_HEIRLOOM = _G.LE_ITEM_QUALITY_HEIRLOOM
37+
ITEM_QUALITY_POOR = _G.LE_ITEM_QUALITY_POOR
38+
end
39+
3140
local QuestDifficultyColors = _G.QuestDifficultyColors
3241
local UnitLevel = _G.UnitLevel
3342
local modf = _G.math.modf

modules/NewItemTracking.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ local GetContainerItemInfo = _G.GetContainerItemInfo
3030
local GetContainerNumSlots = _G.GetContainerNumSlots
3131
local GetInventoryItemID = _G.GetInventoryItemID
3232
local GetInventoryItemLink = _G.GetInventoryItemLink
33-
local ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
33+
34+
local ITEM_QUALITY_POOR
35+
36+
if addon.isRetail then
37+
ITEM_QUALITY_POOR = _G.Enum.ItemQuality.Poor
38+
else
39+
ITEM_QUALITY_POOR = _G.LE_ITEM_QUALITY_POOR
40+
end
41+
3442
local next = _G.next
3543
local pairs = _G.pairs
3644
local PlaySound = _G.PlaySound

widgets/ContainerFrame.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ function containerProto:UpdateContent(bag)
647647
local prevSlotId = slotData.slotId
648648
local prevLink = slotData.link
649649
local prevTexture = slotData.texture
650+
local prevEquipSlot = slotData.equipSlot
650651
-- If links only differ in character level that's the same item
651652
local sameItem = addon.IsSameLinkButLevel(slotData.link, link)
652653

@@ -655,13 +656,12 @@ function containerProto:UpdateContent(bag)
655656
slotData.itemId = itemId
656657
slotData.name, slotData.quality, slotData.iLevel, slotData.reqLevel, slotData.class, slotData.subclass, slotData.equipSlot, slotData.texture, slotData.vendorPrice = name, quality, iLevel, reqLevel, class, subclass, equipSlot, texture, vendorPrice
657658
slotData.maxStack = maxStack or (link and 1 or 0)
658-
659659
if sameItem then
660660
-- Items that are the same item but have mutated are marked as "new" to make them more visble.
661661
-- However, only things with a new texture are marked as new, i.e. wrapped items.
662-
if prevTexture ~= texture then
662+
if prevTexture ~= texture and equipSlot ~= prevEquipSlot then
663663
sameChanged[slotData.slotId] = slotData
664-
addon:SendMessage('AdiBags_AddNewItem', slotData.link)
664+
addon:SendMessage('AdiBags_AddNewItem', slotData.link)
665665
else
666666
changed[slotData.slotId] = slotData
667667
end

0 commit comments

Comments
 (0)