annotate Libs/AceConfig-3.0/AceConfig-3.0.lua @ 63:3552946c0b9a tip

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