Tercio@23: --- AceConfig-3.0 wrapper library. Tercio@23: -- Provides an API to register an options table with the config registry, Tercio@23: -- as well as associate it with a slash command. Tercio@23: -- @class file Tercio@23: -- @name AceConfig-3.0 Tercio@23: -- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $ Tercio@23: Tercio@23: --[[ Tercio@23: AceConfig-3.0 Tercio@23: Tercio@23: Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole. Tercio@23: Tercio@23: ]] Tercio@23: Tercio@23: local MAJOR, MINOR = "AceConfig-3.0", 2 Tercio@23: local AceConfig = LibStub:NewLibrary(MAJOR, MINOR) Tercio@23: Tercio@23: if not AceConfig then return end Tercio@23: Tercio@23: local cfgreg = LibStub("AceConfigRegistry-3.0") Tercio@23: local cfgcmd = LibStub("AceConfigCmd-3.0") Tercio@23: --TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true) Tercio@23: --TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true) Tercio@23: Tercio@23: -- Lua APIs Tercio@23: local pcall, error, type, pairs = pcall, error, type, pairs Tercio@23: Tercio@23: -- ------------------------------------------------------------------- Tercio@23: -- :RegisterOptionsTable(appName, options, slashcmd, persist) Tercio@23: -- Tercio@23: -- - appName - (string) application name Tercio@23: -- - options - table or function ref, see AceConfigRegistry Tercio@23: -- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command Tercio@23: Tercio@23: --- Register a option table with the AceConfig registry. Tercio@23: -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly. Tercio@23: -- @paramsig appName, options [, slashcmd] Tercio@23: -- @param appName The application name for the config table. Tercio@23: -- @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/ Tercio@23: -- @param slashcmd A slash command to register for the option table, or a table of slash commands. Tercio@23: -- @usage Tercio@23: -- local AceConfig = LibStub("AceConfig-3.0") Tercio@23: -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"}) Tercio@23: function AceConfig:RegisterOptionsTable(appName, options, slashcmd) Tercio@23: local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options) Tercio@23: if not ok then error(msg, 2) end Tercio@23: Tercio@23: if slashcmd then Tercio@23: if type(slashcmd) == "table" then Tercio@23: for _,cmd in pairs(slashcmd) do Tercio@23: cfgcmd:CreateChatCommand(cmd, appName) Tercio@23: end Tercio@23: else Tercio@23: cfgcmd:CreateChatCommand(slashcmd, appName) Tercio@23: end Tercio@23: end Tercio@23: end