Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 77 additions & 16 deletions src/Classes/PassiveTreeView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ local m_max = math.max
local m_floor = math.floor
local band = AND64 -- bit.band
local b_rshift = bit.rshift
--This variable is used to display the Unseen Path nodes in green when unallocated and hovered over
--When true the checkUnlockConstraint function will return true for the check
local unseenPathHover = false

local PassiveTreeViewClass = newClass("PassiveTreeView", function(self)
self.ring = NewImageHandle()
Expand Down Expand Up @@ -195,7 +198,12 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
local vY = curTreeY - node.y
if vX * vX + vY * vY <= node.rsq then
hoverNode = node
if hoverNode.id == 5571 and not hoverNode.alloc then
unseenPathHover = true
end
break
else
unseenPathHover = false
end
end
end
Expand Down Expand Up @@ -611,7 +619,13 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
connector.c[5], connector.c[6] = treeToScreen(vert[5], vert[6])
connector.c[7], connector.c[8] = treeToScreen(vert[7], vert[8])

if hoverDep and hoverDep[node1] and hoverDep[node2] then
if hoverNode and hoverNode.id == 5571 and hoverDep and (hoverDep[node1] or hoverDep[node2]) and not hoverNode.alloc and not connector.ascendancyName then
--Used to display Unseen Path nodes green when unallocated and hovered over
setConnectorColor(0, 1, 0)
elseif hoverDep and (hoverDep[node1] or hoverDep[node2]) and hoverNode.id == 5571 and not hoverNode.isAlloc and not connector.ascendancyName then
--Used to display Unseen Path nodes red when allocated and hovered over node
setConnectorColor(1, 0, 0)
elseif hoverDep and hoverDep[node1] and hoverDep[node2] then
-- Both nodes depend on the node currently being hovered over, so color the line red
setConnectorColor(1, 0, 0)
elseif connector.ascendancyName and connector.ascendancyName ~= spec.curAscendClassBaseName then
Expand All @@ -625,9 +639,17 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)

-- Draw the connecting lines between nodes
SetDrawLayer(nil, 20)

for _, connector in pairs(tree.connectors) do
renderConnector(connector)
local node1 = spec.nodes[connector.nodeId1]
local node2 = spec.nodes[connector.nodeId2]
if not node1.unlockConstraint and not node2.unlockConstraint then
renderConnector(connector)
elseif checkUnlockConstraints(build, node1) and checkUnlockConstraints(build, node2) then
renderConnector(connector)
end
end

for _, subGraph in pairs(spec.subGraphs) do
for _, connector in pairs(subGraph.connectors) do
renderConnector(connector)
Expand Down Expand Up @@ -751,18 +773,30 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
end
elseif node.type == "OnlyImage" then
-- This is the icon that appears in the center of many groups
base = tree:GetAssetByName(node.activeEffectImage)

if not node.unlockConstraint then
base = tree:GetAssetByName(node.activeEffectImage)
elseif checkUnlockConstraints(build, node) then
base = tree:GetAssetByName(node.activeEffectImage)
end
SetDrawLayer(nil, 15)
else
-- Normal node (includes keystones and notables)
-- draws image below notables which light up when allocated
if node.activeEffectImage then
effect = tree:GetAssetByName(node.activeEffectImage)
if not node.unlockConstraint then
effect = tree:GetAssetByName(node.activeEffectImage)
elseif checkUnlockConstraints(build, node) then
effect = tree:GetAssetByName(node.activeEffectImage)
end
end
--draws node image and border
if not node.unlockConstraint then
base = tree:GetAssetByName(node.icon)
overlay = node.overlay[state]
elseif checkUnlockConstraints(build, node) then
base = tree:GetAssetByName(node.icon)
overlay = node.overlay[state]
end

base = tree:GetAssetByName(node.icon)

overlay = node.overlay[state]
end
end

Expand Down Expand Up @@ -891,7 +925,9 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
if node.type ~= "ClassStart" and node.type ~= "AscendClassStart" then
if hoverNode and hoverNode ~= node then
-- Mouse is hovering over a different node
if hoverDep and hoverDep[node] then
if hoverDep and hoverDep[node] and hoverNode.id == 5571 and not hoverNode.alloc then
SetDrawColor(0, 1, 0)
elseif hoverDep and hoverDep[node] then
-- This node depends on the hover node, turn it red
SetDrawColor(1, 0, 0)
elseif hoverNode.type == "Socket" and hoverNode.nodesInRadius then
Expand Down Expand Up @@ -970,13 +1006,23 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
end
if node == hoverNode and (node.type ~= "Socket" or not IsKeyDown("SHIFT")) and not IsKeyDown("CTRL") and not main.popups[1] then
-- Draw tooltip
SetDrawLayer(nil, 100)
local size = m_floor(node.size * scale)
if self.tooltip:CheckForUpdate(node, self.showStatDifferences, self.tracePath, launch.devModeAlt, build.outputRevision, build.spec.allocMode) then
self:AddNodeTooltip(self.tooltip, node, build, incSmallPassiveSkillEffect)
if not node.unlockConstraint then
SetDrawLayer(nil, 100)
local size = m_floor(node.size * scale)
if self.tooltip:CheckForUpdate(node, self.showStatDifferences, self.tracePath, launch.devModeAlt, build.outputRevision, build.spec.allocMode) then
self:AddNodeTooltip(self.tooltip, node, build, incSmallPassiveSkillEffect)
end
self.tooltip.center = true
self.tooltip:Draw(m_floor(scrX - size), m_floor(scrY - size), size * 2, size * 2, viewPort)
elseif checkUnlockConstraints(build, node) then
SetDrawLayer(nil, 100)
local size = m_floor(node.size * scale)
if self.tooltip:CheckForUpdate(node, self.showStatDifferences, self.tracePath, launch.devModeAlt, build.outputRevision, build.spec.allocMode) then
self:AddNodeTooltip(self.tooltip, node, build, incSmallPassiveSkillEffect)
end
self.tooltip.center = true
self.tooltip:Draw(m_floor(scrX - size), m_floor(scrY - size), size * 2, size * 2, viewPort)
end
self.tooltip.center = true
self.tooltip:Draw(m_floor(scrX - size), m_floor(scrY - size), size * 2, size * 2, viewPort)
end
end

Expand Down Expand Up @@ -1785,4 +1831,19 @@ function PassiveTreeViewClass:LessLuminance()

local newA = a * alphaFactor;
SetDrawColor(newR, newG, newB, newA)
end

-- Checks if a node has unlockConstraint and if that node is allocated
function checkUnlockConstraints(build, node)
if unseenPathHover and node.unlockConstraint and node.unlockConstraint.nodes[1] == 5571 then
return true
end
if node.unlockConstraint then
for _, nodeId in ipairs(node.unlockConstraint.nodes) do
if nodeId and not build.spec.nodes[nodeId].alloc then
return false
end
end
end
return true
end