Mercurial > wow > reaction
comparison modules/PetAction.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 |
|---|---|
| 33 ]]) | 33 ]]) |
| 34 end | 34 end |
| 35 | 35 |
| 36 -- module methods | 36 -- module methods |
| 37 function module:OnInitialize() | 37 function module:OnInitialize() |
| 38 self.db = ReAction.db:RegisterNamespace( moduleID, | |
| 39 { | |
| 40 profile = { | |
| 41 buttons = { } | |
| 42 } | |
| 43 } | |
| 44 ) | |
| 45 self.buttons = { } | 38 self.buttons = { } |
| 46 | 39 |
| 47 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") | 40 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") |
| 48 | 41 |
| 49 ReAction.RegisterCallback(self, "OnCreateBar") | 42 ReAction.RegisterCallback(self, "OnCreateBar") |
| 50 ReAction.RegisterCallback(self, "OnDestroyBar") | 43 ReAction.RegisterCallback(self, "OnDestroyBar") |
| 51 ReAction.RegisterCallback(self, "OnRefreshBar") | 44 ReAction.RegisterCallback(self, "OnRefreshBar") |
| 52 ReAction.RegisterCallback(self, "OnEraseBar") | |
| 53 ReAction.RegisterCallback(self, "OnRenameBar") | |
| 54 end | 45 end |
| 55 | 46 |
| 56 function module:OnEnable() | 47 function module:OnEnable() |
| 57 ReAction:RegisterBarType(Button) | 48 ReAction:RegisterBarType(Button) |
| 58 end | 49 end |
| 68 self:OnRefreshBar(event, bar, name) | 59 self:OnRefreshBar(event, bar, name) |
| 69 end | 60 end |
| 70 end | 61 end |
| 71 | 62 |
| 72 function module:OnRefreshBar(event, bar, name) | 63 function module:OnRefreshBar(event, bar, name) |
| 73 if bar.config.type == moduleID then | 64 local config = bar:GetConfig() |
| 65 if config.type == moduleID then | |
| 74 if self.buttons[bar] == nil then | 66 if self.buttons[bar] == nil then |
| 75 self.buttons[bar] = { } | 67 self.buttons[bar] = { } |
| 76 end | 68 end |
| 77 local btns = self.buttons[bar] | 69 local btns = self.buttons[bar] |
| 78 local profile = self.db.profile | 70 if not config.buttons then |
| 79 if profile.buttons[name] == nil then | 71 config.buttons = { } |
| 80 profile.buttons[name] = {} | |
| 81 end | 72 end |
| 82 local btnCfg = profile.buttons[name] | 73 local btnCfg = config.buttons |
| 83 | 74 |
| 84 local r, c = bar:GetButtonGrid() | 75 local r, c = bar:GetButtonGrid() |
| 85 local n = r*c | 76 local n = r*c |
| 86 for i = 1, n do | 77 for i = 1, n do |
| 87 if btnCfg[i] == nil then | 78 if btnCfg[i] == nil then |
| 123 end | 114 end |
| 124 self.buttons[bar] = nil | 115 self.buttons[bar] = nil |
| 125 end | 116 end |
| 126 end | 117 end |
| 127 | 118 |
| 128 function module:OnEraseBar(event, bar, name) | |
| 129 self.db.profile.buttons[name] = nil | |
| 130 end | |
| 131 | |
| 132 function module:OnRenameBar(event, bar, oldname, newname) | |
| 133 local b = self.db.profile.buttons | |
| 134 b[newname], b[oldname] = b[oldname], nil | |
| 135 end | |
| 136 | 119 |
| 137 | 120 |
| 138 ---- Options ---- | 121 ---- Options ---- |
| 139 local Handler = { } | 122 local Handler = { } |
| 140 local meta = { __index = Handler } | 123 local meta = { __index = Handler } |
