comparison Profile.lua @ 257:920d17851a93 stable

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