view Profile.lua @ 221:bb13624de7e1

un-namespace Bag bar config
author Flick <flickerstreak@gmail.com>
date Sun, 21 Nov 2010 12:51:24 -0800
parents a4e7475633b3
children d08a74e86c96
line wrap: on
line source
local _, addonTable = ...
local ReAction = addonTable.ReAction

ReAction.PROFILEVERSION_LATEST = 1

ReAction.defaultProfile = { 
  profile = {
    dbversion = nil,
    bars = { },
    options = { 
      hideBlizzardBars = false,
      hideBlizzardVehicleBar = false,
    },
  },
  global = {
    skipKeybindWarning = false,
  }
}

function ReAction:UpgradeProfile()
  local db = self.db

  if not db.profile.dbversion then
    -- upgrade from legacy db to v1

    -- (1) remove unused defaultBars table (cleanup)
    db.profile.defaultBars = nil

    -- (2) HideBlizzard is no longer a module
    local hb = db:GetNamespace("HideBlizzard",true) or db:RegisterNamespace("HideBlizzard")
    if hb then
      db.profile.options.hideBlizzardBars = hb.profile.hide
      db.profile.options.hideBlizzardVehicleBar = hb.profile.hideVehicle
      hb:ResetProfile()
    end

    -- (3) LBF is no longer a module
    local bf = db:GetNamespace("ButtonFacade",true) or db:RegisterNamespace("ButtonFacade")
    if bf then
      for name, bar in pairs(db.profile.bars) do
        bar.ButtonFacade = bf.profile[name] or bar.ButtonFacade
      end
      bf:ResetProfile()
    end

    -- (4) Action module uses the bar config directly
    local action = db:GetNamespace("Action",true) or db:RegisterNamespace("Action")
    if action then
      for name, ac in pairs(action.profile.bars) do
        local c = db.profile.bars[name]
        if c then
          for key, value in pairs(ac) do
            c[key] = value
          end
        end
      end
      action:ResetProfile()
    end

    -- (5) Bags module uses the bar config directly
    local bag = db:GetNamespace("Bag",true) or db:RegisterNamespace("Bag")
    if bag then
      for name, bc in pairs(bag.profile.buttons) do
        local c = db.profile.bars[name]
        c.buttons = bc
      end
      bag:ResetProfile()
    end

    db.profile.dbversion = 1
  end

  db.profile.dbversion = self.PROFILEVERSION_LATEST
end