Mercurial > wow > reaction
comparison State.lua @ 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 |
comparison
equal
deleted
inserted
replaced
96:aa9074c92f11 | 97:5d3b7b025142 |
---|---|
275 combat = "combat", | 275 combat = "combat", |
276 nocombat = "nocombat", | 276 nocombat = "nocombat", |
277 possess = "bonusbar:5", | 277 possess = "bonusbar:5", |
278 } | 278 } |
279 | 279 |
280 -- Have to do these shenanigans instead of hardcoding the stances/forms because | 280 -- Have to do these shenanigans instead of hardcoding the stances/forms because the |
281 -- the ordering varies if the character is missing a form. For warriors | 281 -- ordering varies if the character is missing a form. For warriors this is rarely |
282 -- this is rarely a problem (c'mon, who actually skips the level 10 def stance quest?) | 282 -- a problem (c'mon, who actually skips the level 10 def stance quest?) but for druids |
283 -- but for druids it can be. Some people never bother to do the aquatic form quest | 283 -- it can be. Some people never bother to do the aquatic form quest until well past |
284 -- until well past when they get cat form, and stance 5/6 can be flight, tree, or moonkin | 284 -- when they get cat form, and stance 5/6 can be flight, tree, or moonkin depending |
285 -- depending on talents. | 285 -- on talents. |
286 function InitRules() | 286 function InitRules() |
287 local forms = { } | 287 local forms = { } |
288 -- sort by icon since it's locale-independent | 288 -- sort by icon since it's locale-independent |
289 for i = 1, GetNumShapeshiftForms() do | 289 for i = 1, GetNumShapeshiftForms() do |
290 local icon = GetShapeshiftFormInfo(i) | 290 local icon, name, active = GetShapeshiftFormInfo(i) |
291 -- if it's the current form, the icon is wrong (Ability_Spell_WispSplode) | |
292 -- so capture it from the spell info directly | |
293 if active then | |
294 local _1, _2 | |
295 _1, _2, icon = GetSpellInfo(name) | |
296 end | |
291 forms[icon] = i; | 297 forms[icon] = i; |
292 end | 298 end |
293 -- use 9 if not found since 9 is never a valid stance/form | 299 -- use 9 if not found since 9 is never a valid stance/form |
294 local defensive = forms["Interface\\Icons\\Ability_Warrior_DefensiveStance"] or 9 | 300 local defensive = forms["Interface\\Icons\\Ability_Warrior_DefensiveStance"] or 9 |
295 local berserker = forms["Interface\\Icons\\Ability_Racial_Avatar"] or 9 | 301 local berserker = forms["Interface\\Icons\\Ability_Racial_Avatar"] or 9 |
429 bars = { }, | 435 bars = { }, |
430 } | 436 } |
431 } | 437 } |
432 ) | 438 ) |
433 | 439 |
434 InitRules() | 440 self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") |
435 self:RegisterEvent("PLAYER_AURAS_CHANGED") | |
436 | 441 |
437 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") | 442 ReAction:RegisterBarOptionGenerator(self, "GetBarOptions") |
438 | 443 |
439 ReAction.RegisterCallback(self, "OnCreateBar","OnRefreshBar") | 444 ReAction.RegisterCallback(self, "OnCreateBar","OnRefreshBar") |
440 ReAction.RegisterCallback(self, "OnDestroyBar") | 445 ReAction.RegisterCallback(self, "OnDestroyBar") |
442 ReAction.RegisterCallback(self, "OnEraseBar") | 447 ReAction.RegisterCallback(self, "OnEraseBar") |
443 ReAction.RegisterCallback(self, "OnRenameBar") | 448 ReAction.RegisterCallback(self, "OnRenameBar") |
444 ReAction.RegisterCallback(self, "OnConfigModeChanged") | 449 ReAction.RegisterCallback(self, "OnConfigModeChanged") |
445 end | 450 end |
446 | 451 |
447 function module:PLAYER_AURAS_CHANGED() | 452 function module:OnEnable() |
448 self:UnregisterEvent("PLAYER_AURAS_CHANGED") | 453 self:UPDATE_SHAPESHIFT_FORMS() -- it doesn't fire on a /reloadui |
449 -- on login the number of stances is 0 until this event fires during the init sequence. | 454 end |
450 -- however if you just reload the UI the number of stances is correct immediately | 455 |
451 -- and this event won't fire until you gain/lose buffs/debuffs, at which point you might | 456 function module:UPDATE_SHAPESHIFT_FORMS() |
452 -- be in combat. | 457 -- Re-parse the rules table according to the new form list. |
453 if not InCombatLockdown() then | 458 -- This happens both at initial login (after PLAYER_ENTERING_WORLD) |
454 InitRules() | 459 -- as well as when gaining new abilities. |
455 for name, bar in ReAction:IterateBars() do | 460 InitRules() |
456 self:OnRefreshBar(nil,bar,name) | 461 for name, bar in ReAction:IterateBars() do |
457 end | 462 self:OnRefreshBar(nil,bar,name) |
458 end | 463 end |
459 end | 464 end |
460 | 465 |
461 function module:OnRefreshBar(event, bar, name) | 466 function module:OnRefreshBar(event, bar, name) |
462 local c = self.db.profile.bars[name] | 467 local c = self.db.profile.bars[name] |