changeset 67:84721edaa749

Rearranged rule layout slightly passed nil for OnRefreshBar when it's not actually coming from an event ApplyStates is now only called by UpdateStates
author Flick <flickerstreak@gmail.com>
date Wed, 28 May 2008 17:59:44 +0000
parents 44d3716aba8d
children fcb5dad031f9
files modules/ReAction_State/ReAction_State.lua
diffstat 1 files changed, 30 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/modules/ReAction_State/ReAction_State.lua	Wed May 28 17:41:29 2008 +0000
+++ b/modules/ReAction_State/ReAction_State.lua	Wed May 28 17:59:44 2008 +0000
@@ -36,21 +36,41 @@
 -- PRIVATE --
 local InitRules, ApplyStates
 do
-  local ruleformats = { }
+  -- As far as I can tell the macro clauses are NOT locale-specific.
+  local ruleformats = { 
+    stealth       = "stealth",
+    nostealth     = "nostealth",
+    shadowform    = "form:1",
+    noshadowform  = "noform",
+    pet           = "pet",
+    nopet         = "nopet",
+    harm          = "target=target,harm",
+    help          = "target=target,help",
+    notarget      = "target=target,noexists",
+    focusharm     = "target=focus,harm",
+    focushelp     = "target=focus,help",
+    nofocus       = "target=focus,noexists",
+    raid          = "group:raid",
+    party         = "group:party",
+    solo          = "nogroup",
+    combat        = "combat",
+    nocombat      = "nocombat",
+  }
 
+  -- 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 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)
       forms[icon] = i;
     end
-      -- sort by icon since it's locale-independent
       -- use 9 if not found since 9 is never a valid stance/form
-      -- we do these shenanigans instead of hardcoding the stances because
-      -- the ordering varies if the character is missing a form. For warriors
-      -- this is rarely a problem but for druids it can be. Some people never bother
-      -- to do the aquatic form quest, and stance 5 can be either flight or tree/boomkin
-      -- depending on talents.
     local defensive = forms["Interface\\Icons\\Ability_Warrior_DefensiveStance"] or 9
     local berserker = forms["Interface\\Icons\\Ability_Racial_Avatar"] or 9
     local bear      = forms["Interface\\Icons\\Ability_Racial_BearForm"] or 9 -- bear and dire bear share the same icon
@@ -58,9 +78,8 @@
     local cat       = forms["Interface\\Icons\\Ability_Druid_CatForm"] or 9
     local travel    = forms["Interface\\Icons\\Ability_Druid_TravelForm"] or 9
     local treekin   = forms["Interface\\Icons\\Ability_Druid_TreeofLife"] or forms["Interface\\Icons\\Spell_Nature_ForceOfNature"] or 9
-    local flight    = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- both flight and swift flight share the same icon
+    local flight    = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- flight and swift flight share the same icon
 
-    -- As far as I can tell the macro clauses are NOT locale-specific.
     ruleformats.battle        = "stance:1"
     ruleformats.defensive     = ("stance:%d"):format(defensive)
     ruleformats.berserker     = ("stance:%d"):format(berserker)
@@ -68,23 +87,6 @@
     ruleformats.bear          = ("form:%d"):format(bear)
     ruleformats.cat           = ("form:%d"):format(cat)
     ruleformats.treeOrMoonkin = ("form:%d"):format(treekin)
-    ruleformats.stealth       = "stealth"
-    ruleformats.nostealth     = "nostealth"
-    ruleformats.shadowform    = "form:1"
-    ruleformats.noshadowform  = "noform"
-    ruleformats.pet           = "pet"
-    ruleformats.nopet         = "nopet"
-    ruleformats.harm          = "target=target,harm"
-    ruleformats.help          = "target=target,help"
-    ruleformats.notarget      = "target=target,noexists"
-    ruleformats.focusharm     = "target=focus,harm"
-    ruleformats.focushelp     = "target=focus,help"
-    ruleformats.nofocus       = "target=focus,noexists"
-    ruleformats.raid          = "group:raid"
-    ruleformats.party         = "group:party"
-    ruleformats.solo          = "nogroup"
-    ruleformats.combat        = "combat"
-    ruleformats.nocombat      = "nocombat"
   end
 
   local function BuildRuleString(states)
@@ -195,7 +197,7 @@
   if not InCombatLockdown() then
     InitRules()
     for name, bar in ReAction:IterateBars() do
-      self:OnRefreshBar("OnRefreshBar",bar,name)
+      self:OnRefreshBar(nil,bar,name)
     end
   end
 end
@@ -240,7 +242,7 @@
   local states = tfetch(self.db.profile.bars, bar:GetName(), "states")
   if states[name] then
     states[name] = nil
-    ApplyStates(bar)
+    self:UpdateStates(bar)
   end
 end