Skip to content

Commit 707e6f2

Browse files
committed
Fix mod selectors for jewels and add implicits+corrupts
1 parent 29d745c commit 707e6f2

1 file changed

Lines changed: 52 additions & 22 deletions

File tree

src/Classes/TradeQueryGenerator.lua

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,15 +1213,22 @@ Remove: anoints are completely ignored, and removed from items.]]
12131213
end
12141214
updateLastAnchor(controls.jewelSlot)
12151215
end
1216-
1217-
1216+
-- forward declarations for functions interacting with mod filter selectors
1217+
---@type fun(): table
1218+
local getModList
1219+
---@type fun(controls: any, modList: any)
1220+
local setModSelectors
1221+
-- jewel type selector
12181222
if isJewelSlot and not context.slotTbl.unique then
1219-
controls.jewelType = new("DropDownControl", {"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 100, 18}, { "Base", "Radius" }, function(index, value) end)
1223+
controls.jewelType = new("DropDownControl", { "TOPLEFT", lastItemAnchor, "BOTTOMLEFT" }, { 0, 5, 100, 18 }, { "Base", "Radius" }, function(index, value)
1224+
-- update mod list for selectors
1225+
local mods = getModList()
1226+
setModSelectors(controls, mods)
1227+
end)
12201228
controls.jewelType.selIndex = self.lastJewelType or 1
1221-
controls.jewelTypeLabel = new("LabelControl", {"RIGHT",controls.jewelType,"LEFT"}, {-5, 0, 0, 16}, "Jewel Type:")
1229+
controls.jewelTypeLabel = new("LabelControl", { "RIGHT", controls.jewelType, "LEFT" }, { -5, 0, 0, 16 }, "Jewel Type:")
12221230
updateLastAnchor(controls.jewelType)
12231231
end
1224-
12251232
-- Add max price limit selection dropbox
12261233
local currencyDropdownNames = { }
12271234
for _, currency in ipairs(currencyTable) do
@@ -1337,7 +1344,10 @@ Remove: anoints are completely ignored, and removed from items.]]
13371344
main:ClosePopup()
13381345
end)
13391346

1340-
itemCategoryQueryStr, itemCategory = tradeHelpers.getTradeCategory(slot.slotName, existingItem)
1347+
if context.slotTbl.unique then
1348+
main:OpenPopup(popupWidth, popupHeight, "Query Options", controls)
1349+
return
1350+
end
13411351

13421352
local _, headerYPos = lastItemAnchor:GetPos()
13431353
-- intended width of the whole row, inclding dropdown and aux controls
@@ -1357,25 +1367,45 @@ Remove: anoints are completely ignored, and removed from items.]]
13571367
{ (popupWidth - totalWidth) / 2, lastItemH + lastItemY, 0, 0 },
13581368
"")
13591369
updateLastAnchor(controls.modSelectorHeaderAnchor)
1360-
local mods = { { label = "+ Add Required Stat" } }
1361-
for idStr, modData in pairs(self.modData["Explicit"]) do
1362-
if modData[itemCategory] ~= nil then
1363-
t_insert(mods, { label = modData.tradeMod.text, tradeId = modData.tradeMod.id })
1370+
-- get mod selector list
1371+
getModList = function()
1372+
_, itemCategory = tradeHelpers.getTradeCategory(slot.slotName)
1373+
-- add radius/base as they have different mods
1374+
if controls.jewelType then
1375+
itemCategory = controls.jewelType:GetSelValue() .. itemCategory
1376+
end
1377+
local mods = { { label = "^7+ Add Required Stat" } }
1378+
for _, modType in ipairs({ "Explicit", "Implicit", "Corrupted" }) do
1379+
for idStr, modData in pairs(self.modData[modType]) do
1380+
if modData[itemCategory] ~= nil then
1381+
local text = "^7" .. modData.tradeMod.text:gsub("(%a+) Passive Skills in Radius also grant ", "%1: ")
1382+
if modType ~= "Explicit" then
1383+
-- dim-ish red or the greenish yellow trade site uses for implicits slightly brightened
1384+
local colour = modType == "Corrupted" and "^x9E3E38" or "^x989654"
1385+
text = text .. string.format(" %s(%s)", colour, modType)
1386+
end
1387+
t_insert(mods, { label = text, tradeId = modData.tradeMod.id })
1388+
end
1389+
end
13641390
end
1391+
return mods
13651392
end
1366-
if #mods == 1 then
1367-
main:OpenPopup(popupWidth, popupHeight, "Query Options", controls)
1368-
return
1369-
end
1370-
-- technically we could have 40, but the more we have the fewer stats fit in the weighted sum,
1371-
-- and this means a static popup size is ok
1393+
-- amount of mod selectors: technically we could have 40, but the more we have the fewer
1394+
-- stats fit in the weighted sum, and this means a static popup size is ok
13721395
local maxSelectors = 3
1373-
-- set dropdown labels and adjust width
1374-
local function setModSelectors()
1396+
-- set mod selector dropdown labels, adjust width, and possibly change the mod list
1397+
setModSelectors = function(controls, modList)
1398+
-- reset selections
1399+
if modList then
1400+
selectedMods = {}
1401+
end
13751402
for i = 1, maxSelectors do
13761403
local mod = selectedMods[i]
13771404
local selector = controls["modSelector" .. i]
13781405
local minimumBox = controls["modSelectorMin" .. i]
1406+
if modList then
1407+
selector:SetList(modList)
1408+
end
13791409
if mod then
13801410
selector:SelByValue(mod.label, "label")
13811411
selector.width = totalWidth - auxControlWidth
@@ -1387,7 +1417,7 @@ Remove: anoints are completely ignored, and removed from items.]]
13871417
selector:CheckDroppedWidth(true)
13881418
end
13891419
end
1390-
-- create dropdown and aux controls
1420+
-- mod filter dropdown and aux controls
13911421
for i = 1, maxSelectors do
13921422
-- dropdown which lists all mods that fit
13931423
local dropdown = new("DropDownControl", { "TOPLEFT", lastItemAnchor, "BOTTOMLEFT" },
@@ -1398,7 +1428,7 @@ Remove: anoints are completely ignored, and removed from items.]]
13981428
else
13991429
selectedMods[i] = copyTable(val)
14001430
end
1401-
setModSelectors()
1431+
setModSelectors(controls)
14021432
end)
14031433
dropdown.shown = function()
14041434
return not not selectedMods[i - 1] or i == 1
@@ -1421,14 +1451,14 @@ Remove: anoints are completely ignored, and removed from items.]]
14211451
local clearButton = new("ButtonControl", { "LEFT", minimumBox, "RIGHT" }, { xSpacing, 0, buttonSize, buttonSize },
14221452
"x", function()
14231453
table.remove(selectedMods, i)
1424-
setModSelectors()
1454+
setModSelectors(controls)
14251455
end)
14261456
clearButton.shown = function()
14271457
return not not selectedMods[i]
14281458
end
14291459
controls["modSelectorClear" .. i] = clearButton
14301460
end
1431-
setModSelectors()
1461+
setModSelectors(controls, getModList())
14321462

14331463
main:OpenPopup(popupWidth, popupHeight, "Query Options", controls)
14341464
end

0 commit comments

Comments
 (0)