This repository has been archived by the owner on Nov 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Talented.lua
110 lines (94 loc) · 3.04 KB
/
Talented.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
local AddonName, Addon = ...
Talented = LibStub("AceAddon-3.0"):NewAddon(AddonName, "AceEvent-3.0", "AceConsole-3.0")
local AceGUI = LibStub("AceGUI-3.0")
function Talented:OnInitialize()
self:InitOpts()
self:SeedUI()
self.ldb:Init()
end
function Talented:SeedUI()
if IsAddOnLoaded("Blizzard_TalentUI") then
self:InitUI()
else
self:RegisterEvent("ADDON_LOADED", function(event, ...)
if ... == "Blizzard_TalentUI" then
self:UnregisterEvent("ADDON_LOADED")
self:InitUI()
end
end)
end
end
function Talented:SavePvEBuild()
local newBuild = {
name = '',
build = self.tools.GetActiveTalentString(),
link = nil
}
self:OpenPvESavePanel(newBuild)
end
function Talented:SavePvPBuild(name)
local newBuild = {
name = name,
build = self.tools.GetActivePvPTalentIDs(),
link = nil
}
self:OpenPvPSavePanel(newBuild)
end
function Talented:CommitBuild(build, key)
local specid = self.tools.GetActiveSpecInfo()
local classTable = self.db.class
classTable[specid] = classTable[specid] or { PvE = {}, PvP = {}}
local tbl = classTable[specid][key]
if tbl[build.name] ~= nil then
self:Print(("The build \"%s\" already exists. Overwriting with the new build..."):format(build.name))
end
tbl[build.name] = build
end
function Talented:DeleteMatchingBuilds(key, build, comparator)
local specid = self.tools.GetActiveSpecInfo()
local specTable = self.db.class[specid]
if not specTable or not specTable[key] then return end
specTable = specTable[key]
local buildsToRemove = {}
for k,v in pairs(specTable) do
if comparator(build, v.build) then
tinsert(buildsToRemove, k)
end
end
for _,k in ipairs(buildsToRemove) do
self:Print(("Removing \"%s\""):format(
specTable[k].name
))
specTable[k] = nil
end
end
function Talented:GetActiveBuilds(key)
local specid = self.tools.ActiveSpecID()
-- if not self.db.class[specid] then return {} end
-- if not self.db.class[specid][key] then return {} end
local spectable = self.db.class[specid][key]
local activeBuild, compare
if key == "PvE" then
activeBuild = self.tools.GetActiveTalentString()
compare = self.tools.CompareTalentStrings
elseif key == "PvP" then
activeBuild = self.tools.GetActivePvPTalentIDs()
compare = self.tools.ComparePvPTalentBuilds
else
return {}
end
local activeBuilds = {}
for _,build in pairs(spectable) do
if compare(build.build, activeBuild) then
tinsert(activeBuilds, build)
end
end
return activeBuilds
end
--@do-not-package@
Talented.debug = true
--@end-do-not-package@
-- /tinspect C_SpecializationInfo has lots of PVP Talent stuff we need
-- LearnPvpTalent(spellId, slotNumber)
-- local { 3494, 161, 155, 3509 } = C_SpecializationInfo.GetAllSelectedPvpTalentIDs()
-- local selectedTalentForTier = GetTalentTierInfo(tier, 1)