2016-05-06 16:22:10 +02:00
|
|
|
--[[ $Id: AceConfig-3.0.lua 60131 2008-02-03 13:03:56Z nevcairiel $ ]]
|
2016-05-06 15:25:00 +02:00
|
|
|
--[[
|
|
|
|
AceConfig-3.0
|
|
|
|
|
|
|
|
Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
|
|
|
|
|
2016-05-06 16:22:10 +02:00
|
|
|
Also automatically adds "config", "enable" and "disable" commands to options table as appropriate.
|
|
|
|
|
2016-05-06 15:25:00 +02:00
|
|
|
]]
|
|
|
|
|
|
|
|
local MAJOR, MINOR = "AceConfig-3.0", 2
|
2016-05-06 16:22:10 +02:00
|
|
|
local lib = LibStub:NewLibrary(MAJOR, MINOR)
|
|
|
|
|
|
|
|
if not lib then return end
|
2016-05-06 15:25:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
local cfgreg = LibStub("AceConfigRegistry-3.0")
|
|
|
|
local cfgcmd = LibStub("AceConfigCmd-3.0")
|
|
|
|
local cfgdlg = LibStub("AceConfigDialog-3.0")
|
|
|
|
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
|
|
|
|
|
|
|
|
|
2016-05-06 16:22:10 +02:00
|
|
|
---------------------------------------------------------------------
|
2016-05-06 15:25:00 +02:00
|
|
|
-- :RegisterOptionsTable(appName, options, slashcmd, persist)
|
|
|
|
--
|
|
|
|
-- - 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
|
|
|
|
|
2016-05-06 16:22:10 +02:00
|
|
|
function lib:RegisterOptionsTable(appName, options, slashcmd)
|
2016-05-06 15:25:00 +02:00
|
|
|
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
|