Compare with Previous |
Blame |
View Log
import "Turbine.UI";
import "Turbine.UI.Lotro";
import "KragenPlugs.Utils";
import "KragenPlugs.Utils.UI";
import "KragenPlugs.KragenBars";
SkillWindow = class ( Turbine.UI.Window )
function SkillWindow:Constructor ( properties )
Turbine.UI.Window.Constructor( self );
-- display width/height for default positioning
local displayWidth = Turbine.UI.Display:GetWidth();
local displayHeight = Turbine.UI.Display:GetHeight();
-- declar variables
self.heading = properties.name;
self.x = ((properties.defpos[1] - 1) * 35) + ((displayWidth / 2) - (35 * 6)) + 20;
self.y = (displayHeight - 70) - (5 * 35) + ((properties.defpos[2] - 1) * 35);
self.width = properties.size[1];
self.height = properties.size[2];
self.active = properties.active;
self.defx = properties.defpos[1];
self.defy = properties.defpos[2];
self.incombat = properties.combat[1];
self.outcombat = properties.combat[2];
self.edit = false;
if (properties.rotate ~= nil) then
self.rotate = properties.rotate;
else
self.rotate = false;
end
-- set x and y if they arn't the defaults
if (properties.pos[1] ~= 0 and properties.pos[2] ~= 0) then
self.x = properties.pos[1];
self.y = properties.pos[2];
end
-- set properties
self:SetSize( self.width * 35, self.height * 35 );
self:SetPosition(ValidatePosition(self.x, self.y, self.width*35, self.height*35));
self:SetVisible(true);
-- DRAGBAR
-- attach dragbar class to window
self.dragBar = KragenPlugs.Utils.UI.DragBar( self, self.heading );
self.dragBar:SetRotator(true);
self.dragBar:SetRotatorOffset(3, 23);
-- DRAGBAR EVENTS
-- save position when user stops dragging
self.DragEnd = function( sender )
self:SetWantsUpdates(true);
end
self.Update = function( sender )
local x, y = self:GetPosition();
if (settings.snaptogrid) then
local temp = x / settings.gridspacing;
if (temp - math.floor(temp) > .5) then
x = settings.gridspacing * math.ceil(temp);
else
x = settings.gridspacing * math.floor(temp);
end
local temp = y / settings.gridspacing;
if (temp - math.floor(temp) > .5) then
y = settings.gridspacing * math.ceil(temp);
else
y = settings.gridspacing * math.floor(temp);
end
end
self.x = x;
self.y = y;
self:SetPosition(self.x, self.y);
KragenBars:RecalculateBorders();
self.dragBar:RecalculatePosition();
self:SetWantsUpdates(false);
end
-- set visibility when the user unhides the UI
self.HUDShow = function(sender)
self:SetVisible( self.active );
end
self.DragEnable = function(sender)
self.dragBar:SetVisible(self.active and self.dragBar:IsHUDVisible() and self.dragBar:IsDraggable());
if (self.dragBar:IsDraggable()) then
self:SetZOrder(-1);
else
self:SetZOrder(0);
end
end
self.Rotate = function(sender)
KragenBars:RotateWindow(self);
self.rotate = not self.rotate
self:RotateWindow();
end
-- ON VISIBLE CHANGED EVENT
self.VisibleChanged = function(sender, args)
self.dragBar:SetVisible(self.active and self.dragBar:IsHUDVisible() and self.dragBar:IsDraggable());
end
end
-- UPDATE THE WINDOW STATE
function SkillWindow:Refresh( active )
self.active = active;
self:SetVisible( active );
end
-- ROTATE THE WINDOW
function SkillWindow:RotateWindow()
local newwidth = self.height;
local newheight = self.width;
self:SetSize( newwidth * 35, newheight * 35 );
self.dragBar:RecalculateSize();
self.width = newwidth;
self.height = newheight;
end
function SkillWindow:DefaultPosition()
-- display width/height for default positioning
local displayWidth = Turbine.UI.Display:GetWidth();
local displayHeight = Turbine.UI.Display:GetHeight();
self.x = ((self.defx - 1) * 35) + ((displayWidth / 2) - (35 * 6)) + 20;
self.y = (displayHeight - 70) - (5 * 35) + ((self.defy - 1) * 35);
self:SetPosition(ValidatePosition(self.x, self.y, self.width*35, self.height*35));
self.dragBar:RecalculatePosition();
end
function SkillWindow:SetCombat(incombat, outcombat)
self.incombat = incombat;
self.outcombat = outcombat;
end
function SkillWindow:GetCombat()
if (self.incombat == true and self.outcombat == true) then
return 1;
elseif (self.incombat == true) then
return 2;
else
return 3;
end
end
function SkillWindow:ChangeSize(width, height)
self.width = width;
self.height = height;
self:SetSize( width * 35, height * 35 );
self.dragBar:RecalculateSize();
end
function SkillWindow:SetName(name)
self.heading = name;
self.dragBar.sName = self.heading;
self.dragBar.Label:SetText( self.heading );
end
function SkillWindow:Trash()
self:SetVisible(false);
self.dragBar:SetAllowsDragging(false);
self.dragBar:SetAllowsHUDHiding(false);
self.dragBar:SetVisible(false);
self.VisibleChanged = nil;
self.dragBar = nil;
end
Compare with Previous |
Blame
All times are GMT -5. The time now is 02:06 PM.