Skip to content

Commit

Permalink
Fix missing GetCVarInfo function in Classic
Browse files Browse the repository at this point in the history
  • Loading branch information
semlar committed Nov 23, 2023
1 parent bd3dd5a commit cc65387
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions AdvancedInterfaceOptions.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
## SavedVariables: AdvancedInterfaceOptionsSaved

semlib\semlib.xml
utils.lua
cvars.lua
basicOptions.lua
browser.lua
Expand Down
2 changes: 2 additions & 0 deletions basicOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ local SetCVar = function(...) -- Suppress errors trying to set read-only cvars
return status
end

local GetCVarInfo = addon.GetCVarInfo

local function IsClassic()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end
Expand Down
2 changes: 2 additions & 0 deletions browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local addonName, addon = ...
local _G = _G
local E = addon:Eve()

-- local GetCVarInfo = addon.GetCVarInfo

-- C_Console.GetAllCommands() does not return the complete list of CVars on login
-- Repopulate the list using UpdateCVarList() when the CVar browser is opened
local CVarList = {}
Expand Down
9 changes: 1 addition & 8 deletions cvars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1029,17 +1029,10 @@ local CategoryNames = { -- not sure how meaningful these really are (/Blizzard_C
help: cvar description text
--]]

-- C_Console.GetAllCommands is now ConsoleGetAllCommands as of 10.2.0
local ConsoleGetAllCommands = ConsoleGetAllCommands or C_Console and C_Console.GetAllCommands

function addon:CVarExists(cvar)
return not not select(2, pcall(function() return GetCVarInfo(cvar) end))
end

-- Returns filtered list of CVars
function addon:GetCVars()
local cvars = {}
for _, info in ipairs(ConsoleGetAllCommands()) do
for _, info in ipairs(addon:GetAllCommands()) do
if info.commandType == 0 -- cvar, rather than script
and info.category ~= 0 -- ignore debug category
and not strfind(info.command:lower(), 'debug') -- a number of commands with "debug" in their name are inexplicibly not in the "debug" category
Expand Down
16 changes: 16 additions & 0 deletions utils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local addonName, addon = ...

--------------------------------------
-- Utility functions
--------------------------------------

-- C_Console.GetAllCommands is now ConsoleGetAllCommands as of 10.2.0
addon.GetAllCommands = ConsoleGetAllCommands or C_Console and C_Console.GetAllCommands

-- GetCVarInfo moved to C_CVar
-- value, defaultValue, isStoredServerAccount, isStoredServerCharacter, isLockedFromUser, isSecure, isReadOnly
addon.GetCVarInfo = GetCVarInfo or C_CVar and C_CVar.GetCVarInfo

function addon:CVarExists(cvar)
return not not select(2, pcall(function() return addon.GetCVarInfo(cvar) end))
end

0 comments on commit cc65387

Please sign in to comment.