Skip to content

Commit 0db8a91

Browse files
MrHB212Wires77
andauthored
Fix showing hidden Unseen Path nodes on search (#2023)
Co-authored-by: Wires77 <Wires77@users.noreply.github.com>
1 parent cc8fb82 commit 0db8a91

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/Classes/PassiveSpec.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ function PassiveSpecClass:GetEffectiveAllocationPath(node, altPath)
913913
end
914914

915915
function PassiveSpecClass:AllocNode(node, altPath)
916+
self.build.treeTab.viewer.searchStrCached = ""
916917
if not node.path then
917918
-- Node cannot be connected to the tree as there is no possible path
918919
return
@@ -972,6 +973,7 @@ end
972973

973974
-- Deallocate the given node, and all nodes which depend on it (i.e. which are only connected to the tree through this node)
974975
function PassiveSpecClass:DeallocNode(node)
976+
self.build.treeTab.viewer.searchStrCached = ""
975977
for _, depNode in ipairs(node.depends) do
976978
-- reset any switched attribute nodes
977979
if depNode.isAttribute then

src/Classes/PassiveTreeView.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
763763
local node2 = spec.nodes[connector.nodeId2]
764764
if not node1.unlockConstraint and not node2.unlockConstraint then
765765
renderConnector(connector)
766-
elseif checkUnlockConstraints(build, node1) and checkUnlockConstraints(build, node2) then
766+
elseif self:checkUnlockConstraints(build, node1) and self:checkUnlockConstraints(build, node2) then
767767
renderConnector(connector)
768768
end
769769
end
@@ -809,9 +809,8 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
809809
end
810810

811811
-- Update cached node data
812-
if self.searchStrCached ~= self.searchStr or self.searchNeedsForceUpdate == true then
812+
if self.searchStrCached ~= self.searchStr then
813813
self.searchStrCached = self.searchStr
814-
self.searchNeedsForceUpdate = false
815814

816815
local function prepSearch(search)
817816
search = search:lower()
@@ -831,7 +830,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
831830
self.searchParams = prepSearch(self.searchStr)
832831

833832
for nodeId, node in pairs(spec.nodes) do
834-
self.searchStrResults[nodeId] = #self.searchParams > 0 and self:DoesNodeMatchSearchParams(node)
833+
self.searchStrResults[nodeId] = #self.searchParams > 0 and self:DoesNodeMatchSearchParams(build, node)
835834
end
836835
end
837836

@@ -923,7 +922,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
923922
-- This is the icon that appears in the center of many groups
924923
if not node.unlockConstraint then
925924
base = tree:GetAssetByName(node.activeEffectImage)
926-
elseif checkUnlockConstraints(build, node) then
925+
elseif self:checkUnlockConstraints(build, node) then
927926
base = tree:GetAssetByName(node.activeEffectImage)
928927
end
929928
SetDrawLayer(nil, 15)
@@ -933,15 +932,15 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
933932
if node.activeEffectImage then
934933
if not node.unlockConstraint then
935934
effect = tree:GetAssetByName(node.activeEffectImage)
936-
elseif checkUnlockConstraints(build, node) then
935+
elseif self:checkUnlockConstraints(build, node) then
937936
effect = tree:GetAssetByName(node.activeEffectImage)
938937
end
939938
end
940939
--draws node image and border
941940
if not node.unlockConstraint then
942941
base = tree:GetAssetByName(node.icon)
943942
overlay = node.overlay[state]
944-
elseif checkUnlockConstraints(build, node) then
943+
elseif self:checkUnlockConstraints(build, node) then
945944
base = tree:GetAssetByName(node.icon)
946945
overlay = node.overlay[state]
947946
end
@@ -1157,7 +1156,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
11571156
end
11581157

11591158
end
1160-
if node == hoverNode and (not node.unlockConstraint or checkUnlockConstraints(build, node)) and (node.type ~= "Socket" or not IsKeyDown("SHIFT")) and not IsKeyDown("CTRL") and not main.popups[1] then
1159+
if node == hoverNode and (not node.unlockConstraint or self:checkUnlockConstraints(build, node)) and (node.type ~= "Socket" or not IsKeyDown("SHIFT")) and not IsKeyDown("CTRL") and not main.popups[1] then
11611160
-- Draw tooltip
11621161
SetDrawLayer(nil, 100)
11631162
local size = m_floor(node.size * scale)
@@ -1442,11 +1441,15 @@ function PassiveTreeViewClass:Focus(x, y, viewPort, build)
14421441
self.zoomY = -y * scale
14431442
end
14441443

1445-
function PassiveTreeViewClass:DoesNodeMatchSearchParams(node)
1444+
function PassiveTreeViewClass:DoesNodeMatchSearchParams(build, node)
14461445
if node.type == "ClassStart" or node.type == "OnlyImage" then
14471446
return
14481447
end
14491448

1449+
if node.unlockConstraint and not self:checkUnlockConstraints(build, node) then
1450+
return
1451+
end
1452+
14501453
local needMatches = copyTable(self.searchParams)
14511454
local err
14521455

@@ -2092,7 +2095,7 @@ function PassiveTreeViewClass:LessLuminance()
20922095
end
20932096

20942097
-- Checks if a node has unlockConstraint and if that node is allocated
2095-
function checkUnlockConstraints(build, node)
2098+
function PassiveTreeViewClass:checkUnlockConstraints(build, node)
20962099
if unseenPathHover and node.unlockConstraint and node.unlockConstraint.nodes[1] == 5571 then
20972100
return true
20982101
end

src/Modules/Build.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,21 +246,21 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
246246
self.spec:AddUndoState()
247247
self.spec:SetWindowTitleWithBuildClass()
248248
self.buildFlag = true
249-
self.treeTab.viewer.searchNeedsForceUpdate = true
249+
self.treeTab.viewer.searchStrCached = ""
250250
else
251251
main:OpenConfirmPopup("Class Change", "Changing class to "..value.label.." will reset your passive tree.\nThis can be avoided by connecting one of the "..value.label.." starting nodes to your tree.", "Continue", function()
252252
self.spec:SelectClass(value.classId)
253253
self.spec:AddUndoState()
254254
self.spec:SetWindowTitleWithBuildClass()
255255
self.buildFlag = true
256-
self.treeTab.viewer.searchNeedsForceUpdate = true
256+
self.treeTab.viewer.searchStrCached = ""
257257
end, "Connect Path", function()
258258
if self.spec:ConnectToClass(value.classId) then
259259
self.spec:SelectClass(value.classId)
260260
self.spec:AddUndoState()
261261
self.spec:SetWindowTitleWithBuildClass()
262262
self.buildFlag = true
263-
self.treeTab.viewer.searchNeedsForceUpdate = true
263+
self.treeTab.viewer.searchStrCached = ""
264264
end
265265
end)
266266
end

0 commit comments

Comments
 (0)