--New contextmenu class
JContextMenu=class(Turbine.UI.Window())
function JContextMenu:Constructor()
Turbine.UI.Window(self)
self:SetBackColor ( Turbine.UI.Color(1,0,0,0 ))
self.Control=Turbine.UI.Control()
self.Control:SetParent(self)
self.Control:SetZOrder(990)
self.Control:SetSize(200,200)
self.ListBox=Turbine.UI.ListBox()
self.ListBox:SetParent(self.Control)
self.ListBox:SetWidth(200)
self:SetVisible(true)
local x,y=Turbine.UI.Display:GetMousePosition()
self:SetPosition(x,y)
self.Control.MouseLeave=function()
self:SetVisible(false)
self=nil
end
self:SetVisible(true)
self:SetSize(200,1)
self:SetZOrder(9999)
end
function JContextMenu:AddItem(i)
self.ListBox:AddItem(i)
self:SetHeight(self:GetHeight()+i:GetHeight())
self.ListBox:SetSize(self:GetSize())
self.Control:SetSize(self:GetSize())
--ensure it stays on screen.
local x,y=self:GetPosition()
local w,h=self:GetSize()
local sw,sh=Turbine.UI.Display.GetWidth(),Turbine.UI.Display.GetHeight()
if x+w>sw then x=sw-w end
if y+h>sh then y=sh-h end
self:SetPosition(x,y)
end
--Simple label button function
JClabel=class(Turbine.UI.Control)
function JClabel:Constructor (text,e)
local width=200
local height=20
Turbine.UI.Control.Constructor(self)
self:SetSize(width,height)
self.quickslot = Turbine.UI.Lotro.Quickslot();
self.quickslot:SetParent(self);
self.quickslot:SetSize(width, height);
self.quickslot:SetBackColor(Turbine.UI.Color(0.4, 0.3, 0.0));
self.shortcut = Turbine.UI.Lotro.Shortcut();
self.shortcut:SetType(Turbine.UI.Lotro.ShortcutType.Alias);
self.shortcut:SetData(e);
self.quickslot:SetShortcut(self.shortcut);
self.quickslot:SetVisible(true);
self.quickslot:SetZOrder(991)
self.label=Turbine.UI.Label()
self.label:SetBackColor( Turbine.UI.Color( 1,0,0,0 ) )
self.label:SetMultiline(false)
self.label:SetTextAlignment( Turbine.UI.ContentAlignment.Left )
self.label:SetFont(Turbine.UI.Lotro.Font.TrajanPro14)
self.label:SetText( text )
self.label:SetMouseVisible (false)
self.label:SetSize(width,height)
self.label:SetParent(self)
self.label:SetZOrder(992)
self.label.MouseEnter=function()
self.label:SetOutlineColor(Turbine.UI.Color(0.8, 0.65, 0.1));
self.label:SetFontStyle(Turbine.UI.FontStyle.Outline);
end
self.label.MouseLeave =function()
self.label:SetOutlineColor(Turbine.UI.Color(0.0, 0.0, 0.0));
self.label:SetFontStyle(Turbine.UI.FontStyle.None);
end
self.quickslot.MouseClick=function()
--fudge function Not pretty.
if context~=nil then
context:SetVisible(false)
context=nil
--Unload/load sortpack
Turbine.PluginManager.UnloadScriptState("SortPack")
Turbine.PluginManager.LoadPlugin("SortPack")
end
end
end