Mercurial > wow > reaction
comparison modules/ReAction_ModuleTemplate/ReAction_ModuleName.lua @ 63:768be7eb22a0
Converted several ReAction APIs to event-driven model instead of 'call-method-on-all-modules' model. Cleaned up a number of other architectural issues.
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Thu, 22 May 2008 22:02:08 +0000 |
| parents | 21bcaf8215ff |
| children | da8ba8783924 |
comparison
equal
deleted
inserted
replaced
| 62:f9cdb920470a | 63:768be7eb22a0 |
|---|---|
| 12 local moduleID = "MyModuleName" | 12 local moduleID = "MyModuleName" |
| 13 local module = ReAction:NewModule( moduleID, | 13 local module = ReAction:NewModule( moduleID, |
| 14 -- mixins go here | 14 -- mixins go here |
| 15 ) | 15 ) |
| 16 | 16 |
| 17 -- module methods | 17 -- handlers |
| 18 function module:OnInitialize() | 18 function module:OnInitialize() |
| 19 self.db = ReAction.db:RegisterNamespace( moduleID | 19 self.db = ReAction.db:RegisterNamespace( moduleID |
| 20 { | 20 { |
| 21 profile = { | 21 profile = { |
| 22 -- default profile goes here | 22 -- default profile goes here |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 ) | 25 ) |
| 26 | 26 |
| 27 end | 27 -- register some common events |
| 28 ReAction.RegisterCallback(self, "OnCreateBar") | |
| 29 ReAction.RegisterCallback(self, "OnDestroyBar") | |
| 30 ReAction.RegisterCallback(self, "OnRefreshBar") | |
| 31 ReAction.RegisterCallback(self, "OnEraseBar") | |
| 32 ReAction.RegisterCallback(self, "OnRenameBar") | |
| 33 ReAction.RegisterCallback(self, "OnConfigModeChanged") | |
| 28 end | 34 end |
| 29 | 35 |
| 30 function module:OnEnable() | 36 function module:OnEnable() |
| 31 | 37 |
| 32 end | 38 end |
| 33 | 39 |
| 34 function module:OnDisable() | 40 function module:OnDisable() |
| 35 | 41 |
| 36 end | 42 end |
| 37 | 43 |
| 38 | |
| 39 ---- ReAction module API ---- | |
| 40 | |
| 41 -- apply module features and settings to a bar object (see Bar.lua for Bar API) | 44 -- apply module features and settings to a bar object (see Bar.lua for Bar API) |
| 42 function module:ApplyToBar(bar) | 45 function module:OnCreateBar(event, bar, name) |
| 43 | 46 |
| 44 end | 47 end |
| 45 | 48 |
| 46 -- remove module features and settings from a bar object | 49 -- remove module features and settings from a bar object |
| 47 function module:RemoveFromBar(bar) | 50 function module:OnDestroyBar(event, bar, name) |
| 48 | 51 |
| 49 end | 52 end |
| 50 | 53 |
| 51 -- refresh module features and settings on a bar object | 54 -- refresh module features and settings on a bar object |
| 52 function module:RefreshBar(bar) | 55 function module:OnRefreshBar(event, bar, name) |
| 53 | 56 |
| 54 end | 57 end |
| 55 | 58 |
| 56 -- notification of config mode (true/false) on the list of bars | 59 -- erase any local configuration entries for the supplied bar name |
| 57 function module:ApplyConfigMode(mode,listOfBars) | 60 function module:OnEraseBar(event, bar, name) |
| 58 | 61 |
| 59 end | 62 end |
| 60 | 63 |
| 61 -- return a name-modifier (suffix) for the bar name display. This can reflect a dynamic state. | 64 -- update any local configuration/option entries with the new bar name index |
| 62 function module:GetBarNameModifier(bar) | 65 function module:OnRenameBar(event, bar, oldName, newName) |
| 63 return nil | |
| 64 end | |
| 65 | |
| 66 -- erase any local configuration entries for the supplied bar name | |
| 67 function module:EraseBarConfig(barName) | |
| 68 | 66 |
| 69 end | 67 end |
| 70 | 68 |
| 71 -- update any local configuration entries with the new bar name index | 69 -- update any local display/options based on config mode (true/false) |
| 72 function module:RenameBarConfig(oldName, newName) | 70 function module:OnConfigModeChanged(event, mode) |
| 73 | 71 |
| 74 end | 72 end |
| 73 |
