I CHANGED ALL THE THINGSSSSSSSS

Sammy James [03-23-14 - 21:19]
I CHANGED ALL THE THINGSSSSSSSS
Filename
PSBT.txt
core/PSBT_Label.lua
core/PSBT_Options.lua
core/PSBT_ScrollArea.lua
core/PSBT_Settings.lua
helpers/PSBT_Parabola.lua
libs/LibAnimation-1.0/LibAnimation.lua
modules/PSBT_Combat.lua
diff --git a/PSBT.txt b/PSBT.txt
index 858d7d6..ae6ad1b 100644
--- a/PSBT.txt
+++ b/PSBT.txt
@@ -15,6 +15,9 @@ core/PSBT_Media.lua
 ## constants
 core/PSBT_Constants.lua

+## helpers
+helpers/PSBT_Parabola.lua
+
 ## core modules
 core/PSBT_Module.lua
 core/PSBT_Settings.lua
diff --git a/core/PSBT_Label.lua b/core/PSBT_Label.lua
index ce0b89c..3e4fea0 100644
--- a/core/PSBT_Label.lua
+++ b/core/PSBT_Label.lua
@@ -60,6 +60,7 @@ function PSBT_Label:Finalize()
     self:SetTexture( 0 )
     self:SetExpire( 0 )
     self:SetMoving( false )
+    self.control:ClearAnchors()
 end

 function PSBT_Label:SetText( text )
diff --git a/core/PSBT_Options.lua b/core/PSBT_Options.lua
index 179e4bd..636b66f 100644
--- a/core/PSBT_Options.lua
+++ b/core/PSBT_Options.lua
@@ -105,8 +105,20 @@ function PSBT_Options:InitializeControlPanel()
             sticky_font:SetFont( self._root:FormatFont( current ) )
         end )

-    -- INCOMMING
+    -- INCOMING
     LAM:AddHeader( self.config_panel, '_psbt_incoming', 'Incoming' )
+
+    LAM:AddSlider( self.config_panel, '_psbt_incoming_arc_slider', 'Arc: ', 'How much should the text curve?',
+        -300, 300, 5,
+        function()
+            return self._root:GetSetting( PSBT_AREAS.INCOMING ).arc
+        end,
+        function( selection )
+            local current = self._root:GetSetting( PSBT_AREAS.INCOMING )
+            current.arc = selection
+            self._root:SetSetting( PSBT_AREAS.INCOMING, current )
+        end )
+
     LAM:AddDropdown( self.config_panel, '_psbt_incoming_iconside_dd', 'Icon Side:', '', iconside,
         function()
             return self._root:GetSetting( PSBT_AREAS.INCOMING ).icon end,
@@ -127,6 +139,18 @@ function PSBT_Options:InitializeControlPanel()

     -- OUTGOING
     LAM:AddHeader( self.config_panel, '_psbt_outgoing', 'Outgoing' )
+
+    LAM:AddSlider( self.config_panel, '_psbt_outgoing_arc_slider', 'Arc: ', 'How much should the text curve?',
+        -300, 300, 5,
+        function()
+            return self._root:GetSetting( PSBT_AREAS.OUTGOING ).arc
+        end,
+        function( selection )
+            local current = self._root:GetSetting( PSBT_AREAS.OUTGOING )
+            current.arc = selection
+            self._root:SetSetting( PSBT_AREAS.OUTGOING, current )
+        end )
+
     LAM:AddDropdown( self.config_panel, '_psbt_outgoing_iconside_dd', 'Icon Side:', '', iconside,
         function()
             return self._root:GetSetting( PSBT_AREAS.OUTGOING ).icon end,
diff --git a/core/PSBT_ScrollArea.lua b/core/PSBT_ScrollArea.lua
index 3e4ce1d..d1ad9bf 100644
--- a/core/PSBT_ScrollArea.lua
+++ b/core/PSBT_ScrollArea.lua
@@ -35,6 +35,8 @@ function PSBT_ScrollArea:Initialize( super, areaName, settings )
     self._direction     = settings.dir
     self._iconSide      = settings.icon

+    self._parabolaPoints = PSBT_Parabola:Calculate( self.control:GetHeight(), settings.arc, 50, self._direction )
+
     self:Position( settings )
     self:SetConfigurationMode( false )
     self.control:SetHandler( 'OnUpdate', function( event, ... ) self:OnUpdate( ... ) end )
@@ -42,6 +44,26 @@ function PSBT_ScrollArea:Initialize( super, areaName, settings )
     CBM:RegisterCallback( PSBT_EVENTS.CONFIG, function( ... ) self:SetConfigurationMode( ... ) end )
 end

+function PSBT_ScrollArea:InitParabolaAnim( control )
+    local anim = LibAnim:New( control )
+
+    local points = self._parabolaPoints
+    local x, y = points[1].x, points[1].y
+    local point = nil
+
+    local duration = 3000 / #points
+
+    for i=1,#points do
+        point = points[ i ]
+        anim:TranslateToFrom( x, y, point.x, point.y, duration, (i - 1) * duration )
+
+        x = point.x
+        y = point.y
+    end
+
+    return anim
+end
+
 function PSBT_ScrollArea:SetConfigurationMode( enable )
     self.control:SetMovable( enable )
     self.control:SetMouseEnabled( enable )
@@ -66,21 +88,17 @@ function PSBT_ScrollArea:GetAnchorOffsets()
     return point, relPoint, offsX, offsY
 end

-function PSBT_ScrollArea:AnchorChild( label, sticky )
-    local relativeTo = CENTER
+function PSBT_ScrollArea:AnchorChild( control, sticky )
+    local rel = CENTER
+    local from = CENTER
     if ( not sticky ) then
-        if ( self._direction == PSBT_SCROLL_DIRECTIONS.UP ) then
-            relativeTo = BOTTOM
-        elseif ( self._direction == PSBT_SCROLL_DIRECTIONS.DOWN ) then
-            relativeTo = TOP
-        end
+        rel = TOP
     end
-
-    label.control:SetAnchor( CENTER, self.control, relativeTo, 0, 0 )
+    control:SetAnchor( from, self.control, rel, 0, 0 )
 end

 function PSBT_ScrollArea:Push( entry, sticky )
-    self:AnchorChild( entry, sticky )
+    self:AnchorChild( entry.control, sticky )

     entry:SetIconPosition( self._iconSide )

@@ -94,6 +112,7 @@ end
 function PSBT_ScrollArea:SetSettings( settings )
     self._iconSide = settings.icon
     self._direction = settings.dir
+    self._parabolaPoints = PSBT_Parabola:Calculate( self.control:GetHeight(), settings.arc, 50, self._direction )
 end

 function PSBT_ScrollArea:OnUpdate( frameTime )
@@ -144,11 +163,7 @@ function PSBT_ScrollArea:OnUpdate( frameTime )
         local newEntry = self._pendingNormal:Pop()
         if ( newEntry ) then
             newEntry:SetExpire( frameTime + 5 )
-
-            newEntry.control:SetScale( 0.5 )
-
             local anim = LibAnim:New( newEntry.control )
-            anim:ScaleTo( 1.0, 200 )
             anim:AlphaTo( 1.0, 200 )
             anim:Play()

@@ -177,9 +192,9 @@ function PSBT_ScrollArea:OnUpdate( frameTime )
     while ( i <= #self._normal ) do
         local entry = self._normal[ i ]

-        if ( entry:WillExpire( frameTime + 3 ) ) then
+        if ( entry:WillExpire( frameTime + 2 ) ) then
             local anim = LibAnim:New( entry.control )
-            anim:AlphaTo( 0.0, 300, nil, nil, ZO_EaseInOutQuadratic )
+            anim:AlphaTo( 0.0, 200, nil, nil, ZO_EaseInOutQuadratic )
             anim:Play()

             entry:SetMoving( false )
@@ -187,17 +202,9 @@ function PSBT_ScrollArea:OnUpdate( frameTime )
             tremove( self._normal, i )
         else
             if ( not entry:IsMoving() ) then
-                local anim = LibAnim:New( entry.control )
-
-                local targetY = 0
-                if ( self._direction == PSBT_SCROLL_DIRECTIONS.UP ) then
-                    targetY = self._height * -1
-                else
-                    targetY = self._height
-                end
-
-
-                anim:TranslateTo( 0, targetY, 3000, nil, nil, ZO_EaseInOutQuadratic )
+                local anim = self:InitParabolaAnim( entry.control )
+                anim:ScaleTo( 1.25, 1500 )
+                anim:ScaleToFrom( 1.25, 1.0, 1500, 1500 )
                 anim:Play()

                 entry:SetMoving( true )
diff --git a/core/PSBT_Settings.lua b/core/PSBT_Settings.lua
index 9e372eb..03bcfe0 100644
--- a/core/PSBT_Settings.lua
+++ b/core/PSBT_Settings.lua
@@ -14,14 +14,14 @@ local RIGHT                  = RIGHT
 local LEFT                   = LEFT
 local CENTER                 = CENTER

-local kVersion               = 2.5
+local kVersion               = 3.0

 local defaults =
 {
     normal_font =
     {
         face = 'Cooline',
-        size = 14,
+        size = 14,
         deco = 'shadow'
     },

@@ -39,7 +39,8 @@ local defaults =
         x       = -300,
         y       = 150,
         icon    = PSBT_ICON_SIDE.LEFT,
-        dir     = PSBT_SCROLL_DIRECTIONS.UP
+        dir     = PSBT_SCROLL_DIRECTIONS.UP,
+        arc     = 150
     },

     [ PSBT_AREAS.OUTGOING ] =
@@ -49,7 +50,8 @@ local defaults =
         x       = 300,
         y       = 150,
         icon    = PSBT_ICON_SIDE.LEFT,
-        dir     = PSBT_SCROLL_DIRECTIONS.DOWN
+        dir     = PSBT_SCROLL_DIRECTIONS.DOWN,
+        arc     = -150
     },

     [ PSBT_AREAS.STATIC ] =
@@ -59,7 +61,8 @@ local defaults =
         x       = 0,
         y       = -300,
         icon    = PSBT_ICON_SIDE.LEFT,
-        dir     = PSBT_SCROLL_DIRECTIONS.DOWN
+        dir     = PSBT_SCROLL_DIRECTIONS.DOWN,
+        arc     = 0
     },

     [ PSBT_AREAS.NOTIFICATION ] =
@@ -69,7 +72,8 @@ local defaults =
         x       = 0,
         y       = 450,
         icon    = PSBT_ICON_SIDE.LEFT,
-        dir     = PSBT_SCROLL_DIRECTIONS.UP
+        dir     = PSBT_SCROLL_DIRECTIONS.UP,
+        arc     = 0
     }
 }

diff --git a/helpers/PSBT_Parabola.lua b/helpers/PSBT_Parabola.lua
new file mode 100644
index 0000000..a0365ee
--- /dev/null
+++ b/helpers/PSBT_Parabola.lua
@@ -0,0 +1,33 @@
+PSBT_Parabola = {}
+
+local PSBT_SCROLL_DIRECTIONS = PSBT_SCROLL_DIRECTIONS
+
+local function _DOWN( height, progress )
+    return height * progress
+end
+
+local function _UP( height, progress )
+    return height - _DOWN( height, progress )
+end
+
+function PSBT_Parabola:Calculate( height, width, points, direction )
+        local result = {}
+        local midpoint = height * 0.5
+        local fourA = ( midpoint * midpoint ) / width
+        local fn = nil
+        if ( direction == PSBT_SCROLL_DIRECTIONS.UP ) then
+            fn = _UP
+        else
+            fn = _DOWN
+        end
+
+        for i=1,points do
+                result[ i ] = { x = 0, y = 0 }
+                result[ i ].y = fn( height, i / points )
+
+                local y = result[ i ].y - midpoint
+                result[ i ].x = ( y * y ) / fourA
+        end
+
+        return result
+end
diff --git a/libs/LibAnimation-1.0/LibAnimation.lua b/libs/LibAnimation-1.0/LibAnimation.lua
index 364c62f..dd2d5c9 100644
--- a/libs/LibAnimation-1.0/LibAnimation.lua
+++ b/libs/LibAnimation-1.0/LibAnimation.lua
@@ -30,12 +30,18 @@ THE SOFTWARE.
 ----------------------------------------------------
 if ( not LibStub ) then return end

-local kName, kVersion = 'LibAnimation-1.0', 1.1
+local kName, kVersion = 'LibAnimation-1.0', 2.0
 local LibAnimation = LibStub:NewLibrary( kName, kVersion )
 if ( not LibAnimation ) then return end

-local AnimationMgr = ANIMATION_MANAGER
-local defaultEase = ZO_LinearEase
+local AnimationMgr          = ANIMATION_MANAGER
+local defaultEase           = ZO_LinearEase
+
+local ANIMATION_SIZE        = ANIMATION_SIZE
+local ANIMATION_TRANSLATE   = ANIMATION_TRANSLATE
+local ANIMATION_SCALE       = ANIMATION_SCALE
+local ANIMATION_ALPHA       = ANIMATION_ALPHA
+local _

 --- Create a new animation for control
 -- @tparam table control the gui element to animate
@@ -107,30 +113,60 @@ end
 -- @tparam number animType
 -- @tparam number delay (optional)
 -- @tresult animation
-function LibAnimation:Insert( animType, delay )
-    return self.timeline:InsertAnimation( animType, self.control, delay or 0 )
+function LibAnimation:Insert( animType, duration, delay, anchorIndex, fn )
+    local anim = self.timeline:InsertAnimation( animType, self.control, delay or 0 )
+    anim:SetDuration( duration or 1 )
+    anim:SetEasingFunction( fn or defaultEase )
+
+    if ( animType == ANIMATION_TRANSLATE ) then
+        anim:SetAnchorIndex( anchorIndex or 0 )
+    end
+    return anim
 end

 --- Create new translate animation
+-- @tparam number xorigin
+-- @tparam number yorigin
 -- @tparam number xoffset
 -- @tparam number yoffset
 -- @tparam number duration
 -- @tparam number delay (optional)
 -- @tparam number anchorIndex (optional)
 -- @tparam function fn easing function (optional)
-function LibAnimation:TranslateTo( xoffset, yoffset, duration, delay, anchorIndex, fn )
+function LibAnimation:TranslateToFrom( xorigin, yorigin, xoffset, yoffset, duration, delay, anchorIndex, fn )
     self:Stop()
+    local anim = self:Insert( ANIMATION_TRANSLATE, duration, delay, anchorIndex, fn )
+    anim:SetStartOffsetX( xorigin )
+    anim:SetStartOffsetY( yorigin )
+    anim:SetEndOffsetX( xoffset )
+    anim:SetEndOffsetY( yoffset )
+end

-    local anim = self:Insert( ANIMATION_TRANSLATE, delay )
+--- Create new translate animation
+-- @tparam number xoffset
+-- @tparam number yoffset
+-- @tparam number duration
+-- @tparam number delay (optional)
+-- @tparam number anchorIndex (optional)
+-- @tparam function fn easing function (optional)
+function LibAnimation:TranslateTo( xoffset, yoffset, duration, delay, anchorIndex, fn )
     local _, _, _, _, offsX, offsY = self.control:GetAnchor( anchorIndex or 0 )
+    self:TranslateToFrom( offsX, offsY, xoffset, yoffset, duration, delay, anchorIndex, fn )
+end

-    anim:SetDuration( duration or 1 )
-    anim:SetEasingFunction( fn or defaultEase )
-    anim:SetStartOffsetX( offsX )
-    anim:SetStartOffsetY( offsY )
-    anim:SetEndOffsetX( xoffset )
-    anim:SetEndOffsetY( yoffset )
-    anim:SetAnchorIndex( anchorIndex or 0 )
+--- Create a new size animation
+-- @tparam number startWidth
+-- @tparam number startHeight
+-- @tparam number width target width
+-- @tparam number height target height
+-- @tparam number duration
+-- @tparam number delay (optional)
+-- @tparam function fn easing function (optional)
+function LibAnimation:ResizeToFrom( startWidth, startHeight, width, height, duration, delay, fn )
+    self:Stop()
+    local anim = self:Insert( ANIMATION_SIZE, duration, delay, nil, fn )
+    anim:SetHeightStartAndEnd( startHeight, height )
+    anim:SetWidthStartAndEnd( startWidth, width )
 end

 --- Create a new size animation
@@ -140,14 +176,20 @@ end
 -- @tparam number delay (optional)
 -- @tparam function fn easing function (optional)
 function LibAnimation:ResizeTo( width, height, duration, delay, fn )
-    self:Stop()
+    self:ResizeToFrom( self.control:GetWidth(), self.control:GetHeight(), width, height, duration, delay, fn )
+end

-    local anim = self:Insert( ANIMATION_SIZE, delay )

-    anim:SetDuration( duration or 1 )
-    anim:SetEasingFunction( fn or defaultEase )
-    anim:SetHeightStartAndEnd( self.control:GetHeight(), height )
-    anim:SetWidthStartAndEnd( self.control:GetWidth(), width )
+--- Create a new scale animation
+-- @tparam number startScale
+-- @tparam number scale
+-- @tparam number duration
+-- @tparam number delay (optional)
+-- @tparam function fn easing function (optional)
+function LibAnimation:ScaleToFrom( startScale, scale, duration, delay, fn )
+    self:Stop()
+    local anim = self:Insert( ANIMATION_SCALE, duration, delay, nil, fn )
+    anim:SetScaleValues( startScale, scale )
 end

 --- Create a new scale animation
@@ -156,13 +198,14 @@ end
 -- @tparam number delay (optional)
 -- @tparam function fn easing function (optional)
 function LibAnimation:ScaleTo( scale, duration, delay, fn )
-    self:Stop()
+    self:ScaleToFrom( self.control:GetScale(), scale, duration, delay, fn )
+end

-    local anim = self:Insert( ANIMATION_SCALE, delay )

-    anim:SetDuration( duration or 1 )
-    anim:SetEasingFunction( fn or defaultEase )
-    anim:SetScaleValues( self.control:GetScale(), scale )
+function LibAnimation:AlphaToFrom( startAlpha, alpha, duration, delay, fn )
+    self:Stop()
+    local anim = self:Insert( ANIMATION_ALPHA, duration, delay, nil, fn )
+    anim:SetAlphaValues( startAlpha, alpha )
 end

 --- Create a new alpha animation
@@ -171,13 +214,7 @@ end
 -- @tparam number delay (optional)
 -- @tparam function fn easing function (optional)
 function LibAnimation:AlphaTo( alpha, duration, delay, fn )
-    self:Stop()
-
-    local anim = self:Insert( ANIMATION_ALPHA, delay )
-
-    anim:SetDuration( duration or 1 )
-    anim:SetEasingFunction( fn or defaultEase )
-    anim:SetAlphaValues( self.control:GetAlpha(), alpha )
+    self:AlphaToFrom( self.control:GetAlpha(), alpha, duration, delay, fn )
 end

 --- Create a new scroll animation
diff --git a/modules/PSBT_Combat.lua b/modules/PSBT_Combat.lua
index 1b77899..2abe480 100644
--- a/modules/PSBT_Combat.lua
+++ b/modules/PSBT_Combat.lua
@@ -78,7 +78,7 @@ local combat_events =
         return zo_strformat( 'Blocked <<1>>', hitValue ), area, false
     end,
     [ ACTION_RESULT_CANT_SEE_TARGET ] = function( ... )
-        return 'Can\'t See Target!', PSBT_AREAS.STATIC, false
+        return 'Can\'t See Target!', PSBT_AREAS.STATIC, true
     end,
     [ ACTION_RESULT_CRITICAL_DAMAGE ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue, damageType )
         local area = nil