Skip to content

Commit d6e0bd7

Browse files
committed
Add compareJewelsOfSameType option for ItemsTab
Compare only jewels of the same type when the option is set to true. Maintain existing behavior by defaulting the option to false.
1 parent 79b204e commit d6e0bd7

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

src/Classes/ItemsTab.lua

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3984,14 +3984,17 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
39843984
for _, compareSlot in pairs(compareSlots) do
39853985
if not main.slotOnlyTooltips or (slot and (slot.nodeId == compareSlot.nodeId or slot.slotName == compareSlot.slotName)) or not slot or slot == compareSlot then
39863986
local selItem = self.items[compareSlot.selItemId]
3987-
local output = calcFunc({ repSlotName = compareSlot.slotName, repItem = item ~= selItem and item or nil})
3988-
local header
3989-
if item == selItem then
3990-
header = "^7Removing this item from "..compareSlot.label.." will give you:"
3991-
else
3992-
header = string.format("^7Equipping this item in %s will give you:%s", compareSlot.label, selItem and "\n(replacing "..colorCodes[selItem.rarity]..selItem.name.."^7)" or "")
3987+
3988+
if not (main.compareJewelsOfSameType and item.type == "Jewel" and not self:IsSameBase(item, selItem)) then
3989+
local output = calcFunc({ repSlotName = compareSlot.slotName, repItem = item ~= selItem and item or nil})
3990+
local header
3991+
if item == selItem then
3992+
header = "^7Removing this item from "..compareSlot.label.." will give you:"
3993+
else
3994+
header = string.format("^7Equipping this item in %s will give you:%s", compareSlot.label, selItem and "\n(replacing "..colorCodes[selItem.rarity]..selItem.name.."^7)" or "")
3995+
end
3996+
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, header)
39933997
end
3994-
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, header)
39953998
end
39963999
end
39974000
end
@@ -4006,6 +4009,26 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
40064009
end
40074010
end
40084011

4012+
function ItemsTabClass:IsSameBase(firstItem, secondItem)
4013+
if not secondItem then
4014+
return false
4015+
end
4016+
4017+
if not firstItem.base or not secondItem.base then
4018+
return firstItem.type == secondItem.type
4019+
end
4020+
4021+
if not firstItem.base.subType and not secondItem.base.subType then
4022+
return firstItem.base.type == secondItem.base.type
4023+
end
4024+
4025+
if firstItem.base.subType == secondItem.base.subType then
4026+
return true
4027+
end
4028+
4029+
return false
4030+
end
4031+
40094032
function ItemsTabClass:CreateUndoState()
40104033
local state = { }
40114034
state.activeItemSetId = self.activeItemSetId

src/Modules/Main.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function main:Init()
114114
self.showFlavourText = true
115115
self.showAnimations = true
116116
self.showAllItemAffixes = true
117+
self.compareJewelsOfSameType = false
117118
self.errorReadingSettings = false
118119

119120
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
@@ -660,6 +661,9 @@ function main:LoadSettings(ignoreBuild)
660661
self.dpiScaleOverridePercent = tonumber(node.attrib.dpiScaleOverridePercent) or 0
661662
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
662663
end
664+
if node.attrib.compareJewelsOfSameType then
665+
self.compareJewelsOfSameType = node.attrib.compareJewelsOfSameType == "true"
666+
end
663667
end
664668
end
665669
end
@@ -791,6 +795,7 @@ function main:SaveSettings()
791795
showAnimations = tostring(self.showAnimations),
792796
showAllItemAffixes = tostring(self.showAllItemAffixes),
793797
dpiScaleOverridePercent = tostring(self.dpiScaleOverridePercent),
798+
compareJewelsOfSameType = tostring(self.compareJewelsOfSameType),
794799
} })
795800
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
796801
if not res then
@@ -1078,6 +1083,13 @@ function main:OpenOptionsPopup()
10781083
end)
10791084
controls.invertSliderScrollDirection.tooltipText = "Default scroll direction is:\nScroll Up = Move right\nScroll Down = Move left"
10801085
controls.invertSliderScrollDirection.state = self.invertSliderScrollDirection
1086+
1087+
nextRow()
1088+
controls.compareJewelsOfSameType = new("CheckBoxControl", { "TOPLEFT", nil, "TOPLEFT" }, { defaultLabelPlacementX, currentY, 20 }, "^7Compare jewels of the same type:", function(state)
1089+
self.compareJewelsOfSameType = state
1090+
end)
1091+
controls.compareJewelsOfSameType.tooltipText = "Enabling this option will force comparing jewels only jewels of the same type."
1092+
controls.compareJewelsOfSameType.state = self.compareJewelsOfSameType
10811093

10821094
if launch.devMode then
10831095
nextRow()
@@ -1118,6 +1130,7 @@ function main:OpenOptionsPopup()
11181130
local initialShowAnimations = self.showAnimations
11191131
local initialShowAllItemAffixes = self.showAllItemAffixes
11201132
local initialDpiScaleOverridePercent = self.dpiScaleOverridePercent
1133+
local initialCompareJewelsOfSameType = self.compareJewelsOfSameType
11211134

11221135
-- last line with buttons has more spacing
11231136
nextRow(1.5)
@@ -1175,6 +1188,7 @@ function main:OpenOptionsPopup()
11751188
self.showAllItemAffixes = initialShowAllItemAffixes
11761189
self.dpiScaleOverridePercent = initialDpiScaleOverridePercent
11771190
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
1191+
self.compareJewelsOfSameType = initialCompareJewelsOfSameType
11781192
main:ClosePopup()
11791193
end)
11801194
nextRow(1.5)

0 commit comments

Comments
 (0)