/trunk/Libs/AceConfig-3.0/AceConfigRegistry-3.0
-- * Valid **uiTypes**: "cmd", "dropdown", "dialog". This is verified by the library at call time. \\ |
-- * The **uiName** field is expected to contain the full name of the calling addon, including version, e.g. "FooBar-1.0". This is verified by the library at call time.\\ |
-- * The **appName** field is the options table name as given at registration time \\ |
-- |
-- |
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". |
-- @class file |
-- @name AceConfigRegistry-3.0 |
-- @release $Id: AceConfigRegistry-3.0.lua 1193 2018-08-02 12:24:37Z funkydude $ |
-- @release $Id: AceConfigRegistry-3.0.lua 1207 2019-06-23 12:08:33Z nevcairiel $ |
local CallbackHandler = LibStub("CallbackHandler-1.0") |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 18 |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 20 |
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigRegistry then return end |
AceConfigRegistry.validated = { |
-- list of options table names ran through :ValidateOptionsTable automatically. |
-- list of options table names ran through :ValidateOptionsTable automatically. |
-- CLEARED ON PURPOSE, since newer versions may have newer validators |
cmd = {}, |
dropdown = {}, |
} |
local typedkeys={ |
header={}, |
header={ |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
description={ |
image=optstringnumberfunc, |
imageCoords=optmethodtable, |
imageHeight=optnumber, |
imageWidth=optnumber, |
fontSize=optstringfunc, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
group={ |
args=istable, |
imageCoords=optmethodtable, |
imageHeight=optnumber, |
imageWidth=optnumber, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
input={ |
pattern=optstring, |
tristate=optbool, |
image=optstringnumberfunc, |
imageCoords=optmethodtable, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
tristate={ |
}, |
step=optnumber, |
bigStep=optnumber, |
isPercent=optbool, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
select={ |
values=ismethodtable, |
sorting=optmethodtable, |
style={ |
["nil"]=true, |
["string"]={dropdown=true,radio=true}, |
["nil"]=true, |
["string"]={dropdown=true,radio=true}, |
_="string: 'dropdown' or 'radio'" |
}, |
control=optstring, |
}, |
color={ |
hasAlpha=optmethodbool, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
keybinding={ |
-- TODO |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
}, |
} |
if type(options.type)~="string" then |
err(".type: expected a string, got a "..type(options.type), errlvl,...) |
end |
-- get type and 'typedkeys' member |
local tk = typedkeys[options.type] |
if not tk then |
err(".type: unknown type '"..options.type.."'", errlvl,...) |
end |
-- make sure that all options[] are known parameters |
for k,v in pairs(options) do |
if not (tk[k] or basekeys[k]) then |
AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable |
AceConfigRegistry.validated[uiType][appName] = true |
end |
return options |
return options |
end |
elseif type(options)=="function" then |
AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) |
if not f then |
return nil |
end |
if uiType then |
return f(uiType,uiName,1) -- get the table for us |
else |