annotate Libs/AceConfig-3.0/AceConfig-3.0.lua @ 17:3000eccbf1a0 v7.3.0.017

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