Remove the unconditional Default profile fallback
DeleteProfile no longer has a UI entry point, so the hardcoded "Default" safety net it used to fall back to is no longer needed. Unassigning a deleted profile now just clears the charProfile mapping, and GetActiveProfileName/GetActiveClassSettings already fall back to (and lazily recreate) the character's own auto-created profile - the same thing that happens for a brand new character.
This commit is contained in:
+7
-21
@@ -161,24 +161,17 @@ HideCoA.ResetProfile = ResetProfile
|
|||||||
|
|
||||||
local function DeleteProfile(name)
|
local function DeleteProfile(name)
|
||||||
|
|
||||||
if name == "Default" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local wasActive = (name == GetActiveProfileName())
|
|
||||||
|
|
||||||
HideCoADB.profiles[name] = nil
|
HideCoADB.profiles[name] = nil
|
||||||
|
|
||||||
for charKey, assigned in pairs(HideCoADB.charProfile) do
|
for charKey, assigned in pairs(HideCoADB.charProfile) do
|
||||||
if assigned == name then
|
if assigned == name then
|
||||||
|
-- Unassigning falls back to the character's own auto-created
|
||||||
|
-- profile (see GetActiveProfileName/GetActiveClassSettings),
|
||||||
|
-- which gets recreated on demand if it doesn't exist.
|
||||||
HideCoADB.charProfile[charKey] = nil
|
HideCoADB.charProfile[charKey] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if wasActive then
|
|
||||||
HideCoADB.charProfile[GetCharacterKey()] = "Default"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HideCoA.DeleteProfile = DeleteProfile
|
HideCoA.DeleteProfile = DeleteProfile
|
||||||
@@ -362,18 +355,11 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Legacy pre-profile saved variables stored a single flat classSettings
|
-- Legacy pre-profile saved variables stored a single flat classSettings
|
||||||
-- table shared by every character. Fold it into "Default" so nobody's
|
-- table shared by every character. Fold it into whichever character
|
||||||
-- existing hide/show choices vanish when profiles were introduced.
|
-- happens to load next so those hide/show choices don't just vanish.
|
||||||
if HideCoADB.classSettings and not HideCoADB.profiles["Default"] then
|
local legacyFlatClassSettings = HideCoADB.classSettings
|
||||||
HideCoADB.profiles["Default"] = { classSettings = HideCoADB.classSettings }
|
|
||||||
end
|
|
||||||
|
|
||||||
HideCoADB.classSettings = nil
|
HideCoADB.classSettings = nil
|
||||||
|
|
||||||
if not HideCoADB.profiles["Default"] then
|
|
||||||
HideCoADB.profiles["Default"] = { classSettings = CreateDefaultClassSettings() }
|
|
||||||
end
|
|
||||||
|
|
||||||
local charKey = GetCharacterKey()
|
local charKey = GetCharacterKey()
|
||||||
|
|
||||||
-- The profile-name syntax used to be "realm - character"; rename any
|
-- The profile-name syntax used to be "realm - character"; rename any
|
||||||
@@ -407,7 +393,7 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not HideCoADB.profiles[charKey] then
|
if not HideCoADB.profiles[charKey] then
|
||||||
HideCoADB.profiles[charKey] = { classSettings = CreateDefaultClassSettings() }
|
HideCoADB.profiles[charKey] = { classSettings = legacyFlatClassSettings or CreateDefaultClassSettings() }
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, profile in pairs(HideCoADB.profiles) do
|
for name, profile in pairs(HideCoADB.profiles) do
|
||||||
|
|||||||
Reference in New Issue
Block a user