annotate modules/HideBlizzard.lua @ 193:576c50e51fc5

LibShowGrid-1.0 external library --> LibShowActionGrid-1.0 internal library
author Flick <flickerstreak@gmail.com>
date Mon, 15 Nov 2010 10:22:45 -0800
parents 55c2fc0c8d55
children
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 end
flickerstreak@109 41
flickerstreak@109 42 function module:OnEnable()
flickerstreak@120 43 self:UpdateFrames()
flickerstreak@109 44 end
flickerstreak@109 45
flickerstreak@109 46 function module:OnDisable()
flickerstreak@120 47 self:UpdateFrames(true)
flickerstreak@109 48 end
flickerstreak@109 49
flickerstreak@109 50 function module:OnProfileChanged()
flickerstreak@120 51 self:UpdateFrames()
flickerstreak@109 52 end
flickerstreak@109 53
flickerstreak@109 54 local frames = {
flickerstreak@120 55 [ MainMenuBar ] = { },
flickerstreak@120 56 [ MultiBarLeft ] = { },
flickerstreak@120 57 [ MultiBarRight ] = { },
flickerstreak@120 58 [ MultiBarBottomLeft ] = { },
flickerstreak@120 59 [ MultiBarBottomRight ] = { },
flickerstreak@120 60 [ VehicleMenuBar ] = { field = "hideVehicle" },
flickerstreak@109 61 }
flickerstreak@109 62
flickerstreak@120 63 function module:UpdateFrames( show )
flickerstreak@120 64 show = show or not self.db.profile.hide
flickerstreak@120 65 for frame, info in pairs(frames) do
flickerstreak@120 66 local show = show -- make a local copy for this frame
flickerstreak@120 67 if info.field then
flickerstreak@120 68 show = show or not self.db.profile[info.field]
flickerstreak@120 69 end
flickerstreak@109 70
flickerstreak@120 71 if show then
flickerstreak@120 72 if info.parent then
flickerstreak@120 73 frame:SetParent(info.parent)
flickerstreak@109 74 end
flickerstreak@120 75 if frame:IsShown() then
flickerstreak@120 76 frame:Show() -- refresh
flickerstreak@120 77 end
flickerstreak@120 78 else
flickerstreak@120 79 if not info.parent then
flickerstreak@120 80 info.parent = frame:GetParent()
flickerstreak@120 81 end
flickerstreak@120 82 frame:SetParent(self.hiddenFrame)
flickerstreak@109 83 end
flickerstreak@109 84 end
flickerstreak@109 85 end
flickerstreak@109 86
flickerstreak@120 87 function module:IsHidden(info)
flickerstreak@150 88 if info then
flickerstreak@150 89 return self.db.profile.hide and self.db.profile[info[#info]]
flickerstreak@150 90 else
flickerstreak@150 91 return self.db.profile.hide
flickerstreak@150 92 end
flickerstreak@109 93 end
flickerstreak@109 94
flickerstreak@120 95 function module:SetHidden(info,value)
flickerstreak@120 96 self.db.profile[info[#info]] = value
flickerstreak@120 97 self:UpdateFrames()
flickerstreak@109 98 end
flickerstreak@109 99
flickerstreak@120 100 function module:OptionDisabled(info)
flickerstreak@120 101 local disabled = InCombatLockdown()
flickerstreak@120 102 if not disabled and info[#info] ~= "hide" then
flickerstreak@120 103 disabled = not self.db.profile.hide
flickerstreak@120 104 end
flickerstreak@120 105 return disabled
flickerstreak@120 106 end
flickerstreak@120 107
flickerstreak@120 108
flickerstreak@120 109 -- reroute blizzard action bar config to ReAction config window
flickerstreak@120 110 InterfaceOptionsActionBarsPanel:HookScript("OnShow",
flickerstreak@120 111 function()
flickerstreak@120 112 if module:IsEnabled() and module:IsHidden() then
flickerstreak@182 113 ReAction:ShowOptions()
flickerstreak@120 114 end
flickerstreak@120 115 end )