From cc65387c9121477fb5049404b631d33348409415 Mon Sep 17 00:00:00 2001 From: semlar Date: Thu, 23 Nov 2023 00:40:21 -0500 Subject: [PATCH] Fix missing GetCVarInfo function in Classic --- AdvancedInterfaceOptions.toc | 1 + basicOptions.lua | 2 ++ browser.lua | 2 ++ cvars.lua | 9 +-------- utils.lua | 16 ++++++++++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 utils.lua diff --git a/AdvancedInterfaceOptions.toc b/AdvancedInterfaceOptions.toc index 31a7029..82430b0 100644 --- a/AdvancedInterfaceOptions.toc +++ b/AdvancedInterfaceOptions.toc @@ -17,6 +17,7 @@ ## SavedVariables: AdvancedInterfaceOptionsSaved semlib\semlib.xml +utils.lua cvars.lua basicOptions.lua browser.lua diff --git a/basicOptions.lua b/basicOptions.lua index ec0c836..3f7f391 100644 --- a/basicOptions.lua +++ b/basicOptions.lua @@ -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 diff --git a/browser.lua b/browser.lua index 5b5aac0..f08d22b 100644 --- a/browser.lua +++ b/browser.lua @@ -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 = {} diff --git a/cvars.lua b/cvars.lua index acc6b8e..95682f8 100644 --- a/cvars.lua +++ b/cvars.lua @@ -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 diff --git a/utils.lua b/utils.lua new file mode 100644 index 0000000..f127ac0 --- /dev/null +++ b/utils.lua @@ -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 \ No newline at end of file