Skip to content

Commit

Permalink
Fix Comparison Tooltip adding Time Lost Jewel mods to incorrect radiu…
Browse files Browse the repository at this point in the history
…sNodes (#63)

* fix time-lost jewel mods being added when they shouldn't

* wording

* init flag

* move flag to treeTab because it loads sooner
  • Loading branch information
Peechey authored Jan 19, 2025
1 parent 6c4bfbb commit 4f97083
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,10 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode)
for _, compareSlot in pairs(compareSlots) do
if not main.slotOnlyTooltips or (slot and (slot.nodeId == compareSlot.nodeId or slot.slotName == compareSlot.slotName)) or not slot or slot == compareSlot then
local selItem = self.items[compareSlot.selItemId]
-- short term fix for Time-Lost jewel processing
self.build.treeTab.skipTimeLostJewelProcessing = true
local output = calcFunc({ repSlotName = compareSlot.slotName, repItem = item ~= selItem and item or nil})
self.build.treeTab.skipTimeLostJewelProcessing = false
local header
if item == selItem then
header = "^7Removing this item from "..compareSlot.label.." will give you:"
Expand Down
1 change: 1 addition & 0 deletions src/Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local TreeTabClass = newClass("TreeTab", "ControlHost", function(self, build)
self.specList[1] = new("PassiveSpec", build, latestTreeVersion)
self:SetActiveSpec(1)
self:SetCompareSpec(1)
self.skipTimeLostJewelProcessing = false

self.anchorControls = new("Control", nil, {0, 0, 0, 20})

Expand Down
33 changes: 18 additions & 15 deletions src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,26 @@ local function setRadiusJewelStats(radiusJewel, radiusJewelStats)
end

local function addStats(jewel, node, spec)
-- reset node stats to base or override for attributes
if spec.hashOverrides and spec.hashOverrides[node.id] then
node.sd = copyTable(spec.hashOverrides[node.id].sd, true)
else
node.sd = copyTable(spec.tree.nodes[node.id].sd, true)
end
-- short term to avoid running the logic on AddItemTooltip
if not spec.build.treeTab.skipTimeLostJewelProcessing then
-- reset node stats to base or override for attributes
if spec.hashOverrides and spec.hashOverrides[node.id] then
node.sd = copyTable(spec.hashOverrides[node.id].sd, true)
else
node.sd = copyTable(spec.tree.nodes[node.id].sd, true)
end

local radiusJewelStats = { }
setRadiusJewelStats(jewel, radiusJewelStats)
for _, stat in ipairs(radiusJewelStats) do
-- the node and stat types match, add sd to node if it's not already there and it's an 'also grant' mod
if not isValueInTable(node.sd, stat.sd) and ((node.type == "Notable" and stat.isNotable) or (node.type == "Normal" and not stat.isNotable))
and stat.toAdd then
t_insert(node.sd, stat.sd)
local radiusJewelStats = { }
setRadiusJewelStats(jewel, radiusJewelStats)
for _, stat in ipairs(radiusJewelStats) do
-- the node and stat types match, add sd to node if it's not already there and it's an 'also grant' mod
if not isValueInTable(node.sd, stat.sd) and ((node.type == "Notable" and stat.isNotable) or (node.type == "Normal" and not stat.isNotable))
and stat.toAdd then
t_insert(node.sd, stat.sd)
end
end
spec.tree:ProcessStats(node)
end
spec.tree:ProcessStats(node)
return node.modList
end

Expand All @@ -169,7 +172,7 @@ local function addStatsFromJewelToNode(jewel, node, spec)
-- if the Time-Lost jewel is socketed, add the stat
if itemsTab.activeSocketList then
for _, nodeId in pairs(itemsTab.activeSocketList) do
local _, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
local socketIndex, socketedJewel = itemsTab:GetSocketAndJewelForNodeID(nodeId)
if socketedJewel and socketedJewel.baseName:find("Time%-Lost") == 1 then
return addStats(jewel, node, spec)
end
Expand Down

0 comments on commit 4f97083

Please sign in to comment.