annotate Libs/AceConfig-3.0/AceConfig-3.0.lua @ 0:169f5211fc7f

First public revision. At this point ItemAuditor watches mail for auctions sold or purchased, watches for buy/sell (money and 1 item type change) and conversions/tradeskills. Milling isn't working yet because there is too much time between the first event and the last event.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 20 May 2010 19:22:19 -0700
parents
children
rev   line source
Asa@0 1 --- AceConfig-3.0 wrapper library.
Asa@0 2 -- Provides an API to register an options table with the config registry,
Asa@0 3 -- as well as associate it with a slash command.
Asa@0 4 -- @class file
Asa@0 5 -- @name AceConfig-3.0
Asa@0 6 -- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $
Asa@0 7
Asa@0 8 --[[
Asa@0 9 AceConfig-3.0
Asa@0 10
Asa@0 11 Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
Asa@0 12
Asa@0 13 ]]
Asa@0 14
Asa@0 15 local MAJOR, MINOR = "AceConfig-3.0", 2
Asa@0 16 local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
Asa@0 17
Asa@0 18 if not AceConfig then return end
Asa@0 19
Asa@0 20 local cfgreg = LibStub("AceConfigRegistry-3.0")
Asa@0 21 local cfgcmd = LibStub("AceConfigCmd-3.0")
Asa@0 22 local cfgdlg = LibStub("AceConfigDialog-3.0")
Asa@0 23 --TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
Asa@0 24
Asa@0 25 -- Lua APIs
Asa@0 26 local pcall, error, type, pairs = pcall, error, type, pairs
Asa@0 27
Asa@0 28 -- -------------------------------------------------------------------
Asa@0 29 -- :RegisterOptionsTable(appName, options, slashcmd, persist)
Asa@0 30 --
Asa@0 31 -- - appName - (string) application name
Asa@0 32 -- - options - table or function ref, see AceConfigRegistry
Asa@0 33 -- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
Asa@0 34
Asa@0 35 --- Register a option table with the AceConfig registry.
Asa@0 36 -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
Asa@0 37 -- @paramsig appName, options [, slashcmd]
Asa@0 38 -- @param appName The application name for the config table.
Asa@0 39 -- @param options The option table (or a function to generate one on demand)
Asa@0 40 -- @param slashcmd A slash command to register for the option table, or a table of slash commands.
Asa@0 41 -- @usage
Asa@0 42 -- local AceConfig = LibStub("AceConfig-3.0")
Asa@0 43 -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
Asa@0 44 function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
Asa@0 45 local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
Asa@0 46 if not ok then error(msg, 2) end
Asa@0 47
Asa@0 48 if slashcmd then
Asa@0 49 if type(slashcmd) == "table" then
Asa@0 50 for _,cmd in pairs(slashcmd) do
Asa@0 51 cfgcmd:CreateChatCommand(cmd, appName)
Asa@0 52 end
Asa@0 53 else
Asa@0 54 cfgcmd:CreateChatCommand(slashcmd, appName)
Asa@0 55 end
Asa@0 56 end
Asa@0 57 end