Setting up interface options panel for the addon.
My previous issues are all solved and I will share the addon with you guys once the interface options panel is done.
File 1:
Lua Code:
local function getOptions()
if not options then
options = {
type = "group",
name = "ImmersiveHide",
args = {
general = {
order = 1,
type = "group",
name = "General Settings",
get = optGetter,
set = optSetter,
args = {
intro = {
order = 1,
type = "description",
name = L["Lorem ipsum."],
},
alphadesc = {
order = 2,
type = "description",
name = L["Lorem ipsum."],
},
TESTVARIABLE = {
order = 2.2,
type = "toggle",
name = "TEST_VARIABLE",
desc = L["Hello world will be shown."],
get = function() return GetCVarBool("TESTVARIABLE") end,
set = function(_, v) v = v and 1 or 0; SetCVar("TESTVARIABLE", v); end,
width = "full",
},
alpha = {
order = 3,
name = L["Alpha"],
desc = L["The transparency of stuff."],
type = "range",
min = 0, max = 1, bigStep = 0.01,
isPercent = true,
},
fadealpha = {
order = 4.1,
type = "range",
name = L["Faded Alpha"],
desc = L["The transparency of stuff while faded."],
get = function() return MIN_ALPHA end,
set = function(_, v) SetCVar("MinAlpha", v); WORLD_MAP_MIN_ALPHA = v end,
min = 0, max = 1, bigStep = 0.01,
isPercent = true,
disabled = function() return not GetCVarBool("Fade") end,
},
},
},
},
}
for k,v in pairs(moduleOptions) do
options.args[k] = (type(v) == "function") and v() or v
end
end
return options
end
File 2:
Lua Code:
local function HelloWorld()
if TESTVARIABLE = true then
print("Hello World!")
end
end
HelloWorld()
function addon:FadeIn()
UIFrameFadeIn(UIParent, 1, fadealpha, alpha);
end;
function addon:FadeOut()
UIFrameFadeOut(UIParent, 1, alpha, fadealpha);
end;
Variables from the first file that I want to use on the second file: TESTVARIABLE, alpha, fadealpha.
I've read plenty of addon files but they are all confusing to me because each addon creates the interface options panel in a different way and I have a really hard time identifying when they're using the configuration variables.