Skip to content

Commit afeb2ef

Browse files
committed
Timeless Jewel QoL: copy more, open link directly, and scroll copied to view
1 parent 7e12149 commit afeb2ef

2 files changed

Lines changed: 45 additions & 15 deletions

File tree

src/Classes/TimelessJewelListControl.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ function TimelessJewelListControlClass:SetHighlightColor(index, value)
4141
return false
4242
end
4343

44+
function TimelessJewelListControlClass:ScrollToIndex(index)
45+
if self.scroll then
46+
self.controls.scrollBarV:SetOffset((index - 1) * self.rowHeight)
47+
end
48+
end
49+
4450
function TimelessJewelListControlClass:OverrideSelectIndex(index)
4551
if IsKeyDown("SHIFT") and self.selIndex then
4652
self.highlightIndex = index

src/Classes/TreeTab.lua

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,14 +2098,18 @@ function TreeTabClass:FindTimelessJewel()
20982098
{ edgePadding*2 + listWidth, -(buttonHeight + edgePadding * 2), listWidth, listHeight }, self.build)
20992099
self.tradeQueryRequests = new("TradeQueryRequests")
21002100
controls.msg = new("LabelControl", nil, { -280, 5, 0, 20 }, "")
2101-
controls.searchTradeButton = new("ButtonControl", { "BOTTOMRIGHT", controls.searchResults, "TOPRIGHT" }, { 0, -rowSpacing, 170, buttonHeight }, "Copy Trade URL", function()
2101+
controls.searchTradeButton = new("ButtonControl", { "BOTTOMRIGHT", controls.searchResults, "TOPRIGHT" }, { 0, -rowSpacing, 170, buttonHeight }, "Open Trade URL", function()
21022102
local seedTrades = {}
2103-
local startRow = controls.searchResults.selIndex or 1
2104-
local endRow = startRow + m_floor(10 / ((timelessData.sharedResults.conqueror.id == 1) and 3 or 1))
2105-
if controls.searchResults.highlightIndex then
2103+
local startRow, endRow
2104+
if controls.searchResults.highlightIndex and not controls.searchMore.state then
21062105
startRow = m_min(controls.searchResults.selIndex, controls.searchResults.highlightIndex)
21072106
endRow = m_max(controls.searchResults.selIndex, controls.searchResults.highlightIndex)
2107+
else
2108+
startRow = controls.searchResults.selIndex or 1
2109+
local maxFilters = controls.searchMore.state and 180 or 10
2110+
endRow = startRow + m_floor(maxFilters / ((timelessData.sharedResults.conqueror.id == 1) and 3 or 1))
21082111
end
2112+
21092113

21102114
local seedCount = m_min(#timelessData.searchResults - startRow, endRow - startRow) + 1
21112115
-- update if not highlighted already
@@ -2120,6 +2124,8 @@ function TreeTabClass:FindTimelessJewel()
21202124
endRow = startRow + seedCount - 1
21212125
end
21222126
controls.searchResults.selIndex = startRow
2127+
-- scroll so that startRow is the first visible row
2128+
controls.searchResults:ScrollToIndex(startRow)
21232129
controls.searchResults.highlightIndex = endRow
21242130

21252131
controls.searchTradeButton.lastSearch = {startRow, seedCount}
@@ -2191,17 +2197,20 @@ function TreeTabClass:FindTimelessJewel()
21912197
local selectedRealm = controls.realmSelection:GetSelValue():lower()
21922198

21932199
local realmPath = selectedRealm == "pc" and "" or (selectedRealm .. "/")
2194-
Copy("https://www.pathofexile.com/trade/search/" .. realmPath ..
2195-
(controls.searchTradeLeagueSelect:GetSelValue()) .. "/?q=" .. (s_gsub(dkjson.encode(search), "[^a-zA-Z0-9]", function(a)
2200+
local url = "https://www.pathofexile.com/trade/search/" .. realmPath ..
2201+
(controls.searchTradeLeagueSelect:GetSelValue()) ..
2202+
"/?q=" .. (s_gsub(dkjson.encode(search), "[^a-zA-Z0-9]", function(a)
21962203
return s_format("%%%02X", s_byte(a))
2197-
end)))
2204+
end))
2205+
OpenURL(url)
2206+
Copy(url)
21982207

2199-
controls.searchTradeButton.label = "Copy Next Trade URL"
2208+
controls.searchTradeButton.label = "Open Next Trade URL"
22002209
end)
22012210
controls.searchTradeButton.enabled = timelessData.searchResults and #timelessData.searchResults > 0
22022211
controls.searchTradeButton.tooltipFunc = function(tooltip, mode, index, value)
22032212
tooltip:Clear()
2204-
tooltip:AddLine(16, "^7Click to generate and copy a trade URL for searching for jewels in this list.")
2213+
tooltip:AddLine(16, "^7Click to generate and open a trade URL for searching for jewels in this list.")
22052214
tooltip:AddLine(16, "^7Paste the URL in a web browser to search.")
22062215
tooltip:AddLine(16, "")
22072216
tooltip:AddLine(16, "^7You can click to select a row so that search begins from there.")
@@ -2219,7 +2228,7 @@ function TreeTabClass:FindTimelessJewel()
22192228
"PC", "Sony", "Xbox"
22202229
}
22212230
controls.realmSelection = new("DropDownControl", { "BOTTOMLEFT", controls.searchTradeLeagueSelect, "TOPLEFT" },
2222-
{ 0, -rowSpacing, 80, buttonHeight }, self.realmList, nil)
2231+
{ 0, -rowSpacing, 50, buttonHeight }, self.realmList, nil)
22232232
local function updateLeagues()
22242233
local currentRealmId = controls.realmSelection:GetSelValue():lower()
22252234
if self.tradeLeaguesList[currentRealmId] == nil then self.tradeLeaguesList[currentRealmId] = {} end
@@ -2243,7 +2252,7 @@ function TreeTabClass:FindTimelessJewel()
22432252
for _, league in ipairs(leagues) do
22442253
if league ~= "Standard" and league ~= "Ruthless" and league ~= "Hardcore" and league ~= "Hardcore Ruthless" then
22452254
if not (league:find("Hardcore") or league:find("Ruthless")) then
2246-
-- 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
2255+
-- set the dynamic, base league name to index 1 to sync league shown in dropdown on load with default/old behavior of open trade url
22472256
t_insert(tempLeagueTable, league)
22482257
for _, val in ipairs(leagueList) do
22492258
t_insert(tempLeagueTable, val)
@@ -2283,13 +2292,28 @@ function TreeTabClass:FindTimelessJewel()
22832292
"In person (online)",
22842293
"Any (includes offline)"
22852294
}
2286-
controls.tradeTypeSelection = new("DropDownControl", { "LEFT", controls.realmSelection, "RIGHT" },
2287-
{ labelSpacing, 0, 205, buttonHeight }, tradeTypes, function(index, value)
2295+
controls.tradeTypeSelection = new("DropDownControl", { "BOTTOMRIGHT", controls.searchTradeButton, "TOPRIGHT" },
2296+
{ 0, -rowSpacing, 205, buttonHeight }, tradeTypes, function(index, value)
22882297
self.tradeTypeIndex = index
22892298
end)
22902299
-- remember previous choice
22912300
self.tradeTypeIndex = self.tradeTypeIndex or 1
22922301
controls.tradeTypeSelection:SetSel(self.tradeTypeIndex)
2302+
2303+
-- Checkbox to search a lot at once, or just a few
2304+
controls.searchMore = new("CheckBoxControl", { "BOTTOMRIGHT", controls.tradeTypeSelection, "TOPRIGHT" },
2305+
{ 0, -rowSpacing, 19 }, nil, function(state)
2306+
self.lastSearchMore = state
2307+
end,
2308+
"By default, this tool only searches for 4 or 10 (depending on conqueror) seeds at once to preserve sorting.\nThis option searches up to 180 or 60 seeds at once if you don't care about the sorting.",
2309+
false)
2310+
-- remember previous choice
2311+
if self.lastSearchMore then
2312+
controls.searchMore.state = self.lastSearchMore
2313+
end
2314+
controls.searchMoreLabel = new("LabelControl", { "RIGHT", controls.searchMore, "LEFT" },
2315+
{ -labelSpacing, 0, 0, labelHeight }, "^7Search Maximum Amount:")
2316+
22932317
-- Helper function to search a single socket
22942318
local function searchSingleSocket(socketId, socketInfo)
22952319
if not treeData.nodes[socketId] or not treeData.nodes[socketId].isJewelSocket then
@@ -2654,7 +2678,7 @@ function TreeTabClass:FindTimelessJewel()
26542678

26552679
controls.searchTradeButton.enabled = timelessData.searchResults and #timelessData.searchResults > 0
26562680
controls.searchTradeButton.lastSearch = nil
2657-
controls.searchTradeButton.label = "Copy Trade URL"
2681+
controls.searchTradeButton.label = "Open Trade URL"
26582682
controls.searchResults.highlightIndex = nil
26592683
controls.searchResults.selIndex = 1
26602684
else
@@ -2679,7 +2703,7 @@ function TreeTabClass:FindTimelessJewel()
26792703
t_sort(timelessData.searchResults, function(a, b) return a.total > b.total end)
26802704
controls.searchTradeButton.enabled = timelessData.searchResults and #timelessData.searchResults > 0
26812705
controls.searchTradeButton.lastSearch = nil
2682-
controls.searchTradeButton.label = "Copy Trade URL"
2706+
controls.searchTradeButton.label = "Open Trade URL"
26832707
controls.searchResults.highlightIndex = nil
26842708
controls.searchResults.selIndex = 1
26852709
end

0 commit comments

Comments
 (0)