45 lines
1.9 KiB
Lua
45 lines
1.9 KiB
Lua
|
|
local _, P = ...
|
||
|
|
|
||
|
|
-- Compatibility with layouts and narration profiles from older releases.
|
||
|
|
-- Addon IDs, saved variables and binding names are migrated by the installer.
|
||
|
|
P.legacyLayoutName = "Brad - Clear ESDF"
|
||
|
|
local function renameNarration(saved, database)
|
||
|
|
if not saved then return end
|
||
|
|
local old, new = "Brad Narration", "Ruen Narration"
|
||
|
|
local profiles = saved.profiles
|
||
|
|
if not profiles or not profiles[old] then return end
|
||
|
|
-- Never replace an independently created destination profile.
|
||
|
|
if profiles[new] and profiles[new] ~= profiles[old] then return end
|
||
|
|
profiles[new] = profiles[old]
|
||
|
|
if database and database.GetCurrentProfile and database:GetCurrentProfile() == old then
|
||
|
|
-- Use AceDB's own callbacks to refresh active references.
|
||
|
|
database:SetProfile(new)
|
||
|
|
end
|
||
|
|
for character, name in pairs(saved.profileKeys or {}) do
|
||
|
|
if name == old then saved.profileKeys[character] = new end
|
||
|
|
end
|
||
|
|
if saved.global and saved.global.NewCharacterProfile == old then
|
||
|
|
saved.global.NewCharacterProfile = new
|
||
|
|
end
|
||
|
|
profiles[old] = nil
|
||
|
|
end
|
||
|
|
|
||
|
|
function P.MigrateBrand()
|
||
|
|
if InCombatLockdown() then return end
|
||
|
|
local manager = EditModeManagerFrame
|
||
|
|
if manager and not manager:IsShown() and not manager.overrideLayoutInfo then
|
||
|
|
local info = CopyTable(C_EditMode.GetLayouts())
|
||
|
|
local old, collision
|
||
|
|
for _, layout in ipairs(info.layouts or {}) do
|
||
|
|
if layout.layoutName == P.legacyLayoutName then old = layout end
|
||
|
|
if layout.layoutName == P.layoutName then collision = true end
|
||
|
|
end
|
||
|
|
if old and not collision then
|
||
|
|
old.layoutName = P.layoutName
|
||
|
|
C_EditMode.SaveLayouts(info)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
renameNarration(SpokenSettings, SpokenEnv and SpokenEnv.Addon and SpokenEnv.Addon.db)
|
||
|
|
renameNarration(SpokenQuestsSettings, VoiceOver and VoiceOver.Addon and VoiceOver.Addon.db)
|
||
|
|
end
|