annotate modules/HideBlizzard.lua @ 173:49d49063cb79

remove print statements
author Flick <flickerstreak@gmail.com>
date Tue, 19 Oct 2010 22:07:21 +0000
parents 8cc187143acd
children df68b5a40490
rev   line source
flickerstreak@109 1 --[[
flickerstreak@109 2 ReAction 'Hide Blizzard' module
flickerstreak@109 3
flickerstreak@109 4 Hides Blizzard action bars. This hides the extra action bars, stance bar, pet bar, and
flickerstreak@109 5 main menu bar, which in turn hides the experience bar, bag bar, micro menu bar, and lag meter.
flickerstreak@109 6
flickerstreak@109 7 --]]
flickerstreak@109 8
flickerstreak@109 9 -- local imports
flickerstreak@109 10 local ReAction = ReAction
flickerstreak@109 11 local L = ReAction.L
flickerstreak@109 12
flickerstreak@109 13 -- module declaration
flickerstreak@109 14 local moduleID = "HideBlizzard"
flickerstreak@109 15 local module = ReAction:NewModule( moduleID )
flickerstreak@109 16
flickerstreak@109 17
flickerstreak@109 18 -- module methods
flickerstreak@109 19 function module:OnInitialize()
flickerstreak@109 20 self.db = ReAction.db:RegisterNamespace( moduleID,
flickerstreak@109 21 {
flickerstreak@109 22 profile = {
flickerstreak@109 23 hide = false
flickerstreak@109 24 }
flickerstreak@109 25 }
flickerstreak@109 26 )
flickerstreak@109 27 self.db.RegisterCallback(self,"OnProfileChanged")
flickerstreak@109 28 self.db.RegisterCallback(self,"OnProfileCopied", "OnProfileChanged")
flickerstreak@109 29 self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged")
flickerstreak@109 30
flickerstreak@109 31 self.hiddenFrame = CreateFrame("Frame")
flickerstreak@109 32 self.hiddenFrame:Hide()
flickerstreak@109 33
flickerstreak@149 34 -- It's fairly normal to use the Blizzard vehicle bar, and to have
flickerstreak@149 35 -- your regular buttons in the same location. If you do this, and don't
flickerstreak@149 36 -- bother to hide your buttons, they'll obscure some parts of the vehicle bar.
flickerstreak@149 37 VehicleMenuBar:SetFrameLevel(VehicleMenuBar:GetFrameLevel()+3)
flickerstreak@149 38
flickerstreak@109 39 ReAction:RegisterOptions(self, {
flickerstreak@120 40 hide = {
flickerstreak@109 41 name = L["Hide Blizzard Action Bars"],
flickerstreak@109 42 desc = L["Hide the default main bar and extra action bars"],
flickerstreak@120 43 type = "toggle",
flickerstreak@120 44 order = 10,
flickerstreak@120 45 width = "double",
flickerstreak@120 46 handler = self,
flickerstreak@109 47 get = "IsHidden",
flickerstreak@120 48 set = "SetHidden",
flickerstreak@120 49 disabled = "OptionDisabled",
flickerstreak@120 50 },
flickerstreak@120 51 hideVehicle = {
flickerstreak@120 52 name = L["Hide Blizzard Vehicle Bar"],
flickerstreak@120 53 desc = L["Hide the default vechicle action bar"],
flickerstreak@120 54 type = "toggle",
flickerstreak@120 55 order = 11,
flickerstreak@120 56 width = "double",
flickerstreak@120 57 handler = self,
flickerstreak@120 58 get = "IsHidden",
flickerstreak@120 59 set = "SetHidden",
flickerstreak@120 60 disabled = "OptionDisabled",
flickerstreak@109 61 },
flickerstreak@109 62 }, true) -- global
flickerstreak@109 63
flickerstreak@109 64 end
flickerstreak@109 65
flickerstreak@109 66 function module:OnEnable()
flickerstreak@120 67 self:UpdateFrames()
flickerstreak@109 68 end
flickerstreak@109 69
flickerstreak@109 70 function module:OnDisable()
flickerstreak@120 71 self:UpdateFrames(true)
flickerstreak@109 72 end
flickerstreak@109 73
flickerstreak@109 74 function module:OnProfileChanged()
flickerstreak@120 75 self:UpdateFrames()
flickerstreak@109 76 end
flickerstreak@109 77
flickerstreak@109 78 local frames = {
flickerstreak@120 79 [ MainMenuBar ] = { },
flickerstreak@120 80 [ MultiBarLeft ] = { },
flickerstreak@120 81 [ MultiBarRight ] = { },
flickerstreak@120 82 [ MultiBarBottomLeft ] = { },
flickerstreak@120 83 [ MultiBarBottomRight ] = { },
flickerstreak@120 84 [ VehicleMenuBar ] = { field = "hideVehicle" },
flickerstreak@109 85 }
flickerstreak@109 86
flickerstreak@120 87 function module:UpdateFrames( show )
flickerstreak@120 88 show = show or not self.db.profile.hide
flickerstreak@120 89 for frame, info in pairs(frames) do
flickerstreak@120 90 local show = show -- make a local copy for this frame
flickerstreak@120 91 if info.field then
flickerstreak@120 92 show = show or not self.db.profile[info.field]
flickerstreak@120 93 end
flickerstreak@109 94
flickerstreak@120 95 if show then
flickerstreak@120 96 if info.parent then
flickerstreak@120 97 frame:SetParent(info.parent)
flickerstreak@109 98 end
flickerstreak@120 99 if frame:IsShown() then
flickerstreak@120 100 frame:Show() -- refresh
flickerstreak@120 101 end
flickerstreak@120 102 else
flickerstreak@120 103 if not info.parent then
flickerstreak@120 104 info.parent = frame:GetParent()
flickerstreak@120 105 end
flickerstreak@120 106 frame:SetParent(self.hiddenFrame)
flickerstreak@109 107 end
flickerstreak@109 108 end
flickerstreak@109 109 end
flickerstreak@109 110
flickerstreak@120 111 function module:IsHidden(info)
flickerstreak@150 112 if info then
flickerstreak@150 113 return self.db.profile.hide and self.db.profile[info[#info]]
flickerstreak@150 114 else
flickerstreak@150 115 return self.db.profile.hide
flickerstreak@150 116 end
flickerstreak@109 117 end
flickerstreak@109 118
flickerstreak@120 119 function module:SetHidden(info,value)
flickerstreak@120 120 self.db.profile[info[#info]] = value
flickerstreak@120 121 self:UpdateFrames()
flickerstreak@109 122 end
flickerstreak@109 123
flickerstreak@120 124 function module:OptionDisabled(info)
flickerstreak@120 125 local disabled = InCombatLockdown()
flickerstreak@120 126 if not disabled and info[#info] ~= "hide" then
flickerstreak@120 127 disabled = not self.db.profile.hide
flickerstreak@120 128 end
flickerstreak@120 129 return disabled
flickerstreak@120 130 end
flickerstreak@120 131
flickerstreak@120 132
flickerstreak@120 133 -- reroute blizzard action bar config to ReAction config window
flickerstreak@120 134 InterfaceOptionsActionBarsPanel:HookScript("OnShow",
flickerstreak@120 135 function()
flickerstreak@120 136 if module:IsEnabled() and module:IsHidden() then
flickerstreak@120 137 ReAction:ShowConfig()
flickerstreak@120 138 end
flickerstreak@120 139 end )