comparison modules/HideBlizzard.lua @ 109:410d036c43b2

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