lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

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

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

All times are GMT -5. The time now is 05:57 PM.


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