From db6ffdde2447fb8dee4d96389b5f9c7b8dfb1a03 Mon Sep 17 00:00:00 2001 From: ollidiemaus Date: Wed, 24 Jul 2024 22:37:09 +0200 Subject: [PATCH] fix slash commands to open settings --- AutoPotion.toc | 2 +- FrameXML/InterfaceOptionsFrame.lua | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/AutoPotion.toc b/AutoPotion.toc index 373653c..452ff78 100755 --- a/AutoPotion.toc +++ b/AutoPotion.toc @@ -2,7 +2,7 @@ ## Interface-Classic: 11503 ## Interface-WOTLKC: 30403 ## Interface-Cata: 40400 -## Version: 3.5.0 +## Version: 3.5.1 ## Title: Auto Potion ## Author: ollidiemaus ## Notes: Updates the Macro AutoPotion to use either Healthstone or the highest Potion found in Bags diff --git a/FrameXML/InterfaceOptionsFrame.lua b/FrameXML/InterfaceOptionsFrame.lua index dd5d0a9..5442ff2 100644 --- a/FrameXML/InterfaceOptionsFrame.lua +++ b/FrameXML/InterfaceOptionsFrame.lua @@ -166,14 +166,15 @@ function panel:updatePrio() end function panel:InitializeOptions() - self.panel = CreateFrame("Frame", "Auto Potion", InterfaceOptionsFramePanelContainer) + self.panel = CreateFrame("Frame", addonName, InterfaceOptionsFramePanelContainer) ---@diagnostic disable-next-line: inject-field - self.panel.name = "Auto Potion" + self.panel.name = addonName if InterfaceOptions_AddCategory then InterfaceOptions_AddCategory(self.panel) else - local category = Settings.RegisterCanvasLayoutCategory(self.panel, self.panel.name); + local category = Settings.RegisterCanvasLayoutCategory(self.panel, addonName); Settings.RegisterAddOnCategory(category); + self.panel.categoryID = category:GetID() -- for OpenToCategory use end ------------- HEADER ------------- @@ -342,5 +343,10 @@ SLASH_HAM3 = "/ap" SLASH_HAM4 = "/autopotion" SlashCmdList.HAM = function(msg, editBox) - InterfaceOptionsFrame_OpenToCategory(panel.panel) + if InterfaceOptions_AddCategory then + InterfaceOptionsFrame_OpenToCategory(addonName) + else + local settingsCategoryID = _G[addonName].categoryID + Settings.OpenToCategory(settingsCategoryID) + end end