Skip to content

Commit 4aadc84

Browse files
committed
Added compat methods.
1 parent fbb52c0 commit 4aadc84

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

LibMagicUtil-1.0/LibMagicUtil-1.0.lua

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After embedding you will be able to use the following methods:
2424
]]
2525

2626
local MAJOR = "LibMagicUtil-1.0"
27-
local MINOR = "20240724"
27+
local MINOR = 2024072401
2828

2929
local lib = LibStub:NewLibrary(MAJOR, MINOR)
3030
local media = LibStub("LibSharedMedia-3.0")
@@ -34,7 +34,8 @@ if not lib then return end
3434

3535
local embeddables = {
3636
"GetConfigTemplate", "_GetColorOpt", "_SetColorOpt", "_SetOption", "_GetOption",
37-
"_HideOption", "_DisableTiling", "FixBackdrop", "_SetBackgroundOption"
37+
"_HideOption", "_DisableTiling", "FixBackdrop", "_SetBackgroundOption",
38+
"InterfaceOptions_AddCategory", "InterfaceOptionsFrame_OpenToCategory"
3839
}
3940

4041
lib.optionTemplates = lib.optionTemplates or {}
@@ -178,6 +179,43 @@ function lib:Dump(o)
178179
end
179180
end
180181

182+
183+
184+
function lib:InterfaceOptions_AddCategory(frame, addOn, position)
185+
if InterfaceOptions_AddCategory then
186+
return InterfaceOptions_AddCategory(frame, addon, position)
187+
end
188+
-- cancel is no longer a default option. May add menu extension for this.
189+
frame.OnCommit = frame.okay;
190+
frame.OnDefault = frame.default;
191+
frame.OnRefresh = frame.refresh;
192+
193+
if frame.parent then
194+
local category = Settings.GetCategory(frame.parent);
195+
local subcategory, layout = Settings.RegisterCanvasLayoutSubcategory(category, frame, frame.name, frame.name);
196+
subcategory.ID = frame.name;
197+
return subcategory, category;
198+
else
199+
local category, layout = Settings.RegisterCanvasLayoutCategory(frame, frame.name, frame.name);
200+
category.ID = frame.name;
201+
Settings.RegisterAddOnCategory(category);
202+
return category;
203+
end
204+
end
205+
206+
-- Deprecated. Use Settings.OpenToCategory().
207+
function lib:InterfaceOptionsFrame_OpenToCategory(categoryIDOrFrame)
208+
if InterfaceOptionsFrame_OpenToCategory then
209+
return InterfaceOptionsFrame_OpenToCategory(categoryIDOrFrame)
210+
end
211+
if type(categoryIDOrFrame) == "table" then
212+
local categoryID = categoryIDOrFrame.name;
213+
return Settings.OpenToCategory(categoryID);
214+
else
215+
return Settings.OpenToCategory(categoryIDOrFrame);
216+
end
217+
end
218+
181219
-- Config template for a frame background
182220
optionTemplates.background = {
183221
type = "group",

0 commit comments

Comments
 (0)