annotate Profile.lua @ 281:2098dba4baf5

Merge
author Flick
date Wed, 11 May 2011 16:20:48 -0700
parents 36a29870bf34
children 0cb6a9944497
rev   line source
Flick@276 1 local _, ns = ...
Flick@276 2 local ReAction = ns.ReAction
flickerstreak@211 3
Flick@232 4 ReAction.PROFILEVERSION_LATEST = 2
flickerstreak@211 5
flickerstreak@213 6 ReAction.defaultProfile = {
flickerstreak@213 7 profile = {
flickerstreak@213 8 dbversion = nil,
flickerstreak@213 9 bars = { },
flickerstreak@213 10 options = {
flickerstreak@213 11 hideBlizzardBars = false,
flickerstreak@213 12 hideBlizzardVehicleBar = false,
flickerstreak@213 13 },
flickerstreak@213 14 },
flickerstreak@213 15 global = {
flickerstreak@213 16 skipKeybindWarning = false,
flickerstreak@213 17 }
flickerstreak@213 18 }
flickerstreak@213 19
flickerstreak@213 20 function ReAction:UpgradeProfile()
flickerstreak@211 21 local db = self.db
flickerstreak@211 22
flickerstreak@211 23 if not db.profile.dbversion then
flickerstreak@211 24 -- upgrade from legacy db to v1
flickerstreak@211 25
flickerstreak@213 26 -- (1) remove unused defaultBars table (cleanup)
flickerstreak@211 27 db.profile.defaultBars = nil
flickerstreak@211 28
flickerstreak@211 29 -- (2) HideBlizzard is no longer a module
flickerstreak@215 30 local hb = db:GetNamespace("HideBlizzard",true) or db:RegisterNamespace("HideBlizzard")
flickerstreak@213 31 if hb then
flickerstreak@213 32 db.profile.options.hideBlizzardBars = hb.profile.hide
flickerstreak@213 33 db.profile.options.hideBlizzardVehicleBar = hb.profile.hideVehicle
flickerstreak@213 34 hb:ResetProfile()
flickerstreak@213 35 end
flickerstreak@213 36
flickerstreak@213 37 -- (3) LBF is no longer a module
flickerstreak@215 38 local bf = db:GetNamespace("ButtonFacade",true) or db:RegisterNamespace("ButtonFacade")
flickerstreak@213 39 if bf then
flickerstreak@213 40 for name, bar in pairs(db.profile.bars) do
flickerstreak@213 41 bar.ButtonFacade = bf.profile[name] or bar.ButtonFacade
flickerstreak@213 42 end
flickerstreak@213 43 bf:ResetProfile()
flickerstreak@211 44 end
flickerstreak@211 45
flickerstreak@221 46 -- (4) Action module uses the bar config directly
flickerstreak@220 47 local action = db:GetNamespace("Action",true) or db:RegisterNamespace("Action")
flickerstreak@220 48 if action then
flickerstreak@222 49 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 50 local ac = action.profile.bars and action.profile.bars[name]
flickerstreak@222 51 if ac then
flickerstreak@220 52 for key, value in pairs(ac) do
flickerstreak@222 53 bar[key] = value
flickerstreak@220 54 end
flickerstreak@220 55 end
flickerstreak@220 56 end
flickerstreak@220 57 action:ResetProfile()
flickerstreak@220 58 end
flickerstreak@220 59
flickerstreak@221 60 -- (5) Bags module uses the bar config directly
flickerstreak@221 61 local bag = db:GetNamespace("Bag",true) or db:RegisterNamespace("Bag")
flickerstreak@221 62 if bag then
flickerstreak@222 63 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 64 local bc = bag.profile.buttons and bag.profile.buttons[name]
flickerstreak@222 65 if bc then
flickerstreak@222 66 bar.buttons = bc
flickerstreak@222 67 end
flickerstreak@221 68 end
flickerstreak@221 69 bag:ResetProfile()
flickerstreak@221 70 end
flickerstreak@221 71
flickerstreak@222 72 -- (6) Pet module uses the bar config directly
flickerstreak@222 73 local pet = db:GetNamespace("PetAction",true) or db:RegisterNamespace("PetAction")
flickerstreak@222 74 if pet then
flickerstreak@222 75 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 76 local pc = pet.profile.buttons and pet.profile.buttons[name]
flickerstreak@222 77 if pc then
flickerstreak@222 78 bar.buttons = pc
flickerstreak@222 79 end
flickerstreak@222 80 end
flickerstreak@222 81 pet:ResetProfile()
flickerstreak@222 82 end
flickerstreak@222 83
flickerstreak@222 84 -- (7) Stance module uses the bar config directly
flickerstreak@222 85 local stance = db:GetNamespace("Stance",true) or db:RegisterNamespace("Stance")
flickerstreak@222 86 if stance then
flickerstreak@222 87 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 88 local sc = stance.profile.buttons and stance.profile.buttons[name]
flickerstreak@222 89 if sc then
flickerstreak@222 90 bar.buttons = sc
flickerstreak@222 91 end
flickerstreak@222 92 end
flickerstreak@222 93 stance:ResetProfile()
flickerstreak@222 94 end
flickerstreak@222 95
flickerstreak@222 96 -- (8) Totem module uses the bar config directly
flickerstreak@222 97 local totem = db:GetNamespace("Totem",true) or db:RegisterNamespace("Totem")
flickerstreak@222 98 if totem then
flickerstreak@222 99 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 100 local tc = totem.profile.buttons and totem.profile.buttons[name]
flickerstreak@222 101 if tc then
flickerstreak@222 102 bar.buttons = tc
flickerstreak@222 103 end
flickerstreak@222 104 end
flickerstreak@222 105 totem:ResetProfile()
flickerstreak@222 106 end
flickerstreak@222 107
flickerstreak@222 108 -- (9) Vehicle exit button uses the bar config directly
flickerstreak@222 109 local vehicle = db:GetNamespace("VehicleExit",true) or db:RegisterNamespace("VehicleExit")
flickerstreak@222 110 if vehicle then
flickerstreak@222 111 for name, bar in pairs(db.profile.bars) do
flickerstreak@222 112 local vc = vehicle.profile.buttons and vehicle.profile.buttons[name]
flickerstreak@222 113 if vc then
flickerstreak@222 114 bar.buttons = vc
flickerstreak@222 115 end
flickerstreak@222 116 end
flickerstreak@222 117 vehicle:ResetProfile()
flickerstreak@222 118 end
flickerstreak@222 119
Flick@232 120 db.profile.dbversion = 1
Flick@232 121 end
Flick@232 122
Flick@232 123
Flick@232 124 if db.profile.dbversion < 2 then
Flick@232 125 -- upgrade from v1 to v2
Flick@232 126
Flick@228 127 -- (10) State module uses the bar config directly
Flick@228 128 local state = db:GetNamespace("State",true) or db:RegisterNamespace("State")
Flick@228 129 if state then
Flick@228 130 for name, bar in pairs(db.profile.bars) do
Flick@228 131 local sc = state.profile.bars and state.profile.bars[name] and state.profile.bars[name].states
Flick@228 132 if sc then
Flick@228 133 bar.states = sc
Flick@228 134 end
Flick@228 135 end
Flick@232 136 state:ResetProfile()
Flick@228 137 end
Flick@228 138
Flick@232 139 db.profile.dbversion = 2
flickerstreak@211 140 end
flickerstreak@211 141
flickerstreak@211 142 db.profile.dbversion = self.PROFILEVERSION_LATEST
flickerstreak@211 143 end
Flick@227 144
Flick@227 145 function ReAction:OnProfileChanged()
Flick@227 146 self:UpgradeProfile()
Flick@227 147 self:RebuildAll()
Flick@227 148 if not self.db.global.skipKeybindWarning then
Flick@227 149 StaticPopup_Show("REACTION_KB_WARN") -- see Options.lua
Flick@227 150 end
Flick@227 151 end
Flick@227 152
Flick@227 153 function ReAction:OnNewProfile()
Flick@227 154 self.db.profile.dbversion = ReAction.PROFILEVERSION_LATEST
Flick@227 155 self:OnProfileChanged()
Flick@227 156 end
Flick@227 157