annotate modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua @ 28:21bcaf8215ff

- converted to Ace3 - rearranged file layout - configGUI menus not working right now
author Flick <flickerstreak@gmail.com>
date Mon, 17 Mar 2008 18:24:53 +0000
parents bf997ea151ca
children 0d95ce7a9ec2
rev   line source
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 local _G = _G
flickerstreak@25 13
flickerstreak@25 14 -- module declaration
flickerstreak@25 15 local moduleID = "HideBlizzard"
flickerstreak@25 16 local module = ReAction:NewModule( moduleID )
flickerstreak@25 17
flickerstreak@25 18
flickerstreak@25 19 -- module methods
flickerstreak@25 20 function module:OnInitialize()
flickerstreak@28 21 self.db = ReAction.db:RegisterNamespace( moduleID,
flickerstreak@25 22 {
flickerstreak@28 23 profile = {
flickerstreak@28 24 hide = false
flickerstreak@28 25 }
flickerstreak@25 26 }
flickerstreak@25 27 )
flickerstreak@28 28 self.db.RegisterCallback(self,"OnProfileChanged")
flickerstreak@25 29
flickerstreak@25 30 self.hiddenFrame = CreateFrame("Frame")
flickerstreak@25 31 self.hiddenFrame:Hide()
flickerstreak@25 32
flickerstreak@25 33 -- disable the buttons to hide/show the blizzard multiaction bars
flickerstreak@25 34 -- see UIOptionsFrame.lua and .xml
flickerstreak@25 35 -- This is called every time the options panel is shown, after it is set up
flickerstreak@25 36 local disabledOptionsButtons = {
flickerstreak@25 37 _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR1_TEXT"].index],
flickerstreak@25 38 _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR2_TEXT"].index],
flickerstreak@25 39 _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR3_TEXT"].index],
flickerstreak@25 40 _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["SHOW_MULTIBAR4_TEXT"].index],
flickerstreak@25 41 _G["UIOptionsFrameCheckButton"..UIOptionsFrameCheckButtons["ALWAYS_SHOW_MULTIBARS_TEXT"].index],
flickerstreak@25 42 }
flickerstreak@25 43 hooksecurefunc("UIOptionsFrame_Load",
flickerstreak@25 44 function()
flickerstreak@25 45 if self.db.profile.hide then
flickerstreak@25 46 for _, f in pairs(disabledOptionsButtons) do
flickerstreak@25 47 f.disabled = true
flickerstreak@25 48 OptionsFrame_DisableCheckBox(f)
flickerstreak@25 49 end
flickerstreak@25 50 end
flickerstreak@25 51 end
flickerstreak@25 52 )
flickerstreak@25 53 end
flickerstreak@25 54
flickerstreak@25 55 function module:OnEnable()
flickerstreak@25 56 if self.db.profile.hide then
flickerstreak@25 57 self:HideAll(true)
flickerstreak@25 58 end
flickerstreak@25 59 end
flickerstreak@25 60
flickerstreak@25 61 function module:OnDisable()
flickerstreak@25 62 self:ShowAll(true)
flickerstreak@25 63 end
flickerstreak@25 64
flickerstreak@28 65 function module:OnProfileChanged()
flickerstreak@25 66 if self.db.profile.hide then
flickerstreak@28 67 module:HideAll(true)
flickerstreak@25 68 else
flickerstreak@28 69 module:ShowAll(true)
flickerstreak@25 70 end
flickerstreak@25 71 end
flickerstreak@25 72
flickerstreak@25 73 local frames = {
flickerstreak@25 74 MainMenuBar,
flickerstreak@25 75 PetActionButton1,
flickerstreak@25 76 PetActionButton2,
flickerstreak@25 77 PetActionButton3,
flickerstreak@25 78 PetActionButton4,
flickerstreak@25 79 PetActionButton5,
flickerstreak@25 80 PetActionButton6,
flickerstreak@25 81 PetActionButton7,
flickerstreak@25 82 PetActionButton8,
flickerstreak@25 83 PetActionButton9,
flickerstreak@25 84 PetActionButton10,
flickerstreak@25 85 BonusActionBarFrame,
flickerstreak@25 86 ShapeshiftBarFrame,
flickerstreak@25 87 MultiBarLeft,
flickerstreak@25 88 MultiBarRight,
flickerstreak@25 89 MultiBarBottomLeft,
flickerstreak@25 90 MultiBarBottomRight,
flickerstreak@25 91 SlidingActionBarTexture0,
flickerstreak@25 92 SlidingActionBarTexture1,
flickerstreak@25 93 }
flickerstreak@25 94
flickerstreak@25 95 local hidden = { }
flickerstreak@25 96
flickerstreak@25 97 function module:HideAll( force )
flickerstreak@25 98 if not(self.db.profile.hide) or force then
flickerstreak@25 99 self.db.profile.hide = true
flickerstreak@25 100 -- the pet bar is a child of MainMenuBar, but can't be permanently hidden because it will
flickerstreak@25 101 -- break automatic pet bar show/hide. Need to reparent it instead.
flickerstreak@25 102 PetActionBarFrame:SetParent(UIParent)
flickerstreak@25 103 -- for some odd reason PetActionBarFrame has mouse input enabled even though it has no mouse
flickerstreak@25 104 -- input handlers. Because of this it can potentially trap mouse clicks from getting through
flickerstreak@25 105 -- to things behind it. It's not feasible to move it, either, since UIParent_ManageFramePositions()
flickerstreak@25 106 -- will move it back to its original position whenever it's called.
flickerstreak@25 107 PetActionBarFrame:EnableMouse(false)
flickerstreak@25 108
flickerstreak@25 109 for _, f in pairs(frames) do
flickerstreak@25 110 hidden[f] = hidden[f] or { parent = f:GetParent(), wasShown = f:IsShown() }
flickerstreak@25 111 f:SetParent(self.hiddenFrame)
flickerstreak@25 112 f:Hide()
flickerstreak@25 113 end
flickerstreak@25 114 end
flickerstreak@25 115 end
flickerstreak@25 116
flickerstreak@25 117 function module:ShowAll( force )
flickerstreak@25 118 if self.db.profile.hide or force then
flickerstreak@25 119 self.db.profile.hide = false
flickerstreak@25 120
flickerstreak@25 121 PetActionBarFrame:SetParent(MainMenuBar)
flickerstreak@25 122 for _, f in pairs(frames) do
flickerstreak@25 123 local h = hidden[f]
flickerstreak@25 124 if h then
flickerstreak@25 125 f:SetParent(h.parent)
flickerstreak@25 126 if h.wasShown then
flickerstreak@25 127 f:Show()
flickerstreak@25 128 end
flickerstreak@25 129 end
flickerstreak@25 130 end
flickerstreak@25 131 end
flickerstreak@25 132 end
flickerstreak@25 133
flickerstreak@25 134 function module:IsHidden()
flickerstreak@25 135 return self.db.profile.hide
flickerstreak@25 136 end
flickerstreak@25 137
flickerstreak@25 138 function module:SetHidden(h)
flickerstreak@25 139 if h then
flickerstreak@25 140 self:HideAll()
flickerstreak@25 141 else
flickerstreak@25 142 self:ShowAll()
flickerstreak@25 143 end
flickerstreak@25 144 end
flickerstreak@25 145
flickerstreak@25 146 function module:GetGlobalOptions()
flickerstreak@25 147 if self.globalOptions == nil then
flickerstreak@25 148 self.globalOptions = {
flickerstreak@25 149 hideBlizzard = {
flickerstreak@25 150 type = "toggle",
flickerstreak@25 151 handler = self,
flickerstreak@25 152 name = L["Hide Default Action Bars"],
flickerstreak@25 153 desc = L["Hide the default main bar and extra action bars"],
flickerstreak@25 154 get = "IsHidden",
flickerstreak@25 155 set = "SetHidden",
flickerstreak@25 156 disabled = function() return InCombatLockdown() end
flickerstreak@25 157 }
flickerstreak@25 158 }
flickerstreak@25 159 end
flickerstreak@25 160 return self.globalOptions
flickerstreak@25 161 end