Skip to content
Open
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
17 changes: 17 additions & 0 deletions spec/System/TestTradeHelpers_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,21 @@ describe("TradeHelpers trade hash matching", function()
assert.equal(7, value)
end)
end)
describe("findTradeIdOption", function()
it("matches a '#'-valued option and returns its value", function()
local tradeId, value = tradeHelpers.findTradeIdOption("+2 to Level of all Arc Skills", "explicit")
assert.equal("explicit.stat_448592698|98", tradeId)
assert.equal(2, value)
end)

it("matches an exact-text option and returns no value", function()
local tradeId, value = tradeHelpers.findTradeIdOption("Allocates Abasement", "enchant")
assert.equal("enchant.stat_2954116742|7338", tradeId)
assert.is_nil(value)
end)

it("returns nil for an unmatchable line", function()
assert.is_nil(tradeHelpers.findTradeIdOption("+100 to IQ", "explicit"))
end)
end)
end)
27 changes: 20 additions & 7 deletions src/Classes/CompareBuySimilar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ function M.openPopup(item, slotName, primaryBuild)

-- Helper to fetch and populate leagues for a given realm API id
local function fetchLeaguesForRealm(realmApiId)
local lastIdx = M.lastLeagueIdx
controls.leagueDrop:SetList({"Loading..."})
controls.leagueDrop.selIndex = 1
tradeQueryRequests:FetchLeagues(realmApiId, function(leagues, errMsg)
Expand Down Expand Up @@ -362,39 +363,51 @@ function M.openPopup(item, slotName, primaryBuild)
break
end
end
if lastIdx then
controls.leagueDrop:SetSel(lastIdx)
end
end)
end

local function rebuildUrl()
local result = buildURL(item, slotName, controls, modEntries, defenceEntries, isUnique)
uri = result
end
-- Realm dropdown
controls.realmLabel = new("LabelControl", {"TOPLEFT", nil, "TOPLEFT"}, {leftMargin, ctrlY, 0, 16}, "^7Realm:")
controls.realmDrop = new("DropDownControl", {"LEFT", controls.realmLabel, "RIGHT"}, {4, 0, 80, 20}, {"PoE2"}, function(index, value)
local realmApiId = REALM_API_IDS[value] or "poe2"
fetchLeaguesForRealm(realmApiId)
rebuildUrl()
M.lastLeagueIdx = index
end)
if M.lastRealmIdx then
controls.realmDrop:SetSel(M.lastRealmIdx, true)
end
controls.realmDrop.disabled = true

-- League dropdown
controls.leagueLabel = new("LabelControl", {"LEFT", controls.realmDrop, "RIGHT"}, {12, 0, 0, 16}, "^7League:")
controls.leagueDrop = new("DropDownControl", {"LEFT", controls.leagueLabel, "RIGHT"}, {4, 0, 160, 20}, {"Loading..."}, function(index, value)
-- League selection stored in the dropdown itself
M.lastLeagueIdx = index
end)
controls.leagueDrop.enabled = function() return #controls.leagueDrop.list > 0 and controls.leagueDrop.list[1] ~= "Loading..." end

-- Listed status dropdown
controls.listedDrop = new("DropDownControl", {"TOPRIGHT", nil, "TOPRIGHT"}, {-leftMargin, ctrlY, 242, 20}, LISTED_STATUS_LABELS, function(index, value)
-- Listed status selection stored in the dropdown itself
M.lastListedIndex = index
end)
if M.lastListedIndex then
controls.listedDrop:SetSel(M.lastListedIndex, true)
end
controls.listedLabel = new("LabelControl", {"RIGHT", controls.listedDrop, "LEFT"}, {-4, 0, 0, 16}, "^7Listed:")

-- Fetch initial leagues for default realm
fetchLeaguesForRealm("poe2")
ctrlY = ctrlY + rowHeight + 4

local function rebuildUrl()
local result = buildURL(item, slotName, controls, modEntries, defenceEntries, isUnique)
uri = result
end


if isUnique then
-- Unique item name label
Expand Down Expand Up @@ -483,8 +496,8 @@ function M.openPopup(item, slotName, primaryBuild)
-- when the trade site has a dropdown for the value, we opt to disable
-- the inputs as they are numeric
if not (entry.isOption or entry.needsExactValue) and entry.value then
controls[prefix .. "Min"] = tradeHelpers.newPlainNumericEdit(nil, { minFieldX - popupWidth / 2, controlYPos, fieldW, fieldH }, entry.value ~= 0 and tostring(entry.value) or "", "Min", 8, rebuildUrl)
controls[prefix .. "Max"] = tradeHelpers.newPlainNumericEdit(nil, { maxFieldX - popupWidth / 2, controlYPos, fieldW, fieldH }, "", "Max", 8, rebuildUrl)
controls[prefix .. "Min"] = tradeHelpers.newPlainNumericEdit(nil, { minFieldX - popupWidth / 2, controlYPos, fieldW, fieldH }, entry.value ~= 0 and tostring(entry.value) or "", "Min", 8, nil, rebuildUrl)
controls[prefix .. "Max"] = tradeHelpers.newPlainNumericEdit(nil, { maxFieldX - popupWidth / 2, controlYPos, fieldW, fieldH }, "", "Max", 8, nil, rebuildUrl)
if not canSearch then
controls[prefix .. "Min"].enabled = function() return false end
controls[prefix .. "Max"].enabled = function() return false end
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/ItemSlotHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ local M = {}
---@param w integer
---@param h integer
function M.DrawViewer(itemsTab, nodeId, x, y, w, h)
local node = itemsTab.build.spec.nodes[nodeId]
if not node then return end
SetDrawLayer(nil, 15)
SetDrawColor(1, 1, 1)

local borderWidth = 1
DrawImage(nil, x, y, w + 2 * borderWidth, h + 2 * borderWidth)

local viewer = itemsTab.socketViewer
local node = itemsTab.build.spec.nodes[nodeId]

viewer.zoom = 17

local viewPortSize = math.min(w, h)
Expand Down
Loading