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