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