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