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 == 1) 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
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