Mercurial > wow > reaction
comparison classes/State.lua @ 242:b56cff349bd6
Move non-option stuff out of State.lua
Remove unused callbacks
| author | Flick |
|---|---|
| date | Fri, 25 Mar 2011 17:06:56 -0700 |
| parents | 09c8e9baa35a |
| children | 0ea0cdd7f386 |
comparison
equal
deleted
inserted
replaced
| 241:09c8e9baa35a | 242:b56cff349bd6 |
|---|---|
| 11 local format = string.format | 11 local format = string.format |
| 12 local InCombatLockdown = InCombatLockdown | 12 local InCombatLockdown = InCombatLockdown |
| 13 local RegisterStateDriver = RegisterStateDriver | 13 local RegisterStateDriver = RegisterStateDriver |
| 14 local tfetch = addonTable.tfetch | 14 local tfetch = addonTable.tfetch |
| 15 local tbuild = addonTable.tbuild | 15 local tbuild = addonTable.tbuild |
| 16 local ApplyStates = Bar.ApplyStates | |
| 17 local CleanupStates = Bar.CleanupStates | |
| 18 local SetProperty = Bar.SetStateProperty | |
| 19 local GetProperty = Bar.GetStateProperty | |
| 16 | 20 |
| 17 -- module declaration | 21 -- module declaration |
| 18 local moduleID = "State" | 22 local moduleID = "State" |
| 19 local module = ReAction:NewModule( moduleID, "AceEvent-3.0" ) | 23 local module = ReAction:NewModule( moduleID, "AceEvent-3.0" ) |
| 20 | 24 |
| 21 -- Utility -- | |
| 22 | |
| 23 | |
| 24 | |
| 25 local ApplyStates, CleanupStates, SetProperty, GetProperty | |
| 26 | |
| 27 -- PRIVATE -- | |
| 28 do | |
| 29 function GetProperty( bar, state, propname ) | |
| 30 return tfetch(bar:GetConfig(), "states", state, propname) | |
| 31 end | |
| 32 | |
| 33 function SetProperty( bar, state, propname, value ) | |
| 34 local s = tbuild(bar:GetConfig(), "states", state) | |
| 35 s[propname] = value | |
| 36 bar:SetSecureStateData(state, propname, value) | |
| 37 end | |
| 38 | |
| 39 function ApplyStates( bar ) | |
| 40 local states = tfetch(bar:GetConfig(), "states") | |
| 41 if states then | |
| 42 bar:SetStateDriver(states) | |
| 43 end | |
| 44 end | |
| 45 | |
| 46 function CleanupStates( bar ) | |
| 47 bar:SetStateDriver(nil) | |
| 48 end | |
| 49 end | |
| 50 | |
| 51 | |
| 52 | 25 |
| 53 -- module event handlers -- | 26 -- module event handlers -- |
| 54 | 27 |
| 55 function module:OnInitialize() | 28 function module:OnInitialize() |
| 56 self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") | |
| 57 | |
| 58 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") | 29 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") |
| 59 | |
| 60 ReAction.RegisterCallback(self, "OnCreateBar","OnRefreshBar") | |
| 61 ReAction.RegisterCallback(self, "OnDestroyBar") | |
| 62 ReAction.RegisterCallback(self, "OnRefreshBar") | |
| 63 end | |
| 64 | |
| 65 function module:OnEnable() | |
| 66 self:UPDATE_SHAPESHIFT_FORMS() -- it doesn't fire on a /reloadui | |
| 67 end | |
| 68 | |
| 69 function module:UPDATE_SHAPESHIFT_FORMS() | |
| 70 -- Re-parse the rules table according to the new form list. | |
| 71 -- This happens both at initial login (after PLAYER_ENTERING_WORLD) | |
| 72 -- as well as when gaining new abilities. | |
| 73 ReAction.Bar.InitRuleFormats() | |
| 74 for _, bar in ReAction:IterateBars() do | |
| 75 ApplyStates(bar) | |
| 76 end | |
| 77 end | |
| 78 | |
| 79 function module:OnRefreshBar(event, bar, name) | |
| 80 ApplyStates(bar) | |
| 81 end | |
| 82 | |
| 83 function module:OnDestroyBar(event, bar, name) | |
| 84 CleanupStates(bar) | |
| 85 end | 30 end |
| 86 | 31 |
| 87 | 32 |
| 88 | 33 |
| 89 | 34 |
