comparison modules/HideBlizzard.lua @ 120:320a93c5f72c

Added option to hide the Blizzard vehicle bar Refactored HideBlizzard module
author Flick <flickerstreak@gmail.com>
date Fri, 06 Feb 2009 23:01:50 +0000
parents 410d036c43b2
children 61d89f0918ca
comparison
equal deleted inserted replaced
119:79a44f66683f 120:320a93c5f72c
32 32
33 self.hiddenFrame = CreateFrame("Frame") 33 self.hiddenFrame = CreateFrame("Frame")
34 self.hiddenFrame:Hide() 34 self.hiddenFrame:Hide()
35 35
36 ReAction:RegisterOptions(self, { 36 ReAction:RegisterOptions(self, {
37 hideBlizzard = { 37 hide = {
38 type = "toggle",
39 handler = self,
40 name = L["Hide Blizzard Action Bars"], 38 name = L["Hide Blizzard Action Bars"],
41 desc = L["Hide the default main bar and extra action bars"], 39 desc = L["Hide the default main bar and extra action bars"],
40 type = "toggle",
41 order = 10,
42 width = "double",
43 handler = self,
42 get = "IsHidden", 44 get = "IsHidden",
43 set = function(info,value) self:SetHidden(value) end, 45 set = "SetHidden",
44 disabled = InCombatLockdown 46 disabled = "OptionDisabled",
47 },
48 hideVehicle = {
49 name = L["Hide Blizzard Vehicle Bar"],
50 desc = L["Hide the default vechicle action bar"],
51 type = "toggle",
52 order = 11,
53 width = "double",
54 handler = self,
55 get = "IsHidden",
56 set = "SetHidden",
57 disabled = "OptionDisabled",
45 }, 58 },
46 }, true) -- global 59 }, true) -- global
47 60
48 end 61 end
49 62
50 function module:OnEnable() 63 function module:OnEnable()
51 if self.db.profile.hide then 64 self:UpdateFrames()
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 65 end
63 66
64 function module:OnDisable() 67 function module:OnDisable()
65 self:ShowAll(true) 68 self:UpdateFrames(true)
66 end 69 end
67 70
68 function module:OnProfileChanged() 71 function module:OnProfileChanged()
69 if self.db.profile.hide then 72 self:UpdateFrames()
70 module:HideAll(true)
71 else
72 module:ShowAll(true)
73 end
74 end 73 end
75 74
76 local frames = { 75 local frames = {
77 MainMenuBar, 76 [ MainMenuBar ] = { },
78 MultiBarLeft, 77 [ MultiBarLeft ] = { },
79 MultiBarRight, 78 [ MultiBarRight ] = { },
80 MultiBarBottomLeft, 79 [ MultiBarBottomLeft ] = { },
81 MultiBarBottomRight, 80 [ MultiBarBottomRight ] = { },
82 -- possess bar frame needs to be pulled out separately: stash its children away 81 [ VehicleMenuBar ] = { field = "hideVehicle" },
83 PossessBarLeft,
84 PossessBarRight,
85 PossessButton1,
86 PossessButton2
87 } 82 }
88 83
89 local hidden = { } 84 function module:UpdateFrames( show )
85 show = show or not self.db.profile.hide
86 for frame, info in pairs(frames) do
87 local show = show -- make a local copy for this frame
88 if info.field then
89 show = show or not self.db.profile[info.field]
90 end
90 91
91 function module:HideAll( force ) 92 if show then
92 if not(self.db.profile.hide) or force then 93 if info.parent then
93 self.db.profile.hide = true 94 frame:SetParent(info.parent)
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 95 end
96 if frame:IsShown() then
97 frame:Show() -- refresh
98 end
99 else
100 if not info.parent then
101 info.parent = frame:GetParent()
102 end
103 frame:SetParent(self.hiddenFrame)
118 end 104 end
119 end 105 end
120 end 106 end
121 107
122 function module:IsHidden() 108 function module:IsHidden(info)
123 return self.db.profile.hide 109 return self.db.profile.hide and self.db.profile[info[#info]]
124 end 110 end
125 111
126 function module:SetHidden(h) 112 function module:SetHidden(info,value)
127 if h then 113 self.db.profile[info[#info]] = value
128 self:HideAll() 114 self:UpdateFrames()
129 else
130 self:ShowAll()
131 end
132 end 115 end
133 116
117 function module:OptionDisabled(info)
118 local disabled = InCombatLockdown()
119 if not disabled and info[#info] ~= "hide" then
120 disabled = not self.db.profile.hide
121 end
122 return disabled
123 end
124
125
126 -- reroute blizzard action bar config to ReAction config window
127 InterfaceOptionsActionBarsPanel:HookScript("OnShow",
128 function()
129 if module:IsEnabled() and module:IsHidden() then
130 ReAction:ShowConfig()
131 end
132 end )