-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.lua
More file actions
471 lines (450 loc) · 21.2 KB
/
Config.lua
File metadata and controls
471 lines (450 loc) · 21.2 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
local name, ns = ...
--- @class MythicPlusPull
local MPP = ns.addon
if not MPP then return end
local L = LibStub('AceLocale-3.0'):GetLocale(name)
MPP.version = C_AddOns.GetAddOnMetadata(name, "Version") or "unknown"
--- @type table<MMPE_Setting, any>
MPP.defaultSettings = {
enabled = true,
autoLearnScores = 'newOnly',
inconclusiveDataThreshold = 100, -- Mobs killed within this span of time (in milliseconds) will not be processed since we might not get the criteria update fast enough to know which mob gave what progress. Well, that's the theory anyway.
maxTimeSinceKill = 600, -- Lag tolerance between a mob dying and the progress criteria updating, in milliseconds.
enableTooltip = true,
includeCountInTooltip = true,
tooltipColor = "82E0FF",
enablePullEstimate = true,
pullEstimateCombatOnly = true,
pullFrameTextFormat = L["Current pull:"] .. ' $current%$ + $pull%$ = $estimated%$',
pullFrameTextScale = 1.0,
offsetx = 0, -- extra offset for nameplate text
offsety = 0,
enableNameplateText = true,
nameplateTextFormat = "+$percent$%",
nameplateTextColor = "FFFFFFFF",
nameplateTextScale = 1.0,
lockPullFrame = false,
pullFramePoint = {
["anchorPoint"] = "CENTER",
["relativeFrame"] = "UIParent",
["relativePoint"] = "CENTER",
["offX"] = 400,
["offY"] = 300,
},
debug = false,
debugNewNPCScores = false,
enableMdtEmulation = true,
debugCriteriaEvents = false,
}
local function SetFramePoint(frame, pointInfo)
frame:ClearAllPoints()
frame:SetPoint(
pointInfo.anchorPoint,
pointInfo.relativeFrame,
pointInfo.relativePoint,
pointInfo.offX,
pointInfo.offY
);
end
--- @param setting MMPE_Setting
function MPP:GetSetting(setting)
if (not setting or self.DB.settings[setting] == nil) then
self:PrintWarning(L["MPP attempted to get missing setting:"] .. " " .. (setting or "nil"))
return
end
return self.DB.settings[setting]
end
--- @param setting MMPE_Setting
--- @param value any
function MPP:SetSetting(setting, value)
if (not setting or self.DB.settings[setting] == nil) then
self:PrintWarning(L["MPP attempted to set missing setting:"] .. " " .. (setting or "nil"))
return
end
self.DB.settings[setting] = value
return value
end
--- @param setting MMPE_Setting
function MPP:ToggleSetting(setting)
return self:SetSetting(setting, not self:GetSetting(setting))
end
function MPP:InitPopup()
if not StaticPopupDialogs["MPPEDataExportDialog"] then
StaticPopupDialogs["MPPEDataExportDialog"] = {
text = L["CTRL-C to copy"],
button1 = CLOSE,
--- @param dialog StaticPopupTemplate
--- @param data string
OnShow = function(dialog, data)
local function HidePopup()
dialog:Hide();
end
--- @type StaticPopupTemplate_EditBox
local editBox = dialog.GetEditBox and dialog:GetEditBox() or dialog.editBox;
editBox:SetScript("OnEscapePressed", HidePopup);
editBox:SetScript("OnEnterPressed", HidePopup);
editBox:SetScript("OnKeyUp", function(_, key)
if IsControlKeyDown() and (key == 'C' or key == 'X') then
HidePopup();
end
end);
editBox:SetMaxLetters(0);
editBox:SetText(data);
editBox:HighlightText();
end,
hasEditBox = true,
editBoxWidth = 240,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
};
end
end
function MPP:InitConfig()
local mdtLoaded = C_AddOns.IsAddOnLoaded("MythicDungeonTools");
local increment = CreateCounter()
local function set(info, value)
self:SetSetting(info[#info], value)
end
local function get(info)
return self:GetSetting(info[#info])
end
local options = {
type = "group",
childGroups = "tab",
name = L["Mythic Plus Pull"],
desc = L["Mythic Plus Pull progress tracker"],
get = get,
set = set,
args = {
version = {
order = increment(),
type = "description",
name = L["Version:"] .. " " .. self.version,
},
enabled = {
order = increment(),
type = "toggle",
name = L["Enabled"],
desc = L["Enable/Disable the addon"],
},
wipesettings = {
order = increment(),
type = "execute",
name = L["Reset Settings to default"],
desc = L["Reset Settings to default"],
func = function()
self:VerifySettings(true)
end,
width = "double",
},
mainOptions = {
order = increment(),
type = "group",
name = L["Main Options"],
args = {
tooltip = {
order = increment(),
type = "group",
name = L["Tooltip"],
inline = true,
args = {
enableTooltip = {
order = increment(),
type = "toggle",
name = L["Enable Tooltip"],
desc = L["Adds percentage info to the unit tooltip"],
},
includeCountInTooltip = {
order = increment(),
type = "toggle",
name = L["Include Count"],
desc = L["Include the raw count value in the tooltip, as well as the percentage"],
},
},
},
pullEstimateFrame = {
order = increment(),
type = "group",
name = L["Pull Estimate frame"],
inline = true,
args = {
enablePullEstimate = {
order = increment(),
type = "toggle",
name = L["Enable Current Pull frame"],
desc = L["Display a frame with current pull information"],
},
pullEstimateCombatOnly = {
order = increment(),
type = "toggle",
name = L["Only in combat"],
desc = L["Only show the frame when you are in combat"],
},
lockPullFrame = {
order = increment(),
type = "toggle",
name = L["Lock frame"],
desc = L["Lock the frame in place"],
set = function(info, value)
set(info, value)
self.currentPullFrame:EnableMouse(not value)
end,
},
reset = {
order = increment(),
type = "execute",
name = L["Reset position"],
desc = L["Reset position of Current Pull frame to the default"],
func = function()
self.DB.settings.pullFramePoint = self.defaultSettings.pullFramePoint
SetFramePoint(self.currentPullFrame, self.DB.settings.pullFramePoint)
end,
},
pullFrameTextFormat = {
order = increment(),
type = "input",
name = L["Text Format"],
desc = L["The text format of the pull frame. Use placeholders to display information."],
descStyle = "inline",
width = "full",
},
pullFrameTextFormatDescription = {
order = increment(),
type = "description",
name = L['The following placeholders are available:'] .. '\n' ..
' - $current$ ' .. L['The current count of mobs killed.'] .. '\n' ..
' - $pull$ ' .. L['The count of mobs pulled.'] .. '\n' ..
' - $estimated$ ' .. L['The estimated count after all pulled mobs are killed.'] .. '\n' ..
' - $required$ ' .. L['The required count of mobs to reach 100%%.'] .. '\n' ..
' - $current%$ ' .. L['The current percentage of mobs killed.'] .. '\n' ..
' - $pull%$ ' .. L['The percentage of mobs pulled.'] .. '\n' ..
' - $estimated%$ ' .. L['The estimated percentage after all pulled mobs are killed.'] .. '\n' ..
' - $required%$ ' .. L['A long way of writing 100%%.'],
},
resetTextFormat = {
order = increment(),
type = "execute",
name = "Reset Text Format",
desc = "Reset the text format to the default.",
descStyle = "inline",
width = "full",
func = function() self:SetSetting("pullFrameTextFormat", self.defaultSettings.pullFrameTextFormat); end,
},
pullFrameTextScale = {
order = increment(),
type = "range",
name = L["Pull Frame Text Scale"],
desc = L["Scale of the text on the pull frame"],
width = "double",
softMin = 0.5,
softMax = 2,
bigStep = 0.05,
set = function(info, value)
set(info, value)
self.currentPullFrame:SetScale(value)
end,
},
},
},
nameplate = {
order = increment(),
type = "group",
name = L["Nameplate"],
inline = true,
args = {
enableNameplateText = {
order = increment(),
type = "toggle",
name = L["Enable Nameplate Text"],
desc = L["Adds the % info to the enemy nameplates"],
},
nameplateTextColor = {
order = increment(),
type = "color",
name = L["Nameplate Text Color"],
desc = L["Color of the text on the enemy nameplates"],
hasAlpha = true,
get = function(info)
--- @type string
local hex = self:GetSetting(info[#info])
return tonumber(hex:sub(3, 4), 16) / 255, tonumber(hex:sub(5, 6), 16) / 255, tonumber(hex:sub(7, 8), 16) / 255, tonumber(hex:sub(1, 2), 16) / 255
end,
set = function(info, r, g, b, a)
self:SetSetting(info[#info], string.format("%02x%02x%02x%02x", a * 255, r * 255, g * 255, b * 255))
end,
},
nameplateTextFormat = {
order = increment(),
type = "input",
name = L["Text Format"],
desc = L["The text format of the nameplate text. Use placeholders to display information."],
descStyle = "inline",
width = "full",
},
nameplateTextFormatDescription = {
order = increment(),
type = "description",
name = L['The following placeholders are available:'] .. '\n' ..
' - $percent$ ' .. L['The percentage the mob gives.'] .. '\n' ..
' - $count$ ' .. L['The raw count the mob gives.'],
},
resetTextFormat = {
order = increment(),
type = "execute",
name = "Reset Text Format",
desc = "Reset the text format to the default.",
descStyle = "inline",
width = "full",
func = function() self:SetSetting("nameplateTextFormat", self.defaultSettings.nameplateTextFormat); end,
},
nameplateTextScale = {
order = increment(),
type = "range",
name = L["Nameplate Text Scale"],
desc = L["Scale of the text on the enemy nameplates"],
width = "double",
softMin = 0.5,
softMax = 2,
bigStep = 0.05,
set = function(info, value)
set(info, value)
for _, nameplateText in pairs(self.activeNameplates) do
nameplateText:SetScale(value)
end
end,
},
offsetx = {
order = increment(),
type = "range",
name = L["Horizontal offset ( <-> )"],
desc = L["Horizontal offset of the nameplate text"],
width = "double",
softMin = -100,
softMax = 100,
bigStep = 1,
},
offsety = {
order = increment(),
type = "range",
name = L["Vertical Offset ( | )"],
desc = L["Vertical offset of the nameplate text"],
width = "double",
softMin = -100,
softMax = 100,
bigStep = 1,
},
},
},
mdtEmulation = {
order = increment(),
type = "group",
inline = true,
name = L["MDT Emulation"],
args = {
mdtEmulationDescription = {
order = increment(),
type = "description",
name = mdtLoaded
and L["Disabled when MythicDungeonTools is loaded"]
or L["Allows addons and WAs that use MythicDungeonTools for % info to work with this addon instead."],
width = "full",
},
enableMdtEmulation = {
order = increment(),
type = "toggle",
name = L["Enable MDT Emulation"],
desc = "",
set = function(info, value)
self:SetSetting(info[#info], value)
self:CheckMdtEmulation()
end,
disabled = mdtLoaded,
},
},
},
},
},
devOptions = {
order = increment(),
type = "group",
name = L["Developer Options"],
args = {
debug = {
order = increment(),
type = "toggle",
name = L["Debug"],
desc = L["Enable/Disable debug prints"],
},
debugNewNPCScores = {
order = increment(),
type = "toggle",
name = L["Debug New NPC Scores"],
desc = L["Enable/Disable debug prints for new NPC scores"],
},
npcDataPatchVersion = {
order = increment(),
type = "description",
name = function()
return string.format(
L["NPC data patch version: %s, build %d (ts %d)"],
self.npcDataPatchVersionInfo.version,
self.npcDataPatchVersionInfo.build,
self.npcDataPatchVersionInfo.timestamp
);
end,
},
simulationActive = {
order = increment(),
type = "toggle",
name = L["Simulation Mode"],
desc = L["Enable/Disable Simulation Mode"],
width = "double",
get = function(info) return self.simulationActive end,
set = function(info, value) self.simulationActive = value end,
},
simulationMax = {
order = increment(),
type = "range",
name = L["Simulation Required Points"],
desc = L["Simulated number of 'points' required to complete the run"],
softMin = 1,
softMax = 100,
bigStep = 1,
get = function(info) return self.simulationMax end,
set = function(info, value) self.simulationMax = value end,
},
simulationCurrent = {
order = increment(),
type = "range",
name = L["Simulation Current Points"],
desc = L["Simulated number of 'points' currently earned"],
softMin = 1,
softMax = 100,
bigStep = 1,
get = function(info) return self.simulationCurrent end,
set = function(info, value) self.simulationCurrent = value end,
},
debugCriteriaEvents = {
order = increment(),
type = "toggle",
name = L["Debug Criteria Events"],
desc = L["Enable/Disable debug prints for criteria events, ignores the Debug Print setting"],
},
},
},
},
}
self.configPanelName = "Mythic Plus Pull"
LibStub("AceConfig-3.0"):RegisterOptionsTable(self.configPanelName, options)
local _, categoryID = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(self.configPanelName)
self.categoryID = categoryID
end
function MPP:OpenConfig()
if C_SettingsUtil and C_SettingsUtil.OpenSettingsPanel and InCombatLockdown() then
LibStub("AceConfigDialog-3.0"):Open(self.configPanelName);
return;
end
Settings.OpenToCategory(self.categoryID);
end