Mercurial > wow > reaction
comparison modules/Action.lua @ 147:901c91dc1bf2
Some refactoring of configmode/keybind handlers
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Thu, 07 May 2009 23:55:00 +0000 |
| parents | 729232aeeb5e |
| children | 8cc187143acd |
comparison
equal
deleted
inserted
replaced
| 146:86564b5cbbff | 147:901c91dc1bf2 |
|---|---|
| 6 local wipe = wipe | 6 local wipe = wipe |
| 7 | 7 |
| 8 ReAction:UpdateRevision("$Revision$") | 8 ReAction:UpdateRevision("$Revision$") |
| 9 | 9 |
| 10 local weak = { __mode="k" } | 10 local weak = { __mode="k" } |
| 11 | |
| 12 -- libraries | |
| 13 local KB = LibStub("LibKeyBound-1.0") | |
| 14 | 11 |
| 15 -- module declaration | 12 -- module declaration |
| 16 local moduleID = "Action" | 13 local moduleID = "Action" |
| 17 local module = ReAction:NewModule( moduleID ) | 14 local module = ReAction:NewModule( moduleID ) |
| 18 | 15 |
| 37 ReAction.RegisterCallback(self, "OnCreateBar") | 34 ReAction.RegisterCallback(self, "OnCreateBar") |
| 38 ReAction.RegisterCallback(self, "OnRefreshBar") | 35 ReAction.RegisterCallback(self, "OnRefreshBar") |
| 39 ReAction.RegisterCallback(self, "OnDestroyBar") | 36 ReAction.RegisterCallback(self, "OnDestroyBar") |
| 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["Action Bar"], | 42 ReAction:RegisterBarType(L["Action Bar"], |
| 51 { | 43 { |
| 97 function module:OnRenameBar(event, bar, oldname, newname) | 89 function module:OnRenameBar(event, bar, oldname, newname) |
| 98 b = self.db.profile.bars | 90 b = self.db.profile.bars |
| 99 b[newname], b[oldname] = b[oldname], nil | 91 b[newname], b[oldname] = b[oldname], nil |
| 100 end | 92 end |
| 101 | 93 |
| 102 function module:OnConfigModeChanged(event, mode) | |
| 103 for _, h in pairs(self.handles) do | |
| 104 h:SetConfigMode(mode) | |
| 105 end | |
| 106 end | |
| 107 | |
| 108 function module:LIBKEYBOUND_ENABLED(evt) | |
| 109 for _, h in pairs(self.handles) do | |
| 110 h:SetKeybindMode(true) | |
| 111 end | |
| 112 end | |
| 113 | |
| 114 function module:LIBKEYBOUND_DISABLED(evt) | |
| 115 for _, h in pairs(self.handles) do | |
| 116 h:SetKeybindMode(false) | |
| 117 end | |
| 118 end | |
| 119 | |
| 120 | |
| 121 ---- Interface ---- | 94 ---- Interface ---- |
| 122 function module:GetBarOptions(bar) | 95 function module:GetBarOptions(bar) |
| 123 local h = self.handles[bar] | 96 local h = self.handles[bar] |
| 124 if h then | 97 if h then |
| 125 return h:GetOptions() | 98 return h:GetOptions() |
| 139 get = "GetHideEmpty", | 112 get = "GetHideEmpty", |
| 140 set = "SetHideEmpty", | 113 set = "SetHideEmpty", |
| 141 }, | 114 }, |
| 142 lockButtons = { | 115 lockButtons = { |
| 143 name = L["Lock Buttons"], | 116 name = L["Lock Buttons"], |
| 144 desc = L["Prevents picking up/dragging actions.|nNOTE: This setting is overridden by the global setting in Blizzard's Action Buttons tab"], | 117 desc = L["Prevents picking up/dragging actions (use SHIFT to override this behavior)"], |
| 145 order = 2, | 118 order = 2, |
| 146 type = "toggle", | 119 type = "toggle", |
| 147 get = "GetLockButtons", | 120 get = "GetLockButtons", |
| 148 set = "SetLockButtons", | 121 set = "SetLockButtons", |
| 149 }, | 122 }, |
| 274 | 247 |
| 275 if self.config.buttons == nil then | 248 if self.config.buttons == nil then |
| 276 self.config.buttons = { } | 249 self.config.buttons = { } |
| 277 end | 250 end |
| 278 self:Refresh() | 251 self:Refresh() |
| 279 self:SetKeybindMode(ReAction:GetKeybindMode()) | |
| 280 return self | 252 return self |
| 281 end | 253 end |
| 282 | 254 |
| 283 function Handle:Refresh() | 255 function Handle:Refresh() |
| 284 local r, c = self.bar:GetButtonGrid() | 256 local r, c = self.bar:GetButtonGrid() |
| 319 b:Destroy() | 291 b:Destroy() |
| 320 end | 292 end |
| 321 end | 293 end |
| 322 end | 294 end |
| 323 | 295 |
| 324 function Handle:SetConfigMode(mode) | |
| 325 for _, b in pairs(self.btns) do | |
| 326 b:UpdateActionIDLabel(mode) | |
| 327 end | |
| 328 end | |
| 329 | |
| 330 function Handle:UpdateButtonLock() | 296 function Handle:UpdateButtonLock() |
| 331 Button.SetButtonLock(self.bar, self.config.lockButtons, self.config.lockButtonsCombat) | 297 Button.SetButtonLock(self.bar, self.config.lockButtons, self.config.lockButtonsCombat) |
| 332 end | |
| 333 | |
| 334 function Handle:SetKeybindMode(mode) | |
| 335 for _, b in pairs(self.btns) do | |
| 336 b:SetKeybindMode(mode) | |
| 337 end | |
| 338 end | 298 end |
| 339 | 299 |
| 340 function Handle:GetLastButton() | 300 function Handle:GetLastButton() |
| 341 return self.btns[#self.btns] | 301 return self.btns[#self.btns] |
| 342 end | 302 end |
