Mercurial > wow > reaction
comparison modules/ReAction_Action/ReAction_Action.lua @ 28:21bcaf8215ff
- converted to Ace3
- rearranged file layout
- configGUI menus not working right now
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Mon, 17 Mar 2008 18:24:53 +0000 |
| parents | 9e1984088124 |
| children | 0d95ce7a9ec2 |
comparison
equal
deleted
inserted
replaced
| 27:f1e838841ce1 | 28:21bcaf8215ff |
|---|---|
| 9 | 9 |
| 10 -- local imports | 10 -- local imports |
| 11 local ReAction = ReAction | 11 local ReAction = ReAction |
| 12 local L = ReAction.L | 12 local L = ReAction.L |
| 13 local _G = _G | 13 local _G = _G |
| 14 local AceOO = AceLibrary("AceOO-2.0") | |
| 15 local CreateFrame = CreateFrame | 14 local CreateFrame = CreateFrame |
| 16 local print = ReAction.print | 15 local print = ReAction.print |
| 17 | 16 |
| 18 -- module declaration | 17 -- module declaration |
| 19 local moduleID = "Action" | 18 local moduleID = "Action" |
| 20 local module = ReAction:NewModule( moduleID, | 19 local module = ReAction:NewModule( moduleID ) |
| 21 "AceEvent-2.0" | |
| 22 ) | |
| 23 | |
| 24 -- | |
| 25 -- action button class declaration | |
| 26 -- | |
| 27 local BtnClass = AceOO.Class() | |
| 28 local Button = BtnClass.prototype | |
| 29 module.BtnClass = BtnClass | |
| 30 | |
| 31 | |
| 32 | 20 |
| 33 -- module methods | 21 -- module methods |
| 34 function module:OnInitialize() | 22 function module:OnInitialize() |
| 35 self.db = ReAction:AcquireDBNamespace(moduleID) | 23 self.db = ReAction.db:RegisterNamespace( moduleID, |
| 36 ReAction:RegisterDefaults(moduleID,"profile", | |
| 37 { | 24 { |
| 38 buttons = { } | 25 profile = { |
| 26 buttons = { } | |
| 27 } | |
| 39 } | 28 } |
| 40 ) | 29 ) |
| 41 | |
| 42 self.buttons = { } | 30 self.buttons = { } |
| 43 end | 31 end |
| 44 | 32 |
| 45 function module:OnEnable() | 33 function module:OnEnable() |
| 46 end | 34 end |
| 47 | 35 |
| 48 function module:OnDisable() | 36 function module:OnDisable() |
| 49 end | |
| 50 | |
| 51 function module:OnProfileEnable() | |
| 52 end | 37 end |
| 53 | 38 |
| 54 function module:ApplyToBar(bar) | 39 function module:ApplyToBar(bar) |
| 55 self:RefreshBar(bar) | 40 self:RefreshBar(bar) |
| 56 end | 41 end |
| 134 newActionBar = { | 119 newActionBar = { |
| 135 type = "execute", | 120 type = "execute", |
| 136 name = L["New Action Bar"], | 121 name = L["New Action Bar"], |
| 137 desc = L["Create a new bar of standard action buttons"], | 122 desc = L["Create a new bar of standard action buttons"], |
| 138 func = function() | 123 func = function() |
| 139 ReAction:GetModule("Bar"):CreateBar() | 124 ReAction:CreateBar() |
| 140 end, | 125 end, |
| 141 disabled = InCombatLockdown, | 126 disabled = InCombatLockdown, |
| 142 } | 127 } |
| 143 } | 128 } |
| 144 end | 129 end |
| 192 end | 177 end |
| 193 }) | 178 }) |
| 194 | 179 |
| 195 | 180 |
| 196 | 181 |
| 197 -- button class methods | 182 |
| 198 function Button:init( bar, idx, config ) | 183 ------ Button class ------ |
| 199 BtnClass.super.prototype.init(self) | 184 local Button = { } |
| 185 | |
| 186 local function Constructor( self, bar, idx, config ) | |
| 200 self.bar, self.idx, self.config = bar, idx, config | 187 self.bar, self.idx, self.config = bar, idx, config |
| 201 | 188 |
| 202 local barFrame = bar:GetFrame() | 189 local barFrame = bar:GetFrame() |
| 203 | 190 |
| 204 self.name = config.name or "ReAction_"..bar:GetName().."_"..idx | 191 self.name = config.name or "ReAction_"..bar:GetName().."_"..idx |
| 223 local f = self.frame | 210 local f = self.frame |
| 224 f:UnregisterAllEvents() | 211 f:UnregisterAllEvents() |
| 225 f:Hide() | 212 f:Hide() |
| 226 f:SetParent(UIParent) | 213 f:SetParent(UIParent) |
| 227 f:ClearAllPoints() | 214 f:ClearAllPoints() |
| 228 if self.config.name then | 215 if self.name then |
| 229 _G[self.config.name] = nil | 216 _G[self.name] = nil |
| 230 end | 217 end |
| 231 ActionIDList[self.config.actionID] = nil | 218 ActionIDList[self.config.actionID] = nil |
| 232 self.frame = nil | 219 self.frame = nil |
| 233 self.config = nil | 220 self.config = nil |
| 234 self.bar = nil | 221 self.bar = nil |
| 247 end | 234 end |
| 248 | 235 |
| 249 function Button:GetActionID() | 236 function Button:GetActionID() |
| 250 return self.config.actionID | 237 return self.config.actionID |
| 251 end | 238 end |
| 239 | |
| 240 | |
| 241 -- export as a class-factory to module | |
| 242 module.BtnClass = { | |
| 243 new = function(self, ...) | |
| 244 local x = { } | |
| 245 for k,v in pairs(Button) do | |
| 246 x[k] = v | |
| 247 end | |
| 248 Constructor(x, ...) | |
| 249 return x | |
| 250 end | |
| 251 } |
