-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSettings.lua
More file actions
183 lines (161 loc) · 5.57 KB
/
Settings.lua
File metadata and controls
183 lines (161 loc) · 5.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
local _, addon = ...
-- Register Settings category
local category, layout = Settings.RegisterVerticalLayoutCategory("KeyUI")
addon.settingsCategory = category
local function InitializeSettingsPanel()
-- Minimap Button Setting
local function GetMinimapValue()
return not keyui_settings.minimap.hide
end
local function SetMinimapValue(value)
keyui_settings.minimap.hide = not value
local LibDBIcon = LibStub("LibDBIcon-1.0")
if value then
LibDBIcon:Show("KeyUI")
print("KeyUI: Minimap button enabled")
else
LibDBIcon:Hide("KeyUI")
print("KeyUI: Minimap button disabled")
end
end
local minimapSetting = Settings.RegisterProxySetting(
category,
"KEYUI_MINIMAP_BUTTON",
Settings.VarType.Boolean,
"Minimap Button",
Settings.Default.True,
GetMinimapValue,
SetMinimapValue
)
Settings.CreateCheckbox(category, minimapSetting, "Show or hide the minimap button")
-- Show Keyboard Setting
local showKeyboardSetting = Settings.RegisterAddOnSetting(
category,
"KEYUI_SHOW_KEYBOARD",
"show_keyboard",
keyui_settings,
Settings.VarType.Boolean,
"Show Keyboard",
Settings.Default.False
)
Settings.CreateCheckbox(category, showKeyboardSetting, "Show or hide the keyboard frame")
-- Show Mouse Setting
local showMouseSetting = Settings.RegisterAddOnSetting(
category,
"KEYUI_SHOW_MOUSE",
"show_mouse",
keyui_settings,
Settings.VarType.Boolean,
"Show Mouse",
Settings.Default.False
)
Settings.CreateCheckbox(category, showMouseSetting, "Show or hide the mouse frame")
-- Show Controller Setting
local showControllerSetting = Settings.RegisterAddOnSetting(
category,
"KEYUI_SHOW_CONTROLLER",
"show_controller",
keyui_settings,
Settings.VarType.Boolean,
"Show Controller",
Settings.Default.False
)
Settings.CreateCheckbox(category, showControllerSetting, "Show or hide the controller frame")
-- Font Header + Settings
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Font"))
-- Font Face Dropdown
local function GetFontFace()
return keyui_settings.font_face
end
local function SetFontFace(value)
keyui_settings.font_face = value
addon:RefreshAllFonts()
end
local function GetFontFaceOptions()
local container = Settings.CreateControlTextContainer()
for _, fontName in ipairs(addon.FONT_OPTIONS_ORDER) do
container:Add(fontName, fontName)
end
return container:GetData()
end
local fontFaceSetting = Settings.RegisterProxySetting(
category,
"KEYUI_FONT_FACE",
Settings.VarType.String,
"Font",
"Expressway",
GetFontFace,
SetFontFace
)
Settings.CreateDropdown(category, fontFaceSetting, GetFontFaceOptions, "Select the font used throughout KeyUI")
-- Font Base Size Slider
local function GetFontSize()
return keyui_settings.font_base_size
end
local function SetFontSize(value)
keyui_settings.font_base_size = value
addon:RefreshAllFonts()
end
local fontSizeSetting = Settings.RegisterProxySetting(
category,
"KEYUI_FONT_SIZE",
Settings.VarType.Number,
"Font Size",
16,
GetFontSize,
SetFontSize
)
local fontSizeOptions = Settings.CreateSliderOptions(10, 24, 1)
fontSizeOptions:SetLabelFormatter(MinimalSliderWithSteppersMixin.Label.Right)
Settings.CreateSlider(category, fontSizeSetting, fontSizeOptions, "Adjust the base font size for all KeyUI text")
-- Profiles Header + Buttons
layout:AddInitializer(CreateSettingsListSectionHeaderInitializer("Profiles"))
-- Export Profile Button
local exportButton = CreateSettingsButtonInitializer(
"Export Profile",
"Export Profile",
function()
addon:ShowProfileExportPopup()
end,
"Copy your current KeyUI configuration as a sharable string",
true
)
layout:AddInitializer(exportButton)
-- Import Profile Button
local importButton = CreateSettingsButtonInitializer(
"Import Profile",
"Import Profile",
function()
addon:ShowProfileImportPopup()
end,
"Paste a profile string to apply someone else's configuration",
true
)
layout:AddInitializer(importButton)
-- Reset Settings Button (with confirmation dialog)
local resetButton = CreateSettingsButtonInitializer(
"Full Reset",
"Full Reset",
function()
StaticPopupDialogs["KEYUI_CONFIRM_RESET"] = {
text = "Are you sure you want to reset ALL KeyUI data (settings, layouts, positions, keybinds) to default?",
button1 = "Yes",
button2 = "No",
OnAccept = function()
addon:ResetAddonSettings()
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
StaticPopup_Show("KEYUI_CONFIRM_RESET")
end,
"Completely resets all KeyUI data: settings, custom layouts, frame positions, and keybind configurations",
true
)
layout:AddInitializer(resetButton)
-- Register category
Settings.RegisterAddOnCategory(category)
end
addon.InitializeSettingsPanel = InitializeSettingsPanel