From a3426f0533e0f8f9676ee51d130ac232175f45bf Mon Sep 17 00:00:00 2001 From: Michael Flegler Date: Wed, 3 Sep 2025 19:29:15 +0200 Subject: [PATCH] Feat: Implement trade mode selection --- src/Classes/TradeQuery.lua | 16 +++++++++++++++- src/Classes/TradeQueryGenerator.lua | 8 ++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Classes/TradeQuery.lua b/src/Classes/TradeQuery.lua index 8d54637e9a..c696ac8995 100644 --- a/src/Classes/TradeQuery.lua +++ b/src/Classes/TradeQuery.lua @@ -359,6 +359,20 @@ Highest Weight - Displays the order retrieved from trade]] -- self:PullPoENinjaCurrencyConversion(self.pbLeague) end) self.controls.pbNotice = new("LabelControl", {"BOTTOMRIGHT", nil, "BOTTOMRIGHT"}, {-row_height - pane_margins_vertical - row_vertical_padding, -pane_margins_vertical - row_height - row_vertical_padding, 300, row_height}, "") + + -- Add Trade Mode dropdown to the bottom right + self.tradeModeList = { + "Instant Buyout and In Person Trade", + "Instant Buyout Only", + "In Person Trade Only", + "Any" + } + self.pbTradeModeSelectionIndex = 3 -- Default to "In Person Trade Only" + self.controls.tradeModeSelection = new("DropDownControl", {"BOTTOMRIGHT", nil, "BOTTOMRIGHT"}, {-pane_margins_horizontal, -pane_margins_vertical, 220, row_height}, self.tradeModeList, function(index, value) + self.pbTradeModeSelectionIndex = index + end) + self.controls.tradeModeSelection:SetSel(self.pbTradeModeSelectionIndex) + self.controls.tradeModeSelection.enableDroppedWidth = true -- Realm selection self.controls.realmLabel = new("LabelControl", {"LEFT", self.controls.setSelect, "RIGHT"}, {18, 0, 20, row_height - 4}, "^7Realm:") @@ -844,7 +858,7 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro 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() - self.tradeQueryGenerator:RequestQuery(activeSlot, { slotTbl = slotTbl, controls = controls, row_idx = row_idx }, self.statSortSelectionList, function(context, query, errMsg) + self.tradeQueryGenerator:RequestQuery(activeSlot, { slotTbl = slotTbl, controls = controls, row_idx = row_idx }, self.statSortSelectionList, self.pbTradeModeSelectionIndex, function(context, query, errMsg) if errMsg then self:SetNotice(context.controls.pbNotice, colorCodes.NEGATIVE .. errMsg) return diff --git a/src/Classes/TradeQueryGenerator.lua b/src/Classes/TradeQueryGenerator.lua index b9ce061093..5468a19eec 100644 --- a/src/Classes/TradeQueryGenerator.lua +++ b/src/Classes/TradeQueryGenerator.lua @@ -817,6 +817,9 @@ function TradeQueryGeneratorClass:FinishQuery() -- So apply a modifier to get a reasonable min and hopefully approximate that the query will start out with small upgrades. local minWeight = megalomaniacSpecialMinWeight or currentStatDiff * 0.5 + local tradeModeMap = { "available", "securable", "online", "any" } + local tradeMode = tradeModeMap[self.calcContext.options.tradeModeIndex] or "online" + -- Generate trade query str and open in browser local filters = 0 local queryTable = { @@ -829,7 +832,7 @@ function TradeQueryGeneratorClass:FinishQuery() } } }, - status = { option = "online" }, + status = { option = tradeMode }, stats = { { type = "weight", @@ -910,7 +913,7 @@ function TradeQueryGeneratorClass:FinishQuery() main:ClosePopup() end -function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callback) +function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, tradeModeIndex, callback) self.requesterCallback = callback self.requesterContext = context @@ -1029,6 +1032,7 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb options.sockets = tonumber(controls.sockets.buf) end options.statWeights = statWeights + options.tradeModeIndex = tradeModeIndex self:StartQuery(slot, options) end)