Skip to content

Commit 5dc3bba

Browse files
author
LocalIdentity
committed
Fix issues
Fix crash on no jewel socket Fix tooltip and calc to use selected socket
1 parent 53e60f7 commit 5dc3bba

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

src/Classes/TradeQuery.lua

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,15 @@ Highest Weight - Displays the order retrieved from trade]]
558558
end
559559

560560
row_count = row_count + 1
561-
self.slotTables[row_count] = { slotName = "Heart of the Well", unique = true }
561+
self.slotTables[row_count] = { slotName = "Heart of the Well", unique = true, selectedJewelNodeId = activeSocketList[1] }
562562
self:PriceItemRowDisplay(row_count, top_pane_alignment_ref, row_vertical_padding, row_height)
563563
self.controls["name"..row_count].y = self.controls["name"..row_count].y + (row_height + row_vertical_padding)
564564
self.controls["name"..row_count].shown = function()
565565
return hideRowFunc(self, row_count)
566566
end
567567

568568
row_count = row_count + 1
569-
self.slotTables[row_count] = { slotName = "Against the Darkness", unique = true }
569+
self.slotTables[row_count] = { slotName = "Against the Darkness", unique = true, selectedJewelNodeId = activeSocketList[1] }
570570
self:PriceItemRowDisplay(row_count, top_pane_alignment_ref, row_vertical_padding, row_height)
571571
self.controls["name"..row_count].y = self.controls["name"..row_count].y + (row_height + row_vertical_padding)
572572
self.controls["name"..row_count].shown = function()
@@ -794,7 +794,9 @@ function TradeQueryClass:GetResultEvaluation(row_idx, result_index, calcFunc, ba
794794
self.lastComparedWeightList[row_idx][result_index] = self.statSortSelectionList
795795
end
796796

797-
local slotName = self.slotTables[row_idx].nodeId and "Jewel " .. tostring(self.slotTables[row_idx].nodeId) or self.slotTables[row_idx].slotName
797+
local slotTbl = self.slotTables[row_idx]
798+
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
799+
local slotName = jewelNodeId and "Jewel " .. tostring(jewelNodeId) or slotTbl.slotName
798800
if slotName == "Megalomaniac" then
799801
local addedNodes = {}
800802
for nodeName in (result.item_string.."\r\n"):gmatch("Allocates (.-)\r?\n") do
@@ -1086,14 +1088,19 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
10861088
local isAuthorized = main.api.authToken ~= nil
10871089
local validURL = controls["uri"..row_idx].validURL
10881090
local isSearching = controls["priceButton"..row_idx].label == "Searching..."
1089-
return isAuthorized and validURL and not isSearching
1091+
local selectedJewelSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId]
1092+
local hasRequiredJewelSlot = not slotTbl.unique or slotTbl.slotName == "Megalomaniac" or selectedJewelSlot and not selectedJewelSlot.inactive
1093+
return isAuthorized and validURL and not isSearching and hasRequiredJewelSlot
10901094
end
10911095
controls["priceButton"..row_idx].tooltipFunc = function(tooltip)
10921096
tooltip:Clear()
10931097
if not main.api.authToken then
10941098
tooltip:AddLine(16, "You must log in to use the search feature")
10951099
elseif not controls["uri"..row_idx].validURL then
10961100
tooltip:AddLine(16, "Enter a valid trade URL")
1101+
elseif slotTbl.unique and slotTbl.slotName ~= "Megalomaniac"
1102+
and (not slotTbl.selectedJewelNodeId or not self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or self.itemsTab.sockets[slotTbl.selectedJewelNodeId].inactive) then
1103+
tooltip:AddLine(16, "Requires an active Jewel Socket")
10971104
end
10981105
end
10991106
local clampItemIndex = function(index)
@@ -1124,7 +1131,8 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
11241131
end
11251132
local item = new("Item", result.item_string)
11261133
tooltip:Clear()
1127-
self.itemsTab:AddItemTooltip(tooltip, item, activeSlot)
1134+
local tooltipSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or activeSlot
1135+
self.itemsTab:AddItemTooltip(tooltip, item, tooltipSlot)
11281136
tooltip:AddSeparator(10)
11291137
tooltip:AddLine(16, string.format("^7Price: %s %s", result.amount, result.currency))
11301138
end
@@ -1134,8 +1142,9 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
11341142
-- pass "true" to not auto equip it as we will have our own logic
11351143
self.itemsTab:AddDisplayItem(true)
11361144
-- Autoequip it
1137-
local slot = slotTbl.nodeId and self.itemsTab.sockets[slotTbl.nodeId] or self.itemsTab.slots[slotTbl.slotName]
1138-
if slot and slotTbl.slotName == slot.label and slot:IsShown() and self.itemsTab:IsItemValidForSlot(item, slot.slotName) then
1145+
local jewelNodeId = slotTbl.nodeId or slotTbl.selectedJewelNodeId
1146+
local slot = jewelNodeId and self.itemsTab.sockets[jewelNodeId] or self.itemsTab.slots[slotTbl.slotName]
1147+
if slot and (jewelNodeId or slotTbl.slotName == slot.label) and slot:IsShown() and self.itemsTab:IsItemValidForSlot(item, slot.slotName) then
11391148
slot:SetSelItemId(item.id)
11401149
self.itemsTab:PopulateSlots()
11411150
self.itemsTab:AddUndoState()
@@ -1151,7 +1160,8 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
11511160
-- item.baseName is nil and throws error in the following AddItemTooltip func
11521161
-- if the item is unidentified
11531162
local item = new("Item", item_string)
1154-
self.itemsTab:AddItemTooltip(tooltip, item, activeSlot, true)
1163+
local tooltipSlot = slotTbl.selectedJewelNodeId and self.itemsTab.sockets[slotTbl.selectedJewelNodeId] or activeSlot
1164+
self.itemsTab:AddItemTooltip(tooltip, item, tooltipSlot, true)
11551165
end
11561166
end
11571167
controls["importButton"..row_idx].enabled = function()

src/Classes/TradeQueryGenerator.lua

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,6 @@ end
648648
function TradeQueryGeneratorClass:GenerateModWeights(modsToTest)
649649
local start = GetTime()
650650
for _, entry in pairs(modsToTest) do
651-
if entry.tradeMod.text == "# to Level of all Minion Skills" then
652-
print("help")
653-
end
654651
if entry[self.calcContext.itemCategory] ~= nil then
655652
if self.alreadyWeightedMods[entry.tradeMod.id] ~= nil then -- Don't calculate the same thing twice (can happen with corrupted vs implicit)
656653
goto continue
@@ -1172,10 +1169,16 @@ Remove: anoints are completely ignored, and removed from items.]]
11721169
t_insert(activeSocketList, jewelSlot)
11731170
end
11741171
end
1172+
table.sort(activeSocketList, function(a, b)
1173+
return a.label < b.label
1174+
end)
11751175
controls.jewelSlot = new("DropDownControl", {"TOPLEFT", lastItemAnchor, "BOTTOMLEFT"}, {0, 5, 100, 18}, activeSocketList, function(idx, value) end)
11761176
controls.jewelSlotLabel = new("LabelControl", {"RIGHT",controls.jewelSlot,"LEFT"}, {-5, 0, 0, 16}, "Jewel Slot:")
1177-
if self.lastJewelSlot and self.lastJewelSlot <= #activeSocketList then
1178-
controls.jewelSlot.selIndex = self.lastJewelSlot
1177+
for index, jewelSlot in ipairs(activeSocketList) do
1178+
if jewelSlot.nodeId == context.slotTbl.selectedJewelNodeId then
1179+
controls.jewelSlot.selIndex = index
1180+
break
1181+
end
11791182
end
11801183
updateLastAnchor(controls.jewelSlot)
11811184
end
@@ -1237,6 +1240,10 @@ Remove: anoints are completely ignored, and removed from items.]]
12371240
popupHeight = popupHeight + 4
12381241

12391242
controls.generateQuery = new("ButtonControl", { "BOTTOM", nil, "BOTTOM" }, {-45, -10, 80, 20}, "Execute", function()
1243+
local selectedJewelSlot = controls.jewelSlot and controls.jewelSlot:GetSelValue()
1244+
if controls.jewelSlot and not selectedJewelSlot then
1245+
return
1246+
end
12401247
main:ClosePopup()
12411248

12421249
self.tradeTypeIndex = context.controls.tradeTypeSelection.selIndex
@@ -1266,8 +1273,8 @@ Remove: anoints are completely ignored, and removed from items.]]
12661273
options.jewelType = controls.jewelType:GetSelValue()
12671274
end
12681275
if controls.jewelSlot then
1269-
self.lastJewelSlot = controls.jewelSlot.selIndex
1270-
slot = controls.jewelSlot:GetSelValue()
1276+
slot = selectedJewelSlot
1277+
context.slotTbl.selectedJewelNodeId = slot.nodeId
12711278
end
12721279
if controls.maxPrice.buf then
12731280
options.maxPrice = tonumber(controls.maxPrice.buf)
@@ -1287,6 +1294,10 @@ Remove: anoints are completely ignored, and removed from items.]]
12871294

12881295
self:StartQuery(slot, options)
12891296
end)
1297+
controls.generateQuery.enabled = function()
1298+
return not controls.jewelSlot or controls.jewelSlot:GetSelValue() ~= nil
1299+
end
1300+
controls.generateQuery.tooltipText = controls.jewelSlot and "Requires an active Jewel Socket." or nil
12901301
controls.cancel = new("ButtonControl", { "BOTTOM", nil, "BOTTOM" }, {45, -10, 80, 20}, "Cancel", function()
12911302
main:ClosePopup()
12921303
end)

0 commit comments

Comments
 (0)