View Single Post
01-27-18, 01:58 PM   #5
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
Lua Code:
  1. local function RefreshConfig()
  2.     foreach(LibStub("AceConfigRegistry-3.0").tables,function(k,v)
  3.         ACFG:NotifyChange(k)
  4.     end)
  5. end
  6.  
  7. function Ace3:OnProfileUpdate(event,db,profileKey)
  8.     if (db) then
  9.         ReloadUI()
  10.     end
  11.  
  12.     --What I've tried, but is currently commented
  13.     SCA.profile = self.db.profile
  14.     RefreshConfig()
  15. end
  16.  
  17. -- Event: ADDON_LOADED
  18. function Ace3:OnInitialize()
  19.     local about_panel = LibStub:GetLibrary("LibAboutPanel", true)
  20.  
  21.     if about_panel then
  22.         self.optionsFrame = about_panel.new(nil, "CustomAudio")
  23.     end
  24.  
  25.     self.db = LibStub("AceDB-3.0"):New("SCA_db", SCA.defaults)
  26.     SCA.profile = self.db.profile
  27.  
  28.     self.db.RegisterCallback(self, "OnNewProfile", "OnProfileUpdate")
  29.     self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileUpdate")
  30.     self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileUpdate")
  31.     self.db.RegisterCallback(self, "OnProfileReset", "OnProfileUpdate")
  32.  
  33.     self:SetupOptions()
  34. end
  35.  
  36. function Ace3:SetupOptions()
  37.     local ACFG = LibStub("AceConfigRegistry-3.0")
  38.     ACFG:RegisterOptionsTable("CustomAudio Quick Toggle", GetToggleOptions)
  39.     ACFG:RegisterOptionsTable("CustomAudio Spell Sounds", GetSpellOptions)
  40.     ACFG:RegisterOptionsTable("CustomAudio Defense Sounds", GetDefenseOptions)
  41.     ACFG:RegisterOptionsTable("CustomAudio Combat Sounds", GetCombatOptions)
  42.     ACFG:RegisterOptionsTable("CustomAudio Loot Sounds", GetLootOptions)
  43.     ACFG:RegisterOptionsTable("CustomAudio Chat Sounds", GetChatOptions)
  44.     ACFG:RegisterOptionsTable("CustomAudio Movement Sounds", GetMoveOptions)
  45.     ACFG:RegisterOptionsTable("CustomAudio Backup Sounds", GetBackupOptions)
  46.     ACFG:RegisterOptionsTable("CustomAudio Restore Sounds", GetRestoreOptions)
  47.     ACFG:RegisterOptionsTable("CustomAudio Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db,true))
  48.  
  49.     local ACD = LibStub("AceConfigDialog-3.0")
  50.     ACD:AddToBlizOptions("CustomAudio Quick Toggle", "Quick Toggle", "CustomAudio")
  51.     ACD:AddToBlizOptions("CustomAudio Spell Sounds", "Spell Sounds", "CustomAudio")
  52.     ACD:AddToBlizOptions("CustomAudio Defense Sounds", "Defense Sounds", "CustomAudio")
  53.     ACD:AddToBlizOptions("CustomAudio Combat Sounds", "Combat Sounds", "CustomAudio")
  54.     ACD:AddToBlizOptions("CustomAudio Loot Sounds", "Loot Sounds", "CustomAudio")
  55.     ACD:AddToBlizOptions("CustomAudio Chat Sounds", "Chat Sounds", "CustomAudio")
  56.     ACD:AddToBlizOptions("CustomAudio Movement Sounds", "Movement Sounds", "CustomAudio")
  57.     ACD:AddToBlizOptions("CustomAudio Backup Sounds", "Backup Sounds", "CustomAudio")
  58.     ACD:AddToBlizOptions("CustomAudio Restore Sounds", "Restore Sounds", "CustomAudio")
  59.     ACD:AddToBlizOptions("CustomAudio Profiles", "Profiles", "CustomAudio")
  60. end

The issue I'm having is when I make any profile changes, then try to access any part of my addon's config, I get Lua errors because values can't be found.

Last edited by Sweetsour : 01-27-18 at 02:59 PM.
  Reply With Quote