Skip to content

Commit bb342a3

Browse files
mcagnionclaude
andcommitted
fix(jewels): Add compareJewelsOfSameType option for ItemsTab
Port of bugfix/compare-jewels-same-type-empty-socket onto current origin/dev. Adapted to upstream PathOfBuildingCommunity#9744 changes (new sort-based addCompareForSlot structure): filter moved inside addCompareForSlot so it applies to all codepaths (slotOnlyTooltips, limited uniques, and sorted comparison loop). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0fc3283 commit bb342a3

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

src/Classes/ItemsTab.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,6 +4139,9 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
41394139
if not selItem or not output then
41404140
selItem, output = getReplacedItemAndOutput(compareSlot)
41414141
end
4142+
if main.compareJewelsOfSameType and item.type == "Jewel" and selItem and not self:IsSameJewelComparisonType(item, selItem) then
4143+
return
4144+
end
41424145
local header
41434146
if item == selItem then
41444147
header = "^7Removing this item from "..compareSlot.label.." will give you:"
@@ -4236,6 +4239,22 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
42364239
end
42374240
end
42384241

4242+
function ItemsTabClass:IsSameJewelComparisonType(firstItem, secondItem)
4243+
if not secondItem then
4244+
return false
4245+
end
4246+
if firstItem.type ~= "Jewel" or secondItem.type ~= "Jewel" then
4247+
return false
4248+
end
4249+
4250+
if not firstItem.base or not secondItem.base then
4251+
return firstItem.type == secondItem.type
4252+
end
4253+
4254+
return firstItem.base.type == secondItem.base.type
4255+
and firstItem.base.subType == secondItem.base.subType
4256+
end
4257+
42394258
function ItemsTabClass:CreateUndoState()
42404259
local state = { }
42414260
state.activeItemSetId = self.activeItemSetId

src/Modules/Main.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ function main:Init()
119119
self.showFlavourText = true
120120
self.showAnimations = true
121121
self.showAllItemAffixes = true
122+
self.compareJewelsOfSameType = false
122123
self.errorReadingSettings = false
123124

124125
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
@@ -630,6 +631,9 @@ function main:LoadSettings(ignoreBuild)
630631
self.dpiScaleOverridePercent = tonumber(node.attrib.dpiScaleOverridePercent) or 0
631632
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
632633
end
634+
if node.attrib.compareJewelsOfSameType then
635+
self.compareJewelsOfSameType = node.attrib.compareJewelsOfSameType == "true"
636+
end
633637
end
634638
end
635639
end
@@ -762,6 +766,7 @@ function main:SaveSettings()
762766
showAnimations = tostring(self.showAnimations),
763767
showAllItemAffixes = tostring(self.showAllItemAffixes),
764768
dpiScaleOverridePercent = tostring(self.dpiScaleOverridePercent),
769+
compareJewelsOfSameType = tostring(self.compareJewelsOfSameType),
765770
} })
766771
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
767772
if not res then
@@ -845,11 +850,12 @@ function main:OpenOptionsPopup(savedState)
845850
showFlavourText = self.showFlavourText,
846851
showAnimations = self.showAnimations,
847852
showAllItemAffixes = self.showAllItemAffixes,
848-
dpiScaleOverridePercent = self.dpiScaleOverridePercent
853+
dpiScaleOverridePercent = self.dpiScaleOverridePercent,
854+
compareJewelsOfSameType = self.compareJewelsOfSameType
849855
}
850856

851857
-- NOTE: Height needs to be adjusted if more menu options are added
852-
local oneColumnHeightReq = 850 -- Min height required to not split menu into two columns
858+
local oneColumnHeightReq = 876 -- Min height required to not split menu into two columns
853859
local columnWidth = 600
854860

855861
local startingY = 20
@@ -1114,7 +1120,14 @@ function main:OpenOptionsPopup(savedState)
11141120
end)
11151121
controls.invertSliderScrollDirection.tooltipText = "Default scroll direction is:\nScroll Up = Move right\nScroll Down = Move left"
11161122
controls.invertSliderScrollDirection.state = self.invertSliderScrollDirection
1117-
1123+
1124+
nextRow()
1125+
controls.compareJewelsOfSameType = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Compare jewels by type only:", function(state)
1126+
self.compareJewelsOfSameType = state
1127+
end)
1128+
controls.compareJewelsOfSameType.tooltipText = "Only compare jewels against equipped jewels of the same base type. Empty jewel sockets are still shown."
1129+
controls.compareJewelsOfSameType.state = self.compareJewelsOfSameType
1130+
11181131
if launch.devMode then
11191132
nextRow()
11201133
controls.disableDevAutoSave = new("CheckBoxControl", { "TOPLEFT", controls.sectionAnchor, "TOPLEFT" }, { currentX + defaultLabelPlacementX, currentY, 20 }, "^7Disable Dev AutoSave:", function(state)
@@ -1193,6 +1206,7 @@ function main:OpenOptionsPopup(savedState)
11931206
self.showAllItemAffixes = savedState.showAllItemAffixes
11941207
self.dpiScaleOverridePercent = savedState.dpiScaleOverridePercent
11951208
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
1209+
self.compareJewelsOfSameType = savedState.compareJewelsOfSameType
11961210
main:ClosePopup()
11971211
end)
11981212

0 commit comments

Comments
 (0)