annotate modules/ReAction_HideBlizzard/ReAction_HideBlizzard.lua @ 63:768be7eb22a0

Converted several ReAction APIs to event-driven model instead of 'call-method-on-all-modules' model. Cleaned up a number of other architectural issues.
author Flick <flickerstreak@gmail.com>
date Thu, 22 May 2008 22:02:08 +0000
parents 44649a10378d
children da8ba8783924
rev   line source
flickerstreak@25 1 --[[
flickerstreak@25 2 ReAction 'Hide Blizzard' module
flickerstreak@25 3
flickerstreak@25 4 Hides Blizzard action bars. This hides the extra action bars, stance bar, pet bar, and
flickerstreak@25 5 main menu bar, which in turn hides the experience bar, bag bar, micro menu bar, and lag meter.
flickerstreak@25 6
flickerstreak@25 7 --]]
flickerstreak@25 8
flickerstreak@25 9 -- local imports
flickerstreak@25 10 local ReAction = ReAction
flickerstreak@25 11 local L = ReAction.L
flickerstreak@25 12
flickerstreak@25 13 -- module declaration
flickerstreak@25 14 local moduleID = "HideBlizzard"
flickerstreak@25 15 local module = ReAction:NewModule( moduleID )
flickerstreak@25 16
flickerstreak@25 17
flickerstreak@25 18 -- module methods
flickerstreak@25 19 function module:OnInitialize()
flickerstreak@28 20 self.db = ReAction.db:RegisterNamespace( moduleID,
flickerstreak@25 21 {
flickerstreak@28 22 profile = {
flickerstreak@28 23 hide = false
flickerstreak@28 24 }
flickerstreak@25 25 }
flickerstreak@25 26 )
flickerstreak@28 27 self.db.RegisterCallback(self,"OnProfileChanged")
flickerstreak@43 28 self.db.RegisterCallback(self,"OnProfileReset","OnProfileChanged")
flickerstreak@25 29
flickerstreak@25 30 self.hiddenFrame = CreateFrame("Frame")
flickerstreak@25 31 self.hiddenFrame:Hide()
flickerstreak@60 32
flickerstreak@60 33 ReAction:RegisterOptions(self, {
flickerstreak@60 34 hideBlizzard = {
flickerstreak@60 35 type = "toggle",
flickerstreak@60 36 handler = self,
flickerstreak@60 37 name = L["Hide Blizzard Action Bars"],
flickerstreak@60 38 desc = L["Hide the default main bar and extra action bars"],
flickerstreak@60 39 get = "IsHidden",
flickerstreak@60 40 set = function(info,value) self:SetHidden(value) end,
flickerstreak@60 41 disabled = InCombatLockdown
flickerstreak@60 42 },
flickerstreak@60 43 }, true) -- global
flickerstreak@60 44
flickerstreak@25 45 end
flickerstreak@25 46
flickerstreak@25 47 function module:OnEnable()
flickerstreak@25 48 if self.db.profile.hide then
flickerstreak@25 49 self:HideAll(true)
flickerstreak@25 50 end
flickerstreak@38 51
flickerstreak@38 52 -- reroute blizzard action bar config to ReAction config window
flickerstreak@38 53 InterfaceOptionsActionBarsPanel:HookScript("OnShow",
flickerstreak@38 54 function()
flickerstreak@41 55 if module:IsEnabled() and module:IsHidden() then
flickerstreak@38 56 ReAction:ShowConfig()
flickerstreak@38 57 end
flickerstreak@38 58 end )
flickerstreak@25 59 end
flickerstreak@25 60
flickerstreak@25 61 function module:OnDisable()
flickerstreak@25 62 self:ShowAll(true)
flickerstreak@25 63 end
flickerstreak@25 64
flickerstreak@28 65 function module:OnProfileChanged()
flickerstreak@25 66 if self.db.profile.hide then
flickerstreak@28 67 module:HideAll(true)
flickerstreak@25 68 else
flickerstreak@28 69 module:ShowAll(true)
flickerstreak@25 70 end
flickerstreak@25 71 end
flickerstreak@25 72
flickerstreak@25 73 local frames = {
flickerstreak@25 74 MainMenuBar,
flickerstreak@25 75 MultiBarLeft,
flickerstreak@25 76 MultiBarRight,
flickerstreak@25 77 MultiBarBottomLeft,
flickerstreak@25 78 MultiBarBottomRight,
flickerstreak@54 79 -- possess bar frame needs to be pulled out separately: stash its children away
flickerstreak@54 80 PossessBarLeft,
flickerstreak@54 81 PossessBarRight,
flickerstreak@54 82 PossessButton1,
flickerstreak@54 83 PossessButton2
flickerstreak@25 84 }
flickerstreak@25 85
flickerstreak@25 86 local hidden = { }
flickerstreak@25 87
flickerstreak@25 88 function module:HideAll( force )
flickerstreak@25 89 if not(self.db.profile.hide) or force then
flickerstreak@25 90 self.db.profile.hide = true
flickerstreak@25 91 for _, f in pairs(frames) do
flickerstreak@25 92 hidden[f] = hidden[f] or { parent = f:GetParent(), wasShown = f:IsShown() }
flickerstreak@25 93 f:SetParent(self.hiddenFrame)
flickerstreak@25 94 f:Hide()
flickerstreak@25 95 end
flickerstreak@25 96 end
flickerstreak@54 97 PossessBarFrame:SetParent(UIParent)
flickerstreak@54 98 PossessBarFrame:EnableMouse(false)
flickerstreak@25 99 end
flickerstreak@25 100
flickerstreak@25 101 function module:ShowAll( force )
flickerstreak@54 102 PossessBarFrame:EnableMouse(true)
flickerstreak@54 103 PossessBarFrame:SetParent(MainMenuBar)
flickerstreak@25 104 if self.db.profile.hide or force then
flickerstreak@25 105 self.db.profile.hide = false
flickerstreak@25 106
flickerstreak@25 107 for _, f in pairs(frames) do
flickerstreak@25 108 local h = hidden[f]
flickerstreak@25 109 if h then
flickerstreak@25 110 f:SetParent(h.parent)
flickerstreak@25 111 if h.wasShown then
flickerstreak@25 112 f:Show()
flickerstreak@25 113 end
flickerstreak@25 114 end
flickerstreak@25 115 end
flickerstreak@25 116 end
flickerstreak@25 117 end
flickerstreak@25 118
flickerstreak@25 119 function module:IsHidden()
flickerstreak@25 120 return self.db.profile.hide
flickerstreak@25 121 end
flickerstreak@25 122
flickerstreak@25 123 function module:SetHidden(h)
flickerstreak@25 124 if h then
flickerstreak@25 125 self:HideAll()
flickerstreak@25 126 else
flickerstreak@25 127 self:ShowAll()
flickerstreak@25 128 end
flickerstreak@25 129 end
flickerstreak@25 130