comparison ReAction.lua @ 211:97949dbe987f

Demodularize HideBlizzard - added framework for updating profile database - removed unused profile.defaultBars[]
author Flick <flickerstreak@gmail.com>
date Thu, 18 Nov 2010 12:59:00 -0800
parents c24ac8ee1e45
children e275a8663a16
comparison
equal deleted inserted replaced
207:c24ac8ee1e45 211:97949dbe987f
34 ------ Handlers ------ 34 ------ Handlers ------
35 function ReAction:OnInitialize() 35 function ReAction:OnInitialize()
36 self.db = LibStub("AceDB-3.0"):New("ReAction_DB", 36 self.db = LibStub("AceDB-3.0"):New("ReAction_DB",
37 { 37 {
38 profile = { 38 profile = {
39 dbversion = nil,
39 bars = { }, 40 bars = { },
40 defaultBar = { }, 41 options = {
42 hideBlizzardBars = false,
43 hideBlizzardVehicleBar = false,
44 },
45 },
46 global = {
47 skipKeybindWarning = false,
41 } 48 }
42 }, 49 },
43 true -- use global 'Default' (locale-specific) 50 true -- use global 'Default' (locale-specific)
44 ) 51 )
45 52
53 self:UpdateDB()
54
46 self.bars = { } 55 self.bars = { }
47 self.defaultBarConfig = { } 56 self.defaultBarConfig = { }
57
58 -- It's fairly normal to use the Blizzard vehicle bar, and to have
59 -- your regular buttons in the same location. If you do this, and don't
60 -- bother to hide your buttons, they'll obscure some parts of the vehicle bar.
61 VehicleMenuBar:SetFrameLevel(VehicleMenuBar:GetFrameLevel()+3)
48 62
49 self.callbacks = LibStub("CallbackHandler-1.0"):New(self) 63 self.callbacks = LibStub("CallbackHandler-1.0"):New(self)
50 LKB.RegisterCallback(self,"LIBKEYBOUND_ENABLED") 64 LKB.RegisterCallback(self,"LIBKEYBOUND_ENABLED")
51 LKB.RegisterCallback(self,"LIBKEYBOUND_DISABLED") 65 LKB.RegisterCallback(self,"LIBKEYBOUND_DISABLED")
52 LKB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED") 66 LKB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED")
141 config.point = config.point or "BOTTOM" 155 config.point = config.point or "BOTTOM"
142 config.relpoint = config.relpoint or "BOTTOM" 156 config.relpoint = config.relpoint or "BOTTOM"
143 config.y = config.y or 200 157 config.y = config.y or 200
144 config.x = config.x or 0 158 config.x = config.x or 0
145 end 159 end
146 config = config or profile.bars[name] or tcopy(profile.defaultBar) 160 config = config or profile.bars[name] or { }
147 161
148 profile.bars[name] = config 162 profile.bars[name] = config
149 local bar = self.Bar:New( name, config ) -- ReAction.Bar defined in Bar.lua 163 local bar = self.Bar:New( name, config ) -- ReAction.Bar defined in Bar.lua
150 self.bars[name] = bar 164 self.bars[name] = bar
151 self.callbacks:Fire("OnCreateBar", bar, name) 165 self.callbacks:Fire("OnCreateBar", bar, name)
172 end 186 end
173 end 187 end
174 188
175 function ReAction:InitializeBars() 189 function ReAction:InitializeBars()
176 if not self.barsInitialized then 190 if not self.barsInitialized then
191 self:ManageBlizzardBars()
192
177 for name, config in pairs(self.db.profile.bars) do 193 for name, config in pairs(self.db.profile.bars) do
178 if config then 194 if config then
179 self:CreateBar(name, config) 195 self:CreateBar(name, config)
180 end 196 end
181 end 197 end
230 DestroyBar(bar) 246 DestroyBar(bar)
231 self.db.profile.bars[name] = nil 247 self.db.profile.bars[name] = nil
232 end 248 end
233 end 249 end
234 250
251 local blizzFrames = {
252 MainMenuBar,
253 MultiBarLeft,
254 MultiBarRight,
255 MultiBarBottomLeft,
256 MultiBarBottomRight,
257 }
258
259 local hideFrame = CreateFrame("Frame")
260 hideFrame:Hide()
261 local hiddenParents = { }
262 local function ManageBlizzFrame(f, hide)
263 if hide and not hiddenParents[f] then
264 hiddenParents[f] = f:GetParent()
265 f:SetParent(hideFrame)
266 elseif not hide and hiddenParents[f] then
267 f:SetParent(hiddenParents[f])
268 hiddenParents[f] = nil
269 if f:IsShown() then
270 f:Show() -- refresh
271 end
272 end
273 end
274
275 function ReAction:ManageBlizzardBars()
276 for _, f in pairs(blizzFrames) do
277 ManageBlizzFrame(f, self.db.profile.options.hideBlizzardBars)
278 end
279 ManageBlizzFrame(VehicleMenuBar, self.db.profile.options.hideBlizzardVehicleBar)
280 end
281
235 function ReAction:RegisterBarType( name, config, isDefaultChoice ) 282 function ReAction:RegisterBarType( name, config, isDefaultChoice )
236 self.defaultBarConfig[name] = config 283 self.defaultBarConfig[name] = config
237 if isDefaultChoice then 284 if isDefaultChoice then
238 self.defaultBarConfigChoice = name 285 self.defaultBarConfigChoice = name
239 end 286 end