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