Mercurial > wow > reaction
comparison modules/Stance.lua @ 147:901c91dc1bf2
Some refactoring of configmode/keybind handlers
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Thu, 07 May 2009 23:55:00 +0000 |
parents | d186e041ca14 |
children | df68b5a40490 |
comparison
equal
deleted
inserted
replaced
146:86564b5cbbff | 147:901c91dc1bf2 |
---|---|
14 -- module declaration | 14 -- module declaration |
15 local moduleID = "Stance" | 15 local moduleID = "Stance" |
16 local module = ReAction:NewModule( moduleID | 16 local module = ReAction:NewModule( moduleID |
17 -- mixins go here | 17 -- mixins go here |
18 ) | 18 ) |
19 | |
20 -- libraries | |
21 local KB = LibStub("LibKeyBound-1.0") | |
22 | 19 |
23 -- handlers | 20 -- handlers |
24 function module:OnInitialize() | 21 function module:OnInitialize() |
25 self.db = ReAction.db:RegisterNamespace( moduleID, | 22 self.db = ReAction.db:RegisterNamespace( moduleID, |
26 { | 23 { |
37 ReAction.RegisterCallback(self, "OnCreateBar", "OnRefreshBar") | 34 ReAction.RegisterCallback(self, "OnCreateBar", "OnRefreshBar") |
38 ReAction.RegisterCallback(self, "OnDestroyBar") | 35 ReAction.RegisterCallback(self, "OnDestroyBar") |
39 ReAction.RegisterCallback(self, "OnRefreshBar") | 36 ReAction.RegisterCallback(self, "OnRefreshBar") |
40 ReAction.RegisterCallback(self, "OnEraseBar") | 37 ReAction.RegisterCallback(self, "OnEraseBar") |
41 ReAction.RegisterCallback(self, "OnRenameBar") | 38 ReAction.RegisterCallback(self, "OnRenameBar") |
42 ReAction.RegisterCallback(self, "OnConfigModeChanged") | |
43 | |
44 KB.RegisterCallback(self, "LIBKEYBOUND_ENABLED") | |
45 KB.RegisterCallback(self, "LIBKEYBOUND_DISABLED") | |
46 KB.RegisterCallback(self, "LIBKEYBOUND_MODE_COLOR_CHANGED","LIBKEYBOUND_ENABLED") | |
47 end | 39 end |
48 | 40 |
49 function module:OnEnable() | 41 function module:OnEnable() |
50 ReAction:RegisterBarType(L["Stance Bar"], | 42 ReAction:RegisterBarType(L["Stance Bar"], |
51 { | 43 { |
126 function module:OnRenameBar(event, bar, oldName, newName) | 118 function module:OnRenameBar(event, bar, oldName, newName) |
127 local b = self.db.profile.buttons | 119 local b = self.db.profile.buttons |
128 b[newname], b[oldname] = b[oldname], nil | 120 b[newname], b[oldname] = b[oldname], nil |
129 end | 121 end |
130 | 122 |
131 function module:OnConfigModeChanged(event, mode) | |
132 for bar in pairs(self.buttons) do | |
133 for b in bar:IterateButtons() do | |
134 b:UpdateActionIDLabel(mode) | |
135 end | |
136 end | |
137 end | |
138 | |
139 function module:LIBKEYBOUND_ENABLED(evt) | |
140 for _, buttons in pairs(self.buttons) do | |
141 for _, b in pairs(buttons) do | |
142 b:SetKeybindMode(true) | |
143 end | |
144 end | |
145 end | |
146 | |
147 function module:LIBKEYBOUND_DISABLED(evt) | |
148 for _, buttons in pairs(self.buttons) do | |
149 for _, b in pairs(buttons) do | |
150 b:SetKeybindMode(false) | |
151 end | |
152 end | |
153 end | |
154 | |
155 function module:RefreshAll() | 123 function module:RefreshAll() |
156 for bar in pairs(self.buttons) do | 124 for bar in pairs(self.buttons) do |
157 self:OnRefreshBar(nil,bar,bar:GetName()) | 125 self:OnRefreshBar(nil,bar,bar:GetName()) |
158 end | 126 end |
159 end | 127 end |