-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
Contents
This page creates the smallest useful LibSettingsDesigner integration:
- one app
- one category
- one page
- one group
- one toggle
- one slider
- one slash command to open the UI
For a larger sample, see Complete Settings Center.
Host addon layout:
MyAddon/
MyAddon.toc
libs/
LibSettingsDesigner/
LibSettingsDesigner.xml
LibSettingsDesignerConfig.lua
LibSettingsDesignerUI.lua
Assets/
TOC:
libs\LibSettingsDesigner\LibSettingsDesigner.xml
Settings.luaLibSettingsDesigner.xml must load before Settings.lua.
local addonName, addon = ...
local Designer = addon.LibSettingsDesigner
local Config = Designer and Designer.Config
local ConfigUI = Designer and Designer.UI
if not Config or not ConfigUI then
return
end
MyAddonDB = MyAddonDB or {}
MyAddonDB.profile = MyAddonDB.profile or {}
local function DB()
MyAddonDB.profile.enabled = MyAddonDB.profile.enabled ~= false
MyAddonDB.profile.scale = MyAddonDB.profile.scale or 1
return MyAddonDB.profile
end
local app = Config:RegisterAddOn(addonName, {
title = "My Addon",
settingsTitle = "My Addon Settings",
dashboardTitle = "Dashboard",
addonFolder = addonName,
assetRoot = "Interface\\AddOns\\MyAddon\\libs\\LibSettingsDesigner\\Assets\\",
density = "compact",
getDensity = function() return DB().settingsWindow and DB().settingsWindow.density end,
setDensity = function(value)
DB().settingsWindow = DB().settingsWindow or {}
DB().settingsWindow.density = value
end,
db = DB,
locale = addon.L,
})app:RegisterCategory({
id = "general",
title = GENERAL or "General",
order = 100,
})
app:RegisterPage({
id = "general.core",
category = "general",
title = "Core",
description = "Main addon behavior.",
order = 100,
mainToggleID = "enabled",
})
app:RegisterGroup("general.core", {
id = "behavior",
title = "Behavior",
order = 100,
})Simple DB-backed toggle:
app:RegisterControl("general.core", {
id = "enabled",
key = "enabled",
groupID = "behavior",
type = "toggle",
label = ENABLE or "Enable",
description = "Enable the addon.",
default = true,
})Slider with a runtime refresh callback:
app:RegisterControl("general.core", {
id = "scale",
key = "scale",
groupID = "behavior",
type = "slider",
label = "Scale",
description = "Adjust the main UI scale.",
min = 0.5,
max = 2,
step = 0.05,
default = 1,
parentCheck = function()
return DB().enabled == true
end,
formatter = function(value)
return string.format("%.0f%%", (tonumber(value) or 1) * 100)
end,
setValue = function(value)
DB().scale = tonumber(value) or 1
if addon.RefreshScale then
addon.RefreshScale()
end
end,
})SLASH_MYADDON1 = "/myaddon"
SlashCmdList.MYADDON = function(input)
input = strtrim(input or "")
if input == "core" then
ConfigUI:Open(app, "general.core")
return
end
ConfigUI:Toggle(app)
endDirect navigation examples:
ConfigUI:Open(app)
ConfigUI:Open(app, "general.core")
ConfigUI:Open(app, "general.core", "scale")/reload- Run
/myaddon. - Confirm the settings window opens.
- Change the toggle and slider.
-
/reloadagain and confirm values persisted. - Search for
scale. - Reset the page and confirm defaults return.
Wiki
• Home
• Architecture
• Vendoring
• Quick Start
• Field Glossary
• Troubleshooting
• Validation
Reference
⚬ Config API
⚬ UI API
⚬ Elements
⚬ Examples
Elements
Structure
• Category
• Page
• Group
• Dashboard
• InfoPage
• Custom
Controls
• Toggle
• CheckboxDropdown
• Dropdown
• MultiDropdown
• SoundDropdown
• Input
• Slider
• Button
Advanced
• ColorPicker
• ColorPalette
• ColorOverrides
• ReorderList
• Expandable
• Notes
Examples
Start
• Minimal Addon
• Complete Settings Center
• Wrapper Bridge Pattern
Data and Behavior
• Dependent Controls
• Nested Database Values
• Dynamic Dropdowns
• Runtime Refresh
• Search and New Badges
• Custom Hosted Editors
Polish
• Support Links
• Theme Colors
• Theme Borders