-
Notifications
You must be signed in to change notification settings - Fork 31
/
package_import_dialog.gd
1973 lines (1785 loc) · 83.3 KB
/
package_import_dialog.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file is part of Unidot Importer. See LICENSE.txt for full MIT license.
# Copyright (c) 2021-present Lyuma <[email protected]> and contributors
# SPDX-License-Identifier: MIT
@tool
extends RefCounted
const package_file := preload("./package_file.gd")
const tarfile := preload("./tarfile.gd")
const import_worker_class := preload("./import_worker.gd")
const meta_worker_class := preload("./meta_worker.gd")
const asset_adapter_class := preload("./asset_adapter.gd")
const asset_database_class := preload("./asset_database.gd")
const object_adapter_class := preload("./object_adapter.gd")
const asset_meta_class := preload("./asset_meta.gd")
# Set THREAD_COUNT to 0 to run single-threaded.
const THREAD_COUNT = 10
const DISABLE_TEXTURES = false
const STATE_DIALOG_SHOWING = 0
const STATE_PREPROCESSING = 1
const STATE_TEXTURES = 2
const STATE_IMPORTING_MATERIALS_AND_ASSETS = 3
const STATE_IMPORTING_MODELS = 4
const STATE_IMPORTING_YAML_POST_MODEL = 5
const STATE_IMPORTING_PREFABS = 6
const STATE_IMPORTING_SCENES = 7
const STATE_DONE_IMPORT = 8
var import_worker = import_worker_class.new()
var import_worker2 = import_worker_class.new()
var meta_worker = meta_worker_class.new()
var asset_adapter = asset_adapter_class.new()
var object_adapter = object_adapter_class.new()
var editor_plugin: EditorPlugin = null
var main_dialog: AcceptDialog = null
var file_dialog: EditorFileDialog = null
var main_dialog_tree: Tree = null
var hide_button: Button
var pause_button: Button
var abort_button: Button
var base_control: Control
var spinner_icon: AnimatedTexture = null
var spinner_icon1: Texture = null
var fail_icon: Texture = null
var log_icon: Texture = null
var error_icon: Texture = null
var warning_icon: Texture = null
var status_error_icon: Texture = null
var status_warning_icon: Texture = null
var status_success_icon: Texture = null
var folder_icon: Texture = null
var file_icon: Texture = null
var class_icons: Dictionary # String -> Texture2D
var checkbox_off_unicode: String = "\u2610"
var checkbox_on_unicode: String = "\u2611"
var tmpdir: String = ""
var asset_database: asset_database_class = null
var current_selected_package: String
var tree_dialog_state: int = 0
var path_to_tree_item: Dictionary
var guid_to_dependency_guids: Dictionary
var dependency_guids_to_guid: Dictionary
var ignore_dependencies: Dictionary
var _currently_preprocessing_assets: int = 0
var _preprocessing_second_pass: Array = []
var retry_tex: bool = false
var _keep_open_on_import: bool = false
var paused: bool = false
var auto_import: bool = false
var _meta_work_count: int = 0
var auto_hide_checkbox: CheckBox
var dont_auto_select_dependencies_checkbox: CheckBox
var save_text_resources: CheckBox
var save_text_scenes: CheckBox
var skip_reimport_models_checkbox: CheckBox = null
var set_animation_trees_active_checkbox: CheckBox
var enable_unidot_keys_checkbox: CheckBox
var add_unsupported_components_checkbox: CheckBox
var debug_disable_silhouette_fix_checkbox: CheckBox
var force_humanoid_checkbox: CheckBox
var enable_verbose_log_checkbox: CheckBox
var enable_vrm_spring_bones_checkbox: CheckBox
var convert_fbx_to_gltf_checkbox: CheckBox
var batch_import_list_widget: ItemList
var batch_import_add_button: Button
var batch_import_file_list: PackedStringArray
var batch_import_types: Dictionary
var progress_bar : ProgressBar
var status_bar : Label
var options_vbox : VBoxContainer
var show_advanced_options: CheckButton
var advanced_options_container: Container
var advanced_options_hbox : HBoxContainer
var advanced_options_vbox : VBoxContainer
var import_finished: bool = false
var written_additional_textures: bool = false
var global_logs_tree_item: TreeItem
var global_logs_last_count: int = 0
var select_by_type_tree_item: TreeItem
var select_by_type_items: Dictionary # String -> TreeItem
var asset_work_written_last_stage: int = 0
var asset_work_waiting_write: Array = [].duplicate()
var asset_work_waiting_scan: Array = [].duplicate()
var asset_work_currently_importing: Array = [].duplicate()
var asset_work_completed: Array = [].duplicate()
var asset_all: Array = [].duplicate()
var asset_textures: Array = [].duplicate()
var asset_materials_and_other: Array = [].duplicate()
var asset_models: Array = [].duplicate()
var asset_yaml_post_model: Array = [].duplicate()
var asset_prefabs: Array = [].duplicate()
var asset_scenes: Array = [].duplicate()
var builtin_ufbx_supported: bool = ClassDB.class_exists(&"FBXDocument") and ClassDB.class_exists(&"FBXState")
var result_log_lineedit: TextEdit
var new_editor_plugin := EditorPlugin.new()
var pkg: Object = null # Type package_file, set in _selected_package
func _resource_reimported(resources: PackedStringArray):
if import_finished or tree_dialog_state == STATE_DIALOG_SHOWING or tree_dialog_state == STATE_DONE_IMPORT:
return
asset_database.log_debug([null, 0, "", 0], "RESOURCES REIMPORTED ============")
for res in resources:
asset_database.log_debug([null, 0, "", 0], res)
asset_database.log_debug([null, 0, "", 0], "=================================")
func _resource_reloaded(resources: PackedStringArray):
if import_finished or tree_dialog_state == STATE_DIALOG_SHOWING or tree_dialog_state == STATE_DONE_IMPORT:
return
asset_database.log_debug([null, 0, "", 0], "Got a RESOURCES RELOADED ============")
for res in resources:
asset_database.log_debug([null, 0, "", 0], res)
asset_database.log_debug([null, 0, "", 0], "=====================================")
func _init():
meta_worker.asset_processing_finished.connect(self._meta_completed, CONNECT_DEFERRED)
import_worker.asset_processing_finished.connect(self._asset_processing_finished, CONNECT_DEFERRED)
import_worker.asset_processing_started.connect(self._asset_processing_started, CONNECT_DEFERRED)
import_worker2.stage2 = true
import_worker2.asset_processing_finished.connect(self._asset_processing_stage2_finished, CONNECT_DEFERRED)
tmpdir = asset_adapter.create_temp_dir()
var editor_filesystem: EditorFileSystem = new_editor_plugin.get_editor_interface().get_resource_filesystem()
editor_filesystem.resources_reimported.connect(self._resource_reimported)
editor_filesystem.resources_reload.connect(self._resource_reloaded)
func _set_indeterminate_up_recursively(ti: TreeItem, is_checked: bool):
if ti == null:
return
var is_all_checked: bool = true
var is_all_unchecked: bool = true
for sib in ti.get_children():
if sib.is_checked(0) or sib.is_indeterminate(0):
is_all_unchecked = false
if not sib.is_checked(0) or sib.is_indeterminate(0):
is_all_checked = false
if is_all_checked:
if ti.is_indeterminate(0) or not ti.is_checked(0):
ti.set_indeterminate(0, false)
ti.set_checked(0, true)
_set_indeterminate_up_recursively(ti.get_parent(), is_checked)
if ti == select_by_type_items.get(ti.get_text(0)):
batch_import_types[ti.get_text(0)] = true
elif is_all_unchecked:
if ti.is_indeterminate(0) or ti.is_checked(0):
ti.set_indeterminate(0, false)
ti.set_checked(0, false)
_set_indeterminate_up_recursively(ti.get_parent(), is_checked)
if ti == select_by_type_items.get(ti.get_text(0)):
batch_import_types[ti.get_text(0)] = false
else:
if not ti.is_indeterminate(0):
ti.set_checked(0, false)
ti.set_indeterminate(0, true)
ti.set_checked(0, false)
_set_indeterminate_up_recursively(ti.get_parent(), is_checked)
if ti == select_by_type_items.get(ti.get_text(0)):
batch_import_types[ti.get_text(0)] = false
func _check_recursively(ti: TreeItem, is_checked: bool, process_dependencies: bool, visited_set: Dictionary={}, is_recursive_file: bool=false) -> void:
if visited_set.is_empty():
visited_set = {}
if visited_set.has(ti):
return
visited_set[ti] = true
if ti == select_by_type_items.get(ti.get_text(0)):
batch_import_types[ti.get_text(0)] = is_checked
var other_item: TreeItem = ti.get_metadata(1) as TreeItem
if other_item != null:
_check_recursively(other_item, is_checked, false, visited_set, false)
#other_item.set_checked(0, is_checked)
#_set_indeterminate_up_recursively(other_item, is_checked)
if ti.is_selectable(0):
ti.set_indeterminate(0, false)
ti.set_checked(0, is_checked)
#var old_prefix: String = (checkbox_on_unicode if !is_checked else checkbox_off_unicode)
#var new_prefix: String = (checkbox_on_unicode if is_checked else checkbox_off_unicode)
#ti.set_text(0, new_prefix + ti.get_text(0).substr(len(old_prefix)))
for chld in ti.get_children():
_check_recursively(chld, is_checked, process_dependencies, visited_set, true)
if ti.is_selectable(0):
ti.set_indeterminate(0, false)
ti.set_checked(0, is_checked)
if not is_recursive_file:
var par := ti.get_parent()
_set_indeterminate_up_recursively(par, is_checked)
if process_dependencies and ti.get_child_count() == 0:
var path: String = ti.get_tooltip_text(0)
var asset = pkg.path_to_pkgasset.get(path)
if not asset:
return
var dep_guids: Dictionary
if is_checked:
dep_guids = guid_to_dependency_guids.get(asset.guid, {})
elif not ignore_dependencies.has(asset.guid):
# When unchecking an asset, we must
dep_guids = dependency_guids_to_guid.get(asset.guid, {})
for guid in dep_guids:
if ignore_dependencies.has(guid):
continue
var dep_asset = pkg.guid_to_pkgasset.get(guid)
if not dep_asset:
continue
var child = path_to_tree_item.get(dep_asset.orig_pathname)
if not child:
continue
_check_recursively(child, is_checked, process_dependencies, visited_set)
func update_progress_bar(amt: int):
progress_bar.value += amt
func update_global_logs():
if len(asset_database.log_message_holder.all_logs) == global_logs_last_count:
return
global_logs_last_count = len(asset_database.log_message_holder.all_logs)
var filtered_msgs: PackedStringArray
var col: int = -1
if global_logs_tree_item.is_checked(2):
col = 2
filtered_msgs = asset_database.log_message_holder.all_logs
elif global_logs_tree_item.is_checked(3):
col = 3
filtered_msgs = asset_database.log_message_holder.all_logs
elif global_logs_tree_item.is_checked(4):
col = 4
filtered_msgs = asset_database.log_message_holder.fails
if col > 0:
var data: Variant = global_logs_tree_item.get_metadata(col)
var current_scroll: int = 0
if typeof(data) == TYPE_PACKED_STRING_ARRAY:
current_scroll = unmerge_log_lines(data as PackedStringArray, current_scroll)
current_scroll = merge_log_lines(filtered_msgs, current_scroll)
global_logs_tree_item.set_metadata(col, filtered_msgs)
result_log_lineedit.text = '\n'.join(visible_log_lines)
result_log_lineedit.scroll_vertical = current_scroll
func update_all_logs():
var root_ti: TreeItem = main_dialog_tree.get_root()
var current_scroll = result_log_lineedit.scroll_vertical
var child_list: Array[TreeItem]
_get_children_recursive(child_list, root_ti)
visible_log_lines.resize(0)
var filtered_msgs: PackedStringArray
for child_ti in child_list:
for sub_col in range(2, 5):
child_ti.set_metadata(sub_col, null)
for child_ti in child_list:
if child_ti.get_parent() == null:
continue
for sub_col in range(2, 5):
if child_ti.is_checked(sub_col):
if not child_ti.get_parent().is_checked(sub_col):
log_column_checked(child_ti, sub_col, true, false)
break
result_log_lineedit.text = '\n'.join(visible_log_lines)
result_log_lineedit.scroll_vertical = current_scroll
result_log_lineedit.visible = true
class ErrorSyntaxHighlighter extends SyntaxHighlighter:
var fail_highlight: Dictionary
var warn_highlight: Dictionary
var default_highlight: Dictionary
var inited: bool = false
var pid: Object
const ERROR_COLOR_TAG := "FAIL: "
const WARNING_COLOR_TAG := "warn: "
func _init(package_import_dialog_val: Object):
pid = package_import_dialog_val
func _get_line_syntax_highlighting(line: int):
if line >= len(pid.visible_log_lines) or line < 0:
return {}
var linestr: String = pid.visible_log_lines[line]
if not inited:
var error_color : Color = get_text_edit().get_theme_color(&"error_color", &"Editor")
var warning_color : Color = get_text_edit().get_theme_color(&"warning_color", &"Editor")
fail_highlight = {0: {"size": 1, "color": Color.DIM_GRAY}, 8: {"color": error_color}}
warn_highlight = {0: {"size": 1, "color": Color.DIM_GRAY}, 8: {"color": warning_color}}
default_highlight = {0: {"size": 1, "color": Color.DIM_GRAY}, 8: {}}
inited = true
var off1: int = linestr.find(":")
var beg: String = linestr.substr(0, linestr.find(":", off1 + 1) + 2)
var ret: Dictionary = default_highlight
if beg.contains(ERROR_COLOR_TAG):
ret = fail_highlight
if beg.contains(WARNING_COLOR_TAG):
ret = warn_highlight
ret = ret.duplicate()
ret[off1] = ret[8]
ret[8] = {"color": Color.MEDIUM_PURPLE}
return ret
var visible_log_lines: PackedStringArray = []
var tmp_log_lines: PackedStringArray = []
func merge_log_lines(lines_to_add: PackedStringArray, current_scroll: float) -> float:
var is_end: bool = result_log_lineedit.get_last_full_visible_line() >= len(visible_log_lines) - 1
#len(visible_log_lines) - current_scroll < result_log_lineedit.get_last_full_visible_line()
if lines_to_add.is_empty():
return current_scroll
var idx1: int = len(visible_log_lines) - 1
visible_log_lines.resize(len(visible_log_lines) + len(lines_to_add))
var idx_out: int = len(visible_log_lines) - 1
for idx2 in range(len(lines_to_add) - 1, -1, -1):
while idx1 >= 0 and visible_log_lines[idx1] > lines_to_add[idx2]:
visible_log_lines[idx_out] = visible_log_lines[idx1]
if idx1 == current_scroll:
current_scroll = idx_out
idx1 -= 1
idx_out -= 1
visible_log_lines[idx_out] = lines_to_add[idx2]
idx2 -= 1
idx_out -= 1
while idx1 >= 0:
visible_log_lines[idx_out] = visible_log_lines[idx1]
if idx1 == current_scroll:
current_scroll = idx_out
idx1 -= 1
idx_out -= 1
if is_end:
return len(visible_log_lines) - result_log_lineedit.get_parent_area_size().y / result_log_lineedit.get_line_height() + 1
return current_scroll
func unmerge_log_lines(lines_to_remove: PackedStringArray, current_scroll: float) -> float:
if lines_to_remove.is_empty():
return current_scroll
var idx1: int = 0
var idx_out: int = 0
for line in lines_to_remove:
#print("Remove " + str(line))
while idx1 < len(visible_log_lines) and visible_log_lines[idx1] < line:
#print("loop " + str(idx1) + " " + str(idx_out) + " " + str(len(visible_log_lines)) + " " + str(visible_log_lines[idx1]))
visible_log_lines[idx_out] = visible_log_lines[idx1]
if idx1 == current_scroll:
current_scroll = idx_out
idx1 += 1
idx_out += 1
if idx1 < len(visible_log_lines) and visible_log_lines[idx1] == line:
#print("Do " + str(visible_log_lines[idx1]))
if idx1 == current_scroll:
current_scroll = idx_out
idx1 += 1
#print(str(idx_out) + "," + str(idx1))
while idx1 < len(visible_log_lines):
#print("loop2 " + str(idx1) + " " + str(idx_out) + " " + str(len(visible_log_lines)) + " " + str(visible_log_lines[idx1]))
visible_log_lines[idx_out] = visible_log_lines[idx1]
if idx1 == current_scroll:
current_scroll = idx_out
idx1 += 1
idx_out += 1
#assert(idx_out == len(visible_log_lines) - len(lines_to_remove))
visible_log_lines.resize(idx_out)
return current_scroll
func _get_children_recursive(child_list: Array[TreeItem], cur: TreeItem):
child_list.append(cur)
for i in range(cur.get_child_count()):
_get_children_recursive(child_list, cur.get_child(i))
func _cell_selected() -> void:
var ti: TreeItem = main_dialog_tree.get_selected()
if not ti:
return
var col: int = main_dialog_tree.get_selected_column()
ti.deselect(col)
if (col == 0 or col == 1) and ti.get_cell_mode(0) == TreeItem.CELL_MODE_CHECK:
if ti != null: # and col == 1:
var new_checked: bool = !ti.is_indeterminate(0) and !ti.is_checked(0)
var process_dependencies: bool = false
if new_checked and not dont_auto_select_dependencies_checkbox.button_pressed:
process_dependencies = true
if not new_checked and not dont_auto_select_dependencies_checkbox.button_pressed:
process_dependencies = true
if Input.is_key_pressed(KEY_SHIFT):
process_dependencies = not process_dependencies
_check_recursively(ti, new_checked, process_dependencies)
elif col >= 2:
ti.set_checked(col, not ti.is_checked(col))
log_column_checked(ti, col, ti.is_checked(col))
func log_column_checked(ti: TreeItem, col: int, is_checked: bool, update_textbox: bool=true):
if col >= 2:
var current_scroll = result_log_lineedit.scroll_vertical
var child_list: Array[TreeItem]
_get_children_recursive(child_list, ti)
if ti.is_checked(col):
var filtered_msgs: PackedStringArray
var data_to_unmerge: PackedStringArray
for child_ti in child_list:
for sub_col in range(2, 5):
if ti != child_ti or sub_col > col:
var data: Variant = child_ti.get_metadata(sub_col)
if typeof(data) == TYPE_PACKED_STRING_ARRAY:
data_to_unmerge.append_array(data as PackedStringArray)
child_ti.set_metadata(sub_col, PackedStringArray())
if sub_col >= col:
child_ti.set_checked(sub_col, true)
child_ti.set_selectable(sub_col, false)
if not data_to_unmerge.is_empty():
current_scroll = unmerge_log_lines(data_to_unmerge, current_scroll)
var needs_sort: bool
for child_ti in child_list:
var metadat: Object = child_ti.get_metadata(1)
if metadat is TreeItem:
continue
var tw: package_file.PkgAsset = metadat
var start_idx = len(filtered_msgs)
if tw != null:
if not filtered_msgs.is_empty():
needs_sort = true
if col == 2:
filtered_msgs.append_array(tw.parsed_meta.log_message_holder.all_logs)
elif col == 3:
filtered_msgs.append_array(tw.parsed_meta.log_message_holder.warnings_fails)
elif col == 4:
filtered_msgs.append_array(tw.parsed_meta.log_message_holder.fails)
if ti == global_logs_tree_item:
if not filtered_msgs.is_empty():
needs_sort = true
if col == 2:
filtered_msgs.append_array(asset_database.log_message_holder.all_logs)
elif col == 3:
filtered_msgs.append_array(asset_database.log_message_holder.all_logs)
elif col == 4:
filtered_msgs.append_array(asset_database.log_message_holder.fails)
if needs_sort:
filtered_msgs.sort()
ti.set_metadata(col, filtered_msgs)
current_scroll = merge_log_lines(filtered_msgs, current_scroll)
elif not ti.is_checked(col):
var data: Variant = ti.get_metadata(col)
ti.set_metadata(col, PackedStringArray())
if typeof(data) == TYPE_PACKED_STRING_ARRAY:
current_scroll = unmerge_log_lines(data as PackedStringArray, current_scroll)
for child_ti in child_list:
for sub_col in range(2, 5):
if ti != child_ti or sub_col > col:
child_ti.set_checked(sub_col, false)
child_ti.set_selectable(sub_col, true)
#print("Updating text " + str(ti.is_checked(col)))
#print(len(visible_log_lines))
if update_textbox:
result_log_lineedit.text = '\n'.join(visible_log_lines)
result_log_lineedit.scroll_vertical = current_scroll
result_log_lineedit.visible = true # not visible_log_lines.is_empty()
const HUMAN_READABLE_NAMES: Dictionary = {
5866666021909216657: "Animator",
-8679921383154817045: "Transform",
919132149155446097: "GameObject",
1091099324641564166: "PrefabInstance",
2357318004158062694: "PrefabInstance",
}
func human_readable_fileid_heuristic(fileID: int) -> String:
if fileID == 0:
return ""
if fileID > 0 and (fileID / 1000) % 100 == 0 and (fileID / 100000) < 1002:
var classID: int = fileID / 100000
return object_adapter.utype_to_classname[classID]
if HUMAN_READABLE_NAMES.has(fileID):
return HUMAN_READABLE_NAMES[fileID]
return str(fileID)
func _meta_completed(tw: Object):
_meta_work_count -= 1
var pkgasset = tw.asset
var ti = tw.extra as TreeItem
var importer_type: String = ""
if pkgasset.parsed_meta != null:
importer_type = pkgasset.parsed_meta.importer_type.replace("Importer", "")
if importer_type == "NativeFormat":
importer_type = "[" + tw.asset_main_object_type + "]"
if pkgasset.parsed_meta.main_object_id != 0 and pkgasset.parsed_meta.main_object_id % 100000 == 0:
var clsid: int = pkgasset.parsed_meta.main_object_id / 100000
if object_adapter.utype_to_classname.has(clsid):
importer_type = "[" + object_adapter.utype_to_classname[clsid] + "]"
var dep_guids: Dictionary = pkgasset.parsed_meta.meta_dependency_guids.duplicate()
if importer_type == "[LightingDataAsset]":
if batch_import_types.get(".asset LightingDataAsset", false) == false:
ignore_dependencies[pkgasset.guid] = true
_check_recursively(ti, false, false)
if importer_type == "[MonoScript]" or importer_type == "Mono" or importer_type == "":
if batch_import_types.get(".cs Script", false) == false:
ignore_dependencies[pkgasset.guid] = true
_check_recursively(ti, false, false)
if importer_type == "[Shader]" or importer_type == "Shader":
if batch_import_types.get(".shader Shader", false) == false:
ignore_dependencies[pkgasset.guid] = true
_check_recursively(ti, false, false)
for guid in pkgasset.parsed_meta.dependency_guids:
dep_guids[guid] = pkgasset.parsed_meta.dependency_guids[guid]
var da := DirAccess.open("res://")
for guid in dep_guids:
var guid_meta = asset_database.get_meta_by_guid(guid)
if guid_meta != null and da.file_exists(guid_meta.path):
# No need to force selection
continue
if guid_meta == null and not pkg.guid_to_pkgasset.has(guid):
push_error("Asset " + pkgasset.parsed_meta.path + " depends on missing GUID " + guid + " fileID " + human_readable_fileid_heuristic(dep_guids[guid]))
if not guid_to_dependency_guids.has(pkgasset.guid):
guid_to_dependency_guids[pkgasset.guid] = {}
guid_to_dependency_guids[pkgasset.guid][guid] = dep_guids[guid]
if not dependency_guids_to_guid.has(guid):
dependency_guids_to_guid[guid] = {}
dependency_guids_to_guid[guid][pkgasset.guid] = dep_guids[guid]
ti.set_text(1, "Scene" if pkgasset.orig_pathname.to_lower().ends_with(".scene") else importer_type)
var cls: String
if importer_type.begins_with("["):
cls = importer_type.substr(1, len(importer_type) - 2)
var tmp_instance = object_adapter.instantiate_unidot_object(pkgasset.parsed_meta, 0, 0, cls)
cls = tmp_instance.get_godot_type()
else:
var tmp_importer = null
if pkgasset.parsed_meta != null:
tmp_importer = pkgasset.parsed_meta.importer
if tmp_importer == null:
tmp_importer = object_adapter.instantiate_unidot_object(pkgasset.parsed_meta, 0, 0, importer_type + "Importer")
var main_object_id: int = tmp_importer.get_main_object_id()
if main_object_id == 1 or main_object_id == 100100000:
cls = "PackedScene"
else:
var utype: int = main_object_id / 100000
var tmp_instance = object_adapter.instantiate_unidot_object_from_utype(pkgasset.parsed_meta, 0, utype)
cls = tmp_instance.get_godot_type()
var tooltip_cls: String = cls
if cls.begins_with("AnimationNode"):
cls = "AnimatedTexture"
if cls == "Texture2D":
cls = "ImageTexture"
if cls == "BoneMap":
cls = "BoneAttachment3D"
if not class_icons.has(cls):
class_icons[cls] = base_control.get_theme_icon(cls, "EditorIcons")
var icon: Texture2D = class_icons[cls]
if icon == null:
icon = file_icon
if ti.get_icon(0) == null or ti.get_icon(0) == file_icon:
ti.set_icon(0, icon)
ti.set_icon(1, icon)
ti.set_tooltip_text(1, tooltip_cls)
var color = Color(0.3 + 0.4 * fmod(importer_type.unicode_at(0) * 173.0 / 255.0, 1.0), 0.3 + 0.4 * fmod(importer_type.unicode_at(1) * 139.0 / 255.0, 1.0), 0.7 * fmod(importer_type.unicode_at(2) * 157.0 / 255.0, 1.0), 1.0)
ti.set_custom_color(1, color)
var obj_type: String = tw.asset_main_object_type
if pkgasset.orig_pathname.to_lower().ends_with(".scene"):
obj_type = "Scene"
elif importer_type == "Model":
obj_type = "Model"
elif importer_type == "Prefab":
obj_type = "Prefab"
elif pkgasset.parsed_meta.main_object_id != 0 and pkgasset.parsed_meta.main_object_id % 100000 == 0:
var clsid: int = pkgasset.parsed_meta.main_object_id / 100000
if object_adapter.utype_to_classname.has(clsid):
obj_type = object_adapter.utype_to_classname[clsid]
if pkgasset.orig_pathname.to_lower().ends_with(".cs"):
obj_type = "Script"
if pkgasset.orig_pathname.to_lower().ends_with(".shader"):
obj_type = "Shader"
var select_by_type_item: TreeItem
var type_parent: TreeItem
var obj_type_desc = "." + pkgasset.orig_pathname.get_extension() + " " + obj_type
if auto_import:
if batch_import_types.get(obj_type_desc, true) == false:
ignore_dependencies[pkgasset.guid] = true
_check_recursively(ti, false, false)
if pkgasset.orig_pathname.to_lower().ends_with(".dll") or pkgasset.orig_pathname.to_lower().ends_with(".dylib") or pkgasset.orig_pathname.to_lower().ends_with(".so"):
ignore_dependencies[pkgasset.guid] = true
_check_recursively(ti, false, false)
if select_by_type_items.has(obj_type_desc):
type_parent = select_by_type_items[obj_type_desc]
if type_parent.is_checked(0) and not ti.is_checked(0):
type_parent.set_indeterminate(0, true)
batch_import_types[obj_type_desc] = true
if not type_parent.is_checked(0) and ti.is_checked(0):
type_parent.set_indeterminate(0, true)
batch_import_types[obj_type_desc] = true
else:
var insert_idx: int = 0
for chld in select_by_type_tree_item.get_children():
if chld.get_text(0).casecmp_to(obj_type_desc) > 0:
break
insert_idx += 1
type_parent = select_by_type_tree_item.create_child(insert_idx)
type_parent.set_cell_mode(0, TreeItem.CELL_MODE_CHECK)
type_parent.set_icon(0, icon)
# We have the type in column 0, so copy it here.
type_parent.set_custom_color(0, ti.get_custom_color(1))
type_parent.set_text(0, obj_type_desc)
type_parent.set_collapsed_recursive(true)
type_parent.set_checked(0, ti.is_checked(0))
select_by_type_items[obj_type_desc] = type_parent
batch_import_types[obj_type_desc] = ti.is_checked(0)
select_by_type_item = type_parent.create_child()
select_by_type_item.set_cell_mode(0, TreeItem.CELL_MODE_CHECK)
select_by_type_item.set_checked(0, ti.is_checked(0))
select_by_type_item.set_text(0, ti.get_text(0))
select_by_type_item.set_icon(0, ti.get_icon(0))
select_by_type_item.set_tooltip_text(0, ti.get_tooltip_text(0))
select_by_type_item.set_cell_mode(1, TreeItem.CELL_MODE_STRING)
select_by_type_item.set_text(1, ti.get_text(1))
select_by_type_item.set_icon(1, ti.get_icon(1))
select_by_type_item.set_custom_color(1, ti.get_custom_color(1))
select_by_type_item.set_tooltip_text(1, ti.get_tooltip_text(1))
select_by_type_item.set_metadata(1, ti)
ti.set_metadata(1, select_by_type_item)
if _meta_work_count <= 0:
if auto_import:
if preprocess_timer != null:
preprocess_timer.queue_free()
preprocess_timer = Timer.new()
preprocess_timer.wait_time = 0.1
preprocess_timer.autostart = true
preprocess_timer.process_callback = Timer.TIMER_PROCESS_IDLE
new_editor_plugin.get_editor_interface().get_base_control().add_child(preprocess_timer, true)
preprocess_timer.timeout.connect(self._auto_import_tick)
var auto_clean_tick_count = 10
func _auto_import_tick():
if new_editor_plugin.get_editor_interface().get_resource_filesystem().is_scanning():
auto_clean_tick_count = 10
else:
# Reduce chance of race condition with editor scanning / import
auto_clean_tick_count -= 1
if auto_clean_tick_count < 0:
preprocess_timer.timeout.disconnect(self._auto_import_tick)
preprocess_timer.queue_free()
preprocess_timer = null
_asset_tree_window_confirmed()
func _prune_unselected_items(p_ti: TreeItem) -> bool:
# Directories might be unchecked but have children which are checked.
var children = p_ti.get_children()
children.reverse() # probably faster to remove from end.
var was_directory = not children.is_empty() or p_ti.get_text(1) == "Directory"
for child_ti in children:
if not _prune_unselected_items(child_ti):
p_ti.remove_child(child_ti)
if not p_ti.is_checked(0) and p_ti.get_child_count() == 0:
var path = p_ti.get_tooltip_text(0) # HACK! No data field in TreeItem?? Let's use the tooltip?!
var asset = pkg.path_to_pkgasset.get(path)
if asset != null:
# After the user has made their selection, it is important that we treat all unselected files
# as if they do not exist. Some operations such as roughness texture generation (stage2)
# use this dictionary to find not-yet-imported smoothness textures
pkg.path_to_pkgasset.erase(path)
pkg.guid_to_pkgasset.erase(asset.guid)
return false
# Check if column 1 (type) is "Directory". is there a cleaner way to do this?
if was_directory and p_ti.get_child_count() == 0:
return false
var path = p_ti.get_tooltip_text(0) # HACK! No data field in TreeItem?? Let's use the tooltip?!
var asset = pkg.path_to_pkgasset.get(path)
# Has children or it is checked.
var tooltip = p_ti.get_tooltip_text(0)
var text = p_ti.get_text(0)
#p_ti.add_button(1, log_icon, 1, false, "View Log")
p_ti.set_cell_mode(0, TreeItem.CELL_MODE_STRING)
p_ti.set_checked(0, false)
p_ti.set_selectable(0, false)
if len(text.get_basename()) > 25:
text = text.get_basename().substr(0, 30) + "..." + text.get_extension()
p_ti.set_text(0, text)
p_ti.set_tooltip_text(0, tooltip)
if asset:
p_ti.set_icon(0, spinner_icon)
else:
p_ti.set_icon(0, folder_icon)
#p_ti.set_expand_right(0, true)
if asset_database.enable_verbose_logs:
p_ti.set_cell_mode(2, TreeItem.CELL_MODE_CHECK)
p_ti.set_text_alignment(2, HORIZONTAL_ALIGNMENT_RIGHT)
p_ti.set_text(2, "Logs")
p_ti.set_selectable(2, true)
p_ti.set_icon(2, log_icon)
return true
func _selected_package(p_path: String) -> void:
current_selected_package = p_path
main_dialog.title = "Select Assets to import from " + current_selected_package.get_file()
print(editor_plugin)
if editor_plugin != null and file_dialog != null:
editor_plugin.last_selected_dir = file_dialog.current_dir
editor_plugin.file_dialog_mode = file_dialog.display_mode
print("CURRENT DIR " + file_dialog.current_dir)
if p_path.to_lower().contains("technologies"):
OS.alert("Beware that this package may use a non-standard license.\nPlease take the time to double-check that you are\nin compliance with all licenses.")
_preprocessing_second_pass = [].duplicate()
asset_work_waiting_write = [].duplicate()
asset_work_waiting_scan = [].duplicate()
asset_work_currently_importing = [].duplicate()
asset_all = [].duplicate()
asset_textures = [].duplicate()
asset_materials_and_other = [].duplicate()
asset_models = [].duplicate()
asset_yaml_post_model = [].duplicate()
asset_prefabs = [].duplicate()
asset_scenes = [].duplicate()
asset_database = asset_database_class.new().get_singleton()
print("Got here " + str(p_path))
if p_path.is_empty():
pkg = package_file.new().external_tar_with_filename("")
elif p_path.to_lower().ends_with(".unitypackage"):
pkg = package_file.new().init_with_filename(p_path)
elif p_path.to_lower().ends_with("/asset.meta"):
pkg = package_file.new().external_tar_with_filename("", p_path.get_base_dir().get_base_dir())
elif p_path.to_lower().ends_with(".meta"):
pkg = package_file.new().init_with_asset_dir(p_path.get_base_dir())
elif DirAccess.dir_exists_absolute(p_path):
print("It's a dir!! " + str(p_path))
pkg = package_file.new().init_with_asset_dir(p_path)
#pkg.parse_all_meta(asset_database)
meta_worker.asset_database = asset_database
asset_database.clear_logs()
asset_database.in_package_import = true
asset_database.log_debug([null, 0, "", 0], "Asset database object returned " + str(asset_database))
dont_auto_select_dependencies_checkbox = _add_checkbox_option("Hold shift to select dependencies", false if asset_database.auto_select_dependencies else true)
dont_auto_select_dependencies_checkbox.toggled.connect(self._dont_auto_select_dependencies_checkbox_changed)
save_text_resources = _add_advanced_checkbox_option("Save resources as text .tres (slow)", true if asset_database.use_text_resources else false)
save_text_resources.toggled.connect(self._save_text_resources_changed)
save_text_scenes = _add_advanced_checkbox_option("Save scenes as text .tscn (slow)", true if asset_database.use_text_scenes else false)
save_text_scenes.toggled.connect(self._save_text_scenes_changed)
skip_reimport_models_checkbox = _add_advanced_checkbox_option("Skip already-imported fbx files", true if asset_database.skip_reimport_models else false)
skip_reimport_models_checkbox.toggled.connect(self._skip_reimport_models_checkbox_changed)
set_animation_trees_active_checkbox = _add_checkbox_option("Import active AnimationTrees (animate in editor)", true if asset_database.set_animation_trees_active else false)
set_animation_trees_active_checkbox.toggled.connect(self._set_animation_trees_active_changed)
enable_unidot_keys_checkbox = _add_advanced_checkbox_option("Save yaml data in metadata/unidot_keys", true if asset_database.enable_unidot_keys else false)
enable_unidot_keys_checkbox.toggled.connect(self._enable_unidot_keys_changed)
add_unsupported_components_checkbox = _add_advanced_checkbox_option("Add empty MonoBehaviour/unsupported nodes", true if asset_database.add_unsupported_components else false)
add_unsupported_components_checkbox.toggled.connect(self._add_unsupported_components_changed)
debug_disable_silhouette_fix_checkbox = _add_advanced_checkbox_option("Disable silhouette fix (DEBUG)", true if asset_database.debug_disable_silhouette_fix else false)
debug_disable_silhouette_fix_checkbox.toggled.connect(self._debug_disable_silhouette_fix_changed)
enable_verbose_log_checkbox = _add_advanced_checkbox_option("Enable verbose logs", true if asset_database.enable_verbose_logs else false)
enable_verbose_log_checkbox.toggled.connect(self._enable_verbose_log_changed)
enable_vrm_spring_bones_checkbox = _add_checkbox_option("Convert dynamic bones to VRM springbone", true if asset_database.vrm_spring_bones else false)
enable_vrm_spring_bones_checkbox.toggled.connect(self._enable_vrm_spring_bones_changed)
force_humanoid_checkbox = _add_checkbox_option("Import ALL scenes as humanoid retargeted skeletons", true if asset_database.force_humanoid else false)
force_humanoid_checkbox.toggled.connect(self._force_humanoid_changed)
if builtin_ufbx_supported:
convert_fbx_to_gltf_checkbox = _add_advanced_checkbox_option("Convert FBX models to glTF", true if asset_database.convert_fbx_to_gltf else false)
convert_fbx_to_gltf_checkbox.toggled.connect(self._convert_fbx_to_gltf_changed)
else:
convert_fbx_to_gltf_checkbox = _add_checkbox_option("Convert FBX models to glTF\n(Update to Godot 4.3 to disable)", true)
convert_fbx_to_gltf_checkbox.disabled = true
var vspace := Control.new()
vspace.custom_minimum_size = Vector2(0, 16)
vspace.size = Vector2(0, 16)
options_vbox.add_child(vspace)
options_vbox.add_child(advanced_options_container)
options_vbox.add_child(vspace.duplicate())
batch_import_list_widget = ItemList.new()
batch_import_list_widget.item_activated.connect(self._batch_import_list_widget_activated)
options_vbox.add_child(batch_import_list_widget)
batch_import_add_button = Button.new()
batch_import_add_button.text = "Add extra packages to batch"
batch_import_add_button.pressed.connect(self._add_batch_import)
batch_import_add_button.tooltip_text = """
Batch import additional .unitypackage archives.
Double-click a package to remove it from the list.
The file type checkboxes to the right will determine which files are imported from the batch.
"""
options_vbox.add_child(batch_import_add_button)
meta_worker.start_threads(THREAD_COUNT) # Don't DISABLE_THREADING
main_dialog_tree.hide_root = true
main_dialog_tree.create_item()
var hidden_root: TreeItem = main_dialog_tree.get_root()
select_by_type_tree_item = hidden_root.create_child()
select_by_type_tree_item.set_text(0, "Select by Type")
select_by_type_tree_item.set_text(1, " ") # We check for " " later to remove the subtree.
var tree_names = []
var ti: TreeItem
#var ti: TreeItem = main_dialog_tree.create_item()
#ti.set_cell_mode(0, TreeItem.CELL_MODE_CHECK)
#ti.set_text(0, "Assets")
#ti.set_expand_right(0, true)
#ti.set_expand_right(1, false)
#ti.set_checked(0, true)
#ti.set_icon_max_width(0, 24)
#ti.set_icon(0, folder_icon)
#ti.set_text(1, "RootDirectory")
var tree_items = []
for path in pkg.paths:
var pkgasset = pkg.path_to_pkgasset[path]
var path_names: Array = path.split("/")
var i: int = len(tree_names) - 1
while i >= 0 and (i >= len(path_names) or path_names[i] != tree_names[i]):
#asset_database.log_debug([null,0,"",0], "i=" + str(i) + "/" + str(len(path_names)) + "/" + str(tree_names[i]))
tree_names.pop_back()
tree_items.pop_back()
i -= 1
#if i < 0:
# asset_database.log_fail([null, 0, "", 0], "Path outside of Assets: " + path)
# print("Path outside of Assets: " + path)
# break
while i < len(path_names) - 1:
i += 1
tree_names.push_back(path_names[i])
ti = main_dialog_tree.create_item(null if i == 0 or tree_items.is_empty() else tree_items[i - 1])
tree_items.push_back(ti)
ti.set_expand_right(0, true)
ti.set_expand_right(1, false)
ti.set_cell_mode(0, TreeItem.CELL_MODE_CHECK)
if DISABLE_TEXTURES and (path.to_lower().ends_with("png") or path.to_lower().ends_with("jpg")):
ti.set_checked(0, false)
ti.set_selectable(0, false)
else:
ti.set_checked(0, true)
ti.set_selectable(0, true)
if i == len(path_names) - 1:
path_to_tree_item[path] = ti
ti.set_tooltip_text(0, path)
ti.set_icon_max_width(0, 24)
#ti.set_custom_color(0, Color.DARK_BLUE)
# ti.add_button(0, spinner_icon1, -1, true)
ti.set_text(0, path_names[i])
var icon: Texture = pkgasset.icon
if icon != null:
ti.set_icon(0, icon)
if i == len(path_names) - 1:
meta_worker.push_asset(pkgasset, ti)
_meta_work_count += 1
ti.set_text(1, "")
else:
ti.set_text(1, "Directory")
ti.set_icon(0, folder_icon)
main_dialog.popup_centered_ratio()
check_fbx2gltf()
if file_dialog:
file_dialog.queue_free()
file_dialog = null
func _reselect_pruned_items(p_ti: TreeItem):
for child_ti in p_ti.get_children():
_reselect_pruned_items(child_ti)
var text = p_ti.get_text(0)
p_ti.set_cell_mode(0, TreeItem.CELL_MODE_CHECK)
p_ti.set_checked(0, true)
p_ti.set_text(0, text)
func do_reimport_previous_files() -> void:
_currently_preprocessing_assets = 0
_preprocessing_second_pass.clear()
retry_tex = false
asset_work_waiting_write.clear()
asset_work_waiting_scan.clear()
asset_work_currently_importing.clear()
asset_work_completed.clear()
asset_all.clear()
asset_textures.clear()
asset_materials_and_other.clear()
asset_models.clear()
asset_yaml_post_model.clear()
asset_prefabs.clear()
asset_scenes.clear()
result_log_lineedit.text = ""
result_log_lineedit.syntax_highlighter = ErrorSyntaxHighlighter.new(self)
import_finished = false
written_additional_textures = false
tree_dialog_state = STATE_DIALOG_SHOWING
_reselect_pruned_items(main_dialog_tree.get_root())
_asset_tree_window_confirmed()
main_dialog.show()
func show_reimport(ep: EditorPlugin) -> void:
editor_plugin = ep
file_dialog = null
_show_importer_common()
self._selected_package("")
func show_importer(ep: EditorPlugin) -> void:
file_dialog = EditorFileDialog.new()
file_dialog.add_filter("*.unitypackage, *.meta", "Asset packages or file")
file_dialog.show_hidden_files = true
editor_plugin = ep
file_dialog.file_mode = EditorFileDialog.FILE_MODE_OPEN_ANY
# FILE_MODE_OPEN_FILE = 0 – The dialog allows selecting one, and only one file.
file_dialog.access = EditorFileDialog.ACCESS_FILESYSTEM
file_dialog.set_title("Import .unitypackage archive, or Select Assets folder...")
file_dialog.file_selected.connect(self._selected_package)
file_dialog.dir_selected.connect(self._selected_package)
ep.get_editor_interface().get_base_control().add_child(file_dialog, true)
if ep.get("last_selected_dir"):
file_dialog.current_dir = ep.last_selected_dir
file_dialog.display_mode = ep.file_dialog_mode
_show_importer_common()
check_fbx2gltf()
func check_fbx2gltf():
if builtin_ufbx_supported:
return # No need to check for FBX2glTF on engines with native fbx.
var d = DirAccess.open("res://")
var addon_path: String = new_editor_plugin.get_editor_interface().get_editor_settings().get_setting("filesystem/import/fbx/fbx2gltf_path")
if not addon_path.get_file().is_empty():
print(addon_path)
if not d.file_exists(addon_path):
var error_dialog := AcceptDialog.new()
new_editor_plugin.get_editor_interface().get_base_control().add_child(error_dialog)
error_dialog.title = "Unidot Importer"
error_dialog.dialog_text = "FBX2glTF is not configured in Editor settings. This will cause corrupt imports!\nPlease install FBX2glTF in Editor Settings."
error_dialog.popup_centered()
func show_importer_logs() -> void:
main_dialog.show()
func _auto_hide_toggled(is_on: bool) -> void:
_keep_open_on_import = not is_on
func _add_checkbox_option(optname: String, defl: bool, this_options_vbox: VBoxContainer = null) -> CheckBox:
if this_options_vbox == null:
this_options_vbox = options_vbox
var checkbox := CheckBox.new()
checkbox.text = optname
checkbox.size_flags_vertical = Control.SIZE_SHRINK_END
checkbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
checkbox.size_flags_stretch_ratio = 0.0
this_options_vbox.add_child(checkbox)
checkbox.button_pressed = defl
return checkbox
func _add_advanced_checkbox_option(optname: String, defl: bool):
if defl and not show_advanced_options.button_pressed:
show_advanced_options.button_pressed = true
return _add_checkbox_option(optname, defl, advanced_options_vbox)
func _save_text_resources_changed(val: bool):