lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

[/] [trunk/] [JackdawPlugins/] [SortPack/] [ListOption.Lua] - Blame information for rev 163

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

Line No. Rev Author Line
1 54 MrJackdaw-1942
--Idea Give the player the ability to re-order the list.
2 138 MrJackdaw-1942
 
3 MrJackdaw-1942
function ShowListOption()
4 146 MrJackdaw-1942
        Height=600
5 MrJackdaw-1942
        Width=600
6 100 MrJackdaw-1942
        Font=Turbine.UI.Lotro.Font.TrajanPro16
7 MrJackdaw-1942
 
8 138 MrJackdaw-1942
        if CustomOption~=nil then CustomOption.Window:SetVisible(false) CustomOption=nil end
9 100 MrJackdaw-1942
        if ListOption~=nil then ListOption.Window:SetVisible(false) ListOption=nil end
10 54 MrJackdaw-1942
 
11 MrJackdaw-1942
        ListOption={}
12 MrJackdaw-1942
 
13 MrJackdaw-1942
        --Make the window
14 99 MrJackdaw-1942
        ListOption.Window = Turbine.UI.Lotro.Window()
15 88 MrJackdaw-1942
        ListOption.Window:SetPosition( 100,0 )
16 100 MrJackdaw-1942
        ListOption.Window:SetSize(Width,Height)
17 54 MrJackdaw-1942
 
18 MrJackdaw-1942
        ListOption.Window:SetText( "Change Sort Order")
19 MrJackdaw-1942
        ListOption.Window:SetVisible( true )
20 MrJackdaw-1942
        ListOption.Window:SetZOrder(1000)
21 MrJackdaw-1942
 
22 100 MrJackdaw-1942
        ListOption.Frame={}
23 MrJackdaw-1942
        for i=1,2 do
24 MrJackdaw-1942
                ListOption.Frame[i]=Frame()
25 MrJackdaw-1942
                ListOption.Frame[i]:SetParent(ListOption.Window)
26 MrJackdaw-1942
                ListOption.Frame[i]:SetSize(Width/2-10,Height-60)
27 MrJackdaw-1942
                ListOption.Frame[i]:SetTop(40)
28 MrJackdaw-1942
 
29 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar=Turbine.UI.Lotro.ScrollBar()
30 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar:SetOrientation( Turbine.UI.Orientation.Vertical )
31 54 MrJackdaw-1942
 
32 100 MrJackdaw-1942
                ListOption.Frame[i].ListBox = Turbine.UI.ListBox()
33 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetParent( ListOption.Frame[i] )
34 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetPosition( 10, 2 )
35 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetSize( Width/2-20, Height-64)
36 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetMaxItemsPerLine(1)
37 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetOrientation( Turbine.UI.Orientation.Horizontal )
38 MrJackdaw-1942
                ListOption.Frame[i].ListBox:SetVerticalScrollBar( ListOption.Frame[i].ScrollBar )
39 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar:SetParent(ListOption.Frame[i])
40 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar:SetPosition(0,2)
41 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar:SetHeight(Height-64)
42 MrJackdaw-1942
                ListOption.Frame[i].ScrollBar:SetWidth(10)
43 MrJackdaw-1942
 
44 MrJackdaw-1942
                ListOption.Frame[i].MouseEnter=function()
45 MrJackdaw-1942
                        FrameEntered=i
46 MrJackdaw-1942
                end
47 MrJackdaw-1942
        end
48 MrJackdaw-1942
        ListOption.Frame[1]:SetLeft(10)
49 MrJackdaw-1942
        ListOption.Frame[2]:SetLeft(Width/2)
50 MrJackdaw-1942
 
51 88 MrJackdaw-1942
        ListOption.Resize=Turbine.UI.Control()
52 MrJackdaw-1942
                ListOption.Resize:SetParent(ListOption.Window)
53 MrJackdaw-1942
                ListOption.Resize:SetZOrder(99)
54 100 MrJackdaw-1942
                ListOption.Resize:SetSize(Width,10)
55 MrJackdaw-1942
                ListOption.Resize:SetPosition(0,Height-10)
56 88 MrJackdaw-1942
 
57 MrJackdaw-1942
                ListOption.ResizeBack=Turbine.UI.Control()
58 MrJackdaw-1942
                ListOption.ResizeBack:SetParent(ListOption.Resize)
59 100 MrJackdaw-1942
                ListOption.ResizeBack:SetSize(Width,10)
60 88 MrJackdaw-1942
                ListOption.ResizeBack:SetBackColor(Turbine.UI.Color(1,1,1,1))
61 MrJackdaw-1942
                ListOption.ResizeBack:SetVisible(false)
62 MrJackdaw-1942
                ListOption.ResizeBack:SetMouseVisible(false)
63 MrJackdaw-1942
 
64 MrJackdaw-1942
                ListOption.Resize.MouseEnter=function() ListOption.ResizeBack:SetVisible(true) end
65 MrJackdaw-1942
                ListOption.Resize.MouseLeave=function() ListOption.ResizeBack:SetVisible(false)  end
66 MrJackdaw-1942
 
67 MrJackdaw-1942
                ListOption.Resize.MouseDown=function ()
68 MrJackdaw-1942
                        draggingr=true
69 MrJackdaw-1942
                end
70 MrJackdaw-1942
                ListOption.Resize.MouseUp=function ()
71 MrJackdaw-1942
                        draggingr=false
72 MrJackdaw-1942
                end
73 MrJackdaw-1942
                ListOption.Resize.MouseMove=function()
74 MrJackdaw-1942
                        if draggingr then
75 100 MrJackdaw-1942
                                null,Height=ListOption.Window:GetMousePosition()        --Change later if I want variable width too.
76 MrJackdaw-1942
                                if Height<300 then Height=300 end
77 MrJackdaw-1942
                                ListOption.Window:SetSize(Width,Height)
78 MrJackdaw-1942
                                ListOption.Resize:SetPosition(0,Height-10)
79 MrJackdaw-1942
                                for i=1,2 do
80 MrJackdaw-1942
                                        ListOption.Frame[i]:SetSize(Width/2-10,Height-60)
81 MrJackdaw-1942
                                        ListOption.Frame[i].ListBox:SetSize( Width/2-20, Height-64)
82 MrJackdaw-1942
                                        ListOption.Frame[i].ScrollBar:SetHeight(Height-64)
83 MrJackdaw-1942
                                end
84 MrJackdaw-1942
                                ListOption.Frame[2]:SetLeft(Width/2)
85 88 MrJackdaw-1942
                        end
86 MrJackdaw-1942
                end
87 100 MrJackdaw-1942
 
88 MrJackdaw-1942
        Option=nil Option={}
89 MrJackdaw-1942
        LeftList()
90 112 MrJackdaw-1942
 
91 MrJackdaw-1942
        DragIcon={}
92 MrJackdaw-1942
                DragIcon=Turbine.UI.Control()
93 MrJackdaw-1942
                DragIcon.Window=Turbine.UI.Window()
94 MrJackdaw-1942
                DragIcon.Window:SetVisible(false)
95 MrJackdaw-1942
                DragIcon.Window:SetSize(150,12)
96 MrJackdaw-1942
                DragIcon.Window:SetOpacity(0.8)
97 MrJackdaw-1942
                DragIcon.Window:SetMouseVisible(false)
98 MrJackdaw-1942
                DragIcon.Icon=Turbine.UI.Control()
99 MrJackdaw-1942
                DragIcon.Icon:SetParent(DragIcon.Window)
100 MrJackdaw-1942
                DragIcon.Icon:SetSize(32,32)
101 MrJackdaw-1942
                DragIcon.Icon:SetBackground(0x41007ecf)
102 MrJackdaw-1942
                DragIcon.Icon:SetStretchMode(1)
103 MrJackdaw-1942
                DragIcon.Icon:SetSize(12,12)
104 MrJackdaw-1942
                DragIcon.Icon:SetMouseVisible(false)
105 MrJackdaw-1942
                DragIcon.Label=Turbine.UI.Label()
106 MrJackdaw-1942
                DragIcon.Label:SetParent(DragIcon.Window)
107 MrJackdaw-1942
                DragIcon.Label:SetPosition(12,0)
108 MrJackdaw-1942
                DragIcon.Label:SetSize(140,12)
109 MrJackdaw-1942
                DragIcon.Label:SetText("label!")
110 MrJackdaw-1942
                DragIcon.Label:SetMouseVisible(false)
111 MrJackdaw-1942
 
112 MrJackdaw-1942
        function DragIcon:Update()
113 MrJackdaw-1942
                local x,y=Turbine.UI.Display.GetMousePosition()
114 MrJackdaw-1942
                DragIcon.Window:SetPosition(x+10,y)
115 MrJackdaw-1942
                DragIcon.Window:SetZOrder(9999)
116 MrJackdaw-1942
        end
117 MrJackdaw-1942
 
118 MrJackdaw-1942
        ListOption.Window.Closed=function()
119 MrJackdaw-1942
                ListOption=nil
120 MrJackdaw-1942
                DragIcon=nil
121 MrJackdaw-1942
        end
122 100 MrJackdaw-1942
end
123 54 MrJackdaw-1942
 
124 100 MrJackdaw-1942
function LeftList()
125 MrJackdaw-1942
 
126 MrJackdaw-1942
        ListOption.Frame[1].ListBox:ClearItems()
127 MrJackdaw-1942
 
128 MrJackdaw-1942
 
129 MrJackdaw-1942
        Option.Groups=nil       Option.Groups={}
130 MrJackdaw-1942
 
131 MrJackdaw-1942
        for i=1,#Groups do-- in pairs(Groups) do
132 MrJackdaw-1942
                Option.Groups[i]=Turbine.UI.Control()
133 MrJackdaw-1942
                        Option.Groups[i]:SetSize(Width/2-10,20)
134 MrJackdaw-1942
                Option.Groups[i].Label=Turbine.UI.Label()
135 MrJackdaw-1942
                        Option.Groups[i].Label:SetFont(Font)
136 MrJackdaw-1942
                        Option.Groups[i].Label:SetText(Groups[i].Name)
137 MrJackdaw-1942
                        Option.Groups[i].Label:SetMouseVisible(false)
138 MrJackdaw-1942
                        Option.Groups[i].Label:SetParent(Option.Groups[i])
139 MrJackdaw-1942
                        Option.Groups[i].Label:SetSize(Width/2-10-30,20)
140 MrJackdaw-1942
                Option.Groups[i].Icon=Turbine.UI.Control()
141 MrJackdaw-1942
                        Option.Groups[i].Icon:SetParent(Option.Groups[i])
142 MrJackdaw-1942
                        Option.Groups[i].Icon:SetBackground(0x41007e26)
143 MrJackdaw-1942
                        Option.Groups[i].Icon:SetLeft(Width/2-10-30)
144 MrJackdaw-1942
                        Option.Groups[i].Icon:SetSize(16,16)
145 MrJackdaw-1942
 
146 MrJackdaw-1942
                        Option.Groups[i].Icon:SetVisible(#Groups[i]==0)
147 MrJackdaw-1942
                        Option.Groups[i].Icon.MouseClick=function()
148 MrJackdaw-1942
                                Turbine.Shell.WriteLine("Deleting group "..Groups[i].Name)
149 MrJackdaw-1942
                                table.remove(Groups,i)
150 MrJackdaw-1942
                                BuildList()
151 MrJackdaw-1942
                                LeftList()
152 MrJackdaw-1942
                        end
153 MrJackdaw-1942
 
154 MrJackdaw-1942
 
155 MrJackdaw-1942
                ListOption.Frame[1].ListBox:AddItem(Option.Groups[i])
156 MrJackdaw-1942
                        --Dragging event for group i
157 MrJackdaw-1942
                        --The Drag events do not seem to be firing for these controls so... Replace this when they are fixed.
158 MrJackdaw-1942
                        Option.Groups[i].MouseDown=function(sender,args)
159 MrJackdaw-1942
                                ldragging=i
160 MrJackdaw-1942
                                ldraggedout=nil --Needed to detect just a "click" instead of a drag.
161 MrJackdaw-1942
                                ldraggedin=nil
162 MrJackdaw-1942
                                DragIcon.Window:SetVisible(true)
163 MrJackdaw-1942
                                DragIcon.Label:SetText(Groups[i].Name)
164 MrJackdaw-1942
                                DragIcon:SetWantsUpdates(true)
165 MrJackdaw-1942
                        end
166 MrJackdaw-1942
 
167 MrJackdaw-1942
                        Option.Groups[i].MouseLeave=function(sender,args)
168 MrJackdaw-1942
                                ldraggedout=true
169 MrJackdaw-1942
                        end
170 MrJackdaw-1942
 
171 MrJackdaw-1942
                        Option.Groups[i].MouseEnter=function(sender,args)
172 MrJackdaw-1942
                                ldraggedin=i
173 MrJackdaw-1942
                                ldraggedout=false
174 MrJackdaw-1942
                        end
175 MrJackdaw-1942
 
176 MrJackdaw-1942
                        Option.Groups[i].MouseUp=function(sender,args)
177 MrJackdaw-1942
 
178 MrJackdaw-1942
                                DragIcon.Window:SetVisible(false)
179 MrJackdaw-1942
                                DragIcon:SetWantsUpdates(false)
180 MrJackdaw-1942
                                --if ldraggedout then return end
181 MrJackdaw-1942
                                if ldragging==nil then return end
182 MrJackdaw-1942
                                if ldraggedout==nil then
183 MrJackdaw-1942
                                        --Not dragged, just clicked.
184 MrJackdaw-1942
                                        RightList(i)
185 MrJackdaw-1942
                                end
186 MrJackdaw-1942
                                if ldraggedin~=nil then
187 MrJackdaw-1942
                                        if FrameEntered==1 then
188 MrJackdaw-1942
                                        --Left to left drag - changing group order
189 MrJackdaw-1942
 
190 MrJackdaw-1942
                                        --Dragging has taken place! Long range insert
191 MrJackdaw-1942
                                                RightList(ldragging)
192 MrJackdaw-1942
                                                local temp=Groups[ldragging]
193 MrJackdaw-1942
                                                table.remove(Groups,ldragging)
194 MrJackdaw-1942
                                                table.insert(Groups,ldraggedin,temp)
195 MrJackdaw-1942
 
196 MrJackdaw-1942
                                                BuildList()
197 MrJackdaw-1942
                                        end
198 MrJackdaw-1942
                                end
199 MrJackdaw-1942
                                        ldragging=nil
200 MrJackdaw-1942
                                        ldraggedout=nil
201 MrJackdaw-1942
                                        ldraggedin=nil
202 MrJackdaw-1942
                                        ldragfromgroup=nil
203 MrJackdaw-1942
 
204 MrJackdaw-1942
                                        LeftList()
205 MrJackdaw-1942
 
206 MrJackdaw-1942
                        end
207 MrJackdaw-1942
        end
208 MrJackdaw-1942
        AddGroup=nil AddGroup={}
209 MrJackdaw-1942
                AddGroup=Turbine.UI.Control()
210 MrJackdaw-1942
                AddGroup:SetSize(Width/2-10,20)
211 MrJackdaw-1942
                AddGroup.Icon=Turbine.UI.Control()
212 MrJackdaw-1942
                AddGroup.Icon:SetParent(AddGroup)
213 MrJackdaw-1942
                AddGroup.Icon:SetBackground(0x41007e12)
214 111 MrJackdaw-1942
                AddGroup.Icon:SetBlendMode( Turbine.UI.BlendMode.Overlay )
215 100 MrJackdaw-1942
                AddGroup.Icon:SetSize(16,16)
216 MrJackdaw-1942
                AddGroup.Icon:SetMouseVisible(false)
217 MrJackdaw-1942
                AddGroup.Icon:SetOpacity(0.5)
218 MrJackdaw-1942
                AddGroup.TextBox=Turbine.UI.TextBox()
219 MrJackdaw-1942
                AddGroup.TextBox:SetParent(AddGroup)
220 MrJackdaw-1942
                AddGroup.TextBox:SetSize(Width/2-10-32,20)
221 MrJackdaw-1942
                AddGroup.TextBox:SetLeft(16)
222 MrJackdaw-1942
                AddGroup.Apply=Turbine.UI.Control()
223 MrJackdaw-1942
                AddGroup.Apply:SetParent(AddGroup)
224 MrJackdaw-1942
                AddGroup.Apply:SetBackground(0x41007e27)
225 MrJackdaw-1942
                AddGroup.Apply:SetSize(16,16)
226 MrJackdaw-1942
                AddGroup.Apply:SetVisible(false)
227 MrJackdaw-1942
                AddGroup.Apply:SetLeft(Width/2-10-30)
228 54 MrJackdaw-1942
 
229 100 MrJackdaw-1942
                AddGroup.Apply.MouseClick=function()
230 MrJackdaw-1942
                        --Add a new group
231 MrJackdaw-1942
                        --Step 1: Strip the non-alpha from the name, and make only the first letter uppercase. This is the .Name of the group
232 MrJackdaw-1942
                                local str=AddGroup.TextBox:GetText()
233 MrJackdaw-1942
                                local txt=string.gsub(str,"[^%a%s]","")
234 MrJackdaw-1942
                                if str~=txt then Turbine.Shell.WriteLine("Sortpack: Non alphabetical characters have been removed from the name of the new group.") end
235 MrJackdaw-1942
                                txt=string.upper(string.sub(txt,1,1))..string.lower(string.sub(txt,2))
236 MrJackdaw-1942
                                if txt==nil or txt=="" then return end
237 MrJackdaw-1942
                        --Step 2: Create a new group and apply the above!
238 MrJackdaw-1942
                                Groups[#Groups+1]={}
239 MrJackdaw-1942
                                Groups[#Groups].Name=txt
240 MrJackdaw-1942
                        --Step 3: Refresh the left table.
241 MrJackdaw-1942
                        BuildList()
242 MrJackdaw-1942
                        LeftList()
243 MrJackdaw-1942
                end
244 MrJackdaw-1942
 
245 MrJackdaw-1942
                AddGroup.TextBox.FocusGained=function() AddGroup.Apply:SetVisible(true) end
246 MrJackdaw-1942
                AddGroup.TextBox.FocusLost=function() AddGroup.Apply:SetVisible(false) end
247 MrJackdaw-1942
 
248 MrJackdaw-1942
        ListOption.Frame[1].ListBox:AddItem(AddGroup)
249 105 MrJackdaw-1942
 
250 138 MrJackdaw-1942
        if SortBag~=nil then  populatebag() end
251 100 MrJackdaw-1942
end
252 MrJackdaw-1942
 
253 MrJackdaw-1942
function RightList(i)
254 MrJackdaw-1942
        ListOption.Frame[2].ListBox:ClearItems()
255 MrJackdaw-1942
        Option.Items=nil Option.Items={}
256 MrJackdaw-1942
 
257 MrJackdaw-1942
        for j=1,#Groups[i] do
258 MrJackdaw-1942
                Option.Items[j]=Turbine.UI.Label()
259 MrJackdaw-1942
                Option.Items[j]:SetSize(Width/2-10,20)
260 MrJackdaw-1942
                Option.Items[j]:SetFont(Font)
261 MrJackdaw-1942
                Option.Items[j]:SetText(Groups[i][j])
262 MrJackdaw-1942
                ListOption.Frame[2].ListBox:AddItem(Option.Items[j])
263 MrJackdaw-1942
                --Dragging event for item i,j
264 88 MrJackdaw-1942
                --The Drag events do not seem to be firing for these controls so... Replace this when they are fixed.
265 100 MrJackdaw-1942
                Option.Items[j].MouseDown=function(sender,args)
266 MrJackdaw-1942
                        rdragging=j
267 MrJackdaw-1942
                        rdragfromgroup=i
268 MrJackdaw-1942
                        rdraggedout=nil
269 MrJackdaw-1942
                        rdraggedin=nil
270 88 MrJackdaw-1942
                        DragIcon.Window:SetVisible(true)
271 100 MrJackdaw-1942
                        DragIcon.Label:SetText(Groups[i][j])
272 88 MrJackdaw-1942
                        DragIcon:SetWantsUpdates(true)
273 MrJackdaw-1942
                end
274 100 MrJackdaw-1942
                Option.Items[j].MouseLeave=function(sender,args)
275 MrJackdaw-1942
                        rdraggedout=true
276 88 MrJackdaw-1942
                end
277 100 MrJackdaw-1942
                Option.Items[j].MouseEnter=function(sender,args)
278 MrJackdaw-1942
                        rdraggedin=j
279 MrJackdaw-1942
                        rdraggedout=false
280 88 MrJackdaw-1942
                end
281 MrJackdaw-1942
 
282 100 MrJackdaw-1942
                Option.Items[j].MouseUp=function(sender,args)
283 MrJackdaw-1942
 
284 88 MrJackdaw-1942
                        DragIcon.Window:SetVisible(false)
285 MrJackdaw-1942
                        DragIcon:SetWantsUpdates(false)
286 100 MrJackdaw-1942
 
287 MrJackdaw-1942
                        if FrameEntered==2 then
288 MrJackdaw-1942
                                --Right to right drag performed
289 MrJackdaw-1942
                                if rdraggedout then return end
290 MrJackdaw-1942
                                if rdragging==nil then return end
291 MrJackdaw-1942
                                if rdraggedout==nil then
292 MrJackdaw-1942
                                        --Not dragged out ;Do nothing!
293 88 MrJackdaw-1942
                                end
294 100 MrJackdaw-1942
                                if rdraggedin~=nil then
295 MrJackdaw-1942
                                        --Dragging has taken place! Long range insert. Note: only accepts drags from right to right.
296 MrJackdaw-1942
                                        local temp=Groups[i][rdragging]
297 MrJackdaw-1942
                                        table.remove(Groups[i],rdragging)
298 MrJackdaw-1942
                                        table.insert(Groups[i],rdraggedin,temp)
299 MrJackdaw-1942
                                        BuildList()
300 88 MrJackdaw-1942
                                end
301 100 MrJackdaw-1942
 
302 MrJackdaw-1942
                        else
303 MrJackdaw-1942
                                --If we land here we have done a right-to-left drag.
304 MrJackdaw-1942
                                local temp=Groups[rdragfromgroup][rdragging]
305 MrJackdaw-1942
                                table.remove(Groups[rdragfromgroup],rdragging)
306 MrJackdaw-1942
                                table.insert(Groups[ldraggedin],temp)
307 MrJackdaw-1942
                                BuildList()
308 54 MrJackdaw-1942
                        end
309 88 MrJackdaw-1942
 
310 100 MrJackdaw-1942
                        rdragging=nil
311 MrJackdaw-1942
                        rdraggedout=nil
312 MrJackdaw-1942
                        rdraggedin=nil
313 MrJackdaw-1942
                        rdragfromgroup=nil
314 MrJackdaw-1942
                        RightList(i)
315 MrJackdaw-1942
                        LeftList()
316 54 MrJackdaw-1942
                end
317 MrJackdaw-1942
        end
318 105 MrJackdaw-1942
 
319 MrJackdaw-1942
 
320 54 MrJackdaw-1942
end

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


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