lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

[/] [trunk/] [JackdawPlugins/] [SortPack/] [Button.lua] - Rev 125

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

--[[This first part is only required because of the turbine bug]]

import "Turbine.UI"
import "Deusdictum.UI.Dragbar"

--Unload/load sortpack
Turbine.PluginManager.UnloadScriptState("SortPack")
Turbine.PluginManager.LoadPlugin("SortPack")


if not pcall(function() import "JackdawPlugins.Patch.Patch" end) then 
        --Turbine.Shell.WriteLine("Patch not present - default Load and Save used")
        JackdawPlugins.Patch={}
        function JackdawPlugins.Patch.Load(a,b,c) return Turbine.PluginData.Load(a,b,c) end
        function JackdawPlugins.Patch.Save(a,b,c,d) Turbine.PluginData.Save(a,b,c,d) end
end

SortButtonData=JackdawPlugins.Patch.Load( Turbine.DataScope.Character, "SortPackButton" )

--Data for the Button.
if SortButtonData==nil then SortButtonData={} end
if SortButtonData.Scale==nil then               SortButtonData.Scale=0.5 end
if SortButtonData.X==nil then                   SortButtonData.X=100 end
if SortButtonData.Y==nil then                   SortButtonData.Y=100 end
if SortButtonData.LeftClick==nil then   SortButtonData.LeftClick="sort" end

Plugins["SortPackLoad"].Unload = function( sender, args )
                SortButtonData.X,SortButtonData.Y=SortButton:GetPosition()
                JackdawPlugins.Patch.Save( Turbine.DataScope.Character, "SortPackButton", SortButtonData )
end

SortButton=Turbine.UI.Window()
        SortButton:SetVisible(true)
        SortButton.DragBar = Deusdictum.UI.DragBar( SortButton,"Sort")
        SortButton:SetPosition(SortButtonData.X,SortButtonData.Y)
        
        SortButton:SetMouseVisible(true)

SortButton.shortcut = Turbine.UI.Lotro.Shortcut();
                SortButton.shortcut:SetType(Turbine.UI.Lotro.ShortcutType.Alias);
                SortButton.shortcut:SetData("/"..SortButtonData.LeftClick)      

SortButton.quickslot=Turbine.UI.Lotro.Quickslot();
                SortButton.quickslot:SetParent(SortButton);
                SortButton.quickslot:SetShortcut(SortButton.shortcut);
                SortButton.quickslot:SetVisible(true);
                SortButton.quickslot:SetUseOnRightClick(false)

SortButton.Icon=Turbine.UI.Control()
        SortButton.Icon:SetParent(SortButton)
        SortButton.Icon:SetVisible(true)
        SortButton.Icon:SetSize(32,32)
        SortButton.Icon:SetBackground(0x41007ecf)
        SortButton.Icon:SetStretchMode(1)
        SortButton.Icon:SetMouseVisible(false)
        
SortButton.Cover=Turbine.UI.Control()
        SortButton.Cover:SetParent(SortButton)
        SortButton.Cover:SetVisible(false)
        SortButton.Cover:SetBackColor(Turbine.UI.Color(0.5,1,1,1))
        
SortButton.SizeChanged=function()
        SortButton.quickslot:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
        SortButton.Icon:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
        SortButton.Cover:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
end
        
        SortButton:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
        SortButton.DragBar:Refresh()

--When UI is unlocked then make the cover visible.
        SortButton.DragEnable=function()
                SortButton.Cover:SetVisible(true)
        end
        
        SortButton.DragDisable=function()
                SortButton.Cover:SetVisible(false)
        end
        
        --Cover events - resize the Button.
        
        SortButton.Cover.MouseDown=function(sender,args)
                moving=true
        end
        
        SortButton.Cover.MouseUp=function(sender,args)
                moving=false
        end
        
        SortButton.Cover.MouseMove=function(sender,args)
                        if moving then
                        local x,y=SortButton.Cover:GetMousePosition()

                        SortButtonData.Scale=math.max(x,y)/32
                        if SortButtonData.Scale<0.25 then SortButtonData.Scale=0.25 end

                        SortButton:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
                        SortButton.DragBar:Refresh()
                end
        end
        
SortButton.quickslot.MouseDown=function(sender,args)
        if ( args.Button == Turbine.UI.MouseButton.Left ) then
                Turbine.PluginManager.UnloadScriptState("SortPack")
                Turbine.PluginManager.LoadPlugin("SortPack")
        else
                local contextMenu = Turbine.UI.ContextMenu()
                contextMenu.items = contextMenu:GetItems()
        
                local option1 = Turbine.UI.MenuItem("Action on left click..")
                contextMenu.SubMenuItems = option1:GetItems()
                local suboption1={}
                        suboption1[1] = Turbine.UI.MenuItem("Sort the pack",true,SortButtonData.LeftClick=="sort")
                        suboption1[1].Click = function () 
                                SortButtonData.LeftClick="sort" 
                                SortButton.shortcut:SetData("/"..SortButtonData.LeftClick) 
                                SortButton.quickslot:SetShortcut(SortButton.shortcut);
                        end
                        contextMenu.SubMenuItems:Add(suboption1[1])
                        suboption1[2] = Turbine.UI.MenuItem("Open the SortBag",true,SortButtonData.LeftClick=="openbag")
                        suboption1[2].Click = function () 
                                SortButtonData.LeftClick="openbag" 
                                SortButton.shortcut:SetData("/"..SortButtonData.LeftClick) 
                                SortButton.quickslot:SetShortcut(SortButton.shortcut);
                        end
                        contextMenu.SubMenuItems:Add(suboption1[2])
                        suboption1[3] = Turbine.UI.MenuItem("Open the Sort Options",true,SortButtonData.LeftClick=="sortoption")
                        suboption1[3].Click = function () 
                                SortButtonData.LeftClick="sortoption" 
                                SortButton.shortcut:SetData("/"..SortButtonData.LeftClick) 
                                SortButton.quickslot:SetShortcut(SortButton.shortcut);
                        end
                        contextMenu.SubMenuItems:Add(suboption1[3])
                        
                contextMenu.items:Add(option1)
                contextMenu:ShowMenu()
        end
end

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 06:28 PM.


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