Flick@276: local _, ns = ... Flick@276: local ReAction = ns.ReAction flickerstreak@211: Flick@295: ReAction.PROFILEVERSION_LATEST = 3 flickerstreak@211: flickerstreak@213: ReAction.defaultProfile = { flickerstreak@213: profile = { flickerstreak@213: dbversion = nil, flickerstreak@213: bars = { }, flickerstreak@213: options = { flickerstreak@213: hideBlizzardBars = false, flickerstreak@213: hideBlizzardVehicleBar = false, flickerstreak@213: }, flickerstreak@213: }, flickerstreak@213: global = { flickerstreak@213: skipKeybindWarning = false, flickerstreak@213: } flickerstreak@213: } flickerstreak@213: flickerstreak@213: function ReAction:UpgradeProfile() flickerstreak@211: local db = self.db flickerstreak@211: flickerstreak@211: if not db.profile.dbversion then flickerstreak@211: -- upgrade from legacy db to v1 flickerstreak@211: flickerstreak@213: -- (1) remove unused defaultBars table (cleanup) flickerstreak@211: db.profile.defaultBars = nil flickerstreak@211: flickerstreak@211: -- (2) HideBlizzard is no longer a module flickerstreak@215: local hb = db:GetNamespace("HideBlizzard",true) or db:RegisterNamespace("HideBlizzard") flickerstreak@213: if hb then flickerstreak@213: db.profile.options.hideBlizzardBars = hb.profile.hide flickerstreak@213: db.profile.options.hideBlizzardVehicleBar = hb.profile.hideVehicle flickerstreak@213: hb:ResetProfile() flickerstreak@213: end flickerstreak@213: flickerstreak@213: -- (3) LBF is no longer a module flickerstreak@215: local bf = db:GetNamespace("ButtonFacade",true) or db:RegisterNamespace("ButtonFacade") flickerstreak@213: if bf then flickerstreak@213: for name, bar in pairs(db.profile.bars) do flickerstreak@213: bar.ButtonFacade = bf.profile[name] or bar.ButtonFacade flickerstreak@213: end flickerstreak@213: bf:ResetProfile() flickerstreak@211: end flickerstreak@211: flickerstreak@221: -- (4) Action module uses the bar config directly flickerstreak@220: local action = db:GetNamespace("Action",true) or db:RegisterNamespace("Action") flickerstreak@220: if action then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local ac = action.profile.bars and action.profile.bars[name] flickerstreak@222: if ac then flickerstreak@220: for key, value in pairs(ac) do flickerstreak@222: bar[key] = value flickerstreak@220: end flickerstreak@220: end flickerstreak@220: end flickerstreak@220: action:ResetProfile() flickerstreak@220: end flickerstreak@220: flickerstreak@221: -- (5) Bags module uses the bar config directly flickerstreak@221: local bag = db:GetNamespace("Bag",true) or db:RegisterNamespace("Bag") flickerstreak@221: if bag then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local bc = bag.profile.buttons and bag.profile.buttons[name] flickerstreak@222: if bc then flickerstreak@222: bar.buttons = bc flickerstreak@222: end flickerstreak@221: end flickerstreak@221: bag:ResetProfile() flickerstreak@221: end flickerstreak@221: flickerstreak@222: -- (6) Pet module uses the bar config directly flickerstreak@222: local pet = db:GetNamespace("PetAction",true) or db:RegisterNamespace("PetAction") flickerstreak@222: if pet then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local pc = pet.profile.buttons and pet.profile.buttons[name] flickerstreak@222: if pc then flickerstreak@222: bar.buttons = pc flickerstreak@222: end flickerstreak@222: end flickerstreak@222: pet:ResetProfile() flickerstreak@222: end flickerstreak@222: flickerstreak@222: -- (7) Stance module uses the bar config directly flickerstreak@222: local stance = db:GetNamespace("Stance",true) or db:RegisterNamespace("Stance") flickerstreak@222: if stance then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local sc = stance.profile.buttons and stance.profile.buttons[name] flickerstreak@222: if sc then flickerstreak@222: bar.buttons = sc flickerstreak@222: end flickerstreak@222: end flickerstreak@222: stance:ResetProfile() flickerstreak@222: end flickerstreak@222: flickerstreak@222: -- (8) Totem module uses the bar config directly flickerstreak@222: local totem = db:GetNamespace("Totem",true) or db:RegisterNamespace("Totem") flickerstreak@222: if totem then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local tc = totem.profile.buttons and totem.profile.buttons[name] flickerstreak@222: if tc then flickerstreak@222: bar.buttons = tc flickerstreak@222: end flickerstreak@222: end flickerstreak@222: totem:ResetProfile() flickerstreak@222: end flickerstreak@222: flickerstreak@222: -- (9) Vehicle exit button uses the bar config directly flickerstreak@222: local vehicle = db:GetNamespace("VehicleExit",true) or db:RegisterNamespace("VehicleExit") flickerstreak@222: if vehicle then flickerstreak@222: for name, bar in pairs(db.profile.bars) do flickerstreak@222: local vc = vehicle.profile.buttons and vehicle.profile.buttons[name] flickerstreak@222: if vc then flickerstreak@222: bar.buttons = vc flickerstreak@222: end flickerstreak@222: end flickerstreak@222: vehicle:ResetProfile() flickerstreak@222: end flickerstreak@222: Flick@232: db.profile.dbversion = 1 Flick@232: end Flick@232: Flick@232: Flick@232: if db.profile.dbversion < 2 then Flick@232: -- upgrade from v1 to v2 Flick@232: Flick@228: -- (10) State module uses the bar config directly Flick@228: local state = db:GetNamespace("State",true) or db:RegisterNamespace("State") Flick@228: if state then Flick@228: for name, bar in pairs(db.profile.bars) do Flick@228: local sc = state.profile.bars and state.profile.bars[name] and state.profile.bars[name].states Flick@228: if sc then Flick@228: bar.states = sc Flick@228: end Flick@228: end Flick@232: state:ResetProfile() Flick@228: end Flick@228: Flick@232: db.profile.dbversion = 2 flickerstreak@211: end flickerstreak@211: Flick@295: Flick@295: if db.profile.dbversion < 3 then Flick@295: -- upgrade to v3 Flick@295: Flick@295: -- totem multicast bar no longer part of wow Flick@295: local totem = db:GetNamespace("Totem",true) Flick@295: if totem then Flick@295: wipe(totem) Flick@295: end Flick@295: Flick@295: -- remove any bars set as totem bars Flick@295: for name, bar in pairs(db.profile.bars) do Flick@295: if bar.type == "Totem" then Flick@295: db.profile.bars[name] = nil Flick@295: end Flick@295: end Flick@295: Flick@295: end Flick@295: flickerstreak@211: db.profile.dbversion = self.PROFILEVERSION_LATEST flickerstreak@211: end Flick@227: Flick@227: function ReAction:OnProfileChanged() Flick@227: self:UpgradeProfile() Flick@227: self:RebuildAll() Flick@227: if not self.db.global.skipKeybindWarning then Flick@227: StaticPopup_Show("REACTION_KB_WARN") -- see Options.lua Flick@227: end Flick@227: end Flick@227: Flick@227: function ReAction:OnNewProfile() Flick@227: self.db.profile.dbversion = ReAction.PROFILEVERSION_LATEST Flick@227: self:OnProfileChanged() Flick@227: end Flick@227: