lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [trunk/] [KragenPlugs/] [KragenBars/] [SkillBar.lua] - Rev 133

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

import "Turbine.UI";
import "Turbine.UI.Lotro";
import "KragenPlugs.Utils";
import "KragenPlugs.Utils.Extensions";
import "KragenPlugs.KragenBars";

SkillBar = class ( KragenPlugs.Utils.Extensions.SimpleWindow );

function SkillBar:Constructor ( parent, x, y, width, height, active, exclusive )
        KragenPlugs.Utils.Extensions.SimpleWindow.Constructor( self );
        
        -- declare variables
        self.parent         = parent;
    self.x              = x;
        self.y              = y;
        self.width                      = width;
        self.height         = height;
        self.exclusive      = exclusive;
        self.state          = false;
        self.effectid       = 0;
        self.skilllist = {};
        self.totalskills = 0;

    -- set properties
        self:SetParent( parent );
        self:SetVisible(true);
        self:SetPosition( (x - 1) * 35, (y - 1) * 35 );
        self:SetSize( width * 35, height * 35 );
        
        self.blankslot = {};
        local c = 1;
        for h = 1, height do
                for w = 1, width do
                        self.blankslot[c] = BlankSlot(self, w, h);
                        c = c + 1;
                end
        end

        if (parent.rotate) then
                self:RotateBar();
        end
end

-- SET STATE (To be used to track the effect state of buffs/debuffs)
function SkillBar:SetState( state, id )
        -- update state and effect id
        if ( state ) then
                self.state = true;
                self.effectid = id;
        else
                if ( id == self.effectid ) then
                    self.state = false;
                        self.effectid = 0;
                end

        end
end

-- ROTATE BAR
function SkillBar:RotateBar()
        local newwidth = self.height;
        local newheight = self.width;
        self:SetSize( newwidth * 35, newheight * 35 );
        
        self.width = newwidth;
        self.height = newheight;
        
        local newx = self.y;
        local newy = self.x;
        
        self:SetPosition( (newx - 1) * 35, (newy - 1) * 35 );
        self.x = newx;
        self.y = newy;
        
        for k,v in pairs(self.blankslot) do
                v:Rotate();
        end
end

function SkillBar:ChangeSize(width, height)
        self:SetSize( width * 35, height * 35 );
        
        for k,v in pairs(self.blankslot) do
                v:SetVisible(false);
        end
        
        local c = 1;
        for h = 1, height do
                for w = 1, width do
                        if (self.blankslot[c] ~= nil) then
                                self.blankslot[c]:Move(w, h);
                                self.blankslot[c]:SetVisible(true);
                        else
                                self.blankslot[c] = BlankSlot(self, w, h);
                        end
                        c = c + 1;
                end
        end
        
        for k,v in pairs(self.skilllist) do
                if (v.x > width or v.y > height) then
                        for key,val in pairs(self.skilllist) do
                                if (val == v) then
                                        val = nil;
                                end
                        end
                        v:SetParent(limbo);
                        v.parent = nil;
                end
        end
        
        self.parent:ChangeSize(width, height);
end

function SkillBar:AddSkill(ref, x, y)
        self.totalskills = self.totalskills + 1;
        self.skilllist[self.totalskills] = ref;
end

function SkillBar:ChangeSkill(ref, new)
        for k,v in pairs(self.skilllist) do
                if (v == ref) then
                        self.skilllist[k] = new;
                end
        end
end

-- REFRESH COMBAT (Refresh Visibility for combat changes)
function SkillBar:RefreshCombat()
        if ( ( vars.player:IsInCombat() and self.parent.incombat ) or ( not vars.player:IsInCombat() and self.parent.outcombat ) or self.parent.edit ) then
                self:SetVisible(true);
        else
                self:SetVisible(false);
        end
end

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 02:26 AM.


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