Skip to content

Commit 1610ec8

Browse files
committed
Minor improvements to leveling builds (closes #32)
1 parent 55c8eea commit 1610ec8

File tree

3 files changed

+51
-20
lines changed

3 files changed

+51
-20
lines changed

core/BlizzardLoadoutChanger.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ function Module:UpdateCurrentConfigID()
2525
or (C_ClassTalents.GetStarterBuildActive() and starterConfigID);
2626
end
2727

28-
--- @return FRAME?
28+
--- @return PlayerSpellsFrame_TalentsFrame|nil
2929
function Module:GetTalentFrame()
30-
return (ClassTalentFrame and ClassTalentFrame.TalentsTab) or (PlayerSpellsFrame and PlayerSpellsFrame.TalentsFrame);
30+
return PlayerSpellsFrame and PlayerSpellsFrame.TalentsFrame;
3131
end
3232

3333
function Module:TryRefreshTalentUI()

core/TalentLoadoutManager.lua

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ local SERIALIZATION_VALUE_SEPARATOR = ns.SERIALIZATION_VALUE_SEPARATOR;
2121
if not _G.TLM then _G.TLM = TLM; end
2222
--@end-debug@
2323

24-
--- @type TLM_ImportExportV1|TLM_ImportExportV2
24+
--- @type TLM_ImportExportV2
2525
local ImportExport = ns.ImportExport;
2626

2727
--- @type TLM_IcyVeinsImport
@@ -281,21 +281,11 @@ function TLM:GetActiveBlizzardLoadoutConfigID()
281281
if not self.playerSpecID then return nil; end
282282

283283
local lastSelected = C_ClassTalents.GetLastSelectedSavedConfigID(self.playerSpecID);
284-
local selectionID =
285-
(
286-
ClassTalentFrame
287-
and ClassTalentFrame.TalentsTab
288-
and ClassTalentFrame.TalentsTab.LoadoutDropDown
289-
and ClassTalentFrame.TalentsTab.LoadoutDropDown.GetSelectionID
290-
and ClassTalentFrame.TalentsTab.LoadoutDropDown:GetSelectionID()
291-
)
292-
or (
293-
PlayerSpellsFrame
294-
and PlayerSpellsFrame.TalentsFrame
295-
and PlayerSpellsFrame.TalentsFrame.LoadSystem
296-
and PlayerSpellsFrame.TalentsFrame.LoadSystem.GetSelectionID
297-
and PlayerSpellsFrame.TalentsFrame.LoadSystem:GetSelectionID()
298-
);
284+
local selectionID = PlayerSpellsFrame
285+
and PlayerSpellsFrame.TalentsFrame
286+
and PlayerSpellsFrame.TalentsFrame.LoadSystem
287+
and PlayerSpellsFrame.TalentsFrame.LoadSystem.GetSelectionID
288+
and PlayerSpellsFrame.TalentsFrame.LoadSystem:GetSelectionID();
299289

300290
return selectionID or lastSelected or C_ClassTalents.GetActiveConfigID() or nil;
301291
end
@@ -849,8 +839,7 @@ function TLM:ApplyCustomLoadout(loadoutInfo, autoApply)
849839
self:Print("Failed to commit loadout.");
850840
return false;
851841
end
852-
--- @type Frame|nil
853-
local talentsTab = ClassTalentFrame and ClassTalentFrame.TalentsTab; ---@diagnostic disable-line: undefined-global
842+
local talentsTab = PlayerSpellsFrame and PlayerSpellsFrame.TalentsFrame
854843
local talentsTabIsVisible = talentsTab and talentsTab.IsVisible and talentsTab:IsVisible();
855844
if autoApply and talentsTab and talentsTabIsVisible then
856845
local stagedNodes = C_Traits.GetStagedPurchases(activeConfigID);

modules/Leveling.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,21 @@ function Module:ReapplyLoadout()
4646
if not loadoutInfo then return end
4747

4848
self:Print("Automatically re-applying loadout", loadoutInfo.displayName, ", go to /TLM to disable this behavior.");
49+
local mapBefore = self:GetSpellIDMap();
4950
CharacterAPI:LoadLoadout(loadoutID, true);
51+
local mapAfter = self:GetSpellIDMap();
52+
53+
if mapBefore and mapAfter then
54+
for spellID, rankAfter in pairs(mapAfter) do
55+
if mapBefore[spellID] ~= rankAfter then
56+
if (mapBefore[spellID] or 0) == 0 then
57+
self:Print("New Talent Learned:", C_Spell.GetSpellLink(spellID));
58+
else
59+
self:Print("Talent Upgraded:", C_Spell.GetSpellLink(spellID), "to rank", rankAfter);
60+
end
61+
end
62+
end
63+
end
5064
end
5165

5266
function Module:AddToCombatLockdownQueue(func, ...)
@@ -66,3 +80,31 @@ function Module:PLAYER_REGEN_ENABLED()
6680
end
6781
wipe(self.CombatLockdownQueue);
6882
end
83+
84+
function Module:GetSpellIDMap()
85+
local map = {}
86+
87+
local configID = C_ClassTalents.GetActiveConfigID()
88+
if configID == nil then return end
89+
90+
local configInfo = C_Traits.GetConfigInfo(configID)
91+
if configInfo == nil then return end
92+
93+
for _, treeID in ipairs(configInfo.treeIDs) do
94+
local nodes = C_Traits.GetTreeNodes(treeID)
95+
for _, nodeID in ipairs(nodes) do
96+
local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID)
97+
for _, entryID in ipairs(nodeInfo.entryIDs) do
98+
local entryInfo = C_Traits.GetEntryInfo(configID, entryID)
99+
if entryInfo and entryInfo.definitionID then
100+
local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID)
101+
if definitionInfo.spellID then
102+
map[definitionInfo.spellID] = nodeInfo.activeRank
103+
end
104+
end
105+
end
106+
end
107+
end
108+
109+
return map
110+
end

0 commit comments

Comments
 (0)