Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,21 @@ function TradeQueryClass:PriceItem()
-- Row spacing reference is now the name, which is a smaller font than the total height
local pane_height = (top_pane_alignment_height + row_height) * row_count - 4*row_count + 55
local pane_width = 850
local cnt = 1

local slotTables = {}
for _, slotName in ipairs(baseSlots) do
t_insert(slotTables, {name = slotName})
end
local activeSocketList = { }
for nodeId, slot in pairs(self.itemsTab.sockets) do
if not slot.inactive then
t_insert(activeSocketList, nodeId)
end
end
table.sort(activeSocketList)
for _, nodeId in ipairs(activeSocketList) do
t_insert(slotTables, {name = self.itemsTab.sockets[nodeId].label, ref = nodeId})
end

local newItemList = { }
for index, itemSetId in ipairs(self.itemsTab.itemSetOrderList) do
Expand Down Expand Up @@ -282,7 +296,7 @@ on trade site to work on other leagues and realms)]]
self.controls.itemSortSelection = new("DropDownControl", {"TOPRIGHT", nil, "TOPRIGHT"}, -12, 19, 100, 18, self.sortSelectionList, function(index, value)
self.pbSortSelectionIndex = index
for index, _ in pairs(self.resultTbl) do
self:UpdateControlsWithItems({name = baseSlots[index]}, index)
self:UpdateControlsWithItems(slotTables[index], index)
end
end)
self.controls.itemSortSelection.tooltipText = "Weighted Sum searches will always sort\nusing descending weighted sum."
Expand Down Expand Up @@ -362,25 +376,11 @@ on trade site to work on other leagues and realms)]]
if self.pbRealm == "" then
self:UpdateRealms()
end

-- Individual slot rows
top_pane_alignment_ref = {"TOPLEFT", self.controls.poesessidButton, "BOTTOMLEFT"}
for _, slotName in ipairs(baseSlots) do
self:PriceItemRowDisplay(cnt, {name = slotName}, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..cnt], "BOTTOMLEFT"}
cnt = cnt + 1
end
local activeSocketList = { }
for nodeId, slot in pairs(self.itemsTab.sockets) do
if not slot.inactive then
t_insert(activeSocketList, nodeId)
end
end
table.sort(activeSocketList)
for _, nodeId in pairs(activeSocketList) do
self:PriceItemRowDisplay(cnt, {name = self.itemsTab.sockets[nodeId].label, ref = nodeId}, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..cnt], "BOTTOMLEFT"}
cnt = cnt + 1
for index, slotTbl in pairs(slotTables) do
self:PriceItemRowDisplay(index, slotTbl, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..index], "BOTTOMLEFT"}
end
self.controls.fullPrice = new("LabelControl", nil, -3, pane_height - 58, pane_width - 256, row_height, "")
self.controls.close = new("ButtonControl", nil, 0, pane_height - 30, 90, row_height, "Done", function()
Expand Down Expand Up @@ -464,13 +464,15 @@ function TradeQueryClass:UpdateControlsWithItems(slotTbl, index)
if errMsg == "MissingConversionRates" then
self:SetNotice(self.controls.pbNotice, "^4Price sorting is not available, falling back to DPS sort.")
sortedItems, errMsg = self:SortFetchResults(slotTbl, index, self.sortModes.DPS)
end
if errMsg then
elseif errMsg then
self:SetNotice(self.controls.pbNotice, "Error: " .. errMsg)
return
else
self:SetNotice(self.controls.pbNotice, "")
end

self.sortedResultTbl[index] = sortedItems
self.itemIndexTbl[index] = 1
Copy link
Copy Markdown
Contributor Author

@Dullson Dullson Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also included a fix fir the import button in #5375 but this seems to fix it differently.

Didn't check that PR yet but this line was wrong and had to be fixed. Looks like the intention was to reset the item index to 1 after sorting because dropdowns reset but the sorted item indexes are a little more convoluted. This is the correct way to reference the item on the first slot of dropdown containing sorted items.

self.itemIndexTbl[index] = self.sortedResultTbl[index][1].index
self.controls["priceButton"..index].tooltipText = "Sorted by " .. self.sortSelectionList[self.pbSortSelectionIndex]
local pb_index = self.sortedResultTbl[index][1].index
self.totalPrice[index] = {
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/TradeQueryRequests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function TradeQueryRequestsClass:FetchResultBlock(url, callback)
currency = trade_entry.listing.price.currency,
item_string = common.base64.decode(trade_entry.item.extended.text),
whisper = trade_entry.listing.whisper,
weight = trade_entry.item.pseudoMods[1]:match("Sum: (.+)"),
weight = trade_entry.item.pseudoMods and trade_entry.item.pseudoMods[1]:match("Sum: (.+)"),
id = trade_entry.id
})
end
Expand Down