diff modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua @ 25:bf997ea151ca

yet another attempt to add missing files
author Flick <flickerstreak@gmail.com>
date Fri, 07 Mar 2008 22:19:03 +0000
parents
children 21bcaf8215ff
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua	Fri Mar 07 22:19:03 2008 +0000
@@ -0,0 +1,160 @@
+--[[
+  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
+local _G = _G
+
+-- module declaration
+local moduleID = "HideBlizzard"
+local module = ReAction:NewModule( moduleID )
+
+
+-- module methods
+function module:OnInitialize()
+  self.db = ReAction:AcquireDBNamespace(moduleID)
+  ReAction:RegisterDefaults(moduleID,"profile", 
+    { 
+      hide = false
+    }
+  )
+
+  self.hiddenFrame = CreateFrame("Frame")
+  self.hiddenFrame:Hide()
+
+  -- disable the buttons to hide/show the blizzard multiaction bars
+  -- see UIOptionsFrame.lua and .xml
+  -- This is called every time the options panel is shown, after it is set up
+  local disabledOptionsButtons = {
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR1_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR2_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR3_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR4_TEXT"].index],
+    _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["ALWAYS_SHOW_MULTIBARS_TEXT"].index],
+  }
+  hooksecurefunc("UIOptionsFrame_Load",
+    function()
+      if self.db.profile.hide then
+        for _, f in pairs(disabledOptionsButtons) do
+          f.disabled = true
+          OptionsFrame_DisableCheckBox(f)
+        end
+      end
+    end
+  )
+end
+
+function module:OnEnable()
+  if self.db.profile.hide then
+    self:HideAll(true)
+  end
+end
+
+function module:OnDisable()
+  self:ShowAll(true)
+end
+
+function module:OnProfileEnable()
+  if self.db.profile.hide then
+    self:HideAll(true)
+  else
+    self:ShowAll(true)
+  end
+end
+
+
+local frames = {
+  MainMenuBar,
+  PetActionButton1,
+  PetActionButton2,
+  PetActionButton3,
+  PetActionButton4,
+  PetActionButton5,
+  PetActionButton6,
+  PetActionButton7,
+  PetActionButton8,
+  PetActionButton9,
+  PetActionButton10,
+  BonusActionBarFrame,
+  ShapeshiftBarFrame,
+  MultiBarLeft,
+  MultiBarRight,
+  MultiBarBottomLeft,
+  MultiBarBottomRight,
+  SlidingActionBarTexture0,
+  SlidingActionBarTexture1,
+}
+
+local hidden = { }
+
+function module:HideAll( force )
+  if not(self.db.profile.hide) or force then
+    self.db.profile.hide = true
+    -- the pet bar is a child of MainMenuBar, but can't be permanently hidden because it will
+    -- break automatic pet bar show/hide. Need to reparent it instead.
+    PetActionBarFrame:SetParent(UIParent)
+    -- for some odd reason PetActionBarFrame has mouse input enabled even though it has no mouse
+    -- input handlers. Because of this it can potentially trap mouse clicks from getting through
+    -- to things behind it. It's not feasible to move it, either, since UIParent_ManageFramePositions()
+    -- will move it back to its original position whenever it's called.
+    PetActionBarFrame:EnableMouse(false)
+
+    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
+end
+
+function module:ShowAll( force )
+  if self.db.profile.hide or force then
+    self.db.profile.hide = false
+
+    PetActionBarFrame:SetParent(MainMenuBar)
+    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
+
+function module:GetGlobalOptions()
+  if self.globalOptions == nil then
+    self.globalOptions = {
+      hideBlizzard = {
+        type = "toggle",
+        handler = self,
+        name = L["Hide Default Action Bars"],
+        desc = L["Hide the default main bar and extra action bars"],
+        get  = "IsHidden",
+        set  = "SetHidden",
+        disabled = function() return InCombatLockdown() end
+      }
+    }
+  end
+  return self.globalOptions
+end