/trunk/libs/AceConfig-3.0
-- :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 921 2010-05-09 15:49:14Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 12 |
-- @release $Id: AceConfigRegistry-3.0.lua 998 2010-12-01 18:39:53Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 13 |
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigRegistry then return end |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
itemControl=optstring, |
}, |
multiselect={ |
values=ismethodtable, |
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. |
-- @class file |
-- @name AceConfigDialog-3.0 |
-- @release $Id: AceConfigDialog-3.0.lua 967 2010-09-25 08:20:55Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 998 2010-12-01 18:39:53Z nevcairiel $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 50 |
local MAJOR, MINOR = "AceConfigDialog-3.0", 54 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
end |
function del(t) |
--delcount = delcount + 1 |
for k in pairs(t) do |
t[k] = nil |
end |
wipe(t) |
pool[t] = true |
end |
-- function cached() |
if user.grouplist then |
del(user.grouplist) |
end |
if user.orderlist then |
del(user.orderlist) |
end |
end |
end |
]] |
local function BuildSelect(group, options, path, appName) |
local groups = new() |
local order = new() |
local keySort = new() |
local opts = new() |
local hidden = CheckOptionHidden(v, options, path, appName) |
if not inline and not hidden then |
groups[k] = GetOptionsMemberValue("name", v, options, path, appName) |
tinsert(order, k) |
end |
path[#path] = nil |
end |
end |
del(opts) |
del(keySort) |
del(opts) |
return groups |
return groups, order |
end |
local function BuildSubGroups(group, tree, options, path, appName) |
elseif v.type == "select" then |
local values = GetOptionsMemberValue("values", v, options, path, appName) |
local controlType = v.dialogControl or v.control or "Dropdown" |
control = gui:Create(controlType) |
if not control then |
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) |
control = gui:Create("Dropdown") |
if v.style == "radio" then |
local disabled = CheckOptionDisabled(v, options, path, appName) |
local width = GetOptionsMemberValue("width",v,options,path,appName) |
control = gui:Create("InlineGroup") |
control:SetLayout("Flow") |
control:SetTitle(name) |
control.width = "fill" |
control:PauseLayout() |
local optionValue = GetOptionsMemberValue("get",v, options, path, appName, value) |
for value, text in pairs(values) do |
local radio = gui:Create("CheckBox") |
radio:SetLabel(text) |
radio:SetUserData("value", value) |
radio:SetUserData("text", text) |
radio:SetDisabled(disabled) |
radio:SetType("radio") |
radio:SetValue(optionValue == value) |
radio:SetCallback("OnValueChanged", ActivateMultiControl) |
InjectInfo(radio, options, v, path, rootframe, appName) |
control:AddChild(radio) |
if width == "double" then |
radio:SetWidth(width_multiplier * 2) |
elseif width == "half" then |
radio:SetWidth(width_multiplier / 2) |
elseif width == "full" then |
radio.width = "fill" |
else |
radio:SetWidth(width_multiplier) |
end |
end |
control:ResumeLayout() |
control:DoLayout() |
else |
local controlType = v.dialogControl or v.control or "Dropdown" |
control = gui:Create(controlType) |
if not control then |
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) |
control = gui:Create("Dropdown") |
end |
local itemType = v.itemControl |
if itemType and not gui:GetWidgetVersion(itemType) then |
geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType))) |
itemType = nil |
end |
control:SetLabel(name) |
control:SetList(values, nil, itemType) |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
if not values[value] then |
value = nil |
end |
control:SetValue(value) |
control:SetCallback("OnValueChanged", ActivateControl) |
end |
control:SetLabel(name) |
control:SetList(values) |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
if not values[value] then |
value = nil |
end |
control:SetValue(value) |
control:SetCallback("OnValueChanged",ActivateControl) |
elseif v.type == "multiselect" then |
local values = GetOptionsMemberValue("values", v, options, path, appName) |
status.groups = {} |
end |
select:SetStatusTable(status.groups) |
local grouplist = BuildSelect(group, options, path, appName) |
select:SetGroupList(grouplist) |
local grouplist, orderlist = BuildSelect(group, options, path, appName) |
select:SetGroupList(grouplist, orderlist) |
select:SetUserData("grouplist", grouplist) |
local firstgroup |
for k, v in pairs(grouplist) do |
if not firstgroup or k < firstgroup then |
firstgroup = k |
end |
end |
select:SetUserData("orderlist", orderlist) |
local firstgroup = orderlist[1] |
if firstgroup then |
select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) |
end |