annotate Libs/AceConfig-3.0/AceConfig-3.0.lua @ 0:98c6f55e6619

First commit
author Xiiph
date Sat, 05 Feb 2011 16:45:02 +0100
parents
children
rev   line source
Xiiph@0 1 --- AceConfig-3.0 wrapper library.
Xiiph@0 2 -- Provides an API to register an options table with the config registry,
Xiiph@0 3 -- as well as associate it with a slash command.
Xiiph@0 4 -- @class file
Xiiph@0 5 -- @name AceConfig-3.0
Xiiph@0 6 -- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $
Xiiph@0 7
Xiiph@0 8 --[[
Xiiph@0 9 AceConfig-3.0
Xiiph@0 10
Xiiph@0 11 Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
Xiiph@0 12
Xiiph@0 13 ]]
Xiiph@0 14
Xiiph@0 15 local MAJOR, MINOR = "AceConfig-3.0", 2
Xiiph@0 16 local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
Xiiph@0 17
Xiiph@0 18 if not AceConfig then return end
Xiiph@0 19
Xiiph@0 20 local cfgreg = LibStub("AceConfigRegistry-3.0")
Xiiph@0 21 local cfgcmd = LibStub("AceConfigCmd-3.0")
Xiiph@0 22 --TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
Xiiph@0 23 --TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
Xiiph@0 24
Xiiph@0 25 -- Lua APIs
Xiiph@0 26 local pcall, error, type, pairs = pcall, error, type, pairs
Xiiph@0 27
Xiiph@0 28 -- -------------------------------------------------------------------
Xiiph@0 29 -- :RegisterOptionsTable(appName, options, slashcmd, persist)
Xiiph@0 30 --
Xiiph@0 31 -- - appName - (string) application name
Xiiph@0 32 -- - options - table or function ref, see AceConfigRegistry
Xiiph@0 33 -- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
Xiiph@0 34
Xiiph@0 35 --- Register a option table with the AceConfig registry.
Xiiph@0 36 -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
Xiiph@0 37 -- @paramsig appName, options [, slashcmd]
Xiiph@0 38 -- @param appName The application name for the config table.
Xiiph@0 39 -- @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 40 -- @param slashcmd A slash command to register for the option table, or a table of slash commands.
Xiiph@0 41 -- @usage
Xiiph@0 42 -- local AceConfig = LibStub("AceConfig-3.0")
Xiiph@0 43 -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
Xiiph@0 44 function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
Xiiph@0 45 local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
Xiiph@0 46 if not ok then error(msg, 2) end
Xiiph@0 47
Xiiph@0 48 if slashcmd then
Xiiph@0 49 if type(slashcmd) == "table" then
Xiiph@0 50 for _,cmd in pairs(slashcmd) do
Xiiph@0 51 cfgcmd:CreateChatCommand(cmd, appName)
Xiiph@0 52 end
Xiiph@0 53 else
Xiiph@0 54 cfgcmd:CreateChatCommand(slashcmd, appName)
Xiiph@0 55 end
Xiiph@0 56 end
Xiiph@0 57 end