comparison Libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua @ 18:a0dcdcaec1ea v7.3.0.018

- toc update. - libs update.
author Tercio
date Tue, 17 Oct 2017 10:02:01 -0200
parents ce416064d8a1
children fedcd7c21db9
comparison
equal deleted inserted replaced
17:da84a5064a5a 18:a0dcdcaec1ea
6 -- * The **appName** field is the options table name as given at registration time \\ 6 -- * The **appName** field is the options table name as given at registration time \\
7 -- 7 --
8 -- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". 8 -- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName".
9 -- @class file 9 -- @class file
10 -- @name AceConfigRegistry-3.0 10 -- @name AceConfigRegistry-3.0
11 -- @release $Id: AceConfigRegistry-3.0.lua 1045 2011-12-09 17:58:40Z nevcairiel $ 11 -- @release $Id: AceConfigRegistry-3.0.lua 1161 2017-08-12 14:30:16Z funkydude $
12 local MAJOR, MINOR = "AceConfigRegistry-3.0", 14 12 local CallbackHandler = LibStub("CallbackHandler-1.0")
13
14 local MAJOR, MINOR = "AceConfigRegistry-3.0", 17
13 local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) 15 local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR)
14 16
15 if not AceConfigRegistry then return end 17 if not AceConfigRegistry then return end
16 18
17 AceConfigRegistry.tables = AceConfigRegistry.tables or {} 19 AceConfigRegistry.tables = AceConfigRegistry.tables or {}
18
19 local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
20 20
21 if not AceConfigRegistry.callbacks then 21 if not AceConfigRegistry.callbacks then
22 AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry) 22 AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
23 end 23 end
24 24
55 local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"} 55 local isstringfunc={["string"]=true,["function"]=true, _="string or funcref"}
56 local istable={["table"]=true, _="table"} 56 local istable={["table"]=true, _="table"}
57 local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"} 57 local ismethodtable={["table"]=true,["string"]=true,["function"]=true, _="methodname, funcref or table"}
58 local optstring={["nil"]=true,["string"]=true, _="string"} 58 local optstring={["nil"]=true,["string"]=true, _="string"}
59 local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"} 59 local optstringfunc={["nil"]=true,["string"]=true,["function"]=true, _="string or funcref"}
60 local optstringnumberfunc={["nil"]=true,["string"]=true,["number"]=true,["function"]=true, _="string, number or funcref"}
60 local optnumber={["nil"]=true,["number"]=true, _="number"} 61 local optnumber={["nil"]=true,["number"]=true, _="number"}
61 local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"} 62 local optmethod={["nil"]=true,["string"]=true,["function"]=true, _="methodname or funcref"}
62 local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"} 63 local optmethodfalse={["nil"]=true,["string"]=true,["function"]=true,["boolean"]={[false]=true}, _="methodname, funcref or false"}
63 local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"} 64 local optmethodnumber={["nil"]=true,["string"]=true,["function"]=true,["number"]=true, _="methodname, funcref or number"}
64 local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"} 65 local optmethodtable={["nil"]=true,["string"]=true,["function"]=true,["table"]=true, _="methodname, funcref or table"}
80 hidden=optmethodbool, 81 hidden=optmethodbool,
81 guiHidden=optmethodbool, 82 guiHidden=optmethodbool,
82 dialogHidden=optmethodbool, 83 dialogHidden=optmethodbool,
83 dropdownHidden=optmethodbool, 84 dropdownHidden=optmethodbool,
84 cmdHidden=optmethodbool, 85 cmdHidden=optmethodbool,
85 icon=optstringfunc, 86 icon=optstringnumberfunc,
86 iconCoords=optmethodtable, 87 iconCoords=optmethodtable,
87 handler=opttable, 88 handler=opttable,
88 get=optmethodfalse, 89 get=optmethodfalse,
89 set=optmethodfalse, 90 set=optmethodfalse,
90 func=optmethodfalse, 91 func=optmethodfalse,
93 } 94 }
94 95
95 local typedkeys={ 96 local typedkeys={
96 header={}, 97 header={},
97 description={ 98 description={
98 image=optstringfunc, 99 image=optstringnumberfunc,
99 imageCoords=optmethodtable, 100 imageCoords=optmethodtable,
100 imageHeight=optnumber, 101 imageHeight=optnumber,
101 imageWidth=optnumber, 102 imageWidth=optnumber,
102 fontSize=optstringfunc, 103 fontSize=optstringfunc,
103 }, 104 },
110 dropdownInline=optbool, 111 dropdownInline=optbool,
111 dialogInline=optbool, 112 dialogInline=optbool,
112 childGroups=optstring, 113 childGroups=optstring,
113 }, 114 },
114 execute={ 115 execute={
115 image=optstringfunc, 116 image=optstringnumberfunc,
116 imageCoords=optmethodtable, 117 imageCoords=optmethodtable,
117 imageHeight=optnumber, 118 imageHeight=optnumber,
118 imageWidth=optnumber, 119 imageWidth=optnumber,
119 }, 120 },
120 input={ 121 input={
125 dropdownControl=optstring, 126 dropdownControl=optstring,
126 multiline=optboolnumber, 127 multiline=optboolnumber,
127 }, 128 },
128 toggle={ 129 toggle={
129 tristate=optbool, 130 tristate=optbool,
130 image=optstringfunc, 131 image=optstringnumberfunc,
131 imageCoords=optmethodtable, 132 imageCoords=optmethodtable,
132 }, 133 },
133 tristate={ 134 tristate={
134 }, 135 },
135 range={ 136 range={
286 287
287 --- Register an options table with the config registry. 288 --- Register an options table with the config registry.
288 -- @param appName The application name as given to `:RegisterOptionsTable()` 289 -- @param appName The application name as given to `:RegisterOptionsTable()`
289 -- @param options The options table, OR a function reference that generates it on demand. \\ 290 -- @param options The options table, OR a function reference that generates it on demand. \\
290 -- See the top of the page for info on arguments passed to such functions. 291 -- See the top of the page for info on arguments passed to such functions.
291 function AceConfigRegistry:RegisterOptionsTable(appName, options) 292 -- @param skipValidation Skip options table validation (primarily useful for extremely huge options, with a noticeable slowdown)
293 function AceConfigRegistry:RegisterOptionsTable(appName, options, skipValidation)
292 if type(options)=="table" then 294 if type(options)=="table" then
293 if options.type~="group" then -- quick sanity checker 295 if options.type~="group" then -- quick sanity checker
294 error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2) 296 error(MAJOR..": RegisterOptionsTable(appName, options): 'options' - missing type='group' member in root group", 2)
295 end 297 end
296 AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) 298 AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
297 errlvl=(errlvl or 0)+1 299 errlvl=(errlvl or 0)+1
298 validateGetterArgs(uiType, uiName, errlvl) 300 validateGetterArgs(uiType, uiName, errlvl)
299 if not AceConfigRegistry.validated[uiType][appName] then 301 if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
300 AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable 302 AceConfigRegistry:ValidateOptionsTable(options, appName, errlvl) -- upgradable
301 AceConfigRegistry.validated[uiType][appName] = true 303 AceConfigRegistry.validated[uiType][appName] = true
302 end 304 end
303 return options 305 return options
304 end 306 end
305 elseif type(options)=="function" then 307 elseif type(options)=="function" then
306 AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl) 308 AceConfigRegistry.tables[appName] = function(uiType, uiName, errlvl)
307 errlvl=(errlvl or 0)+1 309 errlvl=(errlvl or 0)+1
308 validateGetterArgs(uiType, uiName, errlvl) 310 validateGetterArgs(uiType, uiName, errlvl)
309 local tab = assert(options(uiType, uiName, appName)) 311 local tab = assert(options(uiType, uiName, appName))
310 if not AceConfigRegistry.validated[uiType][appName] then 312 if not AceConfigRegistry.validated[uiType][appName] and not skipValidation then
311 AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable 313 AceConfigRegistry:ValidateOptionsTable(tab, appName, errlvl) -- upgradable
312 AceConfigRegistry.validated[uiType][appName] = true 314 AceConfigRegistry.validated[uiType][appName] = true
313 end 315 end
314 return tab 316 return tab
315 end 317 end