@@ -230,125 +230,88 @@ enum { # BitFlags
230
230
SKIP_COLUMNS = 1 ,
231
231
SKIP_OBJECTS = 2 ,
232
232
}
233
+
233
234
func export_toml_slabset (filePath ):
234
235
var CODETIME_START = OS .get_ticks_msec ()
235
-
236
- # Find differences if not a full export
237
- var dat_diffs = []
238
- var tng_diffs = []
239
- dat_diffs = find_all_dat_differences ()
240
- tng_diffs = find_all_tng_differences ()
241
- if tng_diffs .size () == 0 and dat_diffs .size () == 0 :
236
+
237
+ var list_of_modified_slabs = get_all_modified_slabs ()
238
+
239
+ if list_of_modified_slabs .empty ():
242
240
oMessage .big ("File wasn't saved" , "You've made zero changes, so the file wasn't saved." )
243
241
return
244
-
245
-
246
-
247
- # # Print differences for debugging
248
- for i in tng_diffs :
249
- print ("---------TNG differences---------" )
250
- print ("Current: " , tng [i ])
251
- if i < default_data ["tng" ].size ():
252
- print ("Default: " , default_data ["tng" ][i ])
253
- else :
254
- print ("Default: Beyond array size" )
255
- #
256
- # # Print differences for debugging
257
- # for i in dat_diffs:
258
- # print("---------DAT differences---------")
259
- # print("Current: ", dat[i])
260
- # if i < default_data["dat"].size():
261
- # print("Default: ", default_data["dat"][i])
262
- # else:
263
- # print("Default: Beyond array size")
264
-
265
- var list_of_modified_slabs = []
266
-
242
+
267
243
var lines = PoolStringArray ()
268
- var totalSlabs = max (dat .size (), tng .size ()) / 28
269
- for slabID in totalSlabs :
270
- var hasChanges = false
271
-
272
- # Check if there are any changes within the 28 variations
244
+ for slabID in list_of_modified_slabs :
245
+ lines .append ("[slab" + str (slabID ) + "]" )
246
+
273
247
for variationNumber in 28 :
274
248
var variation = slabID * 28 + variationNumber
275
- if dat_diffs .has (variation ) or tng_diffs .has (variation ):
276
- hasChanges = true
277
- break
278
-
279
- if hasChanges == true :
280
- list_of_modified_slabs .append (slabID )
281
- lines .append ("[slab" + str (slabID ) + "]" )
282
-
283
- for variationNumber in 28 :
284
- var variation = slabID * 28 + variationNumber
285
- var dirText = dir_texts [variationNumber ]
286
-
287
- lines .append ("[slab" + str (slabID ) + "." + dirText + "]" )
288
-
289
- lines .append ("Columns = " + str (dat [variation ]))
290
-
291
- for object in tng [variation ]:
292
- lines .append ("" )
293
- lines .append ("[[slab" + str (slabID ) + "." + dirText + "_objects" + "]]" )
294
- for z in 9 :
295
- var propertyName
296
- var value
297
- match z :
298
- 0 :
299
- propertyName = "IsLight"
300
- value = object [z ]
301
- 2 :
302
- propertyName = "Subtile"
303
- value = object [z ]
304
- 3 :
305
- propertyName = "RelativePosition"
306
- value = [ object [3 ], object [4 ], object [5 ] ]
307
- 6 :
308
- propertyName = "ThingType"
309
- value = object [z ]
310
- 7 :
311
- propertyName = "Subtype"
312
- value = object [z ]
313
- 8 :
314
- propertyName = "EffectRange"
315
- value = object [z ]
316
- if propertyName :
317
- lines .append (propertyName + " = " + str (value ))
318
- if tng [variation ].size () == 0 :
319
- lines .append ("Objects = []" )
320
-
249
+ var dirText = dir_texts [variationNumber ]
250
+
251
+ lines .append ("[slab" + str (slabID ) + "." + dirText + "]" )
252
+
253
+ lines .append ("Columns = " + str (dat [variation ]))
254
+
255
+ for object in tng [variation ]:
321
256
lines .append ("" )
257
+ lines .append ("[[slab" + str (slabID ) + "." + dirText + "_objects" + "]]" )
258
+ for z in 9 :
259
+ var propertyName
260
+ var value
261
+ match z :
262
+ 0 :
263
+ propertyName = "IsLight"
264
+ value = object [z ]
265
+ 2 :
266
+ propertyName = "Subtile"
267
+ value = object [z ]
268
+ 3 :
269
+ propertyName = "RelativePosition"
270
+ value = [ object [3 ], object [4 ], object [5 ] ]
271
+ 6 :
272
+ propertyName = "ThingType"
273
+ value = object [z ]
274
+ 7 :
275
+ propertyName = "Subtype"
276
+ value = object [z ]
277
+ 8 :
278
+ propertyName = "EffectRange"
279
+ value = object [z ]
280
+ if propertyName :
281
+ lines .append (propertyName + " = " + str (value ))
282
+ if tng [variation ].size () == 0 :
283
+ lines .append ("Objects = []" )
284
+
322
285
lines .append ("" )
323
-
286
+ lines .append ("" )
287
+
324
288
var textFile = File .new ()
325
289
if textFile .open (filePath , File .WRITE ) != OK :
326
290
oMessage .big ("Error" , "Couldn't save file, maybe try saving to another directory." )
327
291
return
328
-
292
+
329
293
textFile .store_string ("\n " .join (lines ))
330
294
textFile .close ()
331
-
295
+
332
296
oMessage .quick ("Saved: " + filePath )
333
297
oMessage .quick ("Saved Slab IDs: " + str (list_of_modified_slabs ).replace ("[" ,"" ).replace ("]" ,"" ))
334
-
335
- print ('Exported in: ' + str (OS .get_ticks_msec () - CODETIME_START ) + 'ms' )
336
-
337
-
338
- func find_all_dat_differences ():
339
- var diff_indices = []
340
- for variation in dat .size ():
341
- if is_dat_variation_different (variation ) == true :
342
- diff_indices .append (variation )
343
- return diff_indices
344
298
299
+ print ('Exported in: ' + str (OS .get_ticks_msec () - CODETIME_START ) + 'ms' )
345
300
346
- func find_all_tng_differences ():
347
- var diff_indices = []
348
- for variation in tng .size ():
349
- if is_tng_variation_different (variation ) == true :
350
- diff_indices .append (variation )
351
- return diff_indices
301
+ func get_all_modified_slabs ():
302
+ var modified_slabs = []
303
+ var totalSlabs = max (dat .size (), tng .size ()) / 28
304
+ for slabID in totalSlabs :
305
+ if is_slab_edited (slabID ):
306
+ modified_slabs .append (slabID )
307
+ return modified_slabs
308
+
309
+ func is_slab_edited (slabID ):
310
+ for variationNumber in 28 :
311
+ var variation = slabID * 28 + variationNumber
312
+ if is_dat_variation_different (variation ) or is_tng_variation_different (variation ):
313
+ return true
314
+ return false
352
315
353
316
354
317
func is_dat_variation_different (variation ):
@@ -392,6 +355,21 @@ func is_tng_object_different(variation, objectIndex, objectProperty):
392
355
return tng [variation ][objectIndex ][objectProperty ] != default_data ["tng" ][variation ][objectIndex ][objectProperty ]
393
356
394
357
358
+ # func find_all_dat_differences():
359
+ # var diff_indices = []
360
+ # for variation in dat.size():
361
+ # if is_dat_variation_different(variation) == true:
362
+ # diff_indices.append(variation)
363
+ # return diff_indices
364
+ #
365
+ # func find_all_tng_differences():
366
+ # var diff_indices = []
367
+ # for variation in tng.size():
368
+ # if is_tng_variation_different(variation) == true:
369
+ # diff_indices.append(variation)
370
+ # return diff_indices
371
+
372
+
395
373
var dir_texts = {
396
374
0 : 'S' ,
397
375
1 : 'W' ,
0 commit comments