Skip to content

Commit 06a8b50

Browse files
committed
tww update, support herotalent
1 parent 6c921dd commit 06a8b50

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

main.lua

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
1010
insets = { left = 4, right = 3, top = 4, bottom = 3 }
1111
}
1212

13+
local GetSpellInfo = GetSpellInfo or function(spellID)
14+
if not spellID then
15+
return nil;
16+
end
17+
18+
local spellInfo = C_Spell.GetSpellInfo(spellID);
19+
if spellInfo then
20+
return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID;
21+
end
22+
end
23+
24+
local GetSpellCharges = GetSpellCharges or function(id)
25+
local chargeInfo = C_Spell.GetSpellCharges(id)
26+
if not chargeInfo then return end
27+
return chargeInfo.currentCharges, chargeInfo.maxCharges, chargeInfo.cooldownStartTime, chargeInfo.cooldownDuration, chargeInfo.chargeModRate
28+
end
29+
30+
local BOOKTYPE_SPELL = "spell";
31+
32+
local GetSpellBookItemName = GetSpellBookItemName or function(index, bookType)
33+
local spellBank = (bookType == BOOKTYPE_SPELL) and Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet;
34+
return C_SpellBook.GetSpellBookItemName(index, spellBank);
35+
end
1336

1437
local frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
1538
frame:SetBackdrop(backdrop)
@@ -62,7 +85,9 @@ local function updateSpec()
6285
"spellsWithGlowOverlay",
6386
"spellsWithRequireTarget",
6487
"spellsWithTotem",
65-
"spellsWithUsable"
88+
"spellsWithUsable",
89+
"spellNameIsHero",
90+
"spellIDIsHero"
6691
}) do
6792
specDB[field] = specDB[field] or {}
6893
end
@@ -87,18 +112,30 @@ local function gatherTalent()
87112
local nodes = C_Traits.GetTreeNodes(treeId)
88113
for _, nodeId in ipairs(nodes) do
89114
local node = C_Traits.GetNodeInfo(configId, nodeId)
90-
if node.ID ~= 0 then
115+
if node and node.ID ~= 0 then
91116
for idx, talentId in ipairs(node.entryIDs) do
92117
local entryInfo = C_Traits.GetEntryInfo(configId, talentId)
93-
local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID)
94-
local spellId = definitionInfo.spellID
95-
local spellName = GetSpellInfo(spellId)
96-
if spellName then
97-
if not specDB.spellIdToTalentId[spellId] then
98-
PRINT("talent: "..GetSpellInfo(spellId))
118+
if entryInfo and entryInfo.definitionID then
119+
local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID)
120+
local spellId = definitionInfo.spellID
121+
if spellId then
122+
local spellName = GetSpellInfo(spellId)
123+
if spellName then
124+
if not specDB.spellIdToTalentId[spellId] then
125+
if node.subTreeID then
126+
PRINT("herotalent: ".. spellName)
127+
else
128+
PRINT("talent: ".. spellName)
129+
end
130+
end
131+
specDB.spellIdToTalentId[spellId] = talentId
132+
specDB.spellNameToTalentId[spellName] = talentId
133+
if node.subTreeID then
134+
specDB.spellNameIsHero[spellName] = true
135+
specDB.spellIDIsHero[spellId] = true
136+
end
137+
end
99138
end
100-
specDB.spellIdToTalentId[spellId] = talentId
101-
specDB.spellNameToTalentId[spellName] = talentId
102139
end
103140
end
104141
end
@@ -621,7 +658,11 @@ function export()
621658
if specDB.spellsWithUsable[spellId] then
622659
parameters = parameters .. ", usable = true"
623660
end
624-
if specDB.spellIdToTalentId[spellId] then
661+
if specDB.spellIDIsHero[spellId] then
662+
parameters = parameters .. (", herotalent = %s"):format(specDB.spellIdToTalentId[spellId])
663+
elseif specDB.spellNameIsHero[spellName] then
664+
parameters = parameters .. (", herotalent = %s"):format(specDB.spellNameToTalentId[spellName])
665+
elseif specDB.spellIdToTalentId[spellId] then
625666
parameters = parameters .. (", talent = %s"):format(specDB.spellIdToTalentId[spellId])
626667
elseif specDB.spellNameToTalentId[spellName] then
627668
parameters = parameters .. (", talent = %d"):format(specDB.spellNameToTalentId[spellName])

0 commit comments

Comments
 (0)