@@ -51,41 +51,75 @@ describe("List", function ()
51
51
assert .same (gui .Stack {
52
52
align_h = " center" ,
53
53
align_v = " center" ,
54
- gui .Image { bgimg = " flow_extras_list_bg.png" , w = 1 , h = 1 },
54
+ gui .Image { texture_name = " flow_extras_list_bg.png" , w = 1 , h = 1 },
55
55
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
56
56
}, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 })
57
57
-- Should be noted that 0,0 is not a valid size, but this should not care.
58
58
end )
59
- it (" has a default theme background" , function ()
60
- assert .same (gui .Stack {
61
- align_h = " center" ,
62
- align_v = " center" ,
63
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" },
64
- gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
65
- }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 })
66
- end )
67
- it (" accepts a theme background string" , function ()
68
- assert .same (gui .Stack {
69
- align_h = " center" ,
70
- align_v = " center" ,
71
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
72
- gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
73
- }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , bgimg = " c" })
74
- end )
75
- it (" accepts a listof theme backgrounds" , function ()
76
- assert .same (gui .Stack {
77
- align_h = " center" ,
78
- align_v = " center" ,
79
- gui .HBox {
80
- spacing = 0.25 ,
81
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
82
- gui .Image { w = 1 , h = 1 , bgimg = " d" },
83
- gui .Image { w = 1 , h = 1 , bgimg = " e" },
84
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
85
- gui .Image { w = 1 , h = 1 , bgimg = " d" }
86
- },
87
- gui .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 }
88
- }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 , bgimg = { " c" , " d" , " e" } })
59
+ describe (" theme background" , function ()
60
+ it (" has a default" , function ()
61
+ assert .same (gui .Stack {
62
+ align_h = " center" ,
63
+ align_v = " center" ,
64
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" },
65
+ gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
66
+ }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 })
67
+ end )
68
+ it (" can be overriden with a string" , function ()
69
+ assert .same (gui .Stack {
70
+ align_h = " center" ,
71
+ align_v = " center" ,
72
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
73
+ gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
74
+ }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , bgimg = " c" })
75
+ end )
76
+ describe (" list overriding" , function ()
77
+ it (" works with default starting_item_index" , function ()
78
+ assert .same (gui .Stack {
79
+ align_h = " center" ,
80
+ align_v = " center" ,
81
+ gui .HBox {
82
+ spacing = 0.25 ,
83
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
84
+ gui .Image { w = 1 , h = 1 , texture_name = " d" },
85
+ gui .Image { w = 1 , h = 1 , texture_name = " e" },
86
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
87
+ gui .Image { w = 1 , h = 1 , texture_name = " d" }
88
+ },
89
+ gui .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 }
90
+ }, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 , bgimg = { " c" , " d" , " e" } })
91
+ end )
92
+ it (" works with specific starting_item_index" , function ()
93
+ assert .same (gui .Stack {
94
+ align_h = " center" ,
95
+ align_v = " center" ,
96
+ gui .HBox {
97
+ spacing = 0.25 ,
98
+ gui .Image { w = 1 , h = 1 , texture_name = " e" },
99
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
100
+ gui .Image { w = 1 , h = 1 , texture_name = " d" },
101
+ gui .Image { w = 1 , h = 1 , texture_name = " e" },
102
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
103
+ },
104
+ gui .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 , starting_item_index = 2 }
105
+ }, flow_extras .List {
106
+ inventory_location = " a" ,
107
+ list_name = " b" ,
108
+ w = 5 ,
109
+ h = 1 ,
110
+ bgimg = { " c" , " d" , " e" },
111
+ starting_item_index = 2
112
+ })
113
+ end )
114
+ it (" asserts an error when list length is zero, according to # operator" , function ()
115
+ assert .has_error (function ()
116
+ return flow_extras .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 , bgimg = { } }
117
+ end , " must not be a nil image 1" )
118
+ assert .has_error (function ()
119
+ return flow_extras .List { inventory_location = " a" , list_name = " b" , w = 5 , h = 1 , bgimg = { [2 ]= " c" } }
120
+ end , " must not be a nil image 1" )
121
+ end )
122
+ end )
89
123
end )
90
124
it (" works with two demensions" , function ()
91
125
assert .same (gui .Stack {
@@ -95,18 +129,18 @@ describe("List", function ()
95
129
spacing = 0.25 ,
96
130
gui .HBox {
97
131
spacing = 0.25 ,
98
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
99
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
132
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
133
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
100
134
},
101
135
gui .HBox {
102
136
spacing = 0.25 ,
103
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
104
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
137
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
138
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
105
139
},
106
140
gui .HBox {
107
141
spacing = 0.25 ,
108
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
109
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
142
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
143
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
110
144
}
111
145
},
112
146
gui .List { inventory_location = " a" , list_name = " b" , w = 2 , h = 3 }
@@ -122,15 +156,15 @@ describe("List", function ()
122
156
spacing = 0.25 ,
123
157
gui .HBox {
124
158
spacing = 0.25 ,
125
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
126
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
127
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
159
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
160
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
161
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
128
162
},
129
163
gui .HBox {
130
164
spacing = 0.25 ,
131
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
132
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
133
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
165
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
166
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
167
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
134
168
}
135
169
},
136
170
gui .List { inventory_location = " a" , list_name = " b" , w = 3 , h = 2 }
@@ -142,8 +176,8 @@ describe("List", function ()
142
176
align_v = " center" ,
143
177
gui .VBox {
144
178
spacing = 0.25 ,
145
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
146
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
179
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
180
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
147
181
},
148
182
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 2 , starting_item_index = 6 }
149
183
}
@@ -167,15 +201,15 @@ describe("List", function ()
167
201
spacing = 0.25 ,
168
202
gui .HBox {
169
203
spacing = 0.25 ,
170
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
171
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
172
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
204
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
205
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
206
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
173
207
},
174
208
gui .HBox {
175
209
spacing = 0.25 ,
176
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
177
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
178
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
210
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
211
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
212
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
179
213
}
180
214
},
181
215
gui .List { inventory_location = " a" , list_name = " b" , w = 3 , h = 2 }
@@ -187,8 +221,8 @@ describe("List", function ()
187
221
align_v = " center" ,
188
222
gui .HBox {
189
223
spacing = 0.25 ,
190
- gui .Image { w = 1 , h = 1 , bgimg = " c" },
191
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
224
+ gui .Image { w = 1 , h = 1 , texture_name = " c" },
225
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
192
226
},
193
227
gui .List { inventory_location = " a" , list_name = " b" , w = 2 , h = 1 , starting_item_index = 6 }
194
228
}
@@ -212,15 +246,15 @@ describe("List", function ()
212
246
gui .Stack {
213
247
align_h = " center" ,
214
248
align_v = " center" ,
215
- gui .Image { bgimg = " flow_extras_list_bg.png" , w = 1 , h = 1 },
249
+ gui .Image { texture_name = " flow_extras_list_bg.png" , w = 1 , h = 1 },
216
250
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
217
251
},
218
252
gui .HBox {
219
253
align_h = " e" ,
220
254
gui .Stack {
221
255
align_h = " center" ,
222
256
align_v = " center" ,
223
- gui .Image { h = 1 , w = 1 , bgimg = " flow_extras_list_bg.png" },
257
+ gui .Image { h = 1 , w = 1 , texture_name = " flow_extras_list_bg.png" },
224
258
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , starting_item_index = 1 }
225
259
}
226
260
}
@@ -242,15 +276,15 @@ describe("List", function ()
242
276
gui .Stack {
243
277
align_h = " center" ,
244
278
align_v = " center" ,
245
- gui .Image { h = 1 , w = 1 , bgimg = " flow_extras_list_bg.png" },
279
+ gui .Image { h = 1 , w = 1 , texture_name = " flow_extras_list_bg.png" },
246
280
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
247
281
},
248
282
gui .VBox {
249
283
align_v = " e" ,
250
284
gui .Stack {
251
285
align_h = " center" ,
252
286
align_v = " center" ,
253
- gui .Image { h = 1 , w = 1 , bgimg = " flow_extras_list_bg.png" },
287
+ gui .Image { h = 1 , w = 1 , texture_name = " flow_extras_list_bg.png" },
254
288
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , starting_item_index = 1 }
255
289
}
256
290
}
@@ -271,13 +305,13 @@ describe("List", function ()
271
305
gui .Stack {
272
306
align_h = " center" ,
273
307
align_v = " center" ,
274
- gui .Image { h = 1 , w = 1 , bgimg = " flow_extras_list_bg.png" },
308
+ gui .Image { h = 1 , w = 1 , texture_name = " flow_extras_list_bg.png" },
275
309
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , starting_item_index = 100 }
276
310
},
277
311
gui .Stack {
278
312
align_v = " center" ,
279
313
align_h = " center" ,
280
- gui .Image { h = 1 , w = 1 , bgimg = " flow_extras_list_bg.png" },
314
+ gui .Image { h = 1 , w = 1 , texture_name = " flow_extras_list_bg.png" },
281
315
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 , starting_item_index = 101 }
282
316
}
283
317
}, flow_extras .List {
@@ -293,7 +327,7 @@ describe("List", function ()
293
327
gui .Stack {
294
328
align_h = " center" ,
295
329
align_v = " center" ,
296
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" },
330
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" },
297
331
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 1 }
298
332
},
299
333
gui .Listring { inventory_location = " a" , list_name = " b" },
@@ -320,7 +354,7 @@ describe("List", function ()
320
354
gui .VBox {
321
355
spacing = 0.25 ,
322
356
gui .Spacer { w = 1 , h = 1 , expand = false },
323
- gui .Image { w = 1 , h = 1 , bgimg = " c" }
357
+ gui .Image { w = 1 , h = 1 , texture_name = " c" }
324
358
},
325
359
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 2 },
326
360
}, flow_extras .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 2 , bgimg = { false , " c" } })
@@ -336,13 +370,13 @@ describe("List", function ()
336
370
spacing = 1 ,
337
371
gui .HBox {
338
372
spacing = 1 ,
339
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" },
340
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" }
373
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" },
374
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" }
341
375
},
342
376
gui .HBox {
343
377
spacing = 1 ,
344
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" },
345
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" }
378
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" },
379
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" }
346
380
}
347
381
},
348
382
gui .List { inventory_location = " a" , list_name = " b" , w = 2 , h = 2 }
@@ -352,8 +386,8 @@ describe("List", function ()
352
386
align_v = " center" ,
353
387
gui .VBox {
354
388
spacing = 1 ,
355
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" },
356
- gui .Image { w = 1 , h = 1 , bgimg = " flow_extras_list_bg.png" }
389
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" },
390
+ gui .Image { w = 1 , h = 1 , texture_name = " flow_extras_list_bg.png" }
357
391
},
358
392
gui .List { inventory_location = " a" , list_name = " b" , w = 1 , h = 2 , starting_item_index = 4 }
359
393
}
0 commit comments