annotate modules/HideBlizzard.lua @ 177:5c01c0d3bf79

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