lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

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

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

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


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