| 
flickerstreak@25
 | 
     1 --[[
 | 
| 
flickerstreak@25
 | 
     2   ReAction 'Hide Blizzard' module
 | 
| 
flickerstreak@25
 | 
     3 
 | 
| 
flickerstreak@25
 | 
     4   Hides Blizzard action bars. This hides the extra action bars, stance bar, pet bar, and 
 | 
| 
flickerstreak@25
 | 
     5   main menu bar, which in turn hides the experience bar, bag bar, micro menu bar, and lag meter.
 | 
| 
flickerstreak@25
 | 
     6 
 | 
| 
flickerstreak@25
 | 
     7 --]]
 | 
| 
flickerstreak@25
 | 
     8 
 | 
| 
flickerstreak@25
 | 
     9 -- local imports
 | 
| 
flickerstreak@25
 | 
    10 local ReAction = ReAction
 | 
| 
flickerstreak@25
 | 
    11 local L = ReAction.L
 | 
| 
flickerstreak@25
 | 
    12 
 | 
| 
flickerstreak@80
 | 
    13 ReAction:UpdateRevision("$Revision$")
 | 
| 
flickerstreak@77
 | 
    14 
 | 
| 
flickerstreak@25
 | 
    15 -- module declaration
 | 
| 
flickerstreak@25
 | 
    16 local moduleID = "HideBlizzard"
 | 
| 
flickerstreak@25
 | 
    17 local module = ReAction:NewModule( moduleID )
 | 
| 
flickerstreak@25
 | 
    18 
 | 
| 
flickerstreak@25
 | 
    19 
 | 
| 
flickerstreak@25
 | 
    20 -- module methods
 | 
| 
flickerstreak@25
 | 
    21 function module:OnInitialize()
 | 
| 
flickerstreak@28
 | 
    22   self.db = ReAction.db:RegisterNamespace( moduleID,
 | 
| 
flickerstreak@25
 | 
    23     { 
 | 
| 
flickerstreak@28
 | 
    24       profile = {
 | 
| 
flickerstreak@28
 | 
    25         hide = false
 | 
| 
flickerstreak@28
 | 
    26       }
 | 
| 
flickerstreak@25
 | 
    27     }
 | 
| 
flickerstreak@25
 | 
    28   )
 | 
| 
flickerstreak@28
 | 
    29   self.db.RegisterCallback(self,"OnProfileChanged")
 | 
| 
flickerstreak@95
 | 
    30   self.db.RegisterCallback(self,"OnProfileCopied", "OnProfileChanged")
 | 
| 
flickerstreak@95
 | 
    31   self.db.RegisterCallback(self,"OnProfileReset",  "OnProfileChanged")
 | 
| 
flickerstreak@25
 | 
    32 
 | 
| 
flickerstreak@25
 | 
    33   self.hiddenFrame = CreateFrame("Frame")
 | 
| 
flickerstreak@25
 | 
    34   self.hiddenFrame:Hide()
 | 
| 
flickerstreak@60
 | 
    35 
 | 
| 
flickerstreak@60
 | 
    36   ReAction:RegisterOptions(self, {
 | 
| 
flickerstreak@60
 | 
    37       hideBlizzard = {
 | 
| 
flickerstreak@60
 | 
    38         type = "toggle",
 | 
| 
flickerstreak@60
 | 
    39         handler = self,
 | 
| 
flickerstreak@60
 | 
    40         name = L["Hide Blizzard Action Bars"],
 | 
| 
flickerstreak@60
 | 
    41         desc = L["Hide the default main bar and extra action bars"],
 | 
| 
flickerstreak@60
 | 
    42         get  = "IsHidden",
 | 
| 
flickerstreak@60
 | 
    43         set  = function(info,value) self:SetHidden(value) end,
 | 
| 
flickerstreak@60
 | 
    44         disabled = InCombatLockdown
 | 
| 
flickerstreak@60
 | 
    45       },
 | 
| 
flickerstreak@60
 | 
    46     }, true) -- global
 | 
| 
flickerstreak@60
 | 
    47 
 | 
| 
flickerstreak@25
 | 
    48 end
 | 
| 
flickerstreak@25
 | 
    49 
 | 
| 
flickerstreak@25
 | 
    50 function module:OnEnable()
 | 
| 
flickerstreak@25
 | 
    51   if self.db.profile.hide then
 | 
| 
flickerstreak@25
 | 
    52     self:HideAll(true)
 | 
| 
flickerstreak@25
 | 
    53   end
 | 
| 
flickerstreak@38
 | 
    54 
 | 
| 
flickerstreak@38
 | 
    55   -- reroute blizzard action bar config to ReAction config window
 | 
| 
flickerstreak@38
 | 
    56   InterfaceOptionsActionBarsPanel:HookScript("OnShow", 
 | 
| 
flickerstreak@38
 | 
    57     function() 
 | 
| 
flickerstreak@41
 | 
    58       if module:IsEnabled() and module:IsHidden() then
 | 
| 
flickerstreak@38
 | 
    59         ReAction:ShowConfig()
 | 
| 
flickerstreak@38
 | 
    60       end
 | 
| 
flickerstreak@38
 | 
    61     end )
 | 
| 
flickerstreak@25
 | 
    62 end
 | 
| 
flickerstreak@25
 | 
    63 
 | 
| 
flickerstreak@25
 | 
    64 function module:OnDisable()
 | 
| 
flickerstreak@25
 | 
    65   self:ShowAll(true)
 | 
| 
flickerstreak@25
 | 
    66 end
 | 
| 
flickerstreak@25
 | 
    67 
 | 
| 
flickerstreak@28
 | 
    68 function module:OnProfileChanged()
 | 
| 
flickerstreak@25
 | 
    69   if self.db.profile.hide then
 | 
| 
flickerstreak@28
 | 
    70     module:HideAll(true)
 | 
| 
flickerstreak@25
 | 
    71   else
 | 
| 
flickerstreak@28
 | 
    72     module:ShowAll(true)
 | 
| 
flickerstreak@25
 | 
    73   end
 | 
| 
flickerstreak@25
 | 
    74 end
 | 
| 
flickerstreak@25
 | 
    75 
 | 
| 
flickerstreak@25
 | 
    76 local frames = {
 | 
| 
flickerstreak@25
 | 
    77   MainMenuBar,
 | 
| 
flickerstreak@25
 | 
    78   MultiBarLeft,
 | 
| 
flickerstreak@25
 | 
    79   MultiBarRight,
 | 
| 
flickerstreak@25
 | 
    80   MultiBarBottomLeft,
 | 
| 
flickerstreak@25
 | 
    81   MultiBarBottomRight,
 | 
| 
flickerstreak@54
 | 
    82   -- possess bar frame needs to be pulled out separately: stash its children away
 | 
| 
flickerstreak@54
 | 
    83   PossessBarLeft,
 | 
| 
flickerstreak@54
 | 
    84   PossessBarRight,
 | 
| 
flickerstreak@54
 | 
    85   PossessButton1,
 | 
| 
flickerstreak@54
 | 
    86   PossessButton2
 | 
| 
flickerstreak@25
 | 
    87 }
 | 
| 
flickerstreak@25
 | 
    88 
 | 
| 
flickerstreak@25
 | 
    89 local hidden = { }
 | 
| 
flickerstreak@25
 | 
    90 
 | 
| 
flickerstreak@25
 | 
    91 function module:HideAll( force )
 | 
| 
flickerstreak@25
 | 
    92   if not(self.db.profile.hide) or force then
 | 
| 
flickerstreak@25
 | 
    93     self.db.profile.hide = true
 | 
| 
flickerstreak@25
 | 
    94     for _, f in pairs(frames) do
 | 
| 
flickerstreak@25
 | 
    95       hidden[f] = hidden[f] or { parent = f:GetParent(), wasShown = f:IsShown() }
 | 
| 
flickerstreak@25
 | 
    96       f:SetParent(self.hiddenFrame)
 | 
| 
flickerstreak@25
 | 
    97       f:Hide()
 | 
| 
flickerstreak@25
 | 
    98     end
 | 
| 
flickerstreak@25
 | 
    99   end
 | 
| 
flickerstreak@54
 | 
   100   PossessBarFrame:SetParent(UIParent)
 | 
| 
flickerstreak@54
 | 
   101   PossessBarFrame:EnableMouse(false)
 | 
| 
flickerstreak@25
 | 
   102 end
 | 
| 
flickerstreak@25
 | 
   103 
 | 
| 
flickerstreak@25
 | 
   104 function module:ShowAll( force )
 | 
| 
flickerstreak@54
 | 
   105   PossessBarFrame:EnableMouse(true)
 | 
| 
flickerstreak@54
 | 
   106   PossessBarFrame:SetParent(MainMenuBar)
 | 
| 
flickerstreak@25
 | 
   107   if self.db.profile.hide or force then
 | 
| 
flickerstreak@25
 | 
   108     self.db.profile.hide = false
 | 
| 
flickerstreak@25
 | 
   109 
 | 
| 
flickerstreak@25
 | 
   110     for _, f in pairs(frames) do
 | 
| 
flickerstreak@25
 | 
   111       local h = hidden[f]
 | 
| 
flickerstreak@25
 | 
   112       if h then
 | 
| 
flickerstreak@25
 | 
   113         f:SetParent(h.parent)
 | 
| 
flickerstreak@25
 | 
   114         if h.wasShown then
 | 
| 
flickerstreak@25
 | 
   115           f:Show()
 | 
| 
flickerstreak@25
 | 
   116         end
 | 
| 
flickerstreak@25
 | 
   117       end
 | 
| 
flickerstreak@25
 | 
   118     end
 | 
| 
flickerstreak@25
 | 
   119   end
 | 
| 
flickerstreak@25
 | 
   120 end
 | 
| 
flickerstreak@25
 | 
   121 
 | 
| 
flickerstreak@25
 | 
   122 function module:IsHidden()
 | 
| 
flickerstreak@25
 | 
   123   return self.db.profile.hide
 | 
| 
flickerstreak@25
 | 
   124 end
 | 
| 
flickerstreak@25
 | 
   125 
 | 
| 
flickerstreak@25
 | 
   126 function module:SetHidden(h)
 | 
| 
flickerstreak@25
 | 
   127   if h then
 | 
| 
flickerstreak@25
 | 
   128     self:HideAll()
 | 
| 
flickerstreak@25
 | 
   129   else
 | 
| 
flickerstreak@25
 | 
   130     self:ShowAll()
 | 
| 
flickerstreak@25
 | 
   131   end
 | 
| 
flickerstreak@25
 | 
   132 end
 | 
| 
flickerstreak@25
 | 
   133 
 |