b2cf327cd9
Bring every embedded Ace3 / CallbackHandler / LibStub copy in line with the canonical Exiles/coa-ace3 bundle so LibStub resolution is predictable across all Exiles forks regardless of which addons are enabled. Libraries updated in this fork: AceAddon-3.0 13 (5 → 13) AceConfig-3.0 3 (2 → 3) AceConfigCmd-3.0 14 (12 → 14) AceConfigDialog-3.0 92 (43 → 92) AceConfigRegistry-3.0 22 (11 → 22) AceConsole-3.0 7 AceDB-3.0 33 (19 → 33) AceDBOptions-3.0 15 (11 → 15) AceEvent-3.0 4 (3 → 4) AceGUI-3.0 41 (30 → 41) AceLocale-3.0 6 (2 → 6) AceTimer-3.0 17 (5 → 17) CallbackHandler-1.0 8 (3 → 8) LibStub 2
59 lines
2.1 KiB
Lua
59 lines
2.1 KiB
Lua
--- AceConfig-3.0 wrapper library.
|
|
-- Provides an API to register an options table with the config registry,
|
|
-- as well as associate it with a slash command.
|
|
-- @class file
|
|
-- @name AceConfig-3.0
|
|
-- @release $Id$
|
|
|
|
--[[
|
|
AceConfig-3.0
|
|
|
|
Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
|
|
|
|
]]
|
|
|
|
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
|
local cfgcmd = LibStub("AceConfigCmd-3.0")
|
|
|
|
local MAJOR, MINOR = "AceConfig-3.0", 3
|
|
local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
|
|
|
|
if not AceConfig then return end
|
|
|
|
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
|
|
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
|
|
|
|
-- Lua APIs
|
|
local pcall, error, type, pairs = pcall, error, type, pairs
|
|
|
|
-- -------------------------------------------------------------------
|
|
-- :RegisterOptionsTable(appName, options, slashcmd)
|
|
--
|
|
-- - appName - (string) application name
|
|
-- - options - table or function ref, see AceConfigRegistry
|
|
-- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
|
|
|
|
--- Register a option table with the AceConfig registry.
|
|
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
|
|
-- @paramsig appName, options [, slashcmd]
|
|
-- @param appName The application name for the config table.
|
|
-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/
|
|
-- @param slashcmd A slash command to register for the option table, or a table of slash commands.
|
|
-- @usage
|
|
-- local AceConfig = LibStub("AceConfig-3.0")
|
|
-- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
|
|
function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
|
|
local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
|
|
if not ok then error(msg, 2) end
|
|
|
|
if slashcmd then
|
|
if type(slashcmd) == "table" then
|
|
for _,cmd in pairs(slashcmd) do
|
|
cfgcmd:CreateChatCommand(cmd, appName)
|
|
end
|
|
else
|
|
cfgcmd:CreateChatCommand(slashcmd, appName)
|
|
end
|
|
end
|
|
end
|