The icon picker expects a numerically indexed array of texture paths.
You would then supply that to the icon picker and in the setFunc you do a reverse lookup for the icon index.
I see that you use strings as array indices for your texture array, which makes things a bit inconvenient.
You will need to generate the list of icons from that, or just change it to numeric indices.
From that array you then want to make a reverse lookup table:
Lua Code:
local icons = { "path/to/icon1.dds", "path/to/icon2.dds" }
local indexByIconPath = {}
for i=1, #icons do
indexByIconPath[icons[i]] = i
end
The iconpicker configuration would then look something like this:
Lua Code:
{ -- Icon for Bar 1
type = "iconpicker",
name = "Icon for Bar 1",
tooltip = "",
choices = icons,
getFunc = function() return icons[SwitchBar.SavedVars.icons["1"]] end, -- indices are now saved as numbers instead of strings
setFunc = function(value)
SwitchBar.SavedVars.icons["1"] = indexByIconPath[value]
SwitchBar.SetIcon("1", tostring(value))
end
},
You can also set the color picker up to update the icon picker's colors whenever you select a different one.
First define a global handle in the iconpicker configuration:
Lua Code:
reference = "SwitchBarIconPicker1"
Then update the setFunc of your color picker:
Lua Code:
{ -- icon 1 colorpicker
type = "colorpicker",
name = "Icon 1 colour",
getFunc = function() SwitchBar.GetBgColor("1") end,
setFunc = function(r,g,b,a)
SwitchBar.SetBgColor(r,g,b,a, "1")
SwitchBarIconPicker1:SetColor(ZO_ColorDef:New(r,g,b,a))
end,
},
You can see a working example of a combination of icon and color picker in
FCOItemSaver.
The answer to your second question is quite easy. You can add any number of widget configurations to the optionsData array in any way you want before you call RegisterOptionControls.
Lua Code:
local optionsData = {
{
type = "header",
name = "SwitchBar",
},
{ -- Move around?
type = "checkbox",
name = "Move around?",
...
}
for i=1, 16 do
optionsData[#optionsData + 1] = { -- icon preview texture
type = "texture",
image = SwitchBar.iconTextures[tostring(i)],
imageWidth = 100,
imageHeight = 100,
tooltip = tostring(i),
width = "half" ,
}
end
LAM:RegisterOptionControls("SwitchBar_Settings", optionsData)
But I can't recommend this way of showing preview textures in your settings menu, because it will take a lot of space.
You could create a custom widget instead which shows them all side by side in whatever way you want.