lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

[/] [trunk/] [JackdawPlugins/] [SortPack/] [Button.lua] - Blame information for rev 156

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 119 MrJackdaw-1942
--[[This first part is only required because of the turbine bug]]
2 MrJackdaw-1942
 
3 145 MrJackdaw-1942
--[[import "Turbine.UI"
4 MrJackdaw-1942
import "Deusdictum.UI.Dragbar"]]
5 135 MrJackdaw-1942
import "JackdawPlugins.SortPack.OptionPanel"
6 114 MrJackdaw-1942
 
7 145 MrJackdaw-1942
--[[    Plugins["SortPackLoad"].Unload = function( sender, args )
8 138 MrJackdaw-1942
                SortButtonData.X,SortButtonData.Y=SortButton:GetPosition()
9 MrJackdaw-1942
                JackdawPlugins.Patch.Save( Turbine.DataScope.Character, "SortPackButton", SortButtonData )
10 MrJackdaw-1942
        end
11 MrJackdaw-1942
 
12 MrJackdaw-1942
        if not pcall(function() import "JackdawPlugins.Patch.Patch" end) then
13 MrJackdaw-1942
                --Turbine.Shell.WriteLine("Patch not present - default Load and Save used")
14 MrJackdaw-1942
                JackdawPlugins.Patch={}
15 MrJackdaw-1942
                function JackdawPlugins.Patch.Load(a,b,c) return Turbine.PluginData.Load(a,b,c) end
16 MrJackdaw-1942
                function JackdawPlugins.Patch.Save(a,b,c,d) Turbine.PluginData.Save(a,b,c,d) end
17 MrJackdaw-1942
        end
18 MrJackdaw-1942
 
19 145 MrJackdaw-1942
        SortButtonData=JackdawPlugins.Patch.Load( Turbine.DataScope.Character, "SortPackButton")]]
20 139 MrJackdaw-1942
 
21 138 MrJackdaw-1942
        --[[Here on in is just the normal button code. This could pass pretty much unchanged when the bug is fixed, however, having the button use slash commands is probably a bit over kill, and I would like to put some of the functionality back there instead of having it in the bag]]
22 114 MrJackdaw-1942
 
23 138 MrJackdaw-1942
        --Data for the Button.
24 156 MrJackdaw-1942
        if SortButtonData==nil then                     SortButtonData={}                                               end
25 138 MrJackdaw-1942
        if SortButtonData.Scale==nil then               SortButtonData.Scale=0.5                                end
26 MrJackdaw-1942
        if SortButtonData.X==nil then                   SortButtonData.X=100                                    end
27 MrJackdaw-1942
        if SortButtonData.Y==nil then                   SortButtonData.Y=100                                    end
28 156 MrJackdaw-1942
        if SortButtonData.LeftClick==nil then   SortButtonData.LeftClick="sort"                 end
29 132 MrJackdaw-1942
 
30 138 MrJackdaw-1942
        --Create the button.
31 MrJackdaw-1942
        --Structure is; Window/Quickslot/Icon/Cover
32 132 MrJackdaw-1942
 
33 138 MrJackdaw-1942
        SortButton=Turbine.UI.Window()
34 MrJackdaw-1942
                SortButton:SetVisible(true)
35 MrJackdaw-1942
                SortButton.DragBar = Deusdictum.UI.DragBar( SortButton,"Sort")
36 MrJackdaw-1942
                SortButton.DragBar:SetZOrder(9999)
37 MrJackdaw-1942
                SortButton:SetPosition(SortButtonData.X,SortButtonData.Y)
38 MrJackdaw-1942
 
39 MrJackdaw-1942
                SortButton:SetMouseVisible(true)
40 111 MrJackdaw-1942
 
41 138 MrJackdaw-1942
        SortButton.shortcut = Turbine.UI.Lotro.Shortcut();
42 MrJackdaw-1942
                        SortButton.shortcut:SetType(Turbine.UI.Lotro.ShortcutType.Alias);
43 MrJackdaw-1942
                        SortButton.shortcut:SetData("/"..SortButtonData.LeftClick)
44 126 MrJackdaw-1942
 
45 138 MrJackdaw-1942
        SortButton.quickslot=Turbine.UI.Lotro.Quickslot();
46 MrJackdaw-1942
                        SortButton.quickslot:SetParent(SortButton);
47 MrJackdaw-1942
                        SortButton.quickslot:SetShortcut(SortButton.shortcut);
48 MrJackdaw-1942
                        SortButton.quickslot:SetVisible(true);
49 MrJackdaw-1942
                        SortButton.quickslot:SetUseOnRightClick(false)
50 114 MrJackdaw-1942
 
51 138 MrJackdaw-1942
        SortButton.Icon=Turbine.UI.Control()
52 MrJackdaw-1942
                SortButton.Icon:SetParent(SortButton)
53 MrJackdaw-1942
                SortButton.Icon:SetVisible(true)
54 MrJackdaw-1942
                SortButton.Icon:SetSize(32,32)
55 MrJackdaw-1942
                SortButton.Icon:SetBackground(0x41007ecf)
56 MrJackdaw-1942
                SortButton.Icon:SetStretchMode(1)
57 MrJackdaw-1942
                SortButton.Icon:SetMouseVisible(false)
58 MrJackdaw-1942
 
59 MrJackdaw-1942
        SortButton.Cover=Turbine.UI.Control()
60 MrJackdaw-1942
                SortButton.Cover:SetParent(SortButton)
61 122 MrJackdaw-1942
                SortButton.Cover:SetVisible(false)
62 138 MrJackdaw-1942
                SortButton.Cover:SetBackColor(Turbine.UI.Color(0.5,1,1,1))
63 MrJackdaw-1942
 
64 MrJackdaw-1942
        SortButton.SizeChanged=function()
65 MrJackdaw-1942
                SortButton.quickslot:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
66 MrJackdaw-1942
                SortButton.Icon:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
67 MrJackdaw-1942
                SortButton.Cover:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
68 122 MrJackdaw-1942
        end
69 138 MrJackdaw-1942
 
70 MrJackdaw-1942
                SortButton:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
71 MrJackdaw-1942
                SortButton.DragBar:Refresh()
72 58 MrJackdaw-1942
 
73 138 MrJackdaw-1942
        --When UI is unlocked then make the cover visible.
74 MrJackdaw-1942
                SortButton.DragEnable=function()
75 MrJackdaw-1942
                        SortButton.Cover:SetVisible(true)
76 58 MrJackdaw-1942
                end
77 126 MrJackdaw-1942
 
78 138 MrJackdaw-1942
                SortButton.DragDisable=function()
79 MrJackdaw-1942
                        SortButton.Cover:SetVisible(false)
80 MrJackdaw-1942
                end
81 126 MrJackdaw-1942
 
82 138 MrJackdaw-1942
                --Cover events - resize the Button.
83 MrJackdaw-1942
                SortButton.Cover.MouseDown=function(sender,args)
84 MrJackdaw-1942
                        moving=true
85 MrJackdaw-1942
                end
86 126 MrJackdaw-1942
 
87 138 MrJackdaw-1942
                SortButton.Cover.MouseUp=function(sender,args)
88 MrJackdaw-1942
                        moving=false
89 MrJackdaw-1942
                end
90 126 MrJackdaw-1942
 
91 138 MrJackdaw-1942
                SortButton.Cover.MouseMove=function(sender,args)
92 MrJackdaw-1942
                                if moving then
93 MrJackdaw-1942
                                local x,y=SortButton.Cover:GetMousePosition()
94 MrJackdaw-1942
 
95 MrJackdaw-1942
                                SortButtonData.Scale=math.max(x,y)/32
96 MrJackdaw-1942
                                if SortButtonData.Scale<0.25 then SortButtonData.Scale=0.25 end
97 MrJackdaw-1942
 
98 MrJackdaw-1942
                                SortButton:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
99 MrJackdaw-1942
                                SortButton.DragBar:Refresh()
100 122 MrJackdaw-1942
                        end
101 126 MrJackdaw-1942
                end
102 MrJackdaw-1942
 
103 138 MrJackdaw-1942
        SortButton.quickslot.MouseDown=function(sender,args)
104 MrJackdaw-1942
                if ( args.Button == Turbine.UI.MouseButton.Left ) then
105 145 MrJackdaw-1942
                        --[[Turbine.PluginManager.UnloadScriptState("SortPack")
106 MrJackdaw-1942
                        Turbine.PluginManager.LoadPlugin("SortPack")]]
107 138 MrJackdaw-1942
                else
108 MrJackdaw-1942
                        local contextMenu = Turbine.UI.ContextMenu()
109 MrJackdaw-1942
                        contextMenu.items = contextMenu:GetItems()
110 MrJackdaw-1942
 
111 MrJackdaw-1942
                        local option1 = Turbine.UI.MenuItem("Action on left click..")
112 MrJackdaw-1942
 
113 MrJackdaw-1942
                        local options={
114 MrJackdaw-1942
                                        [1] =
115 MrJackdaw-1942
                                        {
116 MrJackdaw-1942
                                                ["Text"] = "Sort the pack",
117 MrJackdaw-1942
                                                ["Command"] = "sort"
118 MrJackdaw-1942
                                        },
119 MrJackdaw-1942
                                        [2] =
120 MrJackdaw-1942
                                        {
121 151 MrJackdaw-1942
                                                ["Text"] = "Re-stack the pack - WARNING EXPERIMENTAL!",
122 MrJackdaw-1942
                                                ["Command"] = "stack"
123 MrJackdaw-1942
                                        },
124 MrJackdaw-1942
                                        [3] =
125 MrJackdaw-1942
                                        {
126 138 MrJackdaw-1942
                                                ["Text"] = "Open the SortBag",
127 MrJackdaw-1942
                                                ["Command"] = "openbag"
128 MrJackdaw-1942
                                        },
129 151 MrJackdaw-1942
                                        [4] =
130 138 MrJackdaw-1942
                                        {
131 MrJackdaw-1942
                                                ["Text"] = "Open the Sort Options",
132 MrJackdaw-1942
                                                ["Command"] = "sortoption"
133 MrJackdaw-1942
                                        },
134 151 MrJackdaw-1942
                                        [5] =
135 138 MrJackdaw-1942
                                        {
136 MrJackdaw-1942
                                                ["Text"] = "Create/Edit custom Categories",
137 MrJackdaw-1942
                                                ["Command"] = "SortCat"
138 MrJackdaw-1942
                                        },
139 151 MrJackdaw-1942
                                        [6] =
140 138 MrJackdaw-1942
                                        {
141 MrJackdaw-1942
                                                ["Text"] = "Open the Sort Debug window",
142 MrJackdaw-1942
                                                ["Command"] = "SortDebug"
143 MrJackdaw-1942
                                        },
144 151 MrJackdaw-1942
                                        [7] =
145 138 MrJackdaw-1942
                                        {
146 MrJackdaw-1942
                                                ["Text"] = "Show/Hide Counter",
147 MrJackdaw-1942
                                                ["Command"] = "SortCounter"
148 MrJackdaw-1942
                                        }
149 MrJackdaw-1942
                                        }
150 MrJackdaw-1942
 
151 MrJackdaw-1942
 
152 MrJackdaw-1942
                        contextMenu.SubMenuItems = option1:GetItems()
153 MrJackdaw-1942
 
154 MrJackdaw-1942
                        local suboption={}
155 MrJackdaw-1942
                        for i=1,#options do
156 MrJackdaw-1942
                                suboption[i] = Turbine.UI.MenuItem(options[i].Text,true,SortButtonData.LeftClick==options[i].Command)
157 MrJackdaw-1942
                                suboption[i].Click = function ()
158 MrJackdaw-1942
                                        SortButtonData.LeftClick=options[i].Command
159 MrJackdaw-1942
                                        SortButton.shortcut:SetData("/"..SortButtonData.LeftClick)
160 MrJackdaw-1942
                                        SortButton.quickslot:SetShortcut(SortButton.shortcut);
161 MrJackdaw-1942
                                end
162 MrJackdaw-1942
                                contextMenu.SubMenuItems:Add(suboption[i])
163 MrJackdaw-1942
                        end
164 MrJackdaw-1942
 
165 MrJackdaw-1942
                        contextMenu.items:Add(option1)
166 MrJackdaw-1942
                        contextMenu:ShowMenu()
167 MrJackdaw-1942
                end
168 122 MrJackdaw-1942
        end
169 138 MrJackdaw-1942
 
170 139 MrJackdaw-1942
 
171 145 MrJackdaw-1942
        --[[Turbine.PluginManager.UnloadScriptState("SortPack")
172 MrJackdaw-1942
        Turbine.PluginManager.LoadPlugin("SortPack")]]
173 139 MrJackdaw-1942
 
174 MrJackdaw-1942
        --This fixes a very odd bug that has crept in - I have no idea what is causing it, but it is most annoying.
175 MrJackdaw-1942
        --The icon just doesn't seem to scale properly...
176 MrJackdaw-1942
 
177 MrJackdaw-1942
        SortButton.Icon:SetSize(32*SortButtonData.Scale,32*SortButtonData.Scale)
178 156 MrJackdaw-1942
 
179 MrJackdaw-1942
        SortButton:SetVisible(not(SortButtonData.Hide))

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


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