Skip to content

Commit

Permalink
Add support for selecting league for Timeless Jewel search (#7028)
Browse files Browse the repository at this point in the history
* league dropdown for timeless jewel search

* call out for leagues only once
  • Loading branch information
Peechey authored Dec 17, 2023
1 parent f754f69 commit 88ef4f5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Classes/TradeQueryRequests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ function TradeQueryRequestsClass:FetchLeagues(realm, callback)
end
local leagues = {}
for _, value in pairs(json_data) do
if not value.id:find("SSF") then
if (not value.id:find("SSF") and not value.id:find("Solo")) then
table.insert(leagues, value.id)
end
end
Expand Down
37 changes: 35 additions & 2 deletions src/Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
end, nil, nil, true)
self.controls.treeSearch.tooltipText = "Uses Lua pattern matching for complex searches"

self.tradeLeaguesList = { }
-- Find Timeless Jewel Button
self.controls.findTimelessJewel = new("ButtonControl", { "LEFT", self.controls.treeSearch, "RIGHT" }, 8, 0, 150, 20, "Find Timeless Jewel", function()
self:FindTimelessJewel()
Expand Down Expand Up @@ -1723,7 +1724,39 @@ function TreeTabClass:FindTimelessJewel()

controls.searchResultsLabel = new("LabelControl", { "TOPLEFT", nil, "TOPRIGHT" }, -450, 250, 0, 16, "^7Search Results:")
controls.searchResults = new("TimelessJewelListControl", { "TOPLEFT", nil, "TOPRIGHT" }, -450, 275, 438, 200, self.build)

controls.searchTradeLeagueSelect = new("DropDownControl", { "BOTTOMRIGHT", controls.searchResults, "TOPRIGHT" }, -175, -5, 140, 20, nil, function(_, value)
self.timelessJewelLeagueSelect = value
end)
self.tradeQueryRequests = new("TradeQueryRequests")
controls.msg = new("LabelControl", nil, -280, 5, 0, 16, "")
if #self.tradeLeaguesList > 0 then
controls.searchTradeLeagueSelect:SetList(self.tradeLeaguesList)
else
self.tradeQueryRequests:FetchLeagues("pc", function(leagues, errMsg)
if errMsg then
controls.msg.label = "^1Error fetching league list, default league will be used\n"..errMsg.."^7"
return
end
local tempLeagueTable = { }
for _, league in ipairs(leagues) do
if league ~= "Standard" and league ~= "Hardcore" then
if not (league:find("Hardcore") or league:find("Ruthless")) then
-- set the dynamic, base league name to index 1 to sync league shown in dropdown on load with default/old behavior of copy trade url
t_insert(tempLeagueTable, league)
for _, val in ipairs(self.tradeLeaguesList) do
t_insert(tempLeagueTable, val)
end
self.tradeLeaguesList = copyTable(tempLeagueTable)
else
t_insert(self.tradeLeaguesList, league)
end
end
end
t_insert(self.tradeLeaguesList, "Standard")
t_insert(self.tradeLeaguesList, "Hardcore")
controls.searchTradeLeagueSelect:SetList(self.tradeLeaguesList)
end)
end
controls.searchTradeButton = new("ButtonControl", { "BOTTOMRIGHT", controls.searchResults, "TOPRIGHT" }, 0, -5, 170, 20, "Copy Trade URL", function()
local seedTrades = {}
local startRow = controls.searchResults.selIndex or 1
Expand Down Expand Up @@ -1806,7 +1839,7 @@ function TreeTabClass:FindTimelessJewel()
end
end

Copy("https://www.pathofexile.com/trade/search/?q=" .. (s_gsub(dkjson.encode(search), "[^a-zA-Z0-9]", function(a)
Copy("https://www.pathofexile.com/trade/search/"..(self.timelessJewelLeagueSelect or "").."/?q=" .. (s_gsub(dkjson.encode(search), "[^a-zA-Z0-9]", function(a)
return s_format("%%%02X", s_byte(a))
end)))

Expand Down

0 comments on commit 88ef4f5

Please sign in to comment.