lotrointerface.com
Search Downloads

LoTROInterface SVN SequenceBars

[/] [trunk/] [Thurallor/] [Common/] [UI/] [Marquee/] [Marquee.lua] - Rev 20

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

Marquee = class(Turbine.UI.Control);

local importPath = getfenv(1)._.Name;
local imagePath = string.gsub(string.gsub(importPath, "%.Marquee$", ""), "%.", "/");

function Marquee:Constructor()
        self.antsOffset = 0;
        self.maxAntsOffset = 7;
        self.antsMoveDelay = 0.1; -- 0.1-second delay = 10 updates per second

    Turbine.UI.Control.Constructor(self);

        self.leftBorder = Turbine.UI.Control();
        self.leftBorder:SetParent(self);
        self.leftBorder:SetBackground(imagePath .. "/ants_vertical.tga");

        self.topBorder = Turbine.UI.Control();
        self.topBorder:SetParent(self);
        self.topBorder:SetBackground(imagePath .. "/ants_horizontal.tga");
        
        self.rightBorder = Turbine.UI.Control();
        self.rightBorder:SetParent(self);
        self.rightBorder:SetBackground(imagePath .. "/ants_vertical.tga");
        
        self.bottomBorder = Turbine.UI.Control();
        self.bottomBorder:SetParent(self);
        self.bottomBorder:SetBackground(imagePath .. "/ants_horizontal.tga");

        self.lastAntsMoveTime = Turbine.Engine.GetGameTime();
end

function Marquee:Update()
        -- Make sure enough time has elapsed since the ants moved last.
        local currentTime = Turbine.Engine.GetGameTime();
        if (currentTime - self.lastAntsMoveTime < self.antsMoveDelay) then
                return;
    end
        self.lastAntsMoveTime = currentTime;

        -- Move the ants by one pixel.
        self.antsOffset = self.antsOffset + 1;
        if (self.antsOffset > self.maxAntsOffset) then
                self.antsOffset = 0;
    end

        -- Move ants to new position.
        self.leftBorder:SetTop(self.antsOffset - self.maxAntsOffset);
        self.topBorder:SetLeft(-self.antsOffset);
        self.rightBorder:SetTop(-self.antsOffset);
        self.bottomBorder:SetLeft(self.antsOffset - self.maxAntsOffset);
end

function Marquee:SetColor(color)
    self.leftBorder:SetBackColor(color);
    self.leftBorder:SetBackColorBlendMode(Turbine.UI.BlendMode.Color);
    self.topBorder:SetBackColor(color);
    self.topBorder:SetBackColorBlendMode(Turbine.UI.BlendMode.Color);
    self.rightBorder:SetBackColor(color);
    self.rightBorder:SetBackColorBlendMode(Turbine.UI.BlendMode.Color);
    self.bottomBorder:SetBackColor(color);
    self.bottomBorder:SetBackColorBlendMode(Turbine.UI.BlendMode.Color);
end

function Marquee:SetSize(width, height)
        self:SetWidth(width);
        self:SetHeight(height);
end

function Marquee:SetWidth(width)
        Turbine.UI.Control.SetWidth(self, width);
        self.topBorder:SetSize(width + self.maxAntsOffset, 1);
        self.bottomBorder:SetSize(width + self.maxAntsOffset, 1);
        self.rightBorder:SetLeft(width - 1);
end

function Marquee:SetHeight(height)
        Turbine.UI.Control.SetHeight(self, height);
        self.leftBorder:SetSize(1, height + self.maxAntsOffset);
        self.rightBorder:SetSize(1, height + self.maxAntsOffset);
        self.bottomBorder:SetTop(height - 1);
end

function Marquee:SetParent(parent)
    if (parent) then
        self:SetWantsUpdates(true);
    else
        self:SetWantsUpdates(false);
    end
    Turbine.UI.Control.SetParent(self, parent);
end

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 10:25 PM.


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