Skip to content

Commit 07e12ab

Browse files
committed
Switch to new Settings API
1 parent a778f6b commit 07e12ab

File tree

3 files changed

+37
-32
lines changed

3 files changed

+37
-32
lines changed

AdvancedInterfaceOptions.toc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818
semlib\semlib.xml
1919
utils.lua
2020
cvars.lua
21-
basicOptions.lua
2221
browser.lua
23-
22+
basicOptions.lua

basicOptions.lua

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -958,18 +958,18 @@ local function stTextDisplaySetValue(self)
958958
end
959959

960960
-- TODO: figure out why the built-in tooltipTitle and tooltipText attributes don't work
961-
local stTextDisplay = addon:CreateDropdown(AIO_ST, 130, {
962-
{text = STATUS_TEXT_VALUE, value = 'NUMERIC', func = stTextDisplaySetValue},
963-
{text = STATUS_TEXT_PERCENT, value = 'PERCENT', func = stTextDisplaySetValue},
964-
{text = STATUS_TEXT_BOTH, value = 'BOTH', func = stTextDisplaySetValue},
965-
})
966-
stTextDisplay:SetPoint('LEFT', stToggleStatusText, 'RIGHT', 100, -2)
967-
stTextDisplay:HookScript('OnShow', function(self) self:SetValue(GetCVar('statusTextDisplay')) end)
968-
stTextDisplay:HookScript("OnEnter", function(self)
969-
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
970-
GameTooltip:SetText(OPTION_TOOLTIP_STATUS_TEXT_DISPLAY, nil, nil, nil, nil, true)
971-
end)
972-
stTextDisplay:HookScript("OnLeave", GameTooltip_Hide)
961+
-- local stTextDisplay = addon:CreateDropdown(AIO_ST, 130, {
962+
-- {text = STATUS_TEXT_VALUE, value = 'NUMERIC', func = stTextDisplaySetValue},
963+
-- {text = STATUS_TEXT_PERCENT, value = 'PERCENT', func = stTextDisplaySetValue},
964+
-- {text = STATUS_TEXT_BOTH, value = 'BOTH', func = stTextDisplaySetValue},
965+
-- })
966+
-- stTextDisplay:SetPoint('LEFT', stToggleStatusText, 'RIGHT', 100, -2)
967+
-- stTextDisplay:HookScript('OnShow', function(self) self:SetValue(GetCVar('statusTextDisplay')) end)
968+
-- stTextDisplay:HookScript("OnEnter", function(self)
969+
-- GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
970+
-- GameTooltip:SetText(OPTION_TOOLTIP_STATUS_TEXT_DISPLAY, nil, nil, nil, nil, true)
971+
-- end)
972+
-- stTextDisplay:HookScript("OnLeave", GameTooltip_Hide)
973973

974974
-- Nameplate section
975975
local AIO_NP = CreateFrame('Frame', nil, InterfaceOptionsFramePanelContainer)
@@ -1042,21 +1042,36 @@ spellStartRecovery.minText:SetFormattedText("%d %s", spellStartRecovery.minMaxVa
10421042
spellStartRecovery.maxText:SetFormattedText("%d %s", spellStartRecovery.minMaxValues[2], MILLISECONDS_ABBR)
10431043

10441044
-- Hook up options to addon panel
1045-
InterfaceOptions_AddCategory(AIO, addonName)
1046-
InterfaceOptions_AddCategory(AIO_Chat, addonName)
1047-
InterfaceOptions_AddCategory(AIO_C, addonName)
1048-
InterfaceOptions_AddCategory(AIO_FCT, addonName)
1049-
-- InterfaceOptions_AddCategory(AIO_ST, addonName)
1050-
InterfaceOptions_AddCategory(AIO_NP, addonName)
1045+
local category = Settings.RegisterCanvasLayoutCategory(AIO, AIO.name, AIO.name)
1046+
local chatSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_Chat, AIO_Chat.name, AIO_Chat.name)
1047+
chatSubcategory.ID = AIO_Chat.name;
1048+
local cSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_C, AIO_C.name, AIO_C.name)
1049+
cSubcategory.ID = AIO_C.name;
1050+
local fctSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_FCT, AIO_FCT.name, AIO_FCT.name)
1051+
fctSubcategory.ID = AIO_FCT.name;
1052+
local stSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_ST, AIO_ST.name, AIO_ST.name)
1053+
stSubcategory.ID = AIO_ST.name;
1054+
local npSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_NP, AIO_NP.name, AIO_NP.name)
1055+
npSubcategory.ID = AIO_NP.name;
1056+
local cvarsSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, addon.OptionsPanel, addon.OptionsPanel.name, addon.OptionsPanel.name)
1057+
cvarsSubcategory.ID = addon.OptionsPanel.name;
1058+
Settings.RegisterAddOnCategory(category)
10511059

10521060
-- Slash handler
10531061
SlashCmdList.AIO = function(msg)
10541062
msg = msg:lower()
10551063
if not InCombatLockdown() then
1056-
InterfaceOptionsFrame_OpenToCategory(addonName)
1057-
InterfaceOptionsFrame_OpenToCategory(addonName)
1064+
Settings.OpenToCategory(category.ID)
10581065
else
10591066
DEFAULT_CHAT_FRAME:AddMessage(format("%s: Can't modify interface options in combat", addonName))
10601067
end
10611068
end
10621069
SLASH_AIO1 = "/aio"
1070+
1071+
SlashCmdList.CVAR = function()
1072+
if not InCombatLockdown() then
1073+
-- Does not work, opens to main category
1074+
Settings.OpenToCategory(category.ID, cvarsSubcategory.ID)
1075+
end
1076+
end
1077+
SLASH_CVAR1 = "/cvar"

browser.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ OptionsPanel:Hide()
112112
OptionsPanel:SetAllPoints()
113113
OptionsPanel.name = "CVar Browser"
114114
OptionsPanel.parent = addonName
115+
addon.OptionsPanel = OptionsPanel
115116

116117
local Title = OptionsPanel:CreateFontString(nil, 'ARTWORK', 'GameFontNormalLarge')
117118
Title:SetJustifyV('TOP')
@@ -128,8 +129,6 @@ SubText:SetPoint('TOPLEFT', Title, 'BOTTOMLEFT', 0, -8)
128129
SubText:SetPoint('RIGHT', -32, 0)
129130
SubText:SetText('These options allow you to modify various CVars within the game.')
130131

131-
InterfaceOptions_AddCategory(OptionsPanel, addonName)
132-
133132
-- FilterBox should adjust the contents of the list frame based on the input text
134133
-- todo: Display grey "Search" text in the box if it's empty
135134
local FilterBox = CreateFrame('editbox', nil, OptionsPanel, 'InputBoxTemplate')
@@ -375,11 +374,3 @@ hooksecurefunc('SetCVar', FilteredRefresh)
375374

376375
-- should we even bother checking what the console command did?
377376
hooksecurefunc('ConsoleExec', FilteredRefresh)
378-
379-
SlashCmdList.CVAR = function()
380-
if not InCombatLockdown() then
381-
InterfaceOptionsFrame_OpenToCategory(OptionsPanel)
382-
InterfaceOptionsFrame_OpenToCategory(OptionsPanel)
383-
end
384-
end
385-
SLASH_CVAR1 = "/cvar"

0 commit comments

Comments
 (0)