Skip to content

Commit aebde3e

Browse files
committed
Fixed an issue with outlaw rogues.. again.. (: (fixes #9)
1 parent 53e1c3b commit aebde3e

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

TalentTreeViewer/TalentViewerUIMixin.lua

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ removeFromMixin('GetInspectUnit');
182182
removeFromMixin('OnEvent');
183183
removeFromMixin('RefreshConfigID');
184184

185+
function TalentViewerUIMixin:IsChoiceNode(nodeInfo)
186+
return nodeInfo.type == Enum.TraitNodeType.Selection;
187+
end
188+
185189
--- @return TalentViewer
186190
function TalentViewerUIMixin:GetTalentViewer()
187191
return TalentViewer;
@@ -259,7 +263,7 @@ function TalentViewerUIMixin:MeetsEdgeRequirements(nodeID)
259263
if not nodeInfo then nodeInfo = LibTalentTree:GetNodeInfo(TalentViewer.treeId, incomingNodeId) end
260264
if nodeInfo and LibTalentTree:IsNodeVisibleForSpec(TalentViewer.selectedSpecId, incomingNodeId) then
261265
local isGranted = LibTalentTree:IsNodeGrantedForSpec(TalentViewer.selectedSpecId, incomingNodeId)
262-
local isChoiceNode = #nodeInfo.entryIDs > 1
266+
local isChoiceNode = self:IsChoiceNode(nodeInfo)
263267
local selectedEntryId = isChoiceNode and TalentViewer:GetSelectedEntryId(incomingNodeId) or nil
264268
local activeRank = isGranted
265269
and nodeInfo.maxRanks
@@ -306,7 +310,7 @@ function TalentViewerUIMixin:GetAndCacheNodeInfo(nodeID)
306310
end
307311

308312
local isGranted = LibTalentTree:IsNodeGrantedForSpec(TalentViewer.selectedSpecId, nodeID)
309-
local isChoiceNode = #nodeInfo.entryIDs > 1
313+
local isChoiceNode = self:IsChoiceNode(nodeInfo)
310314
local selectedEntryId = isChoiceNode and TalentViewer:GetSelectedEntryId(nodeID) or nil
311315

312316
local meetsEdgeRequirements = TalentViewer.db.ignoreRestrictions or self:MeetsEdgeRequirements(nodeID)
@@ -615,38 +619,41 @@ function TalentViewerUIMixin:UpdateTreeCurrencyInfo()
615619
end
616620

617621
function TalentViewerUIMixin:ProcessGateMandatedRefunds()
618-
if TalentViewer.db.ignoreRestrictions then return end
622+
if TalentViewer.db.ignoreRestrictions then return; end
623+
local backup = TalentViewer.db.ignoreRestrictions;
624+
TalentViewer.db.ignoreRestrictions = true;
619625

620-
self:UpdateNodeGateMapping()
621-
local eligibleSpendingPerGate = self:GetEligibleSpendingPerGate()
626+
self:UpdateNodeGateMapping();
627+
local eligibleSpendingPerGate = self:GetEligibleSpendingPerGate();
622628
local gates = LibTalentTree:GetGates(self:GetSpecID());
623629

624630
for _, gateInfo in ipairs(gates) do
625-
local eligibleSpending = eligibleSpendingPerGate[gateInfo.conditionID] or 0
631+
local eligibleSpending = eligibleSpendingPerGate[gateInfo.conditionID] or 0;
626632
if eligibleSpending < gateInfo.spentAmountRequired then
627633
for _, nodeID in ipairs(self.nodesPerGate[gateInfo.conditionID]) do
628-
local nodeInfo = self:GetAndCacheNodeInfo(nodeID)
634+
local nodeInfo = self:GetAndCacheNodeInfo(nodeID);
629635
if nodeInfo.ranksPurchased > 0 then
630-
if #nodeInfo.entryIDs > 1 then
631-
self:SetSelection(nodeID, nil)
636+
if self:IsChoiceNode(nodeInfo) then
637+
self:SetSelection(nodeID, nil);
632638
else
633-
self:SetRank(nodeID, 0)
639+
self:SetRank(nodeID, 0);
634640
end
635641
end
636642
end
637643
end
638644
end
645+
TalentViewer.db.ignoreRestrictions = backup;
639646
end
640647

641648
function TalentViewerUIMixin:UpdateNodeGateMapping()
642-
if self.eligibleNodesPerGate and self.nodesPerGate then return end
643-
self.eligibleNodesPerGate = {}
644-
self.nodesPerGate = {}
649+
if self.eligibleNodesPerGate and self.nodesPerGate then return; end
650+
self.eligibleNodesPerGate = {};
651+
self.nodesPerGate = {};
645652
local gates = LibTalentTree:GetGates(self:GetSpecID());
646653

647654
for _, gateInfo in ipairs(gates) do
648-
self.eligibleNodesPerGate[gateInfo.conditionID] = self.eligibleNodesPerGate[gateInfo.conditionID] or {}
649-
self.nodesPerGate[gateInfo.conditionID] = self.nodesPerGate[gateInfo.conditionID] or {}
655+
self.eligibleNodesPerGate[gateInfo.conditionID] = self.eligibleNodesPerGate[gateInfo.conditionID] or {};
656+
self.nodesPerGate[gateInfo.conditionID] = self.nodesPerGate[gateInfo.conditionID] or {};
650657

651658
for _, nodeID in ipairs(C_Traits.GetTreeNodes(TalentViewer.treeId)) do
652659
local nodeInfo = self:GetAndCacheNodeInfo(nodeID);
@@ -662,25 +669,26 @@ function TalentViewerUIMixin:UpdateNodeGateMapping()
662669
end
663670
end
664671
if conditionMatches then
665-
table.insert(self.nodesPerGate[gateInfo.conditionID], nodeID)
672+
table.insert(self.nodesPerGate[gateInfo.conditionID], nodeID);
666673
else
667-
table.insert(self.eligibleNodesPerGate[gateInfo.conditionID], nodeID)
674+
table.insert(self.eligibleNodesPerGate[gateInfo.conditionID], nodeID);
668675
end
669676
end
670677
end
671678
end
672679
end
673680

681+
--- @return table<number, number> # [conditionID] = eligibleSpending
674682
function TalentViewerUIMixin:GetEligibleSpendingPerGate()
675683
local spendingPerGate = {}
676684
for condID, nodeIDs in pairs(self.eligibleNodesPerGate) do
677-
spendingPerGate[condID] = 0
685+
spendingPerGate[condID] = 0;
678686
for _, nodeID in ipairs(nodeIDs) do
679687
local nodeInfo = self:GetAndCacheNodeInfo(nodeID);
680688
local costInfo = self:GetNodeCost(nodeID);
681689
local amount = costInfo[1].amount;
682690
if nodeInfo.ranksPurchased > 0 then
683-
spendingPerGate[condID] = spendingPerGate[condID] + (amount * nodeInfo.ranksPurchased)
691+
spendingPerGate[condID] = spendingPerGate[condID] + (amount * nodeInfo.ranksPurchased);
684692
end
685693
end
686694
end

0 commit comments

Comments
 (0)