Skip to content

Commit 69a2499

Browse files
committed
Update list of CVars each time CVar browser is opened
- Full list of CVars is not available on login, some get added later - Examples: AutoPushSpellToActionBar, showPlayer
1 parent 1217129 commit 69a2499

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

browser.lua

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ function addon:CVarExists(cvar)
77
return pcall(function() return GetCVarDefault(cvar) end)
88
end
99

10-
-- Go through list of cvars and remove any that don't currently exist
10+
-- C_Console.GetAllCommands() does not return the complete list of CVars on login
11+
-- Repopulate the list using UpdateCVarList() when the CVar browser is opened
1112
local CVarList = {}
12-
for i, info in pairs(C_Console.GetAllCommands()) do
13-
local cvar = info.command
14-
if info.commandType == 0 -- cvar, rather than script
15-
and info.category ~= 0 -- ignore debug category
16-
and not strfind(info.command:lower(), 'debug') -- a number of commands with "debug" in their name are inexplicibly not in the "debug" category
17-
and info.category ~= 8 -- ignore GM category
18-
then
19-
if addon.hiddenOptions[cvar] then
20-
CVarList[cvar] = addon.hiddenOptions[cvar]
21-
else
22-
CVarList[cvar] = {
23-
description = info.help,
24-
}
13+
local function UpdateCVarList()
14+
for i, info in pairs(C_Console.GetAllCommands()) do
15+
local cvar = info.command
16+
if info.commandType == 0 -- cvar, rather than script
17+
and info.category ~= 0 -- ignore debug category
18+
and not strfind(info.command:lower(), 'debug') -- a number of commands with "debug" in their name are inexplicibly not in the "debug" category
19+
and info.category ~= 8 -- ignore GM category
20+
then
21+
if addon.hiddenOptions[cvar] then
22+
CVarList[cvar] = addon.hiddenOptions[cvar]
23+
else
24+
CVarList[cvar] = {
25+
description = info.help,
26+
}
27+
end
2528
end
2629
end
2730
end
@@ -199,6 +202,7 @@ end
199202
-- Update CVarTable to reflect current values
200203
local function RefreshCVarList()
201204
wipe(CVarTable)
205+
UpdateCVarList()
202206
-- todo: this needs to be updated every time a cvar changes while the table is visible
203207
for cvar, tbl in pairs(CVarList) do
204208
local value, default, isDefault = GetPrettyCVar(cvar)

0 commit comments

Comments
 (0)