diff 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
line wrap: on
line diff
--- a/ReAction.lua	Tue Nov 16 21:49:54 2010 -0800
+++ b/ReAction.lua	Thu Nov 18 12:59:00 2010 -0800
@@ -36,16 +36,30 @@
   self.db = LibStub("AceDB-3.0"):New("ReAction_DB", 
     { 
       profile = {
+        dbversion = nil,
         bars = { },
-        defaultBar = { },
+        options = { 
+          hideBlizzardBars = false,
+          hideBlizzardVehicleBar = false,
+        },
+      },
+      global = {
+        skipKeybindWarning = false,
       }
     },
     true -- use global 'Default' (locale-specific)
   )
 
+  self:UpdateDB()
+
   self.bars = { }
   self.defaultBarConfig = { }
 
+  -- It's fairly normal to use the Blizzard vehicle bar, and to have
+  -- your regular buttons in the same location. If you do this, and don't
+  -- bother to hide your buttons, they'll obscure some parts of the vehicle bar.
+  VehicleMenuBar:SetFrameLevel(VehicleMenuBar:GetFrameLevel()+3)
+
   self.callbacks = LibStub("CallbackHandler-1.0"):New(self)
   LKB.RegisterCallback(self,"LIBKEYBOUND_ENABLED")
   LKB.RegisterCallback(self,"LIBKEYBOUND_DISABLED")
@@ -143,7 +157,7 @@
     config.y          = config.y or 200
     config.x          = config.x or 0
   end
-  config = config or profile.bars[name] or tcopy(profile.defaultBar)
+  config = config or profile.bars[name] or { }
 
   profile.bars[name] = config
   local bar = self.Bar:New( name, config )  -- ReAction.Bar defined in Bar.lua
@@ -174,6 +188,8 @@
 
 function ReAction:InitializeBars()
   if not self.barsInitialized then
+    self:ManageBlizzardBars()
+
     for name, config in pairs(self.db.profile.bars) do
       if config then
         self:CreateBar(name, config)
@@ -232,6 +248,37 @@
   end
 end
 
+local blizzFrames = {
+  MainMenuBar,
+  MultiBarLeft,
+  MultiBarRight,
+  MultiBarBottomLeft,
+  MultiBarBottomRight,
+}
+
+local hideFrame = CreateFrame("Frame")
+hideFrame:Hide()
+local hiddenParents = { }
+local function ManageBlizzFrame(f, hide)
+  if hide and not hiddenParents[f] then
+    hiddenParents[f] = f:GetParent()
+    f:SetParent(hideFrame)
+  elseif not hide and hiddenParents[f] then
+    f:SetParent(hiddenParents[f])
+    hiddenParents[f] = nil
+    if f:IsShown() then 
+      f:Show() -- refresh
+    end
+  end
+end
+
+function ReAction:ManageBlizzardBars()
+  for _, f in pairs(blizzFrames) do
+    ManageBlizzFrame(f, self.db.profile.options.hideBlizzardBars)
+  end
+  ManageBlizzFrame(VehicleMenuBar, self.db.profile.options.hideBlizzardVehicleBar)
+end
+
 function ReAction:RegisterBarType( name, config, isDefaultChoice )
   self.defaultBarConfig[name] = config
   if isDefaultChoice then