Skip to content

Commit

Permalink
- "/rgl set show" will now show categories as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Feb 19, 2024
1 parent 52191e1 commit b5d1df4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
35 changes: 30 additions & 5 deletions utils/rgmercs_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
value = tonumber(value)
Expand Down Expand Up @@ -329,6 +330,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
local boolValue = false
Expand All @@ -354,6 +356,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
local _, update = self:GetUsageText(config, false, moduleData.defaults)
Expand Down Expand Up @@ -457,12 +460,34 @@ function Config:HandleBind(config, value)
end
table.sort(sortedKeys)

local sortedCategories = {}
for c, d in pairs(self.CommandHandlers or {}) do
sortedCategories[d.subModule] = sortedCategories[d.subModule] or {}
if not RGMercUtils.TableContains(sortedCategories[d.subModule], d.category) then
table.insert(sortedCategories[d.subModule], d.category)
end
end
for _, subModuleTable in pairs(sortedCategories) do
table.sort(subModuleTable)
end

for _, subModuleName in ipairs(allModules) do
printf("\n\ag%s\aw Settings\n------------\n", subModuleName)
for _, c in pairs(sortedKeys) do
local d = self.CommandHandlers[c]
if d.subModule == subModuleName then
printf("\am%-20s\aw - \atUsage: \ay%s\aw | %s", d.name, RGMercUtils.PadString(d.usage, 100, false), d.about)
local printHeader = true
for _, c in ipairs(sortedCategories[subModuleName] or {}) do
local printCategory = true
for _, k in ipairs(sortedKeys) do
local d = self.CommandHandlers[k]
if d.subModule == subModuleName and d.category == c then
if printHeader then
printf("\n\ag%s\aw Settings\n------------", subModuleName)
printHeader = false
end
if printCategory then
printf("\n\aoCategory: %s\aw", c)
printCategory = false
end
printf("\am%-20s\aw - \atUsage: \ay%s\aw | %s", d.name, RGMercUtils.PadString(d.usage, 100, false), d.about)
end
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ function Utils.GetTableSize(t)
return i
end

---@param t table
---@param value string
---@return boolean
function Utils.TableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end

---@param time integer # in seconds
---@return string
function Utils.FormatTime(time)
Expand Down

0 comments on commit b5d1df4

Please sign in to comment.