Quantcast

add combopoints support

rawoil [06-18-21 - 05:37]
add combopoints support
Filename
oUF_Simple/core/style.lua
oUF_Simple/modules/rClassBar.lua
oUF_Simple/oUF_Simple.toc
diff --git a/oUF_Simple/core/style.lua b/oUF_Simple/core/style.lua
index d21ccf3..73de8b8 100644
--- a/oUF_Simple/core/style.lua
+++ b/oUF_Simple/core/style.lua
@@ -29,7 +29,7 @@ local function CreateStyle(self)
   self.Power = L.F.CreatePowerBar(self)
   L.F.CreatePowerText(self)
   self.Castbar = L.F.CreateCastBar(self)
-  -- self.rClassBar = L.F.CreateClassBar(self)
+  self.rClassBar = L.F.CreateClassBar(self)
   -- self.AlternativePower = L.F.CreateAltPowerBar(self)
   -- self.AdditionalPower = L.F.CreateAdditionalPowerBar(self)
   self.Swing = L.F.CreateSwing(self)
diff --git a/oUF_Simple/modules/rClassBar.lua b/oUF_Simple/modules/rClassBar.lua
index ee89537..1516cc1 100644
--- a/oUF_Simple/modules/rClassBar.lua
+++ b/oUF_Simple/modules/rClassBar.lua
@@ -2,7 +2,7 @@
 local A, L = ...
 local oUF = L.oUF or oUF

-local _, PlayerClass = UnitClass'player'
+local _, PlayerClass = UnitClass('player')
 local ClassPowerID, ClassPowerType
 local RequireSpec, RequireSpell, RequirePower
 local unpack = unpack
@@ -20,15 +20,15 @@ local SPELL_POWER_ARCANE_CHARGES = Enum.PowerType.ArcaneCharges or 16

 do
   if(PlayerClass == 'MONK') then
-    ClassPowerID = SPELL_POWER_CHI
-    ClassPowerType = 'CHI'
-    RequireSpec = SPEC_MONK_WINDWALKER
-  elseif(PlayerClass == 'PALADIN') then
-    ClassPowerID = SPELL_POWER_HOLY_POWER
-    ClassPowerType = 'HOLY_POWER'
-  elseif(PlayerClass == 'WARLOCK') then
-    ClassPowerID = SPELL_POWER_SOUL_SHARDS
-    ClassPowerType = 'SOUL_SHARDS'
+  --   ClassPowerID = SPELL_POWER_CHI
+  --   ClassPowerType = 'CHI'
+  --   RequireSpec = SPEC_MONK_WINDWALKER
+  -- elseif(PlayerClass == 'PALADIN') then
+  --   ClassPowerID = SPELL_POWER_HOLY_POWER
+  --   ClassPowerType = 'HOLY_POWER'
+  -- elseif(PlayerClass == 'WARLOCK') then
+  --   ClassPowerID = SPELL_POWER_SOUL_SHARDS
+  --   ClassPowerType = 'SOUL_SHARDS'
   elseif(PlayerClass == 'ROGUE' or PlayerClass == 'DRUID') then
     ClassPowerID = SPELL_POWER_COMBO_POINTS
     ClassPowerType = 'COMBO_POINTS'
@@ -36,10 +36,10 @@ do
       RequirePower = SPELL_POWER_ENERGY
       RequireSpell = 5221 -- Shred
     end
-  elseif(PlayerClass == 'MAGE') then
-    ClassPowerID = SPELL_POWER_ARCANE_CHARGES
-    ClassPowerType = 'ARCANE_CHARGES'
-    RequireSpec = SPEC_MAGE_ARCANE
+  -- elseif(PlayerClass == 'MAGE') then
+  --   ClassPowerID = SPELL_POWER_ARCANE_CHARGES
+  --   ClassPowerType = 'ARCANE_CHARGES'
+  --   RequireSpec = SPEC_MAGE_ARCANE
   end
 end

@@ -86,10 +86,11 @@ local function UpdateSplits(self,maxSegments)
 end

 local function Update(self, event, unit, powerType)
-  if(not (self.unit == unit and (unit == 'player' and powerType == ClassPowerType
-    or unit == 'vehicle' and powerType == 'COMBO_POINTS'))) then
-    return
-  end
+  -- if(not (self.unit == unit and (unit == 'player' and powerType == ClassPowerType
+  --   or unit == 'vehicle' and powerType == 'COMBO_POINTS'))) then
+  --   return
+  -- end
+  if(self.unit ~= unit and (powerType and (powerType ~= 'COMBO_POINTS'))) then return end
   if event == 'ClassPowerDisable' then return end
   local cb = self.rClassBar
   local ppcur, ppmax
@@ -98,7 +99,8 @@ local function Update(self, event, unit, powerType)
     ppmax = MAX_COMBO_POINTS
     UpdateSplits(self,ppmax)
   else
-    ppcur = UnitPower('player', ClassPowerID, true) or 0
+    -- ppcur = UnitPower('player', ClassPowerID, true) or 0
+    ppcur = GetComboPoints("player", "target") or 0
     ppmax = UnitPowerMax('player', ClassPowerID, true)
     UpdateSplits(self,UnitPowerMax('player', ClassPowerID))
   end
@@ -125,8 +127,9 @@ end
 local function ClassPowerEnable(self)
   self:RegisterEvent('UNIT_POWER_FREQUENT', Path)
   self:RegisterEvent('UNIT_MAXPOWER', Path)
+  self:RegisterEvent('PLAYER_TARGET_CHANGED', Path, true)
   self.rClassBar.isEnabled = true
-  if(UnitHasVehicleUI('player')) then
+  if(UnitHasVehicleUI and UnitHasVehicleUI('player')) then
     Path(self, 'ClassPowerEnable', 'vehicle', 'COMBO_POINTS')
   else
     Path(self, 'ClassPowerEnable', 'player', ClassPowerType)
@@ -136,6 +139,7 @@ end
 local function ClassPowerDisable(self)
   self:UnregisterEvent('UNIT_POWER_FREQUENT', Path)
   self:UnregisterEvent('UNIT_MAXPOWER', Path)
+  self:UnregisterEvent('PLAYER_TARGET_CHANGED', Path)
   self.rClassBar:Hide()
   self.rClassBar.isEnabled = false
   Path(self, 'ClassPowerDisable', 'player', ClassPowerType)
@@ -144,7 +148,7 @@ end
 local function Visibility(self, event, unit)
   local element = self.rClassBar
   local shouldEnable
-  if(UnitHasVehicleUI('player')) then
+  if(UnitHasVehicleUI and UnitHasVehicleUI('player')) then
     shouldEnable = true
     unit = 'vehicle'
   elseif(ClassPowerID) then
@@ -187,10 +191,10 @@ local function Enable(self, unit)
   element.__owner = self
   element.ForceUpdate = ForceUpdate
   if(RequireSpec or RequireSpell) then
-    self:RegisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath, true)
+    -- self:RegisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath, true)
   end
   if(RequirePower) then
-    self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
+    -- self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
   end
   return true
 end
@@ -198,8 +202,8 @@ end
 local function Disable(self)
   if self.rClassBar then
     ClassPowerDisable(self)
-    self:UnregisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath)
-    self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
+    -- self:UnregisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath)
+    -- self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
     self:UnregisterEvent('SPELLS_CHANGED', Visibility)
   end
 end
diff --git a/oUF_Simple/oUF_Simple.toc b/oUF_Simple/oUF_Simple.toc
index 248ed3d..9ea8a53 100644
--- a/oUF_Simple/oUF_Simple.toc
+++ b/oUF_Simple/oUF_Simple.toc
@@ -5,7 +5,7 @@
 ## Dependencies: oUF, rLib, oUF_SimpleConfig

 ## modules\rAbsorbBar.lua
-## modules\rClassBar.lua
+modules\rClassBar.lua
 modules\oUF_DebuffHighlight.lua
 modules\oUF_Swing.lua