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