Skip to content

Commit

Permalink
Switch to new Settings API
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanzilla committed Jun 11, 2024
1 parent a778f6b commit 07e12ab
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
3 changes: 1 addition & 2 deletions AdvancedInterfaceOptions.toc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
semlib\semlib.xml
utils.lua
cvars.lua
basicOptions.lua
browser.lua

basicOptions.lua
55 changes: 35 additions & 20 deletions basicOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -958,18 +958,18 @@ local function stTextDisplaySetValue(self)
end

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

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

-- Hook up options to addon panel
InterfaceOptions_AddCategory(AIO, addonName)
InterfaceOptions_AddCategory(AIO_Chat, addonName)
InterfaceOptions_AddCategory(AIO_C, addonName)
InterfaceOptions_AddCategory(AIO_FCT, addonName)
-- InterfaceOptions_AddCategory(AIO_ST, addonName)
InterfaceOptions_AddCategory(AIO_NP, addonName)
local category = Settings.RegisterCanvasLayoutCategory(AIO, AIO.name, AIO.name)
local chatSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_Chat, AIO_Chat.name, AIO_Chat.name)
chatSubcategory.ID = AIO_Chat.name;
local cSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_C, AIO_C.name, AIO_C.name)
cSubcategory.ID = AIO_C.name;
local fctSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_FCT, AIO_FCT.name, AIO_FCT.name)
fctSubcategory.ID = AIO_FCT.name;
local stSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_ST, AIO_ST.name, AIO_ST.name)
stSubcategory.ID = AIO_ST.name;
local npSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, AIO_NP, AIO_NP.name, AIO_NP.name)
npSubcategory.ID = AIO_NP.name;
local cvarsSubcategory = Settings.RegisterCanvasLayoutSubcategory(category, addon.OptionsPanel, addon.OptionsPanel.name, addon.OptionsPanel.name)
cvarsSubcategory.ID = addon.OptionsPanel.name;
Settings.RegisterAddOnCategory(category)

-- Slash handler
SlashCmdList.AIO = function(msg)
msg = msg:lower()
if not InCombatLockdown() then
InterfaceOptionsFrame_OpenToCategory(addonName)
InterfaceOptionsFrame_OpenToCategory(addonName)
Settings.OpenToCategory(category.ID)
else
DEFAULT_CHAT_FRAME:AddMessage(format("%s: Can't modify interface options in combat", addonName))
end
end
SLASH_AIO1 = "/aio"

SlashCmdList.CVAR = function()
if not InCombatLockdown() then
-- Does not work, opens to main category
Settings.OpenToCategory(category.ID, cvarsSubcategory.ID)
end
end
SLASH_CVAR1 = "/cvar"
11 changes: 1 addition & 10 deletions browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ OptionsPanel:Hide()
OptionsPanel:SetAllPoints()
OptionsPanel.name = "CVar Browser"
OptionsPanel.parent = addonName
addon.OptionsPanel = OptionsPanel

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

InterfaceOptions_AddCategory(OptionsPanel, addonName)

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

-- should we even bother checking what the console command did?
hooksecurefunc('ConsoleExec', FilteredRefresh)

SlashCmdList.CVAR = function()
if not InCombatLockdown() then
InterfaceOptionsFrame_OpenToCategory(OptionsPanel)
InterfaceOptionsFrame_OpenToCategory(OptionsPanel)
end
end
SLASH_CVAR1 = "/cvar"

0 comments on commit 07e12ab

Please sign in to comment.