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