Skip to content

Commit 2c109d1

Browse files
committed
Remove redundant search refresh logic, move global functions to local
1 parent 09f9d80 commit 2c109d1

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

src/Classes/PassiveSpec.lua

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

915915
function PassiveSpecClass:AllocNode(node, altPath)
916-
setSearchForceUpdate()
916+
self.build.treeTab.viewer.searchStrCached = ""
917917
if not node.path then
918918
-- Node cannot be connected to the tree as there is no possible path
919919
return
@@ -973,7 +973,7 @@ end
973973

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

src/Classes/PassiveTreeView.lua

Lines changed: 8 additions & 13 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()
@@ -835,10 +834,6 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
835834
end
836835
end
837836

838-
function setSearchForceUpdate()
839-
self.searchNeedsForceUpdate = true
840-
end
841-
842837
if launch.devModeAlt and hoverNode then
843838
-- Draw orbits of the group node
844839
local groupNode = hoverNode.group
@@ -927,7 +922,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
927922
-- This is the icon that appears in the center of many groups
928923
if not node.unlockConstraint then
929924
base = tree:GetAssetByName(node.activeEffectImage)
930-
elseif checkUnlockConstraints(build, node) then
925+
elseif self:checkUnlockConstraints(build, node) then
931926
base = tree:GetAssetByName(node.activeEffectImage)
932927
end
933928
SetDrawLayer(nil, 15)
@@ -937,15 +932,15 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
937932
if node.activeEffectImage then
938933
if not node.unlockConstraint then
939934
effect = tree:GetAssetByName(node.activeEffectImage)
940-
elseif checkUnlockConstraints(build, node) then
935+
elseif self:checkUnlockConstraints(build, node) then
941936
effect = tree:GetAssetByName(node.activeEffectImage)
942937
end
943938
end
944939
--draws node image and border
945940
if not node.unlockConstraint then
946941
base = tree:GetAssetByName(node.icon)
947942
overlay = node.overlay[state]
948-
elseif checkUnlockConstraints(build, node) then
943+
elseif self:checkUnlockConstraints(build, node) then
949944
base = tree:GetAssetByName(node.icon)
950945
overlay = node.overlay[state]
951946
end
@@ -1161,7 +1156,7 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
11611156
end
11621157

11631158
end
1164-
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
11651160
-- Draw tooltip
11661161
SetDrawLayer(nil, 100)
11671162
local size = m_floor(node.size * scale)
@@ -1451,7 +1446,7 @@ function PassiveTreeViewClass:DoesNodeMatchSearchParams(build, node)
14511446
return
14521447
end
14531448

1454-
if node.unlockConstraint and not checkUnlockConstraints(build, node) then
1449+
if node.unlockConstraint and not self:checkUnlockConstraints(build, node) then
14551450
return
14561451
end
14571452

@@ -2100,7 +2095,7 @@ function PassiveTreeViewClass:LessLuminance()
21002095
end
21012096

21022097
-- Checks if a node has unlockConstraint and if that node is allocated
2103-
function checkUnlockConstraints(build, node)
2098+
function PassiveTreeViewClass:checkUnlockConstraints(build, node)
21042099
if unseenPathHover and node.unlockConstraint and node.unlockConstraint.nodes[1] == 5571 then
21052100
return true
21062101
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)