Can someone clarify how to properly address the Set and Get values I should be using?
The help section is a bit vague on how they go about addressing things:
multiselect
Basically multiple "toggle" elements condensed into a group of checkboxes, or something else that makes sense in the interface.
values (table|function) - [key]=value pair table to choose from, key is the value passed to "set", value is the string displayed
get (function|methodname) - will be called for every key in values with the key name as last parameter
set (function|methodname) - will be called with keyname, state as parameters
tristate (boolean) - Make the checkmarks tri-state. Values are cycled through unchecked (false), checked (true), greyed (nil) - in that order.
|
Here is my option section and the various functions and relations:
Lua Code:
-- Values table
local cZones = {
["none"] = "World",
["arena"] = "Arena",
["pvp"] = "Battleground",
["party"] = "Instance",
["raid"] = "Raid"
}
-- Get and Set functions
local function GetValue(info)
local db = AAM.db.profile
if type(info.arg) == "table" then
return db[info.arg[1]][info.arg[2]]
else
return db[info.arg]
end
end
local function SetValue(info,v)
local db = AAM.db.profile
if type(info.arg) == "table" then
db[info.arg[1]][info.arg[2]] = v
else
db[info.arg] = v
end
AAM:UpdateMarks()
end
-- DB
local defaults = {
profile = {
enable = true,
activeLayout = "default",
zoneType = "ANY",
customZones = {
["none"] = true,
["arena"] = false,
["pvp"] = false,
["party"] = false,
["raid"] = false
}
}
}
-- Option table
Zones = {
name = "Enabled Zones",
type = "multiselect",
disabled = function() if db.zoneType ~= "CUSTOM" or not db.enabled then return false end end,
values = cZones,
get = GetValue,
set = SetValue,
arg = "customZones",
}
Basically it's dropping a string value into 'db.customZones' instead of indexing into the table and a boolean value.
Should I be using a string to table, table to string?'
EDIT: After trying to find another addon that uses this method (Omen in this case) I found that there is an extra parameter you can call as the 'keyname' that they state on the AceConfig help page I quoted.
get = function(info,
k)
set = function(info,
k, v)