-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.lua
More file actions
310 lines (279 loc) · 10.3 KB
/
Copy pathsettings.lua
File metadata and controls
310 lines (279 loc) · 10.3 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
local LAM = LibAddonMenu2
local settings = {}
--#region COPY OLD DATA TO NEW ADDON
--[[
local dataMapping = {
['ImpPvPMeterSV'] = 'ImpressiveStatsSV',
['ImpPvPMeterCSV'] = 'ImpressiveStatsCSV',
['PvPMeterBattlegroundsData'] = 'ImpressiveStatsMatchesData',
-- ['ImpPvPMeterMatchBackup'] = 'ImpressiveStatsMatchBackup',
['PvPMeterDuelsData'] = 'ImpressiveStatsDuelsData',
['PvPMeterTOTData'] = 'ImpressiveStatsTributeData',
}
local function IsDataFromImpPvPMeterAvailable()
for oldName, _ in pairs(dataMapping) do
if _G[oldName] ~= nil then return true end
end
end
local function CopyDataFromImpPvPMeter()
for oldSV, newSV in pairs(dataMapping) do
_G[newSV] = _G[oldSV]
_G[oldSV] = nil
end
ReloadUI()
end
--]]
--#endregion
-- TODO: remove this workaround
local function rgbToHex(r, g, b)
return string.format('%02X%02X%02X', math.floor(r * 255), math.floor(g * 255), math.floor(b * 255))
end
local function hexToRGB(hex)
local r = tonumber('0x'..hex:sub(1,2))
local g = tonumber('0x'..hex:sub(3,4))
local b = tonumber('0x'..hex:sub(5,6))
return r / 255, g / 255, b / 255
end
function settings:Initialize(addon)
local settingsName = addon.name .. 'Settings'
local settingsDisplayName = addon.displayName
local addonVersion = addon.addonVersion
local sv = addon.sv
local panelData = {
type = 'panel',
name = settingsDisplayName,
author = '@impda',
website = 'https://www.esoui.com/downloads/info4032-ImpressiveStats.html',
version = addonVersion,
}
local panel = LAM:RegisterAddonPanel(settingsName, panelData)
local errorsSV = sv.errors
local err = {} -- errors module
err[#err+1] = {
type = 'checkbox',
name = 'Enable errors module',
getFunc = function() return errorsSV.enabled end,
setFunc = function(value) errorsSV.enabled = value end,
requiresReload = true,
}
err[#err+1] = {
type = 'checkbox',
name = 'Allow center screen announcements',
tooltip = 'Alert in the middle of the screen',
getFunc = function() return errorsSV.allowCSA end,
setFunc = function(value) errorsSV.allowCSA = value end,
}
err[#err+1] = {
type = 'checkbox',
name = 'Allow alerts',
tooltip = 'Alert in the topright corner',
getFunc = function() return errorsSV.allowAlerts end,
setFunc = function(value) errorsSV.allowAlerts = value end,
}
local bm = {} -- battlegroundsModule
bm[#bm+1] = {
type = 'checkbox',
name = 'Enable',
getFunc = function() return sv.battlegrounds.enabled end,
setFunc = function(value) sv.battlegrounds.enabled = value end,
requiresReload = true,
}
-- {
-- type = 'checkbox',
-- name = '[EXPERIMENTAL]Show only U45 matches',
-- getFunc = function() return sv.battlegrounds.showOnlyLastUpdateMatches end,
-- setFunc = function(value) sv.battlegrounds.showOnlyLastUpdateMatches = value end,
-- requiresReload = true,
-- reference = 'IMP_MATCHES_ShowOnlyLastUpdateMatchesCheckbox',
-- }
bm[#bm+1] = {
type = 'checkbox',
name = 'Save build at the end of match',
getFunc = function() return sv.battlegrounds.saveBuilds end,
setFunc = function(value) sv.battlegrounds.saveBuilds = value end,
}
bm[#bm+1] = {
type = 'checkbox',
name = 'Calculate stats over last 150 matches',
getFunc = function() return sv.battlegrounds.last150 end,
setFunc = function(value)
sv.battlegrounds.last150 = value
IMP_STATS_MATCHES_UI:Update()
end,
}
bm[#bm+1] = {
type = 'button',
name = 'Delete matches data',
func = function()
ImpressiveStatsMatchesData = {}
ReloadUI()
end,
width = 'full',
isDangerous = true,
warning = 'Тhis is |cee0000DESTRUCTIVE|r action and it will DELETE ALL DATA (and for both EU and NA servers) about BATTLEGROUND MATCHES recorded. There would be |cee0000NO WAY TO RECOVER|r it!\n\n|c00aa00Please consider saving it before, you can help to gather statistics by sending this file to me :)|r\n\nProceed only if you 100% sure about it!\n\nUI will be automatically reloaded.',
}
if sv.battlegrounds.debugging ~= nil or HashString(GetUnitDisplayName('player')) == 1558608849 then
bm[#bm+1] = {
type = 'checkbox',
name = '|cFFA500Debug mode|r',
getFunc = function() return sv.battlegrounds.debugging end,
setFunc = function(value) sv.battlegrounds.debugging = value end,
tooltip = '- Turns character filter off',
requiresReload = true,
}
end
bm[#bm+1] = {
type = 'button',
name = '|cFFA500Repack Saved Variables|r',
func = function()
IMP_STATS_MATCHES_MANAGER:RepackMatches()
end,
tooltip = function()
local text = 'Will attempt to repack Saved Variables to make them smaller and increase performance.\n\nThere are %d saved matches total, it can take some time!'
text = text:format(#IMP_STATS_MATCHES_MANAGER.savedMatches)
return text
end,
-- disabled = function() return not IMP_STATS_MATCHES_MANAGER.unpackedSavedMatches end,
requiresReload = true,
reference = IMP_STATS_REPACK_BUTTON_REFERENCE
}
-- ImpressiveStatsPlayersSV
local categories = ImpressiveStatsPlayersSV.categories
bm[#bm+1] = {
type = 'divider',
height = 8,
alpha = 0.5,
}
for ci = 1, #categories do
bm[#bm+1] = {
type = 'editbox',
name = ('Category %d name'):format(ci),
getFunc = function() return categories[ci].name end,
setFunc = function(text) categories[ci].name = text end,
isMultiline = false,
width = 'half',
}
bm[#bm+1] = {
type = 'colorpicker',
name = ('Category %d color'):format(ci),
getFunc = function() return hexToRGB(categories[ci].color) end,
setFunc = function(r, g, b, a) categories[ci].color = rgbToHex(r, g, b) end,
width = 'half',
}
end
local duelsModule = {
{
type = 'checkbox',
name = 'Enable',
getFunc = function() return sv.duels.enabled end,
setFunc = function(value) sv.duels.enabled = value end,
requiresReload = true,
},
{
type = 'dropdown',
name = 'Naming options',
tooltip = 'How to display names',
choices = {
'Character Name',
'@id',
'@id (Character Name)'
},
choicesValues = {
1, 2, 3
},
getFunc = function() return sv.duels.namingMode end,
setFunc = function(var) sv.duels.namingMode = var end,
width = 'full',
requiresReload = true,
-- warning = 'Will need to reload the UI.', --(optional)
},
{
type = 'checkbox',
name = 'Save build at the end of duel',
getFunc = function() return sv.duels.saveBuilds end,
setFunc = function(value) sv.duels.saveBuilds = value end,
},
{
type = 'button',
name = 'Delete duels data',
func = function()
ImpressiveStatsDuelsData = {}
ReloadUI()
end,
width = 'full',
isDangerous = true,
warning = 'Тhis is |cee0000DESTRUCTIVE|r action and it will DELETE ALL DATA (and for both EU and NA servers) about DUELS recorded. There would be |cee0000NO WAY TO RECOVER|r it!\n\nProceed only if you 100% sure about it!\n\nUI will be automatically reloaded.',
},
}
if sv.duels.debugging ~= nil or HashString(GetUnitDisplayName('player')) == 1558608849 then
duelsModule[#duelsModule+1] = {
type = 'checkbox',
name = '|cFFA500Debug mode|r',
getFunc = function() return sv.duels.debugging end,
setFunc = function(value)
sv.duels.debugging = value
IMP_STATS_Duels_UI.debugging = value
IMP_STATS_Duels_UI:UpdateUI()
end,
-- requiresReload = true,
}
end
local tributeModule = {
{
type = 'checkbox',
name = 'Enable',
getFunc = function() return sv.tot.enabled end,
setFunc = function(value) sv.tot.enabled = value end,
requiresReload = true,
},
{
type = 'checkbox',
name = '[EXPERIMENTAL]Add leaderboard',
getFunc = function() return sv.tot.leaderboard end,
setFunc = function(value) sv.tot.leaderboard = value end,
requiresReload = true,
},
}
local optionsData = {
{
type = 'submenu',
name = 'Errors module',
tooltip = 'Everything about error notifications',
controls = err,
},
{
type = 'submenu',
name = 'Battlegrounds module',
tooltip = 'This is the tab for battlegrounds panel',
controls = bm,
},
{
type = 'submenu',
name = 'Duels module',
tooltip = 'For braviest',
controls = duelsModule,
},
{
type = 'submenu',
name = 'Tribute module',
tooltip = 'That is real PvP, no doubts allowed!',
controls = tributeModule,
},
--[[
{
type = 'button',
name = 'Copy from ImpPvPMeter',
tooltip = 'For testers! It will make a full copy of saved data.',
func = CopyDataFromImpPvPMeter,
width = 'full',
warning = 'ALL DATA WILL BE IRREVERSIBLY REPLACED\n\nUse it only ONCE and BEFORE any new bgs/duels/tribute games.\n\nUI will be automatically reloaded.',
isDangerous = true,
disabled = function() return not IsDataFromImpPvPMeterAvailable() end,
},
--]]
}
LAM:RegisterOptionControls(settingsName, optionsData)
end
function IMP_STATS_InitializeSettings(...)
settings:Initialize(...)
end