comparison modules/Totem.lua @ 222:d08a74e86c96

un-namespace totem, pet, stance, vehicle exit
author Flick <flickerstreak@gmail.com>
date Sun, 21 Nov 2010 14:42:38 -0800
parents e63aefb8a555
children c4b134512c50
comparison
equal deleted inserted replaced
221:bb13624de7e1 222:d08a74e86c96
19 -- mixins go here 19 -- mixins go here
20 ) 20 )
21 21
22 -- handlers 22 -- handlers
23 function module:OnInitialize() 23 function module:OnInitialize()
24 self.db = ReAction.db:RegisterNamespace( moduleID,
25 {
26 profile = {
27 buttons = { }
28 }
29 }
30 )
31
32 self.buttons = { } 24 self.buttons = { }
33 25
34 ReAction.RegisterCallback(self, "OnCreateBar", "OnRefreshBar") 26 ReAction.RegisterCallback(self, "OnCreateBar", "OnRefreshBar")
35 ReAction.RegisterCallback(self, "OnDestroyBar") 27 ReAction.RegisterCallback(self, "OnDestroyBar")
36 ReAction.RegisterCallback(self, "OnRefreshBar") 28 ReAction.RegisterCallback(self, "OnRefreshBar")
37 ReAction.RegisterCallback(self, "OnEraseBar")
38 ReAction.RegisterCallback(self, "OnRenameBar")
39 29
40 self:RegisterEvent("UPDATE_MULTI_CAST_ACTIONBAR","PLAYER_ENTERING_WORLD") 30 self:RegisterEvent("UPDATE_MULTI_CAST_ACTIONBAR","PLAYER_ENTERING_WORLD")
41 end 31 end
42 32
43 function module:OnEnable() 33 function module:OnEnable()
59 self.buttons[bar] = nil 49 self.buttons[bar] = nil
60 end 50 end
61 end 51 end
62 52
63 function module:OnRefreshBar(event, bar, name) 53 function module:OnRefreshBar(event, bar, name)
64 if bar.config.type == moduleID then 54 local config = bar:GetConfig()
55 if config.type == moduleID then
65 local btns = self.buttons[bar] 56 local btns = self.buttons[bar]
66 if btns == nil then 57 if btns == nil then
67 btns = { } 58 btns = { }
68 self.buttons[bar] = btns 59 self.buttons[bar] = btns
69 end 60 end
70 local profile = self.db.profile 61 if not config.buttons then
71 if profile.buttons[name] == nil then 62 config.buttons = { }
72 profile.buttons[name] = {}
73 end 63 end
74 local btnCfg = profile.buttons[name] 64 local btnCfg = config.buttons
75 65
76 local r, c = bar:GetButtonGrid() 66 local r, c = bar:GetButtonGrid()
77 local n = min(r*c,6) 67 local n = min(r*c,6)
78 Button.SetupBarHeader(bar) 68 Button.SetupBarHeader(bar)
79 for i = 1, n do 69 for i = 1, n do
109 end 99 end
110 end 100 end
111 101
112 end 102 end
113 103
114 function module:OnEraseBar(event, bar, name)
115 self.db.profile.buttons[name] = nil
116 end
117
118 function module:OnRenameBar(event, bar, oldName, newName)
119 local b = self.db.profile.buttons
120 b[newname], b[oldname] = b[oldname], nil
121 end
122
123 function module:RefreshAll()
124 for bar in pairs(self.buttons) do
125 self:OnRefreshBar(nil,bar,bar:GetName())
126 end
127 end
128
129 function module:UPDATE_MULTI_CAST_ACTIONBAR() 104 function module:UPDATE_MULTI_CAST_ACTIONBAR()
130 if not InCombatLockdown() then 105 if not InCombatLockdown() then
131 for bar in pairs(self.buttons) do 106 for bar in pairs(self.buttons) do
132 self:OnRefreshBar("OnRefreshBar", bar, bar:GetName()) 107 self:OnRefreshBar("OnRefreshBar", bar, bar:GetName())
133 end 108 end