-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOptions.lua
316 lines (256 loc) · 9.72 KB
/
Options.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
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
local L = LibStub("AceLocale-3.0"):GetLocale("BoostWaitlist", true)
local addonName, addon = ...
local Options = {}
-- local Options = _G.BoostWaitlistOptions or {}
local about = CreateFrame("Frame", addonName, InterfaceOptionsFramePanelContainer)
local general = CreateFrame("Frame")
local playerDB = CreateFrame("Frame")
Options.about = about
Options.general = general
Options.playerDB = playerDB
addon.Options = Options
local DB -- assigned during init
local GUI = addon.GUI
local UIBuilder = addon.UIBuilder
---General---------------------------------------------
general.name = L["General"]
general.parent = addonName
general:Hide()
function Options:GeneralShow()
local title = UIBuilder:Header(general, general.name, true)
local minimapIcon = UIBuilder:Checkbox(general, L["EminimapIcon"], L["EminimapIconTT"],
function(checked)
if(checked) then GUI:ShowMinimapIcon() else GUI:HideMinimapIcon() end DB.Main.everActive = checked
end
)
minimapIcon:SetPoint("TOPLEFT", title, "BOTTOMLEFT", -2, -16)
local enableStats = UIBuilder:Checkbox(general, L["EStats"], L["EStatsTT"],
function(checked)
DB.Main.enableStats = checked
end
)
enableStats:SetPoint("TOPLEFT", minimapIcon, "BOTTOMLEFT", 0, 0)
local enableBalanceWhisperThreshold = UIBuilder:Checkbox(general, L["BalanceWhisperThreshold"], L["BalanceWhisperThresholdTT"],
function(checked)
DB.Main.enableBalanceWhisperThreshold = checked
end)
enableBalanceWhisperThreshold:SetPoint("TOPLEFT", enableStats, "BOTTOMLEFT", 0, 0)
local goldThreshold = UIBuilder:Slider(general, L["GThreshold"], L["GThresholdTT"], -100, 100,
function(v)
DB.Main.balanceWhisperThreshold = v
end)
goldThreshold:SetPoint("TOPLEFT", enableBalanceWhisperThreshold, "BOTTOMLEFT", 0, -5)
--
-- Column 2
--
local enableAutobill = UIBuilder:Checkbox(general, L["EAutobill"], L["EAutobillTT"],
function(checked)
DB.Main.autobill = checked
end
)
enableAutobill:SetPoint("LEFT", minimapIcon, "RIGHT", 120, 0)
local enableSounds = UIBuilder:Checkbox(general, L["ESounds"], L["ESoundsTT"],
function(checked)
DB.Main.enableSounds = checked
end
)
enableSounds:SetPoint("TOPLEFT", enableAutobill, "BOTTOMLEFT", 0, 0)
local enableWaitlist = UIBuilder:Checkbox(general, L["EWaitlist"], L["EWaitlistTT"],
function(checked)
DB.Main.enableWaitlist = checked
end)
enableWaitlist:SetPoint("TOPLEFT", enableSounds, "BOTTOMLEFT", 0, 0)
local maxWaitlist = UIBuilder:Slider(general, L["MWaitlist"], L["MWaitlistTT"], 1, 20,
function(v)
DB.Main.maxWaitlist = v
end)
maxWaitlist:SetPoint("TOPLEFT", enableWaitlist, "BOTTOMLEFT", 0, -5)
local function init()
DB = _G.BoostWaitlistDB
minimapIcon:SetChecked(DB.Main.everActive)
enableStats:SetChecked(DB.Main.enableStats or false)
enableBalanceWhisperThreshold:SetChecked(DB.Main.enableBalanceWhisperThreshold or false)
goldThreshold:SetValue(DB.Main.balanceWhisperThreshold)
enableAutobill:SetChecked(DB.Main.autobill or false)
enableSounds:SetChecked(DB.Main.enableSounds or false)
enableWaitlist:SetChecked(DB.Main.enableWaitlist or false)
maxWaitlist:SetValue(DB.Main.maxWaitlist or 20)
end
init()
general:Show()
general:SetScript("OnShow", init)
end
---General END-----------------------------------------
---About-----------------------------------------------
about.name = addonName
about:Hide()
function Options:AboutShow()
local title = UIBuilder:Header(about, about.name, true)
local subtitle = about:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -20)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText(GetAddOnMetadata(addonName, "Notes"))
local author = about:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
author:SetHeight(32)
author:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", 0, 20)
author:SetNonSpaceWrap(true)
author:SetJustifyH("LEFT")
author:SetJustifyV("TOP")
author:SetText("|cFF4400EEWritten by: |r" .. GetAddOnMetadata(addonName, "Author"))
local version = about:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
version:SetHeight(32)
version:SetPoint("TOPLEFT", title, "TOPRIGHT", 0, -2)
version:SetText('v.' .. GetAddOnMetadata(addonName, "Version"))
local line = about:CreateTexture()
line:SetTexture("Interface/BUTTONS/WHITE8X8")
line:SetColorTexture(0.6 ,0.6, 0.6, 0.4)
line:SetSize(500, 2)
line:SetPoint("BOTTOMLEFT", author)
about:Show()
about:SetScript("OnShow", nil)
end
---About END--------------------------------------------
---About-----------------------------------------------
playerDB.name = L["Player Database"]
playerDB.parent = addonName
playerDB:Hide()
function Options:PlayerDBShow()
local tableCols = {
{
name = L["Name"],
width = 120,
align = 'LEFT',
format = 'string',
index = 'name',
sortable = true,
defaultSort = 'dsc',
color = {r=1,g=1,b=1,a=1}
},
{
name = L["Balance"],
width = 100,
align = 'LEFT',
format = 'number',
index = 'accountBalance',
sortable = true,
color = function (table, value)
local c = {r=1,g=1,b=1,a=1}
if (tonumber(value) < 0) then
c = {r=1,g=0,b=0,a=1}
end
return c
end,
events = {
OnClick = function(table, cellFrame, rowFrame, rowData, columnData, rowIndex)
local cellData = rowData[columnData.index]
cellFrame.cellEdit = UIBuilder:TableNumericEditBox(table, cellFrame, cellData, rowData, columnData,
function(value, row)
DB.Main.accountBalance[row.name] = value
end
)
return true
end,
}
},
{
name = L["Override"],
width = 120,
align = 'LEFT',
format = 'number',
index = 'overrideCharge',
sortable = true,
color = function (table, value)
local c = {r=1,g=1,b=1,a=1}
if (tonumber(value) < 0) then
c = {r=1,g=0,b=0,a=1}
end
return c
end,
events = {
OnClick = function(table, cellFrame, rowFrame, rowData, columnData, rowIndex)
local cellData = rowData[columnData.index]
cellFrame.cellEdit = UIBuilder:TableNumericEditBox(table, cellFrame, cellData, rowData, columnData,
function(value)
if (value < 0) then
DB.Main.overrideCharge[rowData.name] = nil
table:Refresh()
else
DB.Main.overrideCharge[rowData.name] = value
end
end
)
return true
end,
}
},
{
name = L["Blacklist"],
width = 70,
align = 'LEFT',
format = 'boolean',
index = 'blacklist',
sortable = false,
}
}
--could definitely use some efficiency improvements
local function populateColumns()
local cols={}
local playerlist = {}
for k,v in pairs(DB.Main.blacklist) do
if (playerlist[k] == nil) then
playerlist[k] = {}
end
playerlist[k].blacklist = 'true'
end
for k,v in pairs(DB.Main.overrideCharge) do
if (playerlist[k] == nil) then
playerlist[k] = {}
end
playerlist[k].overrideCharge = v
end
for k,v in pairs(DB.Main.accountBalance) do
if (playerlist[k] == nil) then
playerlist[k] = {}
end
playerlist[k].accountBalance = v
end
local i=1
for k,v in pairs(playerlist) do
cols[i] = {
name = k,
accountBalance = playerlist[k].accountBalance or 0,
overrideCharge = playerlist[k].overrideCharge or 0,
blacklist = playerlist[k].blacklist or 'false',
}
i = i + 1
end
return cols
end
local title = UIBuilder:Header(playerDB, playerDB.name, true)
local playerTable = UIBuilder:Table(playerDB, tableCols, 18, 10, -100)
local function init()
DB = _G.BoostWaitlistDB
playerTable:SetData(populateColumns())
playerTable:Refresh()
end
init()
playerDB:Show()
playerDB:SetScript("OnShow", init)
end
about:SetScript("OnShow", Options.AboutShow)
general:SetScript("OnShow", Options.GeneralShow)
playerDB:SetScript("OnShow", Options.PlayerDBShow)
if Settings then
local category = Settings.RegisterCanvasLayoutCategory(about, addonName);
category.ID = addonName
local subcategory = Settings.RegisterCanvasLayoutSubcategory(category, general, general.name, general.name);
local subcategory2 = Settings.RegisterCanvasLayoutSubcategory(category, playerDB, playerDB.name, playerDB.name);
Settings.RegisterAddOnCategory(category);
else
InterfaceOptions_AddCategory(about)
InterfaceOptions_AddCategory(general, Options.about)
InterfaceOptions_AddCategory(playerDB, Options.about)
end