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 ( heading, x, y, width, height, prop)
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 = heading;
self.x = ((x - 1) * 35) + ((displayWidth / 2) - (35 * 6)) + 20;
self.y = (displayHeight - 70) - (5 * 35) + ((y - 1) * 35);
self.width = width;
self.height = height;
self.active = prop.active;
self.rotate = prop.rotate;
self.defx = x;
self.defy = y;
-- set x and y if they arn't the defaults
if (prop.x ~= 0 and prop.y ~= 0) then
self.x = prop.x;
self.y = prop.y;
end
-- set properties
self:SetSize( width * 35, height * 35 );
self:SetPosition(ValidatePosition(self.x, self.y, width*35, height*35));
self:SetVisible(true);
if (self.rotate == 1) then
self:RotateWindow();
end
-- DRAGBAR
-- attach dragbar class to window
self.dragBar = KragenPlugs.Utils.UI.DragBar( 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 testx = math.floor(x / 35);
x = 35 * testx + 17;
local testy = math.floor(y / 35);
y = 35 * testy + 17;
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());
end
self.Rotate = function(sender)
KragenBars:RotateWindow(self);
if (self.rotate == 1) then
self.rotate = 0;
else
self.rotate = 1;
end
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.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
Compare with Previous |
Blame
All times are GMT -5. The time now is 08:02 PM.