forked from TylerR909/Talented
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TalentedOptions.lua
190 lines (177 loc) · 5.83 KB
/
TalentedOptions.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
local AddonName, Addon = ...
local defaultOptions = {
global = {
config = {
ldb = {
title = true,
build = true
},
squelch = 1, -- 0: Never, 1: When Talented Switches Talents, 2: Always
hidePvPButton = false,
disableSpellPush = true,
debug = false
},
v2seen = false
},
}
local orderNum = 0;
local function order()
orderNum = orderNum + 1;
return orderNum
end
local optionsTable = {
name = "Talented",
handler = Talented,
type = 'group',
args = {
LDBHeader = {
name = "LDB Plugin",
order = order(),
type = "header"
},
LDBTitle = {
name = "Title",
order = order(),
type = "toggle",
set = function(_,val)
Talented.db.global.config.ldb.title = val
Talented.ldb:Refresh()
end,
get = function() return Talented.db.global.config.ldb.title end,
},
LDBBuild = {
name = "Build",
order = order(),
type = "toggle",
set = function(_,val)
Talented.db.global.config.ldb.build = val
Talented.ldb:Refresh()
end,
get = function() return Talented.db.global.config.ldb.build end,
},
OtherHeader = {
name = "Other",
order = order(),
type = "header"
},
Squelch = {
name = "Squelch",
desc = "Control when Talented should silence Learned/Unlearned system messages",
order = order(),
width = 1.5,
type = "select",
values = {
[0] = "Never",
[1] = "When Talented Changes Talents",
[2] = "Always"
},
set = function(_, val)
Talented:Debug(val)
Talented.db.global.config.squelch = val
Talented:InitSquelch()
end,
get = function() return Talented.db.global.config.squelch end
},
HidePvPButton = {
name = "Hide PvP Button",
desc = "Renders the PvP Button on the Talents Frame",
order = order(),
type = "toggle",
get = function() return Talented.db.global.config.hidePvPButton end,
set = function(_,val)
if val then
Talented.PvPTab:Hide()
else
Talented.PvPTab:Show()
end
Talented.db.global.config.hidePvPButton = val
end
},
SpellPushActionbar = {
name = "Stop New Spells on Actionbars",
desc = "Stops new spells from pushing themselves to the actionbars",
order = order(),
type = "toggle",
get = function() return Talented.db.global.config.disableSpellPush end,
set = function(_, val)
Talented.db.global.config.disableSpellPush = val
Talented.tools.SetSpellPushDisabled(val)
end
},
Debug = {
name = "debug",
hidden = true,
order = order(),
type = "toggle",
get = function() return Talented.debug end,
set = function(_, val)
Talented.debug = val
Talented.db.global.config.debug = val
end
}
}
}
function Talented:OpenOptionsFrame(input)
if not input or input:trim() == "" then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
else
LibStub("AceConfigCmd-3.0"):HandleCommand("talented", AddonName, input)
end
end
function Talented:InitOpts()
LibStub("AceConfig-3.0"):RegisterOptionsTable(AddonName, optionsTable)
self.db = LibStub("AceDB-3.0"):New("TalentedDB", defaultOptions, true)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddonName, "Talented", nil)
self:RegisterChatCommand("talented", "OpenOptionsFrame")
self:InitSquelch()
self.tools.SetSpellPushDisabled(self.db.global.config.disableSpellPush)
self.debug = self.db.global.config.debug
-- GetNumSpecializations and GetSpecializationInfo don't return
-- anything on initialization (num=0, info=nil), so we need to
-- delay calling those until the player loads in
self:RegisterEvent("PLAYER_ENTERING_WORLD", function()
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:SeedDB()
Talented.ldb:Refresh()
end)
end
function Talented:SeedDB()
local classDB = self.db.class
for i=1, GetNumSpecializations(), 1 do
local specid = GetSpecializationInfo(i)
classDB[specid] = classDB[specid] or {
PvE = {},
PvP = {}
}
end
end
function Talented:InitSquelch()
self:RemoveSquelch()
local squelchLevel = self.db.global.config.squelch
if squelchLevel > 1 then self:AddSquelch() end
end
function Talented:AddSquelch()
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", self.Squelch)
end
function Talented:RemoveSquelchDelayed()
C_Timer.After(1, function() self:RemoveSquelch() end)
end
function Talented:RemoveSquelch()
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_SYSTEM", self.Squelch)
end
local token = ".+"
local unlearned = ERR_SPELL_UNLEARNED_S:format(token)
local spell = ERR_LEARN_SPELL_S:format(token)
local ability = ERR_LEARN_ABILITY_S:format(token)
local passive = ERR_LEARN_PASSIVE_S:format(token)
function Talented.Squelch(self, event, msg, ...)
if string.match(msg, unlearned)
or string.match(msg, spell)
or string.match(msg, ability)
or string.match(msg, passive)
then
return true
end
return false
end