-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconfig.lua
More file actions
326 lines (283 loc) · 8.57 KB
/
Copy pathconfig.lua
File metadata and controls
326 lines (283 loc) · 8.57 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
local addonName, addon = ...
if not addon.healthCheck then
return
end
local L = addon.L
local ldbi = LibStub("LibDBIcon-1.0")
local category, layout = Settings.RegisterVerticalLayoutCategory(addonName)
addon.settingsCategory = category
local function InitializeSettings()
-- Auto popup setting
local autoPopupSetting = Settings.RegisterAddOnSetting(
category,
"BUGSACK_AUTO_POPUP",
"auto",
addon.db,
Settings.VarType.Boolean,
L["Auto popup"],
Settings.Default.False
)
Settings.CreateCheckbox(category, autoPopupSetting, L.autoDesc)
-- Chatframe output setting
local chatFrameSetting = Settings.RegisterAddOnSetting(
category,
"BUGSACK_CHATFRAME_OUTPUT",
"chatframe",
addon.db,
Settings.VarType.Boolean,
L["Chatframe output"],
Settings.Default.False
)
Settings.CreateCheckbox(category, chatFrameSetting, L.chatFrameDesc)
-- Minimap icon setting
local function GetMinimapValue()
return not BugSackLDBIconDB.hide
end
local function SetMinimapValue(value)
BugSackLDBIconDB.hide = not value
if BugSackLDBIconDB.hide then
ldbi:Hide(addonName)
else
ldbi:Show(addonName)
end
end
local minimapSetting = Settings.RegisterProxySetting(
category,
"BUGSACK_MINIMAP_ICON",
Settings.VarType.Boolean,
L["Minimap icon"],
Settings.Default.True,
GetMinimapValue,
SetMinimapValue
)
Settings.CreateCheckbox(category, minimapSetting, L.minimapDesc)
-- Addon compartment setting (if available)
if ldbi:IsButtonCompartmentAvailable() then
local function GetCompartmentValue()
return ldbi:IsButtonInCompartment("BugSack")
end
local function SetCompartmentValue(value)
if value then
ldbi:AddButtonToCompartment("BugSack")
else
ldbi:RemoveButtonFromCompartment("BugSack")
end
end
local compartmentSetting = Settings.RegisterProxySetting(
category,
"BUGSACK_ADDON_COMPARTMENT",
Settings.VarType.Boolean,
L.addonCompartment,
Settings.Default.False,
GetCompartmentValue,
SetCompartmentValue
)
Settings.CreateCheckbox(category, compartmentSetting, L.addonCompartment_desc)
end
-- Mute setting
local muteSetting = Settings.RegisterAddOnSetting(
category,
"BUGSACK_MUTE",
"mute",
addon.db,
Settings.VarType.Boolean,
L["Mute"],
Settings.Default.False
)
Settings.CreateCheckbox(category, muteSetting, L.muteDesc)
-- Font size setting
local function GetFontSizeValue()
local fonts =
{ "GameFontHighlightSmall", "GameFontHighlight", "GameFontHighlightMedium", "GameFontHighlightLarge" }
for i, font in next, fonts do
if font == addon.db.fontSize then
return i
end
end
return 2 -- Default to Medium
end
local function SetFontSizeValue(value)
local fonts =
{ "GameFontHighlightSmall", "GameFontHighlight", "GameFontHighlightMedium", "GameFontHighlightLarge" }
addon.db.fontSize = fonts[value]
if _G.BugSackScrollText then
_G.BugSackScrollText:SetFontObject(_G[fonts[value]])
end
end
local function GetFontSizeOptions()
local container = Settings.CreateControlTextContainer()
local names = { L["Small"], L["Medium"], L["Large"], L["X-Large"] }
for i, name in next, names do
container:Add(i, name)
end
return container:GetData()
end
local fontSizeSetting = Settings.RegisterProxySetting(
category,
"BUGSACK_FONT_SIZE",
Settings.VarType.Number,
L["Font size"],
2,
GetFontSizeValue,
SetFontSizeValue
)
Settings.CreateDropdown(category, fontSizeSetting, GetFontSizeOptions)
-- Custom sound dropdown with scrolling support
local function GetSoundValue()
return addon.db.soundMedia or "BugSack: Fatality"
end
local function SetSoundValue(value)
addon.db.soundMedia = value
end
local function IsSoundSelected(sound)
return addon.db.soundMedia == sound
end
local soundSetting = Settings.RegisterProxySetting(
category,
"BUGSACK_SOUND",
Settings.VarType.String,
L["Sound"],
"BugSack: Fatality",
GetSoundValue,
SetSoundValue
)
-- Create custom sound dropdown initializer with scrolling
local BugSackSoundDropdownInitializer = CreateFromMixins(
ScrollBoxFactoryInitializerMixin,
SettingsElementHierarchyMixin,
SettingsSearchableElementMixin
)
function BugSackSoundDropdownInitializer:Init()
ScrollBoxFactoryInitializerMixin.Init(self, "SettingsListElementTemplate")
self.data = {
name = L["Sound"],
tooltip = L["Sound"],
}
self:AddSearchTags(L["Sound"])
end
function BugSackSoundDropdownInitializer:GetExtent()
return 26 -- Height of the control
end
function BugSackSoundDropdownInitializer:InitFrame(frame)
-- Set frame size
frame:SetSize(280, 26)
-- Initialize the SettingsListElementMixin properly
if not frame.cbrHandles then
frame.cbrHandles = Settings.CreateCallbackHandleContainer()
end
-- Set up the standard element display
frame.data = self.data
frame.Text:SetFontObject("GameFontNormal")
frame.Text:SetText(L["Sound"])
frame.Text:SetPoint("LEFT", 37, 0)
frame.Text:SetPoint("RIGHT", frame, "CENTER", -85, 0)
-- Update button text function
local function UpdateDropdownText()
if frame.soundDropdown then
frame.soundDropdown:OverrideText(GetSoundValue())
end
end
-- sound preview button
if not frame.previewButton then
frame.previewButton = CreateFrame("Button", nil, frame)
frame.previewButton:SetSize(20, 20)
frame.previewButton:SetPoint("LEFT", frame, "CENTER", -74, 0)
frame.previewButton:SetHeight(26)
local previewIcon = frame.previewButton:CreateTexture(nil, "ARTWORK")
previewIcon:SetAllPoints()
previewIcon:SetTexture("Interface\\Common\\VoiceChat-Speaker")
previewIcon:SetVertexColor(0.8, 0.8, 0.8)
frame.previewButton:SetScript("OnEnter", function(control)
previewIcon:SetVertexColor(1, 1, 1)
GameTooltip:SetOwner(control, "ANCHOR_TOP")
GameTooltip:SetText(L["Preview Sound"])
GameTooltip:Show()
end)
frame.previewButton:SetScript("OnLeave", function(control)
previewIcon:SetVertexColor(0.8, 0.8, 0.8)
GameTooltip:Hide()
end)
-- Play current sound on click
frame.previewButton:SetScript("OnClick", function(control)
local media = LibStub("LibSharedMedia-3.0")
local currentSound = GetSoundValue()
local soundFile = media:Fetch("sound", currentSound)
if soundFile then
if addon.db.useMaster then
PlaySoundFile(soundFile, "Master")
else
PlaySoundFile(soundFile)
end
end
end)
end
if not frame.soundDropdown then
frame.soundDropdown = CreateFrame("DropdownButton", nil, frame, "WowStyle1DropdownTemplate")
frame.soundDropdown:SetPoint("LEFT", frame.previewButton, "RIGHT", 5, 0)
frame.soundDropdown:SetPoint("RIGHT", frame, "RIGHT", -20, 0)
frame.soundDropdown:SetHeight(26)
-- Setup menu with scrolling
frame.soundDropdown:SetupMenu(function(dropdown, rootDescription)
rootDescription:SetScrollMode(200)
local sounds = LibStub("LibSharedMedia-3.0"):List("sound")
for _, sound in next, sounds do
local function OnSelection(soundValue)
SetSoundValue(soundValue)
UpdateDropdownText()
end
rootDescription:CreateRadio(sound, IsSoundSelected, OnSelection, sound)
end
end)
end
-- Initial text update
UpdateDropdownText()
-- Register callback for external changes
frame.cbrHandles:SetOnValueChangedCallback(soundSetting:GetVariable(), UpdateDropdownText)
end
function BugSackSoundDropdownInitializer:Resetter(frame)
if frame.cbrHandles then
frame.cbrHandles:Unregister()
end
end
-- Create and add the initializer
local customSoundInitializer = CreateFromMixins(BugSackSoundDropdownInitializer)
customSoundInitializer:Init()
layout:AddInitializer(customSoundInitializer)
-- Use Master sound channel setting
local masterSetting = Settings.RegisterAddOnSetting(
category,
"BUGSACK_USE_MASTER",
"useMaster",
addon.db,
Settings.VarType.Boolean,
L.useMaster,
Settings.Default.False
)
Settings.CreateCheckbox(category, masterSetting, L.useMasterDesc)
-- Alt-click wipe setting
local altWipeSetting = Settings.RegisterAddOnSetting(
category,
"BUGSACK_ALT_WIPE",
"altwipe",
addon.db,
Settings.VarType.Boolean,
L["Minimap icon alt-click wipe"],
Settings.Default.False
)
Settings.CreateCheckbox(category, altWipeSetting, L.altWipeDesc)
local wipeButtonInitializer = CreateSettingsButtonInitializer(
L["Wipe saved bugs"], -- name
L["Wipe saved bugs"], -- buttonText
function()
addon:Reset()
end, -- buttonClick
L.wipeDesc, -- tooltip
true, -- addSearchTags
nil, -- newTagID
nil -- gameDataFunc
)
local addonLayout = SettingsPanel:GetLayout(category)
addonLayout:AddInitializer(wipeButtonInitializer)
Settings.RegisterAddOnCategory(category)
end
addon.InitializeSettings = InitializeSettings