Add override notice on Classes tab, include class in profile names

- Show "These settings are currently overridden" and grey out the
  frame checkboxes on the Classes tab, but only while viewing the
  logged-in character's own class and its active profile has the
  override enabled - other classes stay fully editable.
- GetCharacterKey() now embeds the class token ("Name - Class -
  Realm"), so auto-created per-character profiles carry it too.
  Migrate existing "Name - Realm" profiles/assignments/overrides to
  the new key on the affected character's next login.
This commit is contained in:
2026-07-08 00:26:58 +02:00
parent 83a1cda15c
commit 79f45e5c41
2 changed files with 53 additions and 6 deletions
+27 -5
View File
@@ -66,7 +66,9 @@ local function EnsureClassSettingsComplete(classSettings)
end
local function GetCharacterKey()
return UnitName("player") .. " - " .. GetRealmName()
local _, classToken = UnitClass("player")
local className = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[classToken]) or classToken
return UnitName("player") .. " - " .. className .. " - " .. GetRealmName()
end
HideCoA.GetCharacterKey = GetCharacterKey
@@ -377,11 +379,31 @@ f:SetScript("OnEvent", function(self, event, arg1)
-- The profile-name syntax used to be "realm - character"; rename any
-- existing profile created under that scheme to the new ordering
-- instead of leaving it orphaned in the list.
local oldCharKey = GetRealmName() .. " - " .. UnitName("player")
local ancientCharKey = GetRealmName() .. " - " .. UnitName("player")
if HideCoADB.profiles[oldCharKey] and not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = HideCoADB.profiles[oldCharKey]
HideCoADB.profiles[oldCharKey] = nil
if HideCoADB.profiles[ancientCharKey] and not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = HideCoADB.profiles[ancientCharKey]
HideCoADB.profiles[ancientCharKey] = nil
end
-- The syntax was later "character - realm", without the class; rename
-- any existing profile/assignment created under that scheme too.
local legacyCharKey = UnitName("player") .. " - " .. GetRealmName()
if HideCoADB.profiles[legacyCharKey] and not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = HideCoADB.profiles[legacyCharKey]
HideCoADB.profiles[legacyCharKey] = nil
end
if HideCoADB.charProfile[legacyCharKey] then
local assigned = HideCoADB.charProfile[legacyCharKey]
HideCoADB.charProfile[charKey] = (assigned == legacyCharKey) and charKey or assigned
HideCoADB.charProfile[legacyCharKey] = nil
end
if HideCoADB.characterOverrides and HideCoADB.characterOverrides[legacyCharKey] and not HideCoADB.characterOverrides[charKey] then
HideCoADB.characterOverrides[charKey] = HideCoADB.characterOverrides[legacyCharKey]
HideCoADB.characterOverrides[legacyCharKey] = nil
end
if not HideCoADB.profiles[charKey] then
+26 -1
View File
@@ -104,11 +104,17 @@ classContent:SetPoint("BOTTOMRIGHT", contentBox, "BOTTOMRIGHT", -12, 4)
local classLabel = classContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
classLabel:SetPoint("TOPLEFT", classContent, "TOPLEFT", 16, -12)
local overrideNoticeText = classContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
overrideNoticeText:SetPoint("TOPLEFT", classLabel, "BOTTOMLEFT", 0, -8)
overrideNoticeText:SetTextColor(1, 0.35, 0.35)
overrideNoticeText:SetText("These settings are currently overridden")
overrideNoticeText:Hide()
local checks = {}
local selectedClass = nil
local previousAnchor = classLabel
local previousSpacing = -20
local previousSpacing = -34
for _, frameName in ipairs(HideCoA.FRAMES) do
@@ -159,8 +165,27 @@ local function SelectClass(class)
classLabel:SetTextColor(1, 1, 1)
end
local _, ownClass = UnitClass("player")
local overridden = (class == ownClass) and HideCoA.GetProfileOverride(HideCoA.GetActiveProfileName()).enabled
if overridden then
overrideNoticeText:Show()
else
overrideNoticeText:Hide()
end
for _, frameName in ipairs(HideCoA.FRAMES) do
checks[frameName]:SetChecked(HideCoA.GetActiveClassSettings()[class][frameName])
if overridden then
checks[frameName]:Disable()
_G[checks[frameName]:GetName() .. "Text"]:SetTextColor(0.5, 0.5, 0.5)
else
checks[frameName]:Enable()
_G[checks[frameName]:GetName() .. "Text"]:SetTextColor(1, 1, 1)
end
end
for tabClass, button in pairs(tabButtons) do