diff modules/HideBlizzard.lua @ 109:410d036c43b2

- reorganize modularity file structure (part 1)
author Flick <flickerstreak@gmail.com>
date Thu, 08 Jan 2009 00:57:27 +0000
parents
children 320a93c5f72c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/HideBlizzard.lua	Thu Jan 08 00:57:27 2009 +0000
@@ -0,0 +1,133 @@
+--[[
+  ReAction 'Hide Blizzard' module
+
+  Hides Blizzard action bars. This hides the extra action bars, stance bar, pet bar, and 
+  main menu bar, which in turn hides the experience bar, bag bar, micro menu bar, and lag meter.
+
+--]]
+
+-- local imports
+local ReAction = ReAction
+local L = ReAction.L
+
+ReAction:UpdateRevision("$Revision$")
+
+-- module declaration
+local moduleID = "HideBlizzard"
+local module = ReAction:NewModule( moduleID )
+
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction.db:RegisterNamespace( moduleID,
+    { 
+      profile = {
+        hide = false
+      }
+    }
+  )
+  self.db.RegisterCallback(self,"OnProfileChanged")
+  self.db.RegisterCallback(self,"OnProfileCopied", "OnProfileChanged")
+  self.db.RegisterCallback(self,"OnProfileReset",  "OnProfileChanged")
+
+  self.hiddenFrame = CreateFrame("Frame")
+  self.hiddenFrame:Hide()
+
+  ReAction:RegisterOptions(self, {
+      hideBlizzard = {
+        type = "toggle",
+        handler = self,
+        name = L["Hide Blizzard Action Bars"],
+        desc = L["Hide the default main bar and extra action bars"],
+        get  = "IsHidden",
+        set  = function(info,value) self:SetHidden(value) end,
+        disabled = InCombatLockdown
+      },
+    }, true) -- global
+
+end
+
+function module:OnEnable()
+  if self.db.profile.hide then
+    self:HideAll(true)
+  end
+
+  -- reroute blizzard action bar config to ReAction config window
+  InterfaceOptionsActionBarsPanel:HookScript("OnShow", 
+    function() 
+      if module:IsEnabled() and module:IsHidden() then
+        ReAction:ShowConfig()
+      end
+    end )
+end
+
+function module:OnDisable()
+  self:ShowAll(true)
+end
+
+function module:OnProfileChanged()
+  if self.db.profile.hide then
+    module:HideAll(true)
+  else
+    module:ShowAll(true)
+  end
+end
+
+local frames = {
+  MainMenuBar,
+  MultiBarLeft,
+  MultiBarRight,
+  MultiBarBottomLeft,
+  MultiBarBottomRight,
+  -- possess bar frame needs to be pulled out separately: stash its children away
+  PossessBarLeft,
+  PossessBarRight,
+  PossessButton1,
+  PossessButton2
+}
+
+local hidden = { }
+
+function module:HideAll( force )
+  if not(self.db.profile.hide) or force then
+    self.db.profile.hide = true
+    for _, f in pairs(frames) do
+      hidden[f] = hidden[f] or { parent = f:GetParent(), wasShown = f:IsShown() }
+      f:SetParent(self.hiddenFrame)
+      f:Hide()
+    end
+  end
+  PossessBarFrame:SetParent(UIParent)
+  PossessBarFrame:EnableMouse(false)
+end
+
+function module:ShowAll( force )
+  PossessBarFrame:EnableMouse(true)
+  PossessBarFrame:SetParent(MainMenuBar)
+  if self.db.profile.hide or force then
+    self.db.profile.hide = false
+
+    for _, f in pairs(frames) do
+      local h = hidden[f]
+      if h then
+        f:SetParent(h.parent)
+        if h.wasShown then
+          f:Show()
+        end
+      end
+    end
+  end
+end
+
+function module:IsHidden()
+  return self.db.profile.hide
+end
+
+function module:SetHidden(h)
+  if h then
+    self:HideAll()
+  else
+    self:ShowAll()
+  end
+end
+