Skip to content

Commit 54a43e5

Browse files
committed
Adds Split Personality path connector coloring and an option menu toggle to disable it.
Signed-off-by: Andrew Devlin <devlin1991@googlemail.com>
1 parent fb6cd05 commit 54a43e5

4 files changed

Lines changed: 96 additions & 9 deletions

File tree

src/Classes/PassiveSpec.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,51 @@ function PassiveSpecClass:SetNodeDistanceToClassStart(root)
950950
end
951951
end
952952

953+
-- Determine the shortest path from the given node to the class' start
954+
-- Only allocated nodes can be traversed
955+
function PassiveSpecClass:GetShortestPathToClassStart(rootId)
956+
local root = self.nodes[rootId]
957+
if not root or not root.alloc or not root.connectedToStart then
958+
return nil
959+
end
960+
961+
-- Stop once the current class' starting node is reached
962+
local targetNodeId = self.curClass.startNodeId
963+
964+
local parent = { }
965+
parent[root.id] = nil
966+
967+
local queue = { root }
968+
local o, i = 1, 2 -- Out, in
969+
while o < i do
970+
local node = queue[o]
971+
o = o + 1
972+
-- Iterate through all nodes that are connected to this one
973+
for _, other in ipairs(node.linked) do
974+
-- If this connected node is the correct class start node, then construct and return the path
975+
if other.id == targetNodeId then
976+
local path = { [root.id] = true, [other.id] = true }
977+
local cur = node
978+
while cur do
979+
path[cur.id] = true
980+
cur = parent[cur.id]
981+
end
982+
return path
983+
end
984+
985+
-- Otherwise, record the parent of this node if it hasn't already been visited
986+
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
987+
parent[other.id] = node
988+
989+
-- Add the other node to the end of the queue
990+
queue[i] = other
991+
i = i + 1
992+
end
993+
end
994+
end
995+
return nil
996+
end
997+
953998
function PassiveSpecClass:AddMasteryEffectOptionsToNode(node)
954999
node.sd = {}
9551000
if node.masteryEffects ~= nil and #node.masteryEffects > 0 then

src/Classes/PassiveTreeView.lua

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,22 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
269269
end
270270
end
271271

272+
-- Split Personality highlight
273+
local splitPersonalityPath = { }
274+
if main.showSplitPersonalityPath then
275+
for nodeId, itemId in pairs(spec.jewels) do
276+
local item = build.itemsTab.items[itemId]
277+
if item and item.jewelData and item.jewelData.jewelIncEffectFromClassStart then
278+
local path = spec:GetShortestPathToClassStart(nodeId)
279+
if path then
280+
for id in pairs(path) do
281+
splitPersonalityPath[id] = true
282+
end
283+
end
284+
end
285+
end
286+
end
287+
272288
if treeClick == "LEFT" then
273289
if hoverNode then
274290
-- User left-clicked on a node
@@ -503,7 +519,13 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
503519
end
504520
local function renderConnector(connector)
505521
local node1, node2 = spec.nodes[connector.nodeId1], spec.nodes[connector.nodeId2]
506-
setConnectorColor(1, 1, 1)
522+
local connectorDefaultColor = "^xFFFFFF"
523+
524+
if splitPersonalityPath[node1.id] and splitPersonalityPath[node2.id] then
525+
connectorDefaultColor = colorCodes.SPLITPERSONALITY
526+
end
527+
528+
setConnectorColor(connectorDefaultColor)
507529
local state = getState(node1, node2)
508530
local baseState = state
509531
if self.compareSpec then
@@ -589,6 +611,12 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
589611

590612
local base, overlay, effect
591613
local isAlloc = node.alloc or build.calcsTab.mainEnv.grantedPassives[nodeId] or (compareNode and compareNode.alloc)
614+
local nodeDefaultColor = "^xFFFFFF"
615+
616+
if splitPersonalityPath[node.id] then
617+
nodeDefaultColor = colorCodes.SPLITPERSONALITY
618+
end
619+
592620
SetDrawLayer(nil, 25)
593621
if node.type == "ClassStart" then
594622
overlay = isAlloc and node.startArt or "PSStartNodeBackgroundInactive"
@@ -734,11 +762,11 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
734762
-- Node is a mastery, both have it allocated, but mastery changed, color it blue
735763
SetDrawColor(0, 0, 1)
736764
else
737-
-- Both have or both have not, use white
738-
SetDrawColor(1, 1, 1)
765+
-- Both have or both have not
766+
SetDrawColor(nodeDefaultColor)
739767
end
740768
else
741-
SetDrawColor(1, 1, 1)
769+
SetDrawColor(nodeDefaultColor)
742770
end
743771
end
744772
elseif launch.devModeAlt then
@@ -762,11 +790,11 @@ function PassiveTreeViewClass:Draw(build, viewPort, inputEvents)
762790
-- Node is a mastery, both have it allocated, but mastery changed, color it blue
763791
SetDrawColor(0, 0, 1)
764792
else
765-
-- Both have or both have not, use white
766-
SetDrawColor(1, 1, 1)
767-
end
793+
-- Both have or both have not
794+
SetDrawColor(nodeDefaultColor)
795+
end
768796
else
769-
SetDrawColor(1, 1, 1)
797+
SetDrawColor(nodeDefaultColor)
770798
end
771799
end
772800

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

src/Modules/Main.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function main:Init()
115115
self.showAnimations = true
116116
self.showAllItemAffixes = true
117117
self.errorReadingSettings = false
118+
self.showSplitPersonalityPath = true
118119

119120
if not SetDPIScaleOverridePercent then SetDPIScaleOverridePercent = function(scale) end end
120121

@@ -660,6 +661,9 @@ function main:LoadSettings(ignoreBuild)
660661
self.dpiScaleOverridePercent = tonumber(node.attrib.dpiScaleOverridePercent) or 0
661662
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
662663
end
664+
if node.attrib.showSplitPersonalityPath then
665+
self.showSplitPersonalityPath = node.attrib.showSplitPersonalityPath == "true"
666+
end
663667
end
664668
end
665669
end
@@ -791,6 +795,7 @@ function main:SaveSettings()
791795
showAnimations = tostring(self.showAnimations),
792796
showAllItemAffixes = tostring(self.showAllItemAffixes),
793797
dpiScaleOverridePercent = tostring(self.dpiScaleOverridePercent),
798+
showSplitPersonalityPath = tostring(self.showSplitPersonalityPath),
794799
} })
795800
local res, errMsg = common.xml.SaveXMLFile(setXML, self.userPath.."Settings.xml")
796801
if not res then
@@ -1079,6 +1084,12 @@ function main:OpenOptionsPopup()
10791084
controls.invertSliderScrollDirection.tooltipText = "Default scroll direction is:\nScroll Up = Move right\nScroll Down = Move left"
10801085
controls.invertSliderScrollDirection.state = self.invertSliderScrollDirection
10811086

1087+
nextRow()
1088+
controls.showSplitPersonalityPath = new("CheckBoxControl", { "TOPLEFT", nil, "TOPLEFT" }, { defaultLabelPlacementX, currentY, 20 }, "^7Show Split Personality paths:", function(state)
1089+
self.showSplitPersonalityPath = state
1090+
end)
1091+
controls.showSplitPersonalityPath.state = self.showSplitPersonalityPath
1092+
10821093
if launch.devMode then
10831094
nextRow()
10841095
controls.disableDevAutoSave = new("CheckBoxControl", { "TOPLEFT", nil, "TOPLEFT" }, { defaultLabelPlacementX, currentY, 20 }, "^7Disable Dev AutoSave:", function(state)
@@ -1118,6 +1129,7 @@ function main:OpenOptionsPopup()
11181129
local initialShowAnimations = self.showAnimations
11191130
local initialShowAllItemAffixes = self.showAllItemAffixes
11201131
local initialDpiScaleOverridePercent = self.dpiScaleOverridePercent
1132+
local initialShowSplitPersonalityPath = self.showSplitPersonalityPath
11211133

11221134
-- last line with buttons has more spacing
11231135
nextRow(1.5)
@@ -1175,6 +1187,7 @@ function main:OpenOptionsPopup()
11751187
self.showAllItemAffixes = initialShowAllItemAffixes
11761188
self.dpiScaleOverridePercent = initialDpiScaleOverridePercent
11771189
SetDPIScaleOverridePercent(self.dpiScaleOverridePercent)
1190+
self.showSplitPersonalityPath = initialShowSplitPersonalityPath
11781191
main:ClosePopup()
11791192
end)
11801193
nextRow(1.5)

0 commit comments

Comments
 (0)