Below are chunks of code from two files in RepByZone. I am not getting any errors. However, when the user toggles useClassRep, the inline description does not update unless a UI reload occurs. As you can see, I have tried putting a .NotifyChange at line 136, but it isn't doing anything. Therefore, I must be missing something, but I don't know what it is or how to address the issue. According to the Ace3 docs, .NotifyChange fires a callback, which could be what I need, but I am not sure where to handle it, or how.
Examples for Classic and/or Retail: The description, with the toggle on, assign Druids == Cenarion Circle, and Darnassus if off, or Death Knights == Knights of the Ebon Blade when on, or Orgrimmar if off. Like I said above, this does happen, but it requires a UI reload to update the text. Is it possible to do this dynamically based on the status of the toggle?
Lua Code:
---------- Core.lua ----------
function RepByZone:GetRacialRep()
local _, playerRace = UnitRace("player")
--@retail@
local H = UnitFactionGroup("player") == "Horde"
local A = UnitFactionGroup("player") == "Alliance"
--@end-retail@
local racialRepID = playerRace == "Dwarf" and 47 -- Ironforge
or playerRace == "Gnome" and 54 -- Gnomeregan
or playerRace == "Human" and 72 -- Stormwind
or playerRace == "NightElf" and 69 -- Darnassus
or playerRace == "Orc" and 76 -- Orgrimmar
or playerRace == "Tauren" and 81 -- Thunder Bluff
or playerRace == "Troll" and 530 -- Darkspear Trolls
or playerRace == "Scourge" and 68 -- Undercity
--@retail@
or playerRace == "Goblin" and 1133 -- Bilgewater Cartel
or playerRace == "Draenei" and 930 -- Exodar
or playerRace == "Worgen" and 1134 -- Gilneas
or playerRace == "BloodElf" and 911 -- Sukvermoon City
or playerRace == "Pandaren" and (A and 1353 or H and 1352 or 1216) -- Tushui Pandaren or Huojin Pandaren or Shang Xi's Academy
or playerRace == "HighmountainTauren" and 1828 -- Highmountain Tribe
or playerRace == "VoidElf" and 2170 -- Argussian Reach
or playerRace == "Mechagnome" and 2391 -- Rustbolt Resistance
or playerRace == "Vulpera" and 2158 -- Voldunai
or playerRace == "KulTiran" and 2160 -- Proudmoore Admiralty
or playerRace == "ZandalariTroll" and 2103 -- Zandalari Empire
or playerRace == "Nightborne" and 1859 -- The Nightfallen
or playerRace == "MagharOrc" and 941 -- The Mag'har
or playerRace == "DarkIronDwarf" and 59 -- Thorium Brotherhood
or playerRace == "LightforgedDraenei" and 2165 -- Army of the Light
--@end-retail@
-- classes have factions
local classRepID = nil
local _, classFileName = UnitClass("player")
if self.db.char.useClassRep then
classRepID = classFileName == "ROGUE" and 349 -- Ravenholdt
or classFileName == "DRUID" and 609 -- Cenarion Circle
--@retail@
or classFileName == "SHAMAN" and 1135 -- The Earthen Ring
or classFileName == "DEATHKNIGHT" and 1098 -- Knights of the Ebon Blade
or classFileName == "MAGE" and 1090 -- Kirin Tor
--@end-retail@
end
racialRepID = classRepID or racialRepID
local racialRepName = GetFactionInfoByID(racialRepID)
return racialRepID, racialRepName
end
----------- Options.lua -----------
function RepByZone:GetOptions()
local db = self.db.char
local racialRepID, racialRepName = self:GetRacialRep()
local options = {
name = "RepByZone",
handler = RepByZone,
type = "group",
childGroups = "tab",
args = {
enableDisable = {
order = 10,
name = ENABLE .. " " .. JUST_OR .. " " .. DISABLE,
desc = L["Toggle RepByZone on or off."],
descStyle = "inline",
type = "toggle",
width = "full",
get = function() return db.enabled end,
set = function(info, value)
db.enabled = value
if value then
self:OnEnable()
else
self:OnDisable()
end
end
},
factionStuff = {
order = 20,
name = L["Reputation Settings"],
type = "group",
args = {
watchSubZones = {
order = 10,
name = L["Watch Subzones"],
desc = L["Switch watched faction based on subzones."],
descStyle = "inline",
type = "toggle",
width = "double",
get = function() return db.watchSubZones end,
set = function(info, value)
db.watchSubZones = value
if value then
self:RegisterEvent("ZONE_CHANGED", "SwitchedSubZones")
self:RegisterEvent("ZONE_CHANGED_INDOORS", "SwitchedSubZones")
self:SwitchedSubZones()
else
self:UnregisterEvent("ZONE_CHANGED")
self:UnregisterEvent("ZONE_CHANGED_INDOORS")
end
end
},
verbose = {
order = 20,
name = L["Verbose"],
desc = L["Print to chat when you switch watched faction."],
descStyle = "inline",
type = "toggle",
width = "double",
get = function() return db.verbose end,
set = function(info, value) db.verbose = value end
},
watchOnTaxi = {
order = 30,
name = L["Switch on taxi"],
desc = L["Switch watched faction while you are on a taxi."],
descStyle = "inline",
type = "toggle",
width = "double",
get = function() return db.watchOnTaxi end,
set = function(info, value) db.watchOnTaxi = value end
},
useClassRep = {
order = 40,
name = L["Override some default racial reps with class reps."],
desc = (L["Your class reputation is %s"]):format(racialRepName),
descStyle = "inline",
type = "toggle",
width = "double",
get = function() return db.useClassRep end,
set = function(info, value)
db.useClassRep = value
racialRepID, racialRepName = self:GetRacialRep()
LibStub("AceConfigRegistry-3.0"):NotifyChange("RepByZone")
end
},
defaultRep = {
order = 100,
name = L["Default watched faction"],
desc = L["Defaults to your racial faction per character."],
type = "select",
values = function() return self:GetAllFactions() end,
get = function() return db.watchedRepID end,
set = function(info, value)
db.watchedRepID = value
db.watchedRepName = GetFactionInfoByID(value)
end
}
}
}
}
}
return options
end