Skip to content

Commit 6cfdbb1

Browse files
LocalIdentityLocalIdentity
andauthored
Fix Jewel mod sorting not working (#2074)
The sorting of mods on jewels wasn't working as we were using the wrong slot name. The logic now chooses and empty slot then an active slot if it exists so Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent adda267 commit 6cfdbb1

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/Classes/ItemsTab.lua

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ local function checkLineForAllocates(line, nodes)
21362136
end
21372137

21382138
function ItemsTabClass:AddModComparisonTooltip(tooltip, mod)
2139-
local slotName = self.displayItem:GetPrimarySlot()
2139+
local slotName = self:GetComparisonSlotNameForItem(self.displayItem)
21402140
local newItem = new("Item", self.displayItem:BuildRaw())
21412141

21422142
for _, subMod in ipairs(mod) do
@@ -2168,6 +2168,21 @@ function ItemsTabClass:GetEquippedSlotForItem(item)
21682168
end
21692169
end
21702170

2171+
function ItemsTabClass:GetComparisonSlotNameForItem(item)
2172+
local equippedSlot = self:GetEquippedSlotForItem(item)
2173+
if equippedSlot then
2174+
return equippedSlot.slotName
2175+
end
2176+
if item.type == "Jewel" then
2177+
for _, slot in ipairs(self.orderedSlots) do
2178+
if not slot.inactive and slot.selItemId == 0 and slot:IsShown() and self:IsItemValidForSlot(item, slot.slotName) then
2179+
return slot.slotName
2180+
end
2181+
end
2182+
end
2183+
return item:GetPrimarySlot()
2184+
end
2185+
21712186
-- Check if the given item could be equipped in the given slot, taking into account possible conflicts with currently equipped items
21722187
-- For example, a shield is not valid for Weapon 2 if Weapon 1 is a staff, and a wand is not valid for Weapon 2 if Weapon 1 is a dagger
21732188
function ItemsTabClass:IsItemValidForSlot(item, slotName, itemSet, flagState)
@@ -2685,7 +2700,7 @@ function ItemsTabClass:CorruptDisplayItem() -- todo implement vaal orb new outco
26852700
end
26862701
local function sortEnchantList(stat)
26872702
if stat then
2688-
local slotName = self.displayItem:GetPrimarySlot()
2703+
local slotName = self:GetComparisonSlotNameForItem(self.displayItem)
26892704
local calcFunc = self.build.calcsTab:GetMiscCalculator()
26902705
local useFullDPS = stat == "FullDPS"
26912706
sortModList(enchantList[currentModType], stat, function(listMod)
@@ -2913,7 +2928,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
29132928
end
29142929
local selected = not selectFirst and modList[controls.modSelect.selIndex] or nil
29152930
if stat then
2916-
local slotName = self.displayItem:GetPrimarySlot()
2931+
local slotName = self:GetComparisonSlotNameForItem(self.displayItem)
29172932
local calcFunc = self.build.calcsTab:GetMiscCalculator()
29182933
local useFullDPS = stat == "FullDPS"
29192934
sortModList(modList, stat, function(listMod)

0 commit comments

Comments
 (0)