Skip to content
50 changes: 38 additions & 12 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,22 @@ Highest Weight - Displays the order retrieved from trade]]
return hideRowFunc(self, row_count)
end

row_count = row_count + 1
self.slotTables[row_count] = { slotName = "Heart of the Well", unique = true, selectedJewelNodeId = activeSocketList[1] }
self:PriceItemRowDisplay(row_count, top_pane_alignment_ref, row_vertical_padding, row_height)
self.controls["name"..row_count].y = self.controls["name"..row_count].y + (row_height + row_vertical_padding)
self.controls["name"..row_count].shown = function()
return hideRowFunc(self, row_count)
end

row_count = row_count + 1
self.slotTables[row_count] = { slotName = "Against the Darkness", unique = true, selectedJewelNodeId = activeSocketList[1] }
self:PriceItemRowDisplay(row_count, top_pane_alignment_ref, row_vertical_padding, row_height)
self.controls["name"..row_count].y = self.controls["name"..row_count].y + (row_height + row_vertical_padding)
self.controls["name"..row_count].shown = function()
return hideRowFunc(self, row_count)
end

-- fix case where the row count is reduced from the last time the popup was
-- opened, which would leave extra row controls in the menu
for k, v in pairs(self.controls) do
Expand All @@ -571,7 +587,7 @@ Highest Weight - Displays the order retrieved from trade]]
local effective_row_count = row_count - ((scrollBarShown and #slotTables >= 19) and #slotTables-19 or 0) + 2 + 2 -- Two top menu rows, two bottom rows, slots after #19 overlap the other controls at the bottom of the pane
self.effective_rows_height = row_height * (effective_row_count - #slotTables + (18 - (#slotTables > 37 and 3 or 0))) -- scrollBar height, "18 - slotTables > 37" logic is fine tuning whitespace after last row
self.pane_height = (row_height + row_vertical_padding) * effective_row_count + 3 * pane_margins_vertical + row_height / 2
local pane_width = 850 + (scrollBarShown and 25 or 0)
local pane_width = 885 + (scrollBarShown and 25 or 0)

self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT", self.controls["StatWeightMultipliersButton"],"TOPRIGHT"}, {0, 25, 18, 0}, 50, "VERTICAL", false)
self.controls.scrollBar.shown = function() return scrollBarShown end
Expand Down Expand Up @@ -778,7 +794,9 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
self.lastComparedWeightList[row_idx][result_index] = self.statSortSelectionList
end

local slotName = self.slotTables[row_idx].nodeId and "Jewel " .. tostring(self.slotTables[row_idx].nodeId) or self.slotTables[row_idx].slotName
local slotTbl = self.slotTables[row_idx]
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
if slotName == "Megalomaniac" then
local addedNodes = {}
for nodeName in (result.item_string.."\r\n"):gmatch("Allocates (.-)\r?\n") do
Expand Down Expand Up @@ -941,8 +959,8 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
slotTbl.slotName == "Watcher's Eye" and self:findValidSlotForWatchersEye() or
slotTbl.fullName and self.itemsTab.slots[slotTbl.fullName]) -- fullName for Abyssal Sockets
local nameColor = slotTbl.unique and colorCodes.UNIQUE or "^7"
controls["name"..row_idx] = new("LabelControl", top_pane_alignment_ref, {0, row_idx*(row_height + row_vertical_padding), 100, row_height - 4}, nameColor..slotTbl.slotName)
controls["bestButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {100 + 8, 0, 80, row_height}, "Find best", function()
controls["name"..row_idx] = new("LabelControl", top_pane_alignment_ref, {0, row_idx*(row_height + row_vertical_padding), 135, row_height - 4}, nameColor..slotTbl.slotName)
controls["bestButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {135 + 8, 0, 80, row_height}, "Find best", function()
self.tradeQueryGenerator:RequestQuery(activeSlot, { slotTbl = slotTbl, controls = controls, row_idx = row_idx }, self.statSortSelectionList, function(context, query, errMsg)
if errMsg then
self:SetNotice(context.controls.pbNotice, colorCodes.NEGATIVE .. errMsg)
Expand Down Expand Up @@ -1070,28 +1088,33 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
local isAuthorized = main.api.authToken ~= nil
local validURL = controls["uri"..row_idx].validURL
local isSearching = controls["priceButton"..row_idx].label == "Searching..."
return isAuthorized and validURL and not isSearching
local selectedJewelSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId]
local hasRequiredJewelSlot = not slotTbl.unique or slotTbl.slotName == "Megalomaniac" or selectedJewelSlot and not selectedJewelSlot.inactive
return isAuthorized and validURL and not isSearching and hasRequiredJewelSlot
end
controls["priceButton"..row_idx].tooltipFunc = function(tooltip)
tooltip:Clear()
if not main.api.authToken then
tooltip:AddLine(16, "You must log in to use the search feature")
elseif not controls["uri"..row_idx].validURL then
tooltip:AddLine(16, "Enter a valid trade URL")
elseif slotTbl.unique and slotTbl.slotName ~= "Megalomaniac"
and (not slotTbl.selectedJewelNodeId or not self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or self.itemsTab.sockets[slotTbl.selectedJewelNodeId].inactive) then
tooltip:AddLine(16, "Requires an active Jewel Socket")
end
end
local clampItemIndex = function(index)
return m_min(m_max(index or 1, 1), self.sortedResultTbl[row_idx] and #self.sortedResultTbl[row_idx] or 1)
end
controls["changeButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {100 + 8, 0, 80, row_height}, "<< Search", function()
controls["changeButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {135 + 8, 0, 80, row_height}, "<< Search", function()
self.itemIndexTbl[row_idx] = nil
self.sortedResultTbl[row_idx] = nil
self.resultTbl[row_idx] = nil
self.totalPrice[row_idx] = nil
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
end)
controls["changeButton"..row_idx].shown = function() return self.resultTbl[row_idx] end
controls["resultDropdown"..row_idx] = new("DropDownControl", { "TOPLEFT", controls["changeButton"..row_idx], "TOPRIGHT"}, {8, 0, 325, row_height}, {}, function(index)
controls["resultDropdown"..row_idx] = new("DropDownControl", { "TOPLEFT", controls["changeButton"..row_idx], "TOPRIGHT"}, {8, 0, 351, row_height}, {}, function(index)
self.itemIndexTbl[row_idx] = self.sortedResultTbl[row_idx][index].index
self:SetFetchResultReturn(row_idx, self.itemIndexTbl[row_idx])
end)
Expand All @@ -1108,7 +1131,8 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
end
local item = new("Item", result.item_string)
tooltip:Clear()
self.itemsTab:AddItemTooltip(tooltip, item, activeSlot)
local tooltipSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or activeSlot
self.itemsTab:AddItemTooltip(tooltip, item, tooltipSlot)
tooltip:AddSeparator(10)
tooltip:AddLine(16, string.format("^7Price: %s %s", result.amount, result.currency))
end
Expand All @@ -1118,8 +1142,9 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
-- pass "true" to not auto equip it as we will have our own logic
self.itemsTab:AddDisplayItem(true)
-- Autoequip it
local slot = slotTbl.nodeId and self.itemsTab.sockets[slotTbl.nodeId] or self.itemsTab.slots[slotTbl.slotName]
if slot and slotTbl.slotName == slot.label and slot:IsShown() and self.itemsTab:IsItemValidForSlot(item, slot.slotName) then
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
local slot = jewelNodeId and self.itemsTab.sockets[jewelNodeId] or self.itemsTab.slots[slotTbl.slotName]
if slot and (jewelNodeId or slotTbl.slotName == slot.label) and slot:IsShown() and self.itemsTab:IsItemValidForSlot(item, slot.slotName) then
slot:SetSelItemId(item.id)
self.itemsTab:PopulateSlots()
self.itemsTab:AddUndoState()
Expand All @@ -1135,15 +1160,16 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
-- item.baseName is nil and throws error in the following AddItemTooltip func
-- if the item is unidentified
local item = new("Item", item_string)
self.itemsTab:AddItemTooltip(tooltip, item, activeSlot, true)
local tooltipSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or activeSlot
self.itemsTab:AddItemTooltip(tooltip, item, tooltipSlot, true)
end
end
controls["importButton"..row_idx].enabled = function()
return self.itemIndexTbl[row_idx] and self.resultTbl[row_idx][self.itemIndexTbl[row_idx]].item_string ~= nil
end
-- Whisper so we can copy to clipboard
controls["whisperButton" .. row_idx] = new("ButtonControl",
{ "TOPLEFT", controls["importButton" .. row_idx], "TOPRIGHT" }, { 8, 0, 170, row_height }, function()
{ "TOPLEFT", controls["importButton" .. row_idx], "TOPRIGHT" }, { 8, 0, 155, row_height }, function()
local itemResult = self.itemIndexTbl[row_idx] and self.resultTbl[row_idx][self.itemIndexTbl[row_idx]]

if not itemResult then return "" end
Expand Down
Loading
Loading