annotate modules/HideBlizzard.lua @ 122:a2d2f23137c8

- Rearranged and consolidated some files in modules directory - Added 'classes' directory, moved Bar and Overlay there - Added Button, ActionButton, and GridProxy classes, not in use yet
author Flick <flickerstreak@gmail.com>
date Mon, 23 Feb 2009 18:56:57 +0000
parents 320a93c5f72c
children 61d89f0918ca
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 ReAction:UpdateRevision("$Revision$")
flickerstreak@109 14
flickerstreak@109 15 -- module declaration
flickerstreak@109 16 local moduleID = "HideBlizzard"
flickerstreak@109 17 local module = ReAction:NewModule( moduleID )
flickerstreak@109 18
flickerstreak@109 19
flickerstreak@109 20 -- module methods
flickerstreak@109 21 function module:OnInitialize()
flickerstreak@109 22 self.db = ReAction.db:RegisterNamespace( moduleID,
flickerstreak@109 23 {
flickerstreak@109 24 profile = {
flickerstreak@109 25 hide = false
flickerstreak@109 26 }
flickerstreak@109 27 }
flickerstreak@109 28 )
flickerstreak@109 29 self.db.RegisterCallback(self,"OnProfileChanged")
flickerstreak@109 30 self.db.RegisterCallback(self,"OnProfileCopied", "OnProfileChanged")
flickerstreak@109 31 self.db.RegisterCallback(self,"OnProfileReset", "OnProfileChanged")
flickerstreak@109 32
flickerstreak@109 33 self.hiddenFrame = CreateFrame("Frame")
flickerstreak@109 34 self.hiddenFrame:Hide()
flickerstreak@109 35
flickerstreak@109 36 ReAction:RegisterOptions(self, {
flickerstreak@120 37 hide = {
flickerstreak@109 38 name = L["Hide Blizzard Action Bars"],
flickerstreak@109 39 desc = L["Hide the default main bar and extra action bars"],
flickerstreak@120 40 type = "toggle",
flickerstreak@120 41 order = 10,
flickerstreak@120 42 width = "double",
flickerstreak@120 43 handler = self,
flickerstreak@109 44 get = "IsHidden",
flickerstreak@120 45 set = "SetHidden",
flickerstreak@120 46 disabled = "OptionDisabled",
flickerstreak@120 47 },
flickerstreak@120 48 hideVehicle = {
flickerstreak@120 49 name = L["Hide Blizzard Vehicle Bar"],
flickerstreak@120 50 desc = L["Hide the default vechicle action bar"],
flickerstreak@120 51 type = "toggle",
flickerstreak@120 52 order = 11,
flickerstreak@120 53 width = "double",
flickerstreak@120 54 handler = self,
flickerstreak@120 55 get = "IsHidden",
flickerstreak@120 56 set = "SetHidden",
flickerstreak@120 57 disabled = "OptionDisabled",
flickerstreak@109 58 },
flickerstreak@109 59 }, true) -- global
flickerstreak@109 60
flickerstreak@109 61 end
flickerstreak@109 62
flickerstreak@109 63 function module:OnEnable()
flickerstreak@120 64 self:UpdateFrames()
flickerstreak@109 65 end
flickerstreak@109 66
flickerstreak@109 67 function module:OnDisable()
flickerstreak@120 68 self:UpdateFrames(true)
flickerstreak@109 69 end
flickerstreak@109 70
flickerstreak@109 71 function module:OnProfileChanged()
flickerstreak@120 72 self:UpdateFrames()
flickerstreak@109 73 end
flickerstreak@109 74
flickerstreak@109 75 local frames = {
flickerstreak@120 76 [ MainMenuBar ] = { },
flickerstreak@120 77 [ MultiBarLeft ] = { },
flickerstreak@120 78 [ MultiBarRight ] = { },
flickerstreak@120 79 [ MultiBarBottomLeft ] = { },
flickerstreak@120 80 [ MultiBarBottomRight ] = { },
flickerstreak@120 81 [ VehicleMenuBar ] = { field = "hideVehicle" },
flickerstreak@109 82 }
flickerstreak@109 83
flickerstreak@120 84 function module:UpdateFrames( show )
flickerstreak@120 85 show = show or not self.db.profile.hide
flickerstreak@120 86 for frame, info in pairs(frames) do
flickerstreak@120 87 local show = show -- make a local copy for this frame
flickerstreak@120 88 if info.field then
flickerstreak@120 89 show = show or not self.db.profile[info.field]
flickerstreak@120 90 end
flickerstreak@109 91
flickerstreak@120 92 if show then
flickerstreak@120 93 if info.parent then
flickerstreak@120 94 frame:SetParent(info.parent)
flickerstreak@109 95 end
flickerstreak@120 96 if frame:IsShown() then
flickerstreak@120 97 frame:Show() -- refresh
flickerstreak@120 98 end
flickerstreak@120 99 else
flickerstreak@120 100 if not info.parent then
flickerstreak@120 101 info.parent = frame:GetParent()
flickerstreak@120 102 end
flickerstreak@120 103 frame:SetParent(self.hiddenFrame)
flickerstreak@109 104 end
flickerstreak@109 105 end
flickerstreak@109 106 end
flickerstreak@109 107
flickerstreak@120 108 function module:IsHidden(info)
flickerstreak@120 109 return self.db.profile.hide and self.db.profile[info[#info]]
flickerstreak@109 110 end
flickerstreak@109 111
flickerstreak@120 112 function module:SetHidden(info,value)
flickerstreak@120 113 self.db.profile[info[#info]] = value
flickerstreak@120 114 self:UpdateFrames()
flickerstreak@109 115 end
flickerstreak@109 116
flickerstreak@120 117 function module:OptionDisabled(info)
flickerstreak@120 118 local disabled = InCombatLockdown()
flickerstreak@120 119 if not disabled and info[#info] ~= "hide" then
flickerstreak@120 120 disabled = not self.db.profile.hide
flickerstreak@120 121 end
flickerstreak@120 122 return disabled
flickerstreak@120 123 end
flickerstreak@120 124
flickerstreak@120 125
flickerstreak@120 126 -- reroute blizzard action bar config to ReAction config window
flickerstreak@120 127 InterfaceOptionsActionBarsPanel:HookScript("OnShow",
flickerstreak@120 128 function()
flickerstreak@120 129 if module:IsEnabled() and module:IsHidden() then
flickerstreak@120 130 ReAction:ShowConfig()
flickerstreak@120 131 end
flickerstreak@120 132 end )