Skip to content

Commit 5137c1d

Browse files
Devlin1991LocalIdentity
andauthored
Adds Split Personality path connector coloring and an option menu toggle to disable it. (#9504)
* Adds Split Personality path connector coloring and an option menu toggle to disable it. Signed-off-by: Andrew Devlin <devlin1991@googlemail.com> * Remove config and cache path Removed the config as I don't see a reason for it to exists The function was previously called on every frame in PassiveTreeView but is now cached after each tree change and that cache is used instead --------- Signed-off-by: Andrew Devlin <devlin1991@googlemail.com> Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent fe2b5b0 commit 5137c1d

3 files changed

Lines changed: 91 additions & 9 deletions

File tree

src/Classes/PassiveSpec.lua

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ function PassiveSpecClass:Init(treeVersion, convert)
8181

8282
-- Keys are node IDs, values are the replacement node
8383
self.hashOverrides = { }
84+
85+
-- Cached highlight path for Split Personality jewels
86+
self.splitPersonalityPath = { }
8487
end
8588

8689
function PassiveSpecClass:Load(xml, dbFileName)
@@ -950,6 +953,67 @@ function PassiveSpecClass:SetNodeDistanceToClassStart(root)
950953
end
951954
end
952955

956+
-- Determine the shortest path from the given node to the class' start
957+
-- Only allocated nodes can be traversed
958+
function PassiveSpecClass:GetShortestPathToClassStart(rootId)
959+
local root = self.nodes[rootId]
960+
if not root or not root.alloc or not root.connectedToStart then
961+
return nil
962+
end
963+
964+
-- Stop once the current class' starting node is reached
965+
local targetNodeId = self.curClass.startNodeId
966+
967+
local parent = { }
968+
parent[root.id] = nil
969+
970+
local queue = { root }
971+
local o, i = 1, 2 -- Out, in
972+
while o < i do
973+
local node = queue[o]
974+
o = o + 1
975+
-- Iterate through all nodes that are connected to this one
976+
for _, other in ipairs(node.linked) do
977+
-- If this connected node is the correct class start node, then construct and return the path
978+
if other.id == targetNodeId then
979+
local path = { [root.id] = true, [other.id] = true }
980+
local cur = node
981+
while cur do
982+
path[cur.id] = true
983+
cur = parent[cur.id]
984+
end
985+
return path
986+
end
987+
988+
-- Otherwise, record the parent of this node if it hasn't already been visited
989+
if other.alloc and node.type ~= "Mastery" and other.type ~= "ClassStart" and other.type ~= "AscendClassStart" and not parent[other.id] and other.id ~= root.id then
990+
parent[other.id] = node
991+
992+
-- Add the other node to the end of the queue
993+
queue[i] = other
994+
i = i + 1
995+
end
996+
end
997+
end
998+
return nil
999+
end
1000+
1001+
function PassiveSpecClass:BuildSplitPersonalityPath()
1002+
local splitPersonalityPath = { }
1003+
for nodeId, itemId in pairs(self.jewels) do
1004+
local item = self.build.itemsTab.items[itemId]
1005+
if item and item.jewelData and item.jewelData.jewelIncEffectFromClassStart then
1006+
local path = self:GetShortestPathToClassStart(nodeId)
1007+
if path then
1008+
for id in pairs(path) do
1009+
splitPersonalityPath[id] = true
1010+
end
1011+
end
1012+
end
1013+
end
1014+
self.splitPersonalityPath = splitPersonalityPath
1015+
end
1016+
9531017
function PassiveSpecClass:AddMasteryEffectOptionsToNode(node)
9541018
node.sd = {}
9551019
if node.masteryEffects ~= nil and #node.masteryEffects > 0 then
@@ -1470,6 +1534,8 @@ function PassiveSpecClass:BuildAllDependsAndPaths()
14701534
end
14711535
end
14721536
end
1537+
1538+
self:BuildSplitPersonalityPath()
14731539
end
14741540

14751541
function PassiveSpecClass:ReplaceNode(old, newNode)

src/Classes/PassiveTreeView.lua

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
273273
end
274274
end
275275

276+
-- Split Personality highlight
277+
local splitPersonalityPath = spec.splitPersonalityPath or { }
278+
276279
if treeClick == "LEFT" then
277280
if hoverNode then
278281
-- User left-clicked on a node
@@ -547,7 +550,13 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
547550
end
548551
local function renderConnector(connector)
549552
local node1, node2 = spec.nodes[connector.nodeId1], spec.nodes[connector.nodeId2]
550-
setConnectorColor(1, 1, 1)
553+
local connectorDefaultColor = "^xFFFFFF"
554+
555+
if splitPersonalityPath[node1.id] and splitPersonalityPath[node2.id] then
556+
connectorDefaultColor = colorCodes.SPLITPERSONALITY
557+
end
558+
559+
setConnectorColor(connectorDefaultColor)
551560
local state = getState(node1, node2)
552561
local baseState = state
553562
if self.compareSpec then
@@ -633,6 +642,12 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
633642

634643
local base, overlay, effect
635644
local isAlloc = node.alloc or build.calcsTab.mainEnv.grantedPassives[nodeId] or (compareNode and compareNode.alloc)
645+
local nodeDefaultColor = "^xFFFFFF"
646+
647+
if splitPersonalityPath[node.id] then
648+
nodeDefaultColor = colorCodes.SPLITPERSONALITY
649+
end
650+
636651
SetDrawLayer(nil, 25)
637652
if node.type == "ClassStart" then
638653
overlay = isAlloc and node.startArt or "PSStartNodeBackgroundInactive"
@@ -778,11 +793,11 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
778793
-- Node is a mastery, both have it allocated, but mastery changed, color it blue
779794
SetDrawColor(0, 0, 1)
780795
else
781-
-- Both have or both have not, use white
782-
SetDrawColor(1, 1, 1)
796+
-- Both have or both have not
797+
SetDrawColor(nodeDefaultColor)
783798
end
784799
else
785-
SetDrawColor(1, 1, 1)
800+
SetDrawColor(nodeDefaultColor)
786801
end
787802
end
788803
elseif launch.devModeAlt then
@@ -806,11 +821,11 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
806821
-- Node is a mastery, both have it allocated, but mastery changed, color it blue
807822
SetDrawColor(0, 0, 1)
808823
else
809-
-- Both have or both have not, use white
810-
SetDrawColor(1, 1, 1)
811-
end
824+
-- Both have or both have not
825+
SetDrawColor(nodeDefaultColor)
826+
end
812827
else
813-
SetDrawColor(1, 1, 1)
828+
SetDrawColor(nodeDefaultColor)
814829
end
815830
end
816831

src/Data/Global.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ colorCodes = {
5656
BRITTLEBG = "^x00122b",
5757
SAPBG = "^x261500",
5858
SCOURGE = "^xFF6E25",
59-
CRUCIBLE = "^xFFA500"
59+
CRUCIBLE = "^xFFA500",
60+
SPLITPERSONALITY = "^xFFD62A"
6061
}
6162
colorCodes.STRENGTH = colorCodes.MARAUDER
6263
colorCodes.DEXTERITY = colorCodes.RANGER

0 commit comments

Comments
 (0)