diff --git a/HideCoAUI/HideCoAUI.toc b/HideCoAUI/HideCoAUI.toc index 03b8f34..361dfbe 100644 --- a/HideCoAUI/HideCoAUI.toc +++ b/HideCoAUI/HideCoAUI.toc @@ -7,4 +7,5 @@ ## OptionalDeps: ElvUI HideCoAUI.lua +SlashCommands.lua Options.lua \ No newline at end of file diff --git a/HideCoAUI/Options.lua b/HideCoAUI/Options.lua index f7af3a0..13ec99b 100644 --- a/HideCoAUI/Options.lua +++ b/HideCoAUI/Options.lua @@ -557,8 +557,14 @@ aboutTitle:SetText("About") InterfaceOptions_AddCategory(aboutPanel) +local function OpenOptions() + InterfaceOptionsFrame_OpenToCategory(classesPanel) +end + +HideCoAUI.OpenOptions = OpenOptions + -- Jump straight to the Classes subcategory when the HideCoAUI parent node itself is opened. panel:SetScript("OnShow", function(self) - InterfaceOptionsFrame_OpenToCategory(classesPanel) + OpenOptions() self:Hide() end) diff --git a/HideCoAUI/SlashCommands.lua b/HideCoAUI/SlashCommands.lua new file mode 100644 index 0000000..99d6193 --- /dev/null +++ b/HideCoAUI/SlashCommands.lua @@ -0,0 +1,38 @@ +local commands = {} + +local function RegisterCommand(name, description, handler) + table.insert(commands, { name = name, description = description, handler = handler }) +end + +HideCoAUI.RegisterSlashCommand = RegisterCommand + +local function PrintCommandList() + print("|cff33ff99HideCoAUI|r commands:") + for _, command in ipairs(commands) do + print(" |cffffffff/hidecoaui " .. command.name .. "|r - " .. command.description) + end +end + +local function HandleSlashCommand(msg) + + local commandName = msg:match("^%s*(%S*)"):lower() + + if commandName == "" then + HideCoAUI.OpenOptions() + return + end + + for _, command in ipairs(commands) do + if command.name == commandName then + command.handler() + return + end + end + + print("|cff33ff99HideCoAUI|r unknown command: /hidecoaui " .. commandName) + PrintCommandList() + +end + +SLASH_HIDECOAUI1 = "/hidecoaui" +SlashCmdList["HIDECOAUI"] = HandleSlashCommand