Mercurial > wow > reaction
changeset 97:5d3b7b025142
Fixed problems with stances/forms not initializing correctly
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Thu, 23 Oct 2008 00:01:00 +0000 |
parents | aa9074c92f11 |
children | a44173c7a82c |
files | State.lua |
diffstat | 1 files changed, 25 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/State.lua Wed Oct 22 22:15:25 2008 +0000 +++ b/State.lua Thu Oct 23 00:01:00 2008 +0000 @@ -277,17 +277,23 @@ possess = "bonusbar:5", } - -- Have to do these shenanigans instead of hardcoding the stances/forms because - -- the ordering varies if the character is missing a form. For warriors - -- this is rarely a problem (c'mon, who actually skips the level 10 def stance quest?) - -- but for druids it can be. Some people never bother to do the aquatic form quest - -- until well past when they get cat form, and stance 5/6 can be flight, tree, or moonkin - -- depending on talents. + -- Have to do these shenanigans instead of hardcoding the stances/forms because the + -- ordering varies if the character is missing a form. For warriors this is rarely + -- a problem (c'mon, who actually skips the level 10 def stance quest?) but for druids + -- it can be. Some people never bother to do the aquatic form quest until well past + -- when they get cat form, and stance 5/6 can be flight, tree, or moonkin depending + -- on talents. function InitRules() local forms = { } -- sort by icon since it's locale-independent for i = 1, GetNumShapeshiftForms() do - local icon = GetShapeshiftFormInfo(i) + local icon, name, active = GetShapeshiftFormInfo(i) + -- if it's the current form, the icon is wrong (Ability_Spell_WispSplode) + -- so capture it from the spell info directly + if active then + local _1, _2 + _1, _2, icon = GetSpellInfo(name) + end forms[icon] = i; end -- use 9 if not found since 9 is never a valid stance/form @@ -431,8 +437,7 @@ } ) - InitRules() - self:RegisterEvent("PLAYER_AURAS_CHANGED") + self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") @@ -444,17 +449,17 @@ ReAction.RegisterCallback(self, "OnConfigModeChanged") end -function module:PLAYER_AURAS_CHANGED() - self:UnregisterEvent("PLAYER_AURAS_CHANGED") - -- on login the number of stances is 0 until this event fires during the init sequence. - -- however if you just reload the UI the number of stances is correct immediately - -- and this event won't fire until you gain/lose buffs/debuffs, at which point you might - -- be in combat. - if not InCombatLockdown() then - InitRules() - for name, bar in ReAction:IterateBars() do - self:OnRefreshBar(nil,bar,name) - end +function module:OnEnable() + self:UPDATE_SHAPESHIFT_FORMS() -- it doesn't fire on a /reloadui +end + +function module:UPDATE_SHAPESHIFT_FORMS() + -- Re-parse the rules table according to the new form list. + -- This happens both at initial login (after PLAYER_ENTERING_WORLD) + -- as well as when gaining new abilities. + InitRules() + for name, bar in ReAction:IterateBars() do + self:OnRefreshBar(nil,bar,name) end end