# HG changeset patch # User Flick # Date 1300732395 25200 # Node ID ad40cd3fc7e96a1ad7934f2967da9eb002be27c4 # Parent 741c4f9b251e6df8889e2ab6e9d8514c6d374b97 pull states config out of namespace diff -r 741c4f9b251e -r ad40cd3fc7e9 Profile.lua --- a/Profile.lua Mon Mar 21 11:10:23 2011 -0700 +++ b/Profile.lua Mon Mar 21 11:33:15 2011 -0700 @@ -117,6 +117,18 @@ vehicle:ResetProfile() end + -- (10) State module uses the bar config directly + local state = db:GetNamespace("State",true) or db:RegisterNamespace("State") + if state then + for name, bar in pairs(db.profile.bars) do + local sc = state.profile.bars and state.profile.bars[name] and state.profile.bars[name].states + if sc then + bar.states = sc + end + end + vehicle:ResetProfile() + end + db.profile.dbversion = 1 end diff -r 741c4f9b251e -r ad40cd3fc7e9 modules/State.lua --- a/modules/State.lua Mon Mar 21 11:10:23 2011 -0700 +++ b/modules/State.lua Mon Mar 21 11:33:15 2011 -0700 @@ -58,11 +58,11 @@ -- PRIVATE -- do function GetProperty( bar, state, propname ) - return tfetch(module.db.profile.bars, bar:GetName(), "states", state, propname) + return tfetch(bar:GetConfig(), "states", state, propname) end function SetProperty( bar, state, propname, value ) - local s = tbuild(module.db.profile.bars, bar:GetName(), "states", state) + local s = tbuild(bar:GetConfig(), "states", state) s[propname] = value bar:SetSecureStateData(state, propname, value) end @@ -84,7 +84,7 @@ end function ApplyStates( bar ) - local states = tfetch(module.db.profile.bars, bar:GetName(), "states") + local states = tfetch(bar:GetConfig(), "states") if states then bar:SetStateDriver(states) end @@ -115,8 +115,6 @@ ReAction.RegisterCallback(self, "OnCreateBar","OnRefreshBar") ReAction.RegisterCallback(self, "OnDestroyBar") ReAction.RegisterCallback(self, "OnRefreshBar") - ReAction.RegisterCallback(self, "OnEraseBar") - ReAction.RegisterCallback(self, "OnRenameBar") end function module:OnEnable() @@ -134,24 +132,13 @@ end function module:OnRefreshBar(event, bar, name) - local c = self.db.profile.bars[name] - if c then - ApplyStates(bar) - end + ApplyStates(bar) end function module:OnDestroyBar(event, bar, name) CleanupStates(bar) end -function module:OnEraseBar(event, bar, name) - self.db.profile.bars[name] = nil -end - -function module:OnRenameBar(event, bar, oldname, newname) - local bars = self.db.profile.bars - bars[newname], bars[oldname] = bars[oldname], nil -end @@ -525,7 +512,7 @@ -- get reference to states table: even if the bar -- name changes the states table ref won't - self.states = tbuild(module.db.profile.bars, bar:GetName(), "states") + self.states = tbuild(bar:GetConfig(), "states") self.state = tbuild(self.states, opts.name) opts.order = self:GetRuleField("order") @@ -824,7 +811,7 @@ function module:GetBarOptions(bar) local private = { } - local states = tbuild(module.db.profile.bars, bar:GetName(), "states") + local states = tbuild(bar:GetConfig(), "states") local options = { name = L["Dynamic State"], type = "group",