Repository navigation
Expand file tree
/
Copy pathOptions.lua
More file actions
276 lines (261 loc) · 6.56 KB
/
Copy pathOptions.lua
File metadata and controls
276 lines (261 loc) · 6.56 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
local Talented = _G.Talented
local L = LibStub("AceLocale-3.0"):GetLocale("Talented")
Talented.max_talent_points = 71
Talented.defaults = {
profile = {
confirmlearn = true,
level_cap = true,
show_level_req = true,
offset = 48,
scale = 1,
add_bottom_offset = true,
framepos = {},
glyph_on_talent_swap = "active",
restore_bars = false
},
global = {templates = {}},
char = {targets = {}}
}
function Talented:SetOption(info, value)
local name = info[#info]
self.db.profile[name] = value
local arg = info.arg
if arg then
self[arg](self)
end
end
function Talented:GetOption(info)
local name = info[#info]
return self.db.profile[name]
end
function Talented:MustNotConfirmLearn()
return not self.db.profile.confirmlearn
end
Talented.options = {
desc = L["Talented - Talent Editor"],
type = "group",
childGroups = "tab",
handler = Talented,
get = "GetOption",
set = "SetOption",
args = {
options = {
name = L["Options"],
desc = L["General Options for Talented."],
type = "group",
order = 1,
args = {
header1 = {
type = "header",
name = L["General options"],
order = 1
},
always_edit = {
type = "toggle",
name = L["Always edit"],
desc = L["Always allow templates and the current build to be modified, instead of having to Unlock them first."],
arg = "UpdateView",
order = 2
},
confirmlearn = {
type = "toggle",
name = L["Confirm Learning"],
desc = L["Ask for user confirmation before learning any talent."],
order = 3
},
always_call_learn_talents = {
type = "toggle",
name = L["Always try to learn talent"],
desc = L["Always call the underlying API when a user input is made, even when no talent should be learned from it."],
disabled = "MustNotConfirmLearn",
order = 4
},
level_cap = {
type = "toggle",
name = L["Talent cap"],
desc = L["Restrict templates to a maximum of %d points."]:format(Talented.max_talent_points),
arg = "UpdateView",
order = 5
},
show_level_req = {
type = "toggle",
name = L["Level restriction"],
desc = L["Show the required level for the template, instead of the number of points."],
arg = "UpdateView",
order = 6
},
hook_inspect_ui = {
type = "toggle",
name = L["Hook Inspect UI"],
desc = L["Hook the Talent Inspection UI."],
arg = "CheckHookInspectUI",
order = 7
},
show_url_in_chat = {
type = "toggle",
name = L["Output URL in Chat"],
desc = L["Directly outputs the URL in Chat instead of using a Dialog."],
order = 8
},
restore_bars = {
type = "toggle",
name = L["Restore bars with ABS"],
desc = L["If enabled, action bars will be restored automatically after successful respec. Applied template name until first dash is used as parameter (lower case, trailing space removed).\nRequires ABS addon to work."],
order = 9
},
header2 = {
type = "header",
name = L["Glyph frame options"],
order = 10
},
glyph_on_talent_swap = {
name = L["Glyph frame policy on spec swap"],
desc = L["Select the way the glyph frame handle spec swaps."],
type = "select",
order = 11,
width = "double",
values = {
keep = L["Keep the shown spec"],
swap = L["Swap the shown spec"],
active = L["Always show the active spec after a change"]
}
},
header3 = {
type = "header",
name = L["Display options"],
order = 12
},
offset = {
type = "range",
name = L["Icon offset"],
desc = L["Distance between icons."],
arg = "ReLayout",
order = 13,
min = 42,
max = 64,
step = 1
},
scale = {
type = "range",
name = L["Frame scale"],
desc = L["Overall scale of the Talented frame."],
arg = "ReLayout",
order = 14,
min = 0.5,
max = 1.0,
step = 0.01
},
add_bottom_offset = {
type = "toggle",
name = L["Add bottom offset"],
desc = L["Add some space below the talents to show the bottom information."],
arg = "ReLayout",
order = 15
}
}
},
apply = {
name = "Apply",
desc = "Apply the specified template",
type = "input",
dialogHidden = true,
order = 99,
set = function(_, name)
local template = Talented.db.global.templates[name]
if not template then
Talented:Print(L['Can not apply, unknown template "%s"'], name)
return
end
Talented:SetTemplate(template)
Talented:SetMode "apply"
end
}
}
}
function Talented:ReLayout()
self:ViewsReLayout(true)
end
function Talented:UpgradeOptions()
local p = self.db.profile
if p.point or p.offsetx or p.offsety then
local opts = {
anchor = p.point or "CENTER",
anchorTo = p.point or "CENTER",
x = p.offsetx or 0,
y = p.offsety or 0
}
p.framepos.TalentedFrame = opts
p.point, p.offsetx, p.offsety = nil, nil, nil
end
local c = self.db.char
if c.target then
c.targets[1] = c.target
c.target = nil
end
self.UpgradeOptions = nil
end
function Talented:SaveFramePosition(frame)
local db = self.db.profile.framepos
local name = frame:GetName()
local data, _ = db[name]
if not data then
data = {}
db[name] = data
end
data.anchor, _, data.anchorTo, data.x, data.y = frame:GetPoint(1)
end
function Talented:LoadFramePosition(frame)
if not self.db then
self:OnInitialize()
end
local data = self.db.profile.framepos[frame:GetName()]
if data and data.anchor then
frame:ClearAllPoints()
frame:SetPoint(data.anchor, UIParent, data.anchorTo, data.x, data.y)
else
frame:SetPoint "CENTER"
self:SaveFramePosition(frame)
end
end
local function BaseFrame_OnMouseDown(self)
if self.OnMouseDown then
self:OnMouseDown()
end
self:StartMoving()
end
local function BaseFrame_OnMouseUp(self)
self:StopMovingOrSizing()
Talented:SaveFramePosition(self)
if self.OnMouseUp then
self:OnMouseUp()
end
end
function Talented:SetFrameLock(frame, locked)
local db = self.db.profile.framepos
local name = frame:GetName()
local data = db[name]
if not data then
data = {}
db[name] = data
end
if locked == nil then
locked = data.locked
elseif locked == false then
locked = nil
end
data.locked = locked
if locked then
frame:SetMovable(false)
frame:SetScript("OnMouseDown", nil)
frame:SetScript("OnMouseUp", nil)
else
frame:SetMovable(true)
frame:SetScript("OnMouseDown", BaseFrame_OnMouseDown)
frame:SetScript("OnMouseUp", BaseFrame_OnMouseUp)
end
frame:SetClampedToScreen(true)
end
function Talented:GetFrameLock(frame)
local data = self.db.profile.framepos[frame:GetName()]
return data and data.locked
end