Originally Posted by Sweetsour
So if my code does something that adds new controls to my config panel, I have to reload the UI, correct?
|
No.
Since the code you've provided is incomplete we are left to guess what is going wrong. Based on what has been provided this code should throw an error:
Code:
local function RefreshConfig()
foreach(LibStub("AceConfigRegistry-3.0").tables,function(k,v)
ACFG:NotifyChange(k)
end)
end
That function should look like:
Code:
local function RefreshConfig()
local ACR = LibStub("AceConfigRegistry-3.0")
for k, v in pairs(ACR.tables) do
ACR:NotifyChange(k)
end
end
But even that is overkill since you are trying to refresh every registered set of options. Something more along the lines of this is what you are going for:
Code:
local optionsSubTables = {
["Quick Toggle"] = GetToggleOptions,
["Spell Sounds"] = GetSpellOptions,
["Defense Sounds"] = GetDefenseOptions,
["Combat Sounds"] = GetCombatOptions,
["Loot Sounds"] = GetLootOptions,
["Chat Sounds"] = GetChatOptions,
["Movement Sounds"] = GetMoveOptions,
["Backup Sounds"] = GetBackupOptions,
["Restore Sounds"] = GetRestoreOptions,
["Profiles"] = false
}
local function RefreshConfig()
local ACR = LibStub("AceConfigRegistry-3.0")
for name in pairs(optionsSubTables) do
ACR:NotifyChange(("CustomAudio %s"):format(name))
end
end
function Ace3:OnProfileUpdate(event,db,profileKey)
SCA.profile = self.db.profile
RefreshConfig()
end
function Ace3:OnInitialize() -- Event: ADDON_LOADED
local about_panel = LibStub("LibAboutPanel", true)
if about_panel then
self.optionsFrame = about_panel.new(nil, "CustomAudio")
end
self.db = LibStub("AceDB-3.0"):New("SCA_db", SCA.defaults)
SCA.profile = self.db.profile
self.db.RegisterCallback(self, "OnNewProfile", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileUpdate")
-- Setup Options
local ACD, ACR = LibStub("AceConfigDialog-3.0"), LibStub("AceConfigRegistry-3.0")
for name, options in pairs(optionsSubTables) do
local appName = ("CustomAudio %s"):format(name)
ACR:RegisterOptionsTable(appName, options or LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db, true))
ACD:AddToBlizOptions(appName, name, "CustomAudio")
end
end
If you don't have an alternate way to change profiles (i.e. slash command or plugin menu) you could potentially shrink that more to:
Code:
local optionsSubTables = {
["Quick Toggle"] = GetToggleOptions,
["Spell Sounds"] = GetSpellOptions,
["Defense Sounds"] = GetDefenseOptions,
["Combat Sounds"] = GetCombatOptions,
["Loot Sounds"] = GetLootOptions,
["Chat Sounds"] = GetChatOptions,
["Movement Sounds"] = GetMoveOptions,
["Backup Sounds"] = GetBackupOptions,
["Restore Sounds"] = GetRestoreOptions,
["Profiles"] = false
}
function Ace3:OnProfileUpdate(event,db,profileKey)
SCA.profile = self.db.profile
end
function Ace3:OnInitialize() -- Event: ADDON_LOADED
local about_panel = LibStub("LibAboutPanel", true)
if about_panel then
self.optionsFrame = about_panel.new(nil, "CustomAudio")
end
self.db = LibStub("AceDB-3.0"):New("SCA_db", SCA.defaults)
SCA.profile = self.db.profile
self.db.RegisterCallback(self, "OnNewProfile", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileUpdate")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileUpdate")
-- Setup Options
local ACD, ACR = LibStub("AceConfigDialog-3.0"), LibStub("AceConfigRegistry-3.0")
for name, options in pairs(optionsSubTables) do
local appName = ("CustomAudio %s"):format(name)
ACR:RegisterOptionsTable(appName, options or LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db, true))
ACD:AddToBlizOptions(appName, name, "CustomAudio")
end
end
However, since you didn't post all of your code that can't be tested and your problem may be in unposted code.