view modules/HideBlizzard.lua @ 179:bf64e71701e2

Remove support for hunter aspects in stance bar. Remove option to disable DK/paladin auras in stance bar. (drycoded)
author Flick <flickerstreak@gmail.com>
date Wed, 20 Oct 2010 23:40:41 +0000
parents df68b5a40490
children 55c2fc0c8d55
line wrap: on
line source
--[[
  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 addonName, addonTable = ...
local ReAction = addonTable.ReAction
local L = ReAction.L

-- 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()

  -- 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)

  ReAction:RegisterOptions(self, {
      hide = {
        name = L["Hide Blizzard Action Bars"],
        desc = L["Hide the default main bar and extra action bars"],
        type = "toggle",
        order = 10,
        width = "double",
        handler = self,
        get  = "IsHidden",
        set  = "SetHidden",
        disabled = "OptionDisabled",
      },
      hideVehicle = {
        name = L["Hide Blizzard Vehicle Bar"],
        desc = L["Hide the default vechicle action bar"],
        type = "toggle",
        order = 11,
        width = "double",
        handler = self,
        get  = "IsHidden",
        set  = "SetHidden",
        disabled = "OptionDisabled",
      },
    }, true) -- global

end

function module:OnEnable()
  self:UpdateFrames()
end

function module:OnDisable()
  self:UpdateFrames(true)
end

function module:OnProfileChanged()
  self:UpdateFrames()
end

local frames = {
  [ MainMenuBar         ] = { },
  [ MultiBarLeft        ] = { },
  [ MultiBarRight       ] = { },
  [ MultiBarBottomLeft  ] = { },
  [ MultiBarBottomRight ] = { },
  [ VehicleMenuBar      ] = { field = "hideVehicle" },
}

function module:UpdateFrames( show )
  show = show or not self.db.profile.hide
  for frame, info in pairs(frames) do
    local show = show  -- make a local copy for this frame
    if info.field then
      show = show or not self.db.profile[info.field]
    end

    if show then
      if info.parent then
        frame:SetParent(info.parent)
      end
      if frame:IsShown() then
        frame:Show() -- refresh
      end
    else
      if not info.parent then
        info.parent = frame:GetParent()
      end
      frame:SetParent(self.hiddenFrame)
    end
  end
end

function module:IsHidden(info)
  if info then
    return self.db.profile.hide and self.db.profile[info[#info]]
  else
    return self.db.profile.hide
  end
end

function module:SetHidden(info,value)
  self.db.profile[info[#info]] = value
  self:UpdateFrames()
end

function module:OptionDisabled(info)
  local disabled = InCombatLockdown()
  if not disabled and info[#info] ~= "hide" then
    disabled = not self.db.profile.hide
  end
  return disabled
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 )