disabled stamina drain

Pawkette [03-31-14 - 21:11]
disabled stamina drain
added font coloring options
Filename
core/PSBT.lua
core/PSBT_Constants.lua
core/PSBT_Label.lua
core/PSBT_Module.lua
core/PSBT_Options.lua
core/PSBT_Settings.lua
modules/PSBT_Combat.lua
diff --git a/core/PSBT.lua b/core/PSBT.lua
index a17542b..1ef1236 100644
--- a/core/PSBT.lua
+++ b/core/PSBT.lua
@@ -222,13 +222,17 @@ function PSBT:UnregisterForEvent( event, callback )
     end
 end

-function PSBT:NewEvent( scrollArea, sticky, icon, text )
+function PSBT:NewEvent( scrollArea, sticky, icon, text, color )
     local entry = self:AcquireObject()
     local area = self._areas[ scrollArea ]
     if ( not area ) then
         return
     end

+    if ( not color ) then
+        color = self:GetSetting( PSBT_SETTINGS.normal_color )
+    end
+
     if ( sticky ) then
         entry.label:SetFont( self:FormatFont( self:GetSetting( PSBT_SETTINGS.sticky_font ) ) )
         entry.control:SetDrawTier( DT_HIGH )
@@ -240,6 +244,7 @@ function PSBT:NewEvent( scrollArea, sticky, icon, text )
     entry:SetExpire( -1 )
     entry:SetText( text )
     entry:SetTexture( icon )
+    entry:SetColor( color )

     area:Push( entry, sticky, direction )
 end
diff --git a/core/PSBT_Constants.lua b/core/PSBT_Constants.lua
index bc46244..4dd0de4 100644
--- a/core/PSBT_Constants.lua
+++ b/core/PSBT_Constants.lua
@@ -21,7 +21,10 @@ PSBT_AREAS =
 PSBT_SETTINGS =
 {
     normal_font         = 'normal_font',
-    sticky_font         = 'sticky_font'
+    sticky_font         = 'sticky_font',
+    damage_color        = 'damage_color',
+    healing_color       = 'healing_color',
+    normal_color        = 'normal_color'
 }

 PSBT_EVENTS =
diff --git a/core/PSBT_Label.lua b/core/PSBT_Label.lua
index f76e47e..5f813e4 100644
--- a/core/PSBT_Label.lua
+++ b/core/PSBT_Label.lua
@@ -3,6 +3,7 @@ PSBT_Label = ZO_Object:Subclass()
 local CENTER = CENTER
 local PSBT_SCROLL_DIRECTIONS = PSBT_SCROLL_DIRECTIONS
 local PSBT_ICON_SIDE = PSBT_ICON_SIDE
+local unpack = unpack

 function PSBT_Label:New( ... )
     local result = ZO_Object.New( self )
@@ -66,6 +67,10 @@ function PSBT_Label:SetText( text )
     self.label:SetText( text )
 end

+function PSBT_Label:SetColor( color )
+    self.label:SetColor( unpack( color ) )
+end
+
 function PSBT_Label:SetIconPosition( side )
     self.iconPos = side

diff --git a/core/PSBT_Module.lua b/core/PSBT_Module.lua
index 20feaa5..8177043 100644
--- a/core/PSBT_Module.lua
+++ b/core/PSBT_Module.lua
@@ -24,6 +24,6 @@ function PSBT_Module:OnUpdate( frametime )
     -- stub, implement if needed
 end

-function PSBT_Module:NewEvent( scrollArea, sticky, icon, text )
-    self._root:NewEvent( scrollArea, sticky, icon, text )
+function PSBT_Module:NewEvent( scrollArea, sticky, icon, text, color )
+    self._root:NewEvent( scrollArea, sticky, icon, text, color )
 end
\ No newline at end of file
diff --git a/core/PSBT_Options.lua b/core/PSBT_Options.lua
index 636b66f..bdddcd7 100644
--- a/core/PSBT_Options.lua
+++ b/core/PSBT_Options.lua
@@ -35,6 +35,25 @@ function PSBT_Options:InitializeControlPanel()
             self.config_mode = not self.config_mode
         end )

+    LAM:AddHeader( self.config_panel, '_psbt_font_colors', 'Colors' )
+    LAM:AddColorPicker( self.config_panel, '_psbt_font_colors_healing', 'Healing:', '',
+        function() return unpack( self._root:GetSetting( PSBT_SETTINGS.healing_color ) ) end,
+        function( r, g, b, a )
+            self._root:SetSetting( PSBT_SETTINGS.healing_color, { r,g,b,a } )
+        end )
+
+    LAM:AddColorPicker( self.config_panel, '_psbt_font_colors_damage', 'Damage:', '',
+        function() return unpack( self._root:GetSetting( PSBT_SETTINGS.damage_color ) ) end,
+        function( r, g, b, a )
+            self._root:SetSetting( PSBT_SETTINGS.damage_color, { r,g,b,a } )
+        end )
+
+    LAM:AddColorPicker( self.config_panel, '_psbt_font_colors_normal', 'Normal:', '',
+        function() return unpack( self._root:GetSetting( PSBT_SETTINGS.normal_color ) ) end,
+        function( r, g, b, a )
+            self._root:SetSetting( PSBT_SETTINGS.normal_color, { r,g,b,a } )
+        end )
+
     -- normal font
     local normal_font = LAM:AddHeader( self.config_panel, '_psbt_normal_font_header', 'Normal Font' ):GetNamedChild( 'Label' )
     normal_font:SetFont( self._root:FormatFont( self._root:GetSetting( PSBT_SETTINGS.normal_font ) ) )
diff --git a/core/PSBT_Settings.lua b/core/PSBT_Settings.lua
index 03bcfe0..028e446 100644
--- a/core/PSBT_Settings.lua
+++ b/core/PSBT_Settings.lua
@@ -14,7 +14,7 @@ local RIGHT                  = RIGHT
 local LEFT                   = LEFT
 local CENTER                 = CENTER

-local kVersion               = 3.0
+local kVersion               = 3.1

 local defaults =
 {
@@ -32,6 +32,21 @@ local defaults =
         deco = 'shadow'
     },

+    damage_color =
+    {
+        255, 255, 255, 1
+    },
+
+    healing_color =
+    {
+        255, 255, 255, 1
+    },
+
+    normal_color =
+    {
+        255, 255, 255, 1
+    },
+
     [ PSBT_AREAS.INCOMING ] =
     {
         to      = RIGHT,
diff --git a/modules/PSBT_Combat.lua b/modules/PSBT_Combat.lua
index 7c3c62f..6d79bc0 100644
--- a/modules/PSBT_Combat.lua
+++ b/modules/PSBT_Combat.lua
@@ -50,7 +50,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Absorbed <<1>>', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Absorbed <<1>>', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_BLADETURN ] = function( combatEvent )
         local area = nil
@@ -60,7 +60,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Blocked <<1>>', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Blocked <<1>>', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_BLOCKED ] = function( combatEvent )
         local area = nil
@@ -70,7 +70,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Blocked <<1>>', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Blocked <<1>>', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_BLOCKED_DAMAGE ] = function( combatEvent )
         local area = nil
@@ -80,7 +80,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Blocked <<1>>', combatEvent.hitValue ), area, false
+        return zo_strformat( 'Blocked <<1>>', combatEvent.hitValue ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_CANT_SEE_TARGET ] = function( combatEvent )
         return 'Can\'t See Target!', PSBT_AREAS.STATIC, true
@@ -93,7 +93,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( '<<1>>!', combatEvent.hitValue ), area, true
+        return zo_strformat( '<<1>>!', combatEvent.hitValue ), area, true, PSBT_SETTINGS.damage_color
     end,
     [ ACTION_RESULT_CRITICAL_HEAL ] = function( combatEvent )
         local area = nil
@@ -103,7 +103,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( '+<<1>>!', combatEvent.hitValue ), area, true
+        return zo_strformat( '+<<1>>!', combatEvent.hitValue ), area, true, PSBT_SETTINGS.healing_color
     end,
     [ ACTION_RESULT_DAMAGE ] = function( combatEvent )
         local area = nil
@@ -115,7 +115,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( format, combatEvent.hitValue ), area, false
+        return zo_strformat( format, combatEvent.hitValue ), area, false, PSBT_SETTINGS.damage_color
     end,
     [ ACTION_RESULT_DAMAGE_SHIELDED ] = function( combatEvent )
         local area = nil
@@ -125,7 +125,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Shielded <<1>>', combatEvent.hitValue ), area, false
+        return zo_strformat( 'Shielded <<1>>', combatEvent.hitValue ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_DEFENDED ] = function( combatEvent )
         local area = nil
@@ -135,7 +135,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Defended <<1>>', combatEvent.hitValue ), area, false
+        return zo_strformat( 'Defended <<1>>', combatEvent.hitValue ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_DOT_TICK ] = function( combatEvent )
         local area = nil
@@ -147,7 +147,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( format, combatEvent.hitValue ), area, false
+        return zo_strformat( format, combatEvent.hitValue ), area, false, PSBT_SETTINGS.damage_color
     end,
     [ ACTION_RESULT_DOT_TICK_CRITICAL ] = function( combatEvent )
         local area = nil
@@ -159,7 +159,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( format, combatEvent.hitValue ), area, true
+        return zo_strformat( format, combatEvent.hitValue ), area, true, PSBT_SETTINGS.damage_color
     end,
     [ ACTION_RESULT_HEAL ] = function( combatEvent )
         local area = nil
@@ -169,7 +169,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( '+<<1>>' , combatEvent.hitValue ), area, false
+        return zo_strformat( '+<<1>>' , combatEvent.hitValue ), area, false, PSBT_SETTINGS.healing_color
     end,
     [ ACTION_RESULT_HOT_TICK ] = function( combatEvent )
         local area = nil
@@ -179,7 +179,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( '+<<1>>', combatEvent.hitValue ), area, false
+        return zo_strformat( '+<<1>>', combatEvent.hitValue ), area, false, PSBT_SETTINGS.healing_color
     end,
     [ ACTION_RESULT_HOT_TICK_CRITICAL ] = function( combatEvent )
         local area = nil
@@ -189,7 +189,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( '+<<1>>!', combatEvent.hitValue ), area, true
+        return zo_strformat( '+<<1>>!', combatEvent.hitValue ), area, true, PSBT_SETTINGS.healing_color
     end,
     [ ACTION_RESULT_DODGED ] = function( combatEvent )
         local area = nil
@@ -199,7 +199,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Dodged <<1>>', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Dodged <<1>>', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_MISS ] = function( combatEvent )
         local area = nil
@@ -209,7 +209,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return 'Miss!', area, false
+        return 'Miss!', area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_PARRIED ] = function( combatEvent )
         local area = nil
@@ -219,7 +219,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Parried <<1>>!', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Parried <<1>>!', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_RESIST ] = function( combatEvent )
         local area = nil
@@ -229,7 +229,7 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Resisted <<1>>!', combatEvent.abilityName ), area, false
+        return zo_strformat( 'Resisted <<1>>!', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_PARTIAL_RESIST ] = function( combatEvent )
         local area = nil
@@ -239,93 +239,93 @@ local combat_events =
             area = PSBT_AREAS.OUTGOING
         end

-        return zo_strformat( 'Partially Resisted <<1>>!', combatEvent.abilityName ), nil, false
+        return zo_strformat( 'Partially Resisted <<1>>!', combatEvent.abilityName ), area, false, PSBT_SETTINGS.normal_color
     end,
     [ ACTION_RESULT_FALL_DAMAGE ] = function( combatEvent )
         local area = nil
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
             area = PSBT_AREAS.INCOMING
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return nil, nil, false
+            return nil, nil, false, PSBT_SETTINGS.normal_color
         end

-        return zo_strformat( '-<<1>> falling', combatEvent.hitValue ), area, false
+        return zo_strformat( '-<<1>> falling', combatEvent.hitValue ), area, false, PSBT_SETTINGS.damage_color
     end,
     [ ACTION_RESULT_KILLING_BLOW ] = function( combatEvent )
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
             return 'Looks like you\'re dead.', PSBT_AREAS.STATIC, true
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return zo_strformat( 'Killing Blow |cCC7D5E<<1>>|r!', combatEvent.targetName ), PSBT_AREAS.STATIC, true
+            return zo_strformat( 'Killing Blow |cCC7D5E<<1>>|r!', combatEvent.targetName ), PSBT_AREAS.STATIC, true, PSBT_SETTINGS.normal_color
         end

         return nil, nil, false
     end,

-    [ ACTION_RESULT_POWER_DRAIN ] = function( combatEvent )
+    --[[[ ACTION_RESULT_POWER_DRAIN ] = function( combatEvent )
         local mechanicName = GetString( 'SI_COMBATMECHANICTYPE', combatEvent.powerType )
-        return zo_strformat( '-<<1>> (<<2>>)', combatEvent.hitValue, mechanicName ), PSBT_AREAS.OUTGOING, false
-    end,
+        return zo_strformat( '-<<1>> (<<2>>)', combatEvent.hitValue, mechanicName ), PSBT_AREAS.INCOMING, false, PSBT_SETTINGS.normal_color
+    end,]]

     [ ACTION_RESULT_POWER_ENERGIZE ] = function( combatEvent )
         local mechanicName = GetString( 'SI_COMBATMECHANICTYPE', combatEvent.powerType )
-        return zo_strformat( '+<<1>> (<<2>>)', combatEvent.hitValue, mechanicName ), PSBT_AREAS.INCOMING, false
+        return zo_strformat( '+<<1>> (<<2>>)', combatEvent.hitValue, mechanicName ), PSBT_AREAS.INCOMING, false, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_CANNOT_USE ] = function( combatEvent )
-        return 'Cannot Use', PSBT_AREAS.STATIC, true
+        return 'Cannot Use', PSBT_AREAS.STATIC, true, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_BUSY ] = function( combatEvent)
-        return 'Busy', PSBT_AREAS.STATIC, true
+        return 'Busy', PSBT_AREAS.STATIC, true, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_FALLING ] = function( combatEvent )
-        return 'You\'re falling', PSBT_AREAS.STATIC, true
+        return 'You\'re falling', PSBT_AREAS.STATIC, true, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_DISORIENTED ] = function( combatEvent )
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
-            return 'Disoriented!', PSBT_AREAS.INCOMING, true
+            return 'Disoriented!', PSBT_AREAS.INCOMING, true, PSBT_SETTINGS.normal_color
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return 'Disoriented!', PSBT_AREAS.OUTGOING, true
+            return 'Disoriented!', PSBT_AREAS.OUTGOING, true, PSBT_SETTINGS.normal_color
         end
-        return nil, nil, false
+        return nil, nil, false, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_DISARMED ] = function( combatEvent )
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
-            return 'Disarmed!', PSBT_AREAS.OUTGOING, true
+            return 'Disarmed!', PSBT_AREAS.OUTGOING, true, PSBT_SETTINGS.normal_color
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return 'Disarmed!', PSBT_AREAS.INCOMING, true
+            return 'Disarmed!', PSBT_AREAS.INCOMING, true, PSBT_SETTINGS.normal_color
         end
-        return nil, nil, false
+        return nil, nil, false, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_FEARED ] = function( combatEvent )
          if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
-            return 'Feared!', PSBT_AREAS.INCOMING, true
+            return 'Feared!', PSBT_AREAS.INCOMING, true, PSBT_SETTINGS.normal_color
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return 'Feared!', PSBT_AREAS.OUTGOING, true
+            return 'Feared!', PSBT_AREAS.OUTGOING, true, PSBT_SETTINGS.normal_color
         end
-        return nil, nil, false
+        return nil, nil, false, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_IMMUNE ] = function( combatEvent )
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
-            return 'Immune!', PSBT_AREAS.INCOMING, true
+            return 'Immune!', PSBT_AREAS.INCOMING, true, PSBT_SETTINGS.normal_color
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return 'Immune!', PSBT_AREAS.OUTGOING, true
+            return 'Immune!', PSBT_AREAS.OUTGOING, true, PSBT_SETTINGS.normal_color
         end
-        return nil, nil, false
+        return nil, nil, false, PSBT_SETTINGS.normal_color
     end,

     [ ACTION_RESULT_INTERRUPT ] = function( combatEvent )
         if ( IsPlayer( combatEvent.targetType, combatEvent.targetName ) ) then
-            return 'Interrupt!', PSBT_AREAS.INCOMING, true
+            return 'Interrupt!', PSBT_AREAS.INCOMING, true, PSBT_SETTINGS.normal_color
         elseif ( IsPlayer( combatEvent.sourceType, combatEvent.sourceName ) ) then
-            return 'Interrupt!', PSBT_AREAS.OUTGOING, true
+            return 'Interrupt!', PSBT_AREAS.OUTGOING, true, PSBT_SETTINGS.normal_color
         end
-        return nil, nil, false
+        return nil, nil, false, PSBT_SETTINGS.normal_color
     end,

     --ACTION_RESULT_BEGIN
@@ -520,10 +520,10 @@ end
 --integer result, bool isError, string abilityName, integer abilityGraphic, integer abilityActionSlotType, string sourceName, integer sourceType, string targetName, integer targetType, integer hitValue, integer powerType, integer damageType, bool log
 function PSBT_Combat:DispatchEvent( result, combatEvent )
     local func = combat_events[ result ]
-    local text, area, crit = func( combatEvent )
+    local text, area, crit, color = func( combatEvent )

     local icon = self._iconRegistry[ combatEvent.abilityName ]
-    self:NewEvent( area, crit, icon, text )
+    self:NewEvent( area, crit, icon, text, self._root:GetSetting( color ) )
 end

 CBM:RegisterCallback( PSBT_EVENTS.LOADED,