lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [trunk/] [KragenPlugs/] [Utils/] [Extensions/] [FadeSlot.lua] - Rev 133

Go to most recent revision | Compare with Previous | Blame | View Log


import "Turbine.UI";
import "Turbine.UI.Lotro";

FadeSlot = class( Turbine.UI.Lotro.Quickslot );

function FadeSlot:Constructor()
        Turbine.UI.Lotro.Quickslot.Constructor( self );

        self:SetFadeSpeed( 0.2 );
        self:SetOpacity( 1 );
end

function FadeSlot:SetFadeSpeed( value )
        self.fadeSpeed = 1 / value;
end

function FadeSlot:SetOpacity( value )
        self.realOpacity = value;
        self.currentTime = Turbine.Engine.GetGameTime();
        self.currentOpacity = Turbine.UI.Lotro.Quickslot.GetOpacity( self );
        self.targetOpacity = value;
        
        if (value > 0) then
                if (Turbine.UI.Lotro.Quickslot.GetShortcut( self ) ~= self.realShortcut) then
                        Turbine.UI.Lotro.Quickslot.SetShortcut( self, self.realShortcut );
                end
        end
  
        if ( self.targetOpacity ~= self.currentOpacity ) then
                self:SetWantsUpdates( true );
        end
end

function FadeSlot:Update( sender, args )
        local newOpacity;

        local now = Turbine.Engine.GetGameTime();
        local delta = now - self.currentTime;
        self.currentTime = now;

        delta = delta * self.fadeSpeed;

        if ( self.currentOpacity < self.targetOpacity ) then
                newOpacity = self.currentOpacity + delta;

                if ( newOpacity > self.targetOpacity ) then
                        self:SetWantsUpdates( false )
                        newOpacity = self.targetOpacity
                        if (self.realOpacity == 0 or self.realShortcut == nil) then
                                Turbine.UI.Lotro.Quickslot.SetShortcut( self, Turbine.UI.Lotro.Shortcut( Turbine.UI.Lotro.ShortcutType.Undefined, "" ) );
                        end
                end
        else
                newOpacity = self.currentOpacity - delta;

                if ( newOpacity < self.targetOpacity ) then
                        self:SetWantsUpdates( false )
                        newOpacity = self.targetOpacity;
                        if (self.realOpacity == 0 or self.realShortcut == nil) then
                                Turbine.UI.Lotro.Quickslot.SetShortcut( self, Turbine.UI.Lotro.Shortcut( Turbine.UI.Lotro.ShortcutType.Undefined, "" ) );
                        end
                end
        end

        self.currentOpacity = newOpacity;
        Turbine.UI.Lotro.Quickslot.SetOpacity( self, newOpacity );
end

function FadeSlot:SetShortcut(shortcut)
        self.realShortcut = shortcut;
        if (Turbine.UI.Lotro.Quickslot.GetShortcut( self ) ~= self.realShortcut) then
                Turbine.UI.Lotro.Quickslot.SetShortcut( self, self.realShortcut );
        end
end

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 01:47 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui