-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
config.lua
158 lines (142 loc) · 4.85 KB
/
config.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
local addonName, addon = ...
if not addon.healthCheck then return end
local L = addon.L
local frame = addon.frame
frame.name = addonName
frame:Hide()
local ldbi = LibStub("LibDBIcon-1.0")
frame:SetScript("OnShow", function(frame)
local function newCheckbox(label, description, onClick)
local check = CreateFrame("CheckButton", "BugSackCheck" .. label, frame, "InterfaceOptionsCheckButtonTemplate")
check:SetScript("OnClick", function(self)
local tick = self:GetChecked()
onClick(self, tick and true or false)
if tick then
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
else
PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end)
check.label = _G[check:GetName() .. "Text"]
check.label:SetText(label)
check.tooltipText = label
check.tooltipRequirement = description
return check
end
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText(addonName)
local autoPopup = newCheckbox(
L["Auto popup"],
L.autoDesc,
function(self, value) addon.db.auto = value end)
autoPopup:SetChecked(addon.db.auto)
autoPopup:SetPoint("TOPLEFT", title, "BOTTOMLEFT", -2, -16)
local chatFrame = newCheckbox(
L["Chatframe output"],
L.chatFrameDesc,
function(self, value) addon.db.chatframe = value end)
chatFrame:SetChecked(addon.db.chatframe)
chatFrame:SetPoint("TOPLEFT", autoPopup, "BOTTOMLEFT", 0, -8)
local minimap = newCheckbox(
L["Minimap icon"],
L.minimapDesc,
function(self, value)
BugSackLDBIconDB.hide = not value
if BugSackLDBIconDB.hide then
ldbi:Hide(addonName)
else
ldbi:Show(addonName)
end
end)
minimap:SetPoint("TOPLEFT", chatFrame, "BOTTOMLEFT", 0, -8)
minimap:SetChecked(not BugSackLDBIconDB.hide)
if ldbi:IsButtonCompartmentAvailable() then
local addonCompartment = newCheckbox(
L.addonCompartment,
L.addonCompartment_desc,
function(self, value)
if value then
ldbi:AddButtonToCompartment("BugSack")
else
ldbi:RemoveButtonFromCompartment("BugSack")
end
end)
addonCompartment:SetPoint("LEFT", minimap, "RIGHT", 150, 0)
addonCompartment:SetChecked(ldbi:IsButtonInCompartment("BugSack"))
end
local mute = newCheckbox(
L["Mute"],
L.muteDesc,
function(self, value) addon.db.mute = value end)
mute:SetChecked(addon.db.mute)
mute:SetPoint("TOPLEFT", minimap, "BOTTOMLEFT", 0, -8)
local info = {}
local fontSizeDropdown = CreateFrame("Frame", "BugSackFontSize", frame, "UIDropDownMenuTemplate")
fontSizeDropdown:SetPoint("TOPLEFT", mute, "BOTTOMLEFT", -15, -10)
fontSizeDropdown.initialize = function()
wipe(info)
local fonts = {"GameFontHighlightSmall", "GameFontHighlight", "GameFontHighlightMedium", "GameFontHighlightLarge"}
local names = {L["Small"], L["Medium"], L["Large"], L["X-Large"]}
for i, font in next, fonts do
info.text = names[i]
info.value = font
info.func = function(self)
addon.db.fontSize = self.value
if _G.BugSackFrameScrollText then
_G.BugSackFrameScrollText:SetFontObject(_G[self.value])
end
BugSackFontSizeText:SetText(self:GetText())
end
info.checked = font == addon.db.fontSize
UIDropDownMenu_AddButton(info)
end
end
BugSackFontSizeText:SetText(L["Font size"])
local soundDropdown = CreateFrame("Frame", "BugSackSoundDropdown", frame, "UIDropDownMenuTemplate")
soundDropdown:SetPoint("LEFT", fontSizeDropdown, "RIGHT", 150, 0)
soundDropdown.initialize = function()
wipe(info)
for _, sound in next, LibStub("LibSharedMedia-3.0"):List("sound") do
info.text = sound
info.value = sound
info.func = function(self)
addon.db.soundMedia = self.value
soundDropdown.Text:SetText(self:GetText())
end
info.checked = sound == addon.db.soundMedia
UIDropDownMenu_AddButton(info)
end
end
soundDropdown.Text:SetText(L["Sound"])
local master = newCheckbox(
L.useMaster,
L.useMasterDesc,
function(self, value) addon.db.useMaster = value end)
master:SetChecked(addon.db.useMaster)
master:SetPoint("LEFT", soundDropdown, "RIGHT", 140, 0)
local clear = CreateFrame("Button", "BugSackSaveButton", frame, "UIPanelButtonTemplate")
clear:SetText(L["Wipe saved bugs"])
clear:SetWidth(177)
clear:SetHeight(24)
clear:SetPoint("TOPLEFT", fontSizeDropdown, "BOTTOMLEFT", 17, -25)
clear:SetScript("OnClick", function()
addon:Reset()
end)
clear.tooltipText = L["Wipe saved bugs"]
clear.newbieText = L.wipeDesc
local altWipe = newCheckbox(
L["Minimap icon alt-click wipe"],
L.altWipeDesc,
function(self, value) addon.db.altwipe = value end)
altWipe:SetChecked(addon.db.altwipe)
altWipe:SetPoint("LEFT", clear, "RIGHT", 10, 0)
frame:SetScript("OnShow", nil)
end)
if InterfaceOptions_AddCategory then
InterfaceOptions_AddCategory(frame)
else
local category, layout = Settings.RegisterCanvasLayoutCategory(frame, frame.name);
Settings.RegisterAddOnCategory(category);
addon.settingsCategory = category
end